/**
* MapLibre GL JS
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.11.2/LICENSE.txt
*/var Cx=Object.create,kg=Object.defineProperty,Ix=Object.getOwnPropertyDescriptor,Mx=Object.getOwnPropertyNames,zx=Object.getPrototypeOf,Fx=Object.prototype.hasOwnProperty,$c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Rx=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=Mx(t),n=0,s=a.length,o;n<s;n++)o=a[n],!Fx.call(e,o)&&o!==r&&kg(e,o,{get:(l=>t[l]).bind(null,o),enumerable:!(i=Ix(t,o))||i.enumerable});return e},kx=(e,t,r)=>(r=e==null?{}:Cx(zx(e)),Rx(kg(r,"default",{value:e,enumerable:!0}),e));function C(e,t){this.x=e,this.y=t}C.prototype={clone(){return new C(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let t=e[0]*this.x+e[1]*this.y,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),r=Math.sin(e),i=t*this.x-r*this.y,a=r*this.x+t*this.y;return this.x=i,this.y=a,this},_rotateAround(e,t){let r=Math.cos(e),i=Math.sin(e),a=t.x+r*(this.x-t.x)-i*(this.y-t.y),n=t.y+i*(this.x-t.x)+r*(this.y-t.y);return this.x=a,this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:C},C.convert=function(e){if(e instanceof C)return e;if(Array.isArray(e))return new C(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new C(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};function Lx(e,t,r,i){let a=3*e,n=3*(r-e)-a,s=1-a-n,o=3*t,l=3*(i-t)-o,u=1-o-l;return function(h,c=1e-6){if(h<=0)return 0;if(h>=1)return 1;let d=h;for(let m=0;m<8;m++){let g=((s*d+n)*d+a)*d-h;if(Math.abs(g)<c)return((u*d+l)*d+o)*d;let _=(3*s*d+2*n)*d+a;if(Math.abs(_)<1e-6)break;d-=g/_}let p=0,f=1;d=h;for(let m=0;m<20;m++){let g=((s*d+n)*d+a)*d;if(Math.abs(g-h)<c)break;h>g?p=d:f=d,d=(p+f)*.5}return((u*d+l)*d+o)*d}}let zp;function jc(){return zp??(zp=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),zp}let Vs;function Lg(){if(Vs==null&&(Vs=!1,jc())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r<25;r++){let i=r*4;e.fillStyle=`rgb(${i},${i+1},${i+2})`,e.fillRect(r%5,Math.floor(r/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let r=0;r<100;r++)if(r%4!=3&&t[r]!==r){Vs=!0;break}}}return Vs||!1}var _t=typeof Float32Array<"u"?Float32Array:Array;function Bg(){var e=new _t(9);return _t!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Bx(e){var t=e[0],r=e[1],i=e[2],a=e[3],n=e[4],s=e[5],o=e[6],l=e[7],u=e[8];return t*(u*n-s*l)+r*(-u*a+s*o)+i*(l*a-n*o)}function Ox(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=-r,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function $x(e,t){var r=t[0],i=t[1],a=t[2],n=t[3],s=r+r,o=i+i,l=a+a,u=r*s,h=i*s,c=i*o,d=a*s,p=a*o,f=a*l,m=n*s,g=n*o,_=n*l;return e[0]=1-c-f,e[3]=h-_,e[6]=d+g,e[1]=h+_,e[4]=1-u-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-u-c,e}function Ci(){var e=new _t(16);return _t!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function uh(e){var t=new _t(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function jx(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ar(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ko(e,t){var r=t[0],i=t[1],a=t[2],n=t[3],s=t[4],o=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],y=r*o-i*s,v=r*l-a*s,x=r*u-n*s,w=i*l-a*o,b=i*u-n*o,T=a*u-n*l,P=h*m-c*f,S=h*g-d*f,I=h*_-p*f,R=c*g-d*m,F=c*_-p*m,D=d*_-p*g,A=y*D-v*F+x*R+w*I-b*S+T*P;return A?(A=1/A,e[0]=(o*D-l*F+u*R)*A,e[1]=(a*F-i*D-n*R)*A,e[2]=(m*T-g*b+_*w)*A,e[3]=(d*b-c*T-p*w)*A,e[4]=(l*I-s*D-u*S)*A,e[5]=(r*D-a*I+n*S)*A,e[6]=(g*x-f*T-_*v)*A,e[7]=(h*T-d*x+p*v)*A,e[8]=(s*F-o*I+u*P)*A,e[9]=(i*I-r*F-n*P)*A,e[10]=(f*b-m*x+_*y)*A,e[11]=(c*x-h*b-p*y)*A,e[12]=(o*S-s*R-l*P)*A,e[13]=(r*R-i*S+a*P)*A,e[14]=(m*v-f*w-g*y)*A,e[15]=(h*w-c*v+d*y)*A,e):null}function Da(e,t,r){var i=t[0],a=t[1],n=t[2],s=t[3],o=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],y=t[15],v=r[0],x=r[1],w=r[2],b=r[3];return e[0]=v*i+x*o+w*c+b*m,e[1]=v*a+x*l+w*d+b*g,e[2]=v*n+x*u+w*p+b*_,e[3]=v*s+x*h+w*f+b*y,v=r[4],x=r[5],w=r[6],b=r[7],e[4]=v*i+x*o+w*c+b*m,e[5]=v*a+x*l+w*d+b*g,e[6]=v*n+x*u+w*p+b*_,e[7]=v*s+x*h+w*f+b*y,v=r[8],x=r[9],w=r[10],b=r[11],e[8]=v*i+x*o+w*c+b*m,e[9]=v*a+x*l+w*d+b*g,e[10]=v*n+x*u+w*p+b*_,e[11]=v*s+x*h+w*f+b*y,v=r[12],x=r[13],w=r[14],b=r[15],e[12]=v*i+x*o+w*c+b*m,e[13]=v*a+x*l+w*d+b*g,e[14]=v*n+x*u+w*p+b*_,e[15]=v*s+x*h+w*f+b*y,e}function ot(e,t,r){var i=r[0],a=r[1],n=r[2],s,o,l,u,h,c,d,p,f,m,g,_;return t===e?(e[12]=t[0]*i+t[4]*a+t[8]*n+t[12],e[13]=t[1]*i+t[5]*a+t[9]*n+t[13],e[14]=t[2]*i+t[6]*a+t[10]*n+t[14],e[15]=t[3]*i+t[7]*a+t[11]*n+t[15]):(s=t[0],o=t[1],l=t[2],u=t[3],h=t[4],c=t[5],d=t[6],p=t[7],f=t[8],m=t[9],g=t[10],_=t[11],e[0]=s,e[1]=o,e[2]=l,e[3]=u,e[4]=h,e[5]=c,e[6]=d,e[7]=p,e[8]=f,e[9]=m,e[10]=g,e[11]=_,e[12]=s*i+h*a+f*n+t[12],e[13]=o*i+c*a+m*n+t[13],e[14]=l*i+d*a+g*n+t[14],e[15]=u*i+p*a+_*n+t[15]),e}function Et(e,t,r){var i=r[0],a=r[1],n=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Va(e,t,r){var i=Math.sin(r),a=Math.cos(r),n=t[4],s=t[5],o=t[6],l=t[7],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=n*a+u*i,e[5]=s*a+h*i,e[6]=o*a+c*i,e[7]=l*a+d*i,e[8]=u*a-n*i,e[9]=h*a-s*i,e[10]=c*a-o*i,e[11]=d*a-l*i,e}function Og(e,t,r){var i=Math.sin(r),a=Math.cos(r),n=t[0],s=t[1],o=t[2],l=t[3],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a-u*i,e[1]=s*a-h*i,e[2]=o*a-c*i,e[3]=l*a-d*i,e[8]=n*i+u*a,e[9]=s*i+h*a,e[10]=o*i+c*a,e[11]=l*i+d*a,e}function xi(e,t,r){var i=Math.sin(r),a=Math.cos(r),n=t[0],s=t[1],o=t[2],l=t[3],u=t[4],h=t[5],c=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a+u*i,e[1]=s*a+h*i,e[2]=o*a+c*i,e[3]=l*a+d*i,e[4]=u*a-n*i,e[5]=h*a-s*i,e[6]=c*a-o*i,e[7]=d*a-l*i,e}function Vx(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Nx(e,t,r,i,a){var n=1/Math.tan(t/2);if(e[0]=n/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,a!=null&&a!==1/0){var s=1/(i-a);e[10]=(a+i)*s,e[14]=2*a*i*s}else e[10]=-1,e[14]=-2*i;return e}var hh=Nx;function Ux(e,t,r,i,a,n,s){var o=1/(t-r),l=1/(i-a),u=1/(n-s);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*o,e[13]=(a+i)*l,e[14]=(s+n)*u,e[15]=1,e}var Br=Ux;function Gx(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function qx(e,t){var r=e[0],i=e[1],a=e[2],n=e[3],s=e[4],o=e[5],l=e[6],u=e[7],h=e[8],c=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],_=e[15],y=t[0],v=t[1],x=t[2],w=t[3],b=t[4],T=t[5],P=t[6],S=t[7],I=t[8],R=t[9],F=t[10],D=t[11],A=t[12],E=t[13],z=t[14],L=t[15];return Math.abs(r-y)<=1e-6*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-v)<=1e-6*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(n-w)<=1e-6*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(s-b)<=1e-6*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(o-T)<=1e-6*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(l-P)<=1e-6*Math.max(1,Math.abs(l),Math.abs(P))&&Math.abs(u-S)<=1e-6*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-I)<=1e-6*Math.max(1,Math.abs(h),Math.abs(I))&&Math.abs(c-R)<=1e-6*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(d-F)<=1e-6*Math.max(1,Math.abs(d),Math.abs(F))&&Math.abs(p-D)<=1e-6*Math.max(1,Math.abs(p),Math.abs(D))&&Math.abs(f-A)<=1e-6*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(m-E)<=1e-6*Math.max(1,Math.abs(m),Math.abs(E))&&Math.abs(g-z)<=1e-6*Math.max(1,Math.abs(g),Math.abs(z))&&Math.abs(_-L)<=1e-6*Math.max(1,Math.abs(_),Math.abs(L))}function $g(){var e=new _t(3);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ch(e){var t=new _t(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Sr(e){var t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)}function Fp(e,t,r){var i=new _t(3);return i[0]=e,i[1]=t,i[2]=r,i}function fr(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function Vc(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function Ve(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Lo(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e}function Zx(e,t){var r=t[0]-e[0],i=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(r*r+i*i+a*a)}function Wx(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Bt(e,t){var r=t[0],i=t[1],a=t[2],n=r*r+i*i+a*a;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function lt(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ht(e,t,r){var i=t[0],a=t[1],n=t[2],s=r[0],o=r[1],l=r[2];return e[0]=a*l-n*o,e[1]=n*s-i*l,e[2]=i*o-a*s,e}function Hx(e,t,r){var i=t[0],a=t[1],n=t[2],s=r[3]*i+r[7]*a+r[11]*n+r[15];return s||(s=1),e[0]=(r[0]*i+r[4]*a+r[8]*n+r[12])/s,e[1]=(r[1]*i+r[5]*a+r[9]*n+r[13])/s,e[2]=(r[2]*i+r[6]*a+r[10]*n+r[14])/s,e}function Xx(e,t,r){var i=t[0],a=t[1],n=t[2];return e[0]=i*r[0]+a*r[3]+n*r[6],e[1]=i*r[1]+a*r[4]+n*r[7],e[2]=i*r[2]+a*r[5]+n*r[8],e}function vu(e,t,r){var i=r[0],a=r[1],n=r[2],s=r[3],o=t[0],l=t[1],u=t[2],h=a*u-n*l,c=n*o-i*u,d=i*l-a*o;return h+=h,c+=c,d+=d,e[0]=o+s*h+a*d-n*c,e[1]=l+s*c+n*h-i*d,e[2]=u+s*d+i*c-a*h,e}function mn(e,t,r,i){var a=[],n=[];return a[0]=t[0]-r[0],a[1]=t[1]-r[1],a[2]=t[2]-r[2],n[0]=a[0],n[1]=a[1]*Math.cos(i)-a[2]*Math.sin(i),n[2]=a[1]*Math.sin(i)+a[2]*Math.cos(i),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function ya(e,t,r,i){var a=[],n=[];return a[0]=t[0]-r[0],a[1]=t[1]-r[1],a[2]=t[2]-r[2],n[0]=a[2]*Math.sin(i)+a[0]*Math.cos(i),n[1]=a[1],n[2]=a[2]*Math.cos(i)-a[0]*Math.sin(i),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function bu(e,t,r,i){var a=[],n=[];return a[0]=t[0]-r[0],a[1]=t[1]-r[1],a[2]=t[2]-r[2],n[0]=a[0]*Math.cos(i)-a[1]*Math.sin(i),n[1]=a[0]*Math.sin(i)+a[1]*Math.cos(i),n[2]=a[2],e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Yx(e){return e[0]=0,e[1]=0,e[2]=0,e}var li=Vc,Bo=Sr;(function(){var e=$g();return function(t,r,i,a,n,s){var o,l;for(r||(r=3),i||(i=0),l=a?Math.min(a*r+i,t.length):t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],n(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();function Kx(){var e=new _t(4);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Jx(e,t,r,i){var a=new _t(4);return a[0]=e,a[1]=t,a[2]=r,a[3]=i,a}function Qx(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function ev(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function tv(e,t){var r=t[0],i=t[1],a=t[2],n=t[3],s=r*r+i*i+a*a+n*n;return s>0&&(s=1/Math.sqrt(s)),e[0]=r*s,e[1]=i*s,e[2]=a*s,e[3]=n*s,e}function Pt(e,t,r){var i=t[0],a=t[1],n=t[2],s=t[3];return e[0]=r[0]*i+r[4]*a+r[8]*n+r[12]*s,e[1]=r[1]*i+r[5]*a+r[9]*n+r[13]*s,e[2]=r[2]*i+r[6]*a+r[10]*n+r[14]*s,e[3]=r[3]*i+r[7]*a+r[11]*n+r[15]*s,e}var rv=Qx;(function(){var e=Kx();return function(t,r,i,a,n,s){var o,l;for(r||(r=4),i||(i=0),l=a?Math.min(a*r+i,t.length):t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],n(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();function Rp(){var e=new _t(4);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function iv(e,t,r){r*=.5;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function av(e,t,r){var i=t[0],a=t[1],n=t[2],s=t[3],o=r[0],l=r[1],u=r[2],h=r[3];return e[0]=i*h+s*o+a*u-n*l,e[1]=a*h+s*l+n*o-i*u,e[2]=n*h+s*u+i*l-a*o,e[3]=s*h-i*o-a*l-n*u,e}function bo(e,t,r,i){var a=t[0],n=t[1],s=t[2],o=t[3],l=r[0],u=r[1],h=r[2],c=r[3],d,p=a*l+n*u+s*h+o*c,f,m,g;return p<0&&(p=-p,l=-l,u=-u,h=-h,c=-c),1-p>1e-6?(d=Math.acos(p),f=Math.sin(d),m=Math.sin((1-i)*d)/f,g=Math.sin(i*d)/f):(m=1-i,g=i),e[0]=m*a+g*l,e[1]=m*n+g*u,e[2]=m*s+g*h,e[3]=m*o+g*c,e}function nv(e,t){var r=t[0]+t[4]+t[8],i;if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{var a=0;t[4]>t[0]&&(a=1),t[8]>t[a*3+a]&&(a=2);var n=(a+1)%3,s=(a+2)%3;i=Math.sqrt(t[a*3+a]-t[n*3+n]-t[s*3+s]+1),e[a]=.5*i,i=.5/i,e[3]=(t[n*3+s]-t[s*3+n])*i,e[n]=(t[n*3+a]+t[a*3+n])*i,e[s]=(t[s*3+a]+t[a*3+s])*i}return e}function Nc(e,t,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",n=Math.PI/360;t*=n,i*=n,r*=n;var s=Math.sin(t),o=Math.cos(t),l=Math.sin(r),u=Math.cos(r),h=Math.sin(i),c=Math.cos(i);switch(a){case"xyz":e[0]=s*u*c+o*l*h,e[1]=o*l*c-s*u*h,e[2]=o*u*h+s*l*c,e[3]=o*u*c-s*l*h;break;case"xzy":e[0]=s*u*c-o*l*h,e[1]=o*l*c-s*u*h,e[2]=o*u*h+s*l*c,e[3]=o*u*c+s*l*h;break;case"yxz":e[0]=s*u*c+o*l*h,e[1]=o*l*c-s*u*h,e[2]=o*u*h-s*l*c,e[3]=o*u*c+s*l*h;break;case"yzx":e[0]=s*u*c+o*l*h,e[1]=o*l*c+s*u*h,e[2]=o*u*h-s*l*c,e[3]=o*u*c-s*l*h;break;case"zxy":e[0]=s*u*c-o*l*h,e[1]=o*l*c+s*u*h,e[2]=o*u*h+s*l*c,e[3]=o*u*c-s*l*h;break;case"zyx":e[0]=s*u*c-o*l*h,e[1]=o*l*c+s*u*h,e[2]=o*u*h-s*l*c,e[3]=o*u*c+s*l*h;break;default:throw Error("Unknown angle order "+a)}return e}var kp=Jx,Lp=tv;(function(){var e=$g(),t=Fp(1,0,0),r=Fp(0,1,0);return function(i,a,n){var s=lt(a,n);return s<-.999999?(Ht(e,t,a),Bo(e)<1e-6&&Ht(e,r,a),Bt(e,e),iv(i,e,Math.PI),i):s>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Ht(e,a,n),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+s,Lp(i,i))}})(),function(){var e=Rp(),t=Rp();return function(r,i,a,n,s,o){return bo(e,i,s,o),bo(t,a,n,o),bo(r,e,t,2*o*(1-o)),r}}(),function(){var e=Bg();return function(t,r,i,a){return e[0]=i[0],e[3]=i[1],e[6]=i[2],e[1]=a[0],e[4]=a[1],e[7]=a[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],Lp(t,nv(t,e))}}();function dh(){var e=new _t(2);return _t!=Float32Array&&(e[0]=0,e[1]=0),e}function Bp(e,t){var r=new _t(2);return r[0]=e,r[1]=t,r}function Op(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function $p(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function sv(e){var t=e[0],r=e[1];return t*t+r*r}function ov(e,t){return e[0]*t[0]+e[1]*t[1]}function jp(e){return e[0]=0,e[1]=0,e}var lv=sv;(function(){var e=dh();return function(t,r,i,a,n,s){var o,l;for(r||(r=2),i||(i=0),l=a?Math.min(a*r+i,t.length):t.length,o=i;o<l;o+=r)e[0]=t[o],e[1]=t[o+1],n(e,e,s),t[o]=e[0],t[o+1]=e[1];return t}})();const k=8192;function nr(e,t,r){return t*(k/(e.tileSize*2**(r-e.tileID.overscaledZ)))}function zt(e){return e instanceof Error?e:Error(typeof e=="string"?e:String(e))}function Oi(){return new Float64Array(4)}function Pe(){return new Float64Array(3)}function $i(){return new Float64Array(16)}function Ns(){let e=new Float64Array(16);return Ar(e),e}function jg(){let e=new Float32Array(16);return Ar(e),e}function Di(e,t,r,i,a=!1){if(!r[0]&&!r[1])return[0,0];let n=a?i==="map"?-e.bearingInRadians:0:i==="viewport"?e.bearingInRadians:0;if(n){let s=Math.sin(n),o=Math.cos(n);r=[r[0]*o-r[1]*s,r[0]*s+r[1]*o]}return[a?r[0]:nr(t,r[0],e.zoom),a?r[1]:nr(t,r[1],e.zoom)]}function ph(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function lr(e,t,r){let i=Bx([e[0],e[1],e[2],t[0],t[1],t[2],r[0],r[1],r[2]]);if(i===0)return null;let a=Ht([],[t[0],t[1],t[2]],[r[0],r[1],r[2]]),n=Ht([],[r[0],r[1],r[2]],[e[0],e[1],e[2]]),s=Ht([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),o=Ve([],a,-e[3]);return fr(o,o,Ve([],n,-t[3])),fr(o,o,Ve([],s,-r[3])),Ve(o,o,1/i),o}function uv(e,t,r){let i=e[0]*r[0]+e[1]*r[1]+e[2]*r[2],a=t[0]*r[0]+t[1]*r[1]+t[2]*r[2];return a===0?null:(-i-r[3])/a}function Us(e,t,r,i){let a=Math.sqrt(e*e+t*t),n=Math.sqrt(r*r+i*i);e/=a,t/=a,r/=n,i/=n;let s=e*r+t*i,o=Math.acos(s);return-t*r+e*i>0?o:-o}function er(e,t){let r=Ki(e,360),i=Ki(t,360),a=i-r,n=i>r?a-360:a+360;return Math.abs(a)<Math.abs(n)?a:n}function Gs(e,t){let r=Ki(e,Math.PI*2),i=Ki(t,Math.PI*2);return Math.min(Math.abs(r-i),Math.abs(r-i+Math.PI*2),Math.abs(r-i-Math.PI*2))}function Ki(e,t){return(e%t+t)%t}function wo(e,t,r,i,a){return Fa(i,a,ne((e-t)/(r-t),0,1))}function Fa(e,t,r){return e*(1-r)+t*r}function hv(e){let t=1/0,r=1/0,i=-1/0,a=-1/0;for(let n of e)t=Math.min(t,n.x),r=Math.min(r,n.y),i=Math.max(i,n.x),a=Math.max(a,n.y);return[t,r,i,a]}function cv(e){if(!e.length)return new Set;let t=Math.max(...e.map(l=>l.canonical.z)),r=1/0,i=-1/0,a=1/0,n=-1/0,s=[];for(let l of e){let{x:u,y:h,z:c}=l.canonical,d=2**(t-c),p=u*d,f=h*d;s.push({id:l,x:p,y:f}),p<r&&(r=p),p>i&&(i=p),f<a&&(a=f),f>n&&(n=f)}let o=new Set;for(let l of s)(l.x===r||l.x===i||l.y===a||l.y===n)&&o.add(l.id);return o}function dv(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}function Uc(e,t,r,i){return Lx(e,t,r,i)}const fh=Uc(.25,.1,.25,1);function ne(e,t,r){return Math.min(r,Math.max(t,e))}function mr(e,t,r){let i=r-t,a=((e-t)%i+i)%i+t;return a===t?r:a}function W(e,...t){for(let r of t)for(let i in r)e[i]=r[i];return e}function us(e,t){let r={};for(let i of t)i in e&&(r[i]=e[i]);return r}let pv=1;function Vg(){return pv++}function fv(e){return Math.log(e)/Math.LN2%1==0}function mv(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}function $t(e){return 2**e}function It(e){return Math.log(e)/Math.LN2}function rr(e,t,r){if(t<=0)return e;let i=1/t;return r===void 0||Math.abs(r)<1e-10?Math.round(e*i)/i:(r>0?Math.ceil(e*i-1e-9):Math.floor(e*i+1e-10))/i}function Gc(e,t,r){let i={};for(let a in e)i[a]=t.call(this,e[a],a,e);return i}function Ng(e,t,r){let i={};for(let a in e)t.call(this,e[a],a,e)&&(i[a]=e[a]);return i}function Or(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Or(e[r],t[r]))return!1;return!0}if(typeof e=="object"&&e&&t!==null){if(typeof t!="object"||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(!Or(e[r],t[r]))return!1;return!0}return e===t}function Wt(e){return Array.isArray(e)?e.map(Wt):typeof e=="object"&&e?Gc(e,Wt):e}const Vp={};function _e(e){Vp[e]||(typeof console<"u"&&console.warn(e),Vp[e]=!0)}function vi(e,t,r){return(r.y-e.y)*(t.x-e.x)>(t.y-e.y)*(r.x-e.x)}function gv(e,t,r,i){let a=t.y-e.y,n=t.x-e.x,s=i.y-r.y,o=i.x-r.x,l=s*n-o*a;if(l===0)return null;let u=e.y-r.y,h=e.x-r.x,c=(o*u-s*h)/l;return new C(e.x+c*n,e.y+c*a)}function _v([e,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,[e*Math.cos(t)*Math.sin(r),e*Math.sin(t)*Math.sin(r),e*Math.cos(r)]}function Na(e){return typeof WorkerGlobalScope<"u"&&e!==void 0&&e instanceof WorkerGlobalScope}function yv(e){let t=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,r={};if(e.replace(t,(i,a,n,s)=>{let o=n||s;return r[a]=!o||o.toLowerCase(),""}),r["max-age"]){let i=parseInt(r["max-age"],10);isNaN(i)?delete r["max-age"]:r["max-age"]=i}return r}let wu=null;function xv(e){if(wu==null){let t=e.navigator?e.navigator.userAgent:null;wu=!!e.safari||!!(t&&(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return wu}function Gi(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap}const vv=async(e,t)=>{let r=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(r,t)}catch(i){throw Error(`Could not load image because of ${zt(i).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}},bv=e=>new Promise((t,r)=>{let i=new Image;i.onload=()=>{t(i),URL.revokeObjectURL(i.src),i.onload=null,window.requestAnimationFrame(()=>i.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=")},i.onerror=()=>r(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let a=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=URL.createObjectURL(a)});function wv(e,t,r,i,a){let n=Math.max(-t,0)*4,s=(Math.max(0,r)-r)*i*4+n,o=i*4,l=Math.max(0,t),u=Math.max(0,r),h=Math.min(e.width,t+i),c=Math.min(e.height,r+a);return{rect:{x:l,y:u,width:h-l,height:c-u},layout:[{offset:s,stride:o}]}}async function Tv(e,t,r,i,a){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let n=new VideoFrame(e,{timestamp:0});try{let s=n==null?void 0:n.format;if(!s||!(s.startsWith("BGR")||s.startsWith("RGB")))throw Error(`Unrecognized format ${s}`);let o=s.startsWith("BGR"),l=new Uint8ClampedArray(i*a*4);if(await n.copyTo(l,wv(e,t,r,i,a)),o)for(let u=0;u<l.length;u+=4){let h=l[u];l[u]=l[u+2],l[u+2]=h}return l}finally{n.close()}}function Oo(e,t,r,i){return e.addEventListener(t,r,i),{unsubscribe:()=>{e.removeEventListener(t,r,i)}}}function Ge(e){return e*Math.PI/180}function jr(e){return e/Math.PI*180}function Ug(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function Dv(e){let t=new Float64Array(9);$x(t,e);let r=jr(-Math.asin(ne(t[2],-1,1))),i,a;return Math.hypot(t[5],t[8])<.001?(i=0,a=-jr(Math.atan2(t[3],t[4]))):(i=jr(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),a=jr(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:i,pitch:r+90,bearing:a}}function Sv(e,t,r){let i=Bp(t.x-r.x,t.y-r.y),a=Bp(e.x-r.x,e.y-r.y),n=i[0]*a[1]-i[1]*a[0];return jr(Math.atan2(n,ov(i,a)))}function Np(e,t,r){let i=new Float64Array(4);return Nc(i,e,t-90,r),i}const qr=85.051129,Gg={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},qg={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Ev(e,t){return Gg[t]&&"touches"in e}function Pv(e,t){var a,n;if(!qg[t])return!1;let r=e,i=((n=(a=r==null?void 0:r.target)==null?void 0:a.ownerDocument)==null?void 0:n.defaultView)||window;return r instanceof i.MouseEvent||r instanceof i.WheelEvent}function Av(e){return Gg[e]||qg[e]}const Up="AbortError";var hs=class extends Error{constructor(e=Up){super(e instanceof Error?e.message:e),this.name=Up,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function Si(e){return e instanceof Error&&e.name==="AbortError"}function qc(e){if(e.aborted)throw new hs(e.reason)}const Ei={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Zg(e){return Ei.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const mh="global-dispatcher";var $o=class extends Error{constructor(e,t,r,i){super(`AJAXError: ${t} (${e}): ${r}`),this.status=e,this.statusText=t,this.url=r,this.body=i}};function Zc(){var e;if(Na(self))return(e=self.worker)==null?void 0:e.referrer;if(window.location.protocol==="blob:")try{return window.parent.location.href}catch{}return window.location.href}const Cv=e=>{var t;return e.startsWith("file:")||((t=Zc())==null?void 0:t.startsWith("file:"))&&!/^\w+:/.test(e)};async function Iv(e,t){let r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:Zc(),referrerPolicy:e.referrerPolicy,signal:t.signal});e.type==="json"&&!r.headers.has("Accept")&&r.headers.set("Accept","application/json");let i;try{i=await fetch(r)}catch(s){throw Si(s)?s:new $o(0,zt(s).message,e.url,new Blob)}if(!i.ok){let s=await i.blob();throw new $o(i.status,i.statusText,e.url,s)}let a;a=e.type==="arrayBuffer"||e.type==="image"?i.arrayBuffer():e.type==="json"?i.json():i.text();let n=await a;return qc(t.signal),{data:n,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}function Mv(e,t){return new Promise((r,i)=>{var n;let a=new XMLHttpRequest;a.open(e.method||"GET",e.url,!0),(e.type==="arrayBuffer"||e.type==="image")&&(a.responseType="arraybuffer");for(let s in e.headers)a.setRequestHeader(s,e.headers[s]);e.type==="json"&&(a.responseType="text",(n=e.headers)!=null&&n.Accept||a.setRequestHeader("Accept","application/json")),a.withCredentials=e.credentials==="include",a.onerror=()=>{i(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||a.status===0)&&a.response!==null){let s=a.response;if(e.type==="json")try{s=JSON.parse(a.response)}catch(o){i(o);return}r({data:s,cacheControl:a.getResponseHeader("Cache-Control"),expires:a.getResponseHeader("Expires"),etag:a.getResponseHeader("ETag")})}else{let s=new Blob([a.response],{type:a.getResponseHeader("Content-Type")});i(new $o(a.status,a.statusText,e.url,s))}},t.signal.addEventListener("abort",()=>{a.abort(),i(new hs(t.signal.reason))}),a.send(e.body)})}const gl=async function(e,t){var r,i;if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){let a=Zg(e.url);if(a){let n=await a(e,t);return!n.data&&e.type==="arrayBuffer"?W(n,{data:new ArrayBuffer(0)}):n}if(Na(self)&&((r=self.worker)!=null&&r.actor))return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:mh},t)}if(!Cv(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return Iv(e,t);if(Na(self)&&((i=self.worker)!=null&&i.actor))return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:mh},t)}return Mv(e,t)},_l=(e,t)=>gl(W(e,{type:"json"}),t),Wg=(e,t)=>gl(W(e,{type:"arrayBuffer"}),t);function Hg(e){if(!e||e.startsWith("data:image/"))return!0;if(e.startsWith("blob:")&&(e=e.slice(5),e.startsWith("null")))return!1;if(e.indexOf("://")<=0)return!0;let t=new URL(e),r=window.location;return t.protocol===r.protocol&&t.host===r.host}const zv=e=>{let t=window.document.createElement("video");return t.muted=!0,new Promise(r=>{t.onloadstart=()=>{r(t)};for(let i of e){let a=window.document.createElement("source");Hg(i)||(t.crossOrigin="Anonymous"),a.src=i,t.appendChild(a)}})};function Gp(e,t,r){var i;(i=r[e])!=null&&i.includes(t)||(r[e]||(r[e]=[]),r[e].push(t))}function Tu(e,t,r){if(r!=null&&r[e]){let i=r[e].indexOf(t);i!==-1&&r[e].splice(i,1)}}var ia=class{constructor(e,t={}){W(this,t),this.type=e}},X=class extends ia{constructor(e,t={}){super("error",W({error:e},t))}},Rt=class{on(e,t){return this._listeners||(this._listeners={}),Gp(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return Tu(e,t,this._listeners),Tu(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||(this._oneTimeListeners={}),Gp(e,t,this._oneTimeListeners),this):new Promise(r=>this.once(e,r))}fire(e,t){var a,n,s,o;let r=typeof e=="string"?new ia(e,t||{}):e,i=r.type;if(this.listens(i)){r.target=this;let l=((n=(a=this._listeners)==null?void 0:a[i])==null?void 0:n.slice())??[];for(let c of l)c.call(this,r);let u=((o=(s=this._oneTimeListeners)==null?void 0:s[i])==null?void 0:o.slice())??[];for(let c of u)Tu(i,c,this._oneTimeListeners),c.call(this,r);let h=this._eventedParent;h&&(W(r,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),h.fire(r))}else r instanceof X&&console.error(r.error);return this}listens(e){var t,r,i,a,n;return!!((r=(t=this._listeners)==null?void 0:t[e])!=null&&r.length||(a=(i=this._oneTimeListeners)==null?void 0:i[e])!=null&&a.length||(n=this._eventedParent)!=null&&n.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},Xg={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"},"fill-extrusion-rounded-corner-distance":{type:"number",default:0,minimum:0,units:"meters","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-height-offset":{type:"number",default:0,units:"meters",requires:[{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-height-anchor":{type:"enum",values:{ground:{},absolute:{}},default:"ground",requires:["symbol-height-offset"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const M=Xg,Fv=["type","source","source-layer","minzoom","maxzoom","filter","layout"];var O=class{constructor(e,t,r,i,a="error"){this.message=(e?`${e}: `:"")+r,i&&(this.identifier=i),this.severity=a,t!=null&&t.__line__&&(this.line=t.__line__)}};const cs={kind:"null"},j={kind:"number"},oe={kind:"string"},fe={kind:"boolean"},Er={kind:"color"},yl={kind:"projectionDefinition"},qi={kind:"object"},ue={kind:"value"},Rv={kind:"error"},xl={kind:"collator"},ds={kind:"formatted"},vl={kind:"padding"},Gn={kind:"colorArray"},bl={kind:"numberArray"},ps={kind:"resolvedImage"},wl={kind:"variableAnchorOffsetCollection"};function kt(e,t){return{kind:"array",itemType:e,N:t}}function Ke(e){if(e.kind==="array"){let t=Ke(e.itemType);return typeof e.N=="number"?`array<${t}, ${e.N}>`:e.itemType.kind==="value"?"array":`array<${t}>`}return e.kind}const kv=[cs,j,oe,fe,Er,yl,ds,qi,kt(ue),vl,bl,Gn,ps,wl];function qn(e,t){if(t.kind==="error")return null;if(e.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!qn(e.itemType,t.itemType))&&(typeof e.N!="number"||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if(e.kind==="value"){for(let r of kv)if(!qn(r,t))return null}}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function Wc(e,t){return t.some(r=>r.kind===e.kind)}function Zi(e,t){return t.some(r=>r==="null"?e===null:r==="array"?Array.isArray(e):r==="object"?e&&!Array.isArray(e)&&typeof e=="object":r===typeof e)}function mi(e,t){return e.kind==="array"&&t.kind==="array"?e.itemType.kind===t.itemType.kind&&typeof e.N=="number":e.kind===t.kind}const Yg=.96422,Kg=.82521,Jg=4/29,gh=6/29,Qg=3*gh*gh,Lv=Math.PI/180,Bv=180/Math.PI;function e_(e){return e%=360,e<0&&(e+=360),e}function t_([e,t,r,i]){e=Du(e),t=Du(t),r=Du(r);let a,n,s=Su((.2225045*e+.7168786*t+.0606169*r)/1);e===t&&t===r?a=n=s:(a=Su((.4360747*e+.3850649*t+.1430804*r)/Yg),n=Su((.0139322*e+.0971045*t+.7141733*r)/Kg));let o=116*s-16;return[o<0?0:o,500*(a-s),200*(s-n),i]}function Du(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Su(e){return e>.008856451679035631?e**(1/3):e/Qg+Jg}function r_([e,t,r,i]){let a=(e+16)/116,n=isNaN(t)?a:a+t/500,s=isNaN(r)?a:a-r/200;return a=1*Pu(a),n=Yg*Pu(n),s=Kg*Pu(s),[Eu(3.1338561*n-1.6168667*a-.4906146*s),Eu(-.9787684*n+1.9161415*a+.033454*s),Eu(.0719453*n-.2289914*a+1.4052427*s),i]}function Eu(e){return e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055,e<0?0:e>1?1:e}function Pu(e){return e>gh?e*e*e:Qg*(e-Jg)}function Ov(e){let[t,r,i,a]=t_(e),n=Math.sqrt(r*r+i*i);return[Math.round(n*1e4)?e_(Math.atan2(i,r)*Bv):NaN,n,t,a]}function $v([e,t,r,i]){return e=isNaN(e)?0:e*Lv,r_([r,Math.cos(e)*t,Math.sin(e)*t,i])}function jv([e,t,r,i]){e=e_(e),t/=100,r/=100;function a(n){let s=(n+e/30)%12,o=t*Math.min(r,1-r);return r-o*Math.max(-1,Math.min(s-3,9-s,1))}return[a(0),a(8),a(4),i]}const Vv=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function kn(e,t){return Vv(e,t)?e[t]:void 0}function Nv(e){if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t=kn(Uv,e);if(t){let[i,a,n]=t;return[i/255,a/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let i=e.length<6?1:2,a=1;return[qs(e.slice(a,a+=i)),qs(e.slice(a,a+=i)),qs(e.slice(a,a+=i)),qs(e.slice(a,a+i)||"ff")]}if(e.startsWith("rgb")){let i=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[a,n,s,o,l,u,h,c,d,p,f,m]=i,g=[o||" ",h||" ",p].join("");if(g===" "||g===" /"||g===",,"||g===",,,"){let _=[s,u,d].join(""),y=_==="%%%"?100:_===""?255:0;if(y){let v=[Sa(+n/y,0,1),Sa(+l/y,0,1),Sa(+c/y,0,1),f?qp(+f,m):1];if(Zp(v))return v}}return}}let r=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){let[i,a,n,s,o,l,u,h,c]=r,d=[n||" ",o||" ",u].join("");if(d===" "||d===" /"||d===",,"||d===",,,"){let p=[+a,Sa(+s,0,100),Sa(+l,0,100),h?qp(+h,c):1];if(Zp(p))return jv(p)}}}function qs(e){return parseInt(e.padEnd(2,e),16)/255}function qp(e,t){return Sa(t?e/100:e,0,1)}function Sa(e,t,r){return Math.min(Math.max(t,e),r)}function Zp(e){return!e.some(Number.isNaN)}const Uv={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function wi(e,t,r){return e+r*(t-e)}function Ua(e,t,r){return e.map((i,a)=>wi(i,t[a],r))}function Gv(e){return e==="rgb"||e==="hcl"||e==="lab"}var vt,se=(vt=class{constructor(t,r,i,a=1,n=!0){this.r=t,this.g=r,this.b=i,this.a=a,n||(this.r*=a,this.g*=a,this.b*=a,a||this.overwriteGetter("rgb",[t,r,i,a]))}static parse(t){if(t instanceof vt)return t;if(typeof t!="string")return;let r=Nv(t);if(r)return new vt(...r,!1)}get rgb(){let{r:t,g:r,b:i,a}=this,n=a||1/0;return this.overwriteGetter("rgb",[t/n,r/n,i/n,a])}get hcl(){return this.overwriteGetter("hcl",Ov(this.rgb))}get lab(){return this.overwriteGetter("lab",t_(this.rgb))}overwriteGetter(t,r){return Object.defineProperty(this,t,{value:r}),r}toString(){let[t,r,i,a]=this.rgb;return`rgba(${[t,r,i].map(n=>Math.round(n*255)).join(",")},${a})`}static interpolate(t,r,i,a="rgb"){switch(a){case"rgb":{let[n,s,o,l]=Ua(t.rgb,r.rgb,i);return new vt(n,s,o,l,!1)}case"hcl":{let[n,s,o,l]=t.hcl,[u,h,c,d]=r.hcl,p,f;if(!isNaN(n)&&!isNaN(u)){let v=u-n;u>n&&v>180?v-=360:u<n&&n-u>180&&(v+=360),p=n+i*v}else isNaN(n)?isNaN(u)?p=NaN:(p=u,(o===1||o===0)&&(f=h)):(p=n,(c===1||c===0)&&(f=s));let[m,g,_,y]=$v([p,f??wi(s,h,i),wi(o,c,i),wi(l,d,i)]);return new vt(m,g,_,y,!1)}case"lab":{let[n,s,o,l]=r_(Ua(t.lab,r.lab,i));return new vt(n,s,o,l,!1)}}}},vt.black=new vt(0,0,0,1),vt.white=new vt(1,1,1,1),vt.transparent=new vt(0,0,0,0),vt.red=new vt(1,0,0,1),vt);const qv=["bottom","center","top"];var _h=class{constructor(t,r,i,a,n,s){this.text=t,this.image=r,this.scale=i,this.fontStack=a,this.textColor=n,this.verticalAlign=s}},ui=class To{constructor(t){this.sections=t}static fromString(t){return new To([new _h(t,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof To?t:To.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}},Hr=class An{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof An)return t;if(typeof t=="number")return new An([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let r of t)if(typeof r!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new An(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,r,i){return new An(Ua(t.values,r.values,i))}},Xr=class Cn{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Cn)return t;if(typeof t=="number")return new Cn([t]);if(Array.isArray(t)){for(let r of t)if(typeof r!="number")return;return new Cn(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,r,i){return new Cn(Ua(t.values,r.values,i))}},_r=class In{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof In)return t;if(typeof t=="string"){let i=se.parse(t);return i?new In([i]):void 0}if(!Array.isArray(t))return;let r=[];for(let i of t){if(typeof i!="string")return;let a=se.parse(i);if(!a)return;r.push(a)}return new In(r)}toString(){return JSON.stringify(this.values)}static interpolate(t,r,i,a="rgb"){let n=[];if(t.values.length!=r.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${r.values.length}), cannot interpolate.`);for(let s=0;s<t.values.length;s++)n.push(se.interpolate(t.values[s],r.values[s],i,a));return new In(n)}},qe=class extends Error{constructor(e,t){super(e),this.name="RuntimeError",this.path=t}toJSON(){return this.message}};const Zv=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var Zr=class Do{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Do)return t;if(!(!Array.isArray(t)||t.length<1||t.length%2!=0)){for(let r=0;r<t.length;r+=2){let i=t[r],a=t[r+1];if(typeof i!="string"||!Zv.has(i)||!Array.isArray(a)||a.length!==2||typeof a[0]!="number"||typeof a[1]!="number")return}return new Do(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,r,i,a){let n=t.values,s=r.values;if(n.length!==s.length)throw new qe(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${r.toString()}`,a);let o=[];for(let l=0;l<n.length;l+=2){if(n[l]!==s[l])throw new qe(`Cannot interpolate values containing mismatched anchors. from[${l}]: ${n[l]}, to[${l}]: ${s[l]}`,a);o.push(n[l]);let[u,h]=n[l+1],[c,d]=s[l+1];o.push([wi(u,c,i),wi(h,d,i)])}return new Do(o)}},Wr=class i_{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new i_({name:t,available:!1}):null}},Ii=class Ea{constructor(t,r,i){this.from=t,this.to=r,this.transition=i}toString(){return this.from===this.to&&this.transition===1?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(t,r,i){return new Ea(t,r,i)}static parse(t){if(t instanceof Ea)return t;if(Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number")return new Ea(t[0],t[1],t[2]);if(typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number")return new Ea(t.from,t.to,t.transition);if(typeof t=="string")return new Ea(t,t,1)}},Hc=class{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};function a_(e,t,r,i){return typeof e=="number"&&e>=0&&e<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof r=="number"&&r>=0&&r<=255?i===void 0||typeof i=="number"&&i>=0&&i<=1?null:`Invalid rgba value [${[e,t,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof i=="number"?[e,t,r,i]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ga(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||e instanceof Ii||e instanceof se||e instanceof Hc||e instanceof ui||e instanceof Hr||e instanceof Xr||e instanceof _r||e instanceof Zr||e instanceof Wr)return!0;if(Array.isArray(e)){for(let t of e)if(!Ga(t))return!1;return!0}if(typeof e=="object"){for(let t in e)if(!Ga(e[t]))return!1;return!0}return!1}function at(e){if(e===null)return cs;if(typeof e=="string")return oe;if(typeof e=="boolean")return fe;if(typeof e=="number")return j;if(e instanceof se)return Er;if(e instanceof Ii)return yl;if(e instanceof Hc)return xl;if(e instanceof ui)return ds;if(e instanceof Hr)return vl;if(e instanceof Xr)return bl;if(e instanceof _r)return Gn;if(e instanceof Zr)return wl;if(e instanceof Wr)return ps;if(Array.isArray(e)){let t=e.length,r;for(let i of e){let a=at(i);if(!r)r=a;else{if(r===a)continue;r=ue;break}}return kt(r||ue,t)}return qi}function Ln(e){let t=typeof e;return e===null?"":t==="string"||t==="number"||t==="boolean"?String(e):e instanceof se||e instanceof Ii||e instanceof ui||e instanceof Hr||e instanceof Xr||e instanceof _r||e instanceof Zr||e instanceof Wr?e.toString():JSON.stringify(e)}var qa=class n_{constructor(t,r){this.type=t,this.value=r}static parse(t,r){if(t.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ga(t[1]))return r.error(`invalid value of type "${typeof t[1]}"`);let i=t[1],a=at(i),n=r.expectedType;return a.kind==="array"&&a.N===0&&n&&n.kind==="array"&&(typeof n.N!="number"||n.N===0)&&(a=n),new n_(a,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const Wv=["Unknown","Point","LineString","Polygon"];var s_=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Wv[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let r=this._parseColorCache.get(t);return r||(r=se.parse(t),this._parseColorCache.set(t,r)),r}};function Tl(e,t,r){let i=e.length-1,a=0,n=i,s=0,o,l;for(;a<=n;)if(s=Math.floor((a+n)/2),o=e[s],l=e[s+1],o<=t){if(s===i||t<l)return s;a=s+1}else if(o>t)n=s-1;else throw new qe("Input is not a number.",r);return 0}var Xc=class o_{constructor(t,r,i,a){this.type=t,this.input=r,this.key=a,this.labels=[],this.outputs=[];for(let[n,s]of i)this.labels.push(n),this.outputs.push(s)}static parse(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");let i=r.parse(t[1],1,j);if(!i)return null;let a=[],n=null;r.expectedType&&r.expectedType.kind!=="value"&&(n=r.expectedType);for(let s=1;s<t.length;s+=2){let o=s===1?-1/0:t[s],l=t[s+1],u=s,h=s+1;if(typeof o!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',u);if(a.length&&a[a.length-1][0]>=o)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);let c=r.parse(l,h,n);if(!c)return null;n||(n=c.type),a.push([o,c])}return new o_(n,i,a,r.key)}evaluate(t){let r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(t);let a=this.input.evaluate(t);if(a<=r[0])return i[0].evaluate(t);let n=r.length;return a>=r[n-1]?i[n-1].evaluate(t):i[Tl(r,a,this.key)].evaluate(t)}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function Hv(e,t,r,i){let a=3*e,n=3*(r-e)-a,s=1-a-n,o=3*t,l=3*(i-t)-o,u=1-o-l;return function(h,c=1e-6){if(h<=0)return 0;if(h>=1)return 1;let d=h;for(let m=0;m<8;m++){let g=((s*d+n)*d+a)*d-h;if(Math.abs(g)<c)return((u*d+l)*d+o)*d;let _=(3*s*d+2*n)*d+a;if(Math.abs(_)<1e-6)break;d-=g/_}let p=0,f=1;d=h;for(let m=0;m<20;m++){let g=((s*d+n)*d+a)*d;if(Math.abs(g-h)<c)break;h>g?p=d:f=d,d=(p+f)*.5}return((u*d+l)*d+o)*d}}var yr=class yh{constructor(t,r,i,a,n,s){this.type=t,this.operator=r,this.interpolation=i,this.input=a,this.key=s,this.labels=[],this.outputs=[];for(let[o,l]of n)this.labels.push(o),this.outputs.push(l)}static interpolationFactor(t,r,i,a){let n=0;if(t.name==="exponential")n=Au(r,t.base,i,a);else if(t.name==="linear")n=Au(r,1,i,a);else if(t.name==="cubic-bezier"){let s=t.controlPoints;n=Hv(s[0],s[1],s[2],s[3])(Au(r,1,i,a))}return n}static parse(t,r){let[i,a,n,...s]=t;if(!Array.isArray(a)||a.length===0)return r.error("Expected an interpolation type expression.",1);if(a[0]==="linear")a={name:"linear"};else if(a[0]==="exponential"){let u=a[1];if(typeof u!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:u}}else if(a[0]==="cubic-bezier"){let u=a.slice(1);if(u.length!==4||u.some(h=>typeof h!="number"||h<0||h>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:u}}else return r.error(`Unknown interpolation type ${String(a[0])}`,1,0);if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(n=r.parse(n,2,j),!n)return null;let o=[],l=null;(i==="interpolate-hcl"||i==="interpolate-lab")&&r.expectedType!=Gn?l=Er:r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);for(let u=0;u<s.length;u+=2){let h=s[u],c=s[u+1],d=u+3,p=u+4;if(typeof h!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',d);if(o.length&&o[o.length-1][0]>=h)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);let f=r.parse(c,p,l);if(!f)return null;l||(l=f.type),o.push([h,f])}return!mi(l,j)&&!mi(l,yl)&&!mi(l,Er)&&!mi(l,vl)&&!mi(l,bl)&&!mi(l,Gn)&&!mi(l,wl)&&!mi(l,kt(j))?r.error(`Type ${Ke(l)} is not interpolatable.`):new yh(l,i,a,n,o,r.key)}evaluate(t){let r=this.labels,i=this.outputs;if(r.length===1)return i[0].evaluate(t);let a=this.input.evaluate(t);if(a<=r[0])return i[0].evaluate(t);let n=r.length;if(a>=r[n-1])return i[n-1].evaluate(t);let s=Tl(r,a,this.key),o=r[s],l=r[s+1],u=yh.interpolationFactor(this.interpolation,a,o,l),h=i[s].evaluate(t),c=i[s+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return wi(h,c,u);case"color":return se.interpolate(h,c,u);case"padding":return Hr.interpolate(h,c,u);case"colorArray":return _r.interpolate(h,c,u);case"numberArray":return Xr.interpolate(h,c,u);case"variableAnchorOffsetCollection":return Zr.interpolate(h,c,u,this.key);case"array":return Ua(h,c,u);case"projectionDefinition":return Ii.interpolate(h,c,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return se.interpolate(h,c,u,"hcl");case"colorArray":return _r.interpolate(h,c,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return se.interpolate(h,c,u,"lab");case"colorArray":return _r.interpolate(h,c,u,"lab")}}}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function Au(e,t,r,i){let a=i-r,n=e-r;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}const We={color:se.interpolate,number:wi,padding:Hr.interpolate,numberArray:Xr.interpolate,colorArray:_r.interpolate,variableAnchorOffsetCollection:Zr.interpolate,array:Ua};var l_=class u_{constructor(t){this.type=ds,this.sections=t}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let i=t[1];if(!Array.isArray(i)&&typeof i=="object")return r.error("First argument must be an image or text section.");let a=[],n=!1;for(let s=1;s<=t.length-1;++s){let o=t[s];if(n&&typeof o=="object"&&!Array.isArray(o)){n=!1;let l=null;if(o["font-scale"]&&(l=r.parse(o["font-scale"],1,j),!l))return null;let u=null;if(o["text-font"]&&(u=r.parse(o["text-font"],1,kt(oe)),!u))return null;let h=null;if(o["text-color"]&&(h=r.parse(o["text-color"],1,Er),!h))return null;let c=null;if(o["vertical-align"]){if(typeof o["vertical-align"]=="string"&&!qv.includes(o["vertical-align"]))return r.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(c=r.parse(o["vertical-align"],1,oe),!c)return null}let d=a[a.length-1];d.scale=l,d.font=u,d.textColor=h,d.verticalAlign=c}else{let l=r.parse(t[s],1,ue);if(!l)return null;let u=l.type.kind;if(u!=="string"&&u!=="value"&&u!=="null"&&u!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,a.push({content:l,scale:null,font:null,textColor:null,verticalAlign:null})}}return new u_(a)}evaluate(t){return new ui(this.sections.map(r=>{let i=r.content.evaluate(t);return at(i)===ps?new _h("",i,null,null,null,r.verticalAlign?r.verticalAlign.evaluate(t):null):new _h(Ln(i),null,r.scale?r.scale.evaluate(t):null,r.font?r.font.evaluate(t).join(","):null,r.textColor?r.textColor.evaluate(t):null,r.verticalAlign?r.verticalAlign.evaluate(t):null)}))}eachChild(t){for(let r of this.sections)t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor),r.verticalAlign&&t(r.verticalAlign)}outputDefined(){return!1}};function h_(e,t,r=0,i=e.length-1,a=Xv){for(;i>r;){if(i-r>600){let l=i-r+1,u=t-r+1,h=Math.log(l),c=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*c*(l-c)/l)*(u-l/2<0?-1:1);h_(e,t,Math.max(r,Math.floor(t-u*c/l+d)),Math.min(i,Math.floor(t+(l-u)*c/l+d)),a)}let n=e[t],s=r,o=i;for(gn(e,r,t),a(e[i],n)>0&&gn(e,r,i);s<o;){for(gn(e,s,o),s++,o--;a(e[s],n)<0;)s++;for(;a(e[o],n)>0;)o--}a(e[r],n)===0?gn(e,r,o):(o++,gn(e,o,i)),o<=t&&(r=o+1),t<=o&&(i=o-1)}}function gn(e,t,r){let i=e[t];e[t]=e[r],e[r]=i}function Xv(e,t){return e<t?-1:+(e>t)}function Dl(e,t){if(e.length<=1)return[e];let r=[],i,a;for(let n of e){let s=Kv(n);s!==0&&(n.area=Math.abs(s),a===void 0&&(a=s<0),a===s<0?(i&&r.push(i),i=[n]):i.push(n))}if(i&&r.push(i),t>1)for(let n=0;n<r.length;n++)r[n].length<=t||(h_(r[n],t,1,r[n].length-1,Yv),r[n]=r[n].slice(0,t));return r}function Yv(e,t){return t.area-e.area}function Kv(e){let t=0;for(let r=0,i=e.length,a=i-1,n,s;r<i;a=r++)n=e[r],s=e[a],t+=(s.x-n.x)*(n.y+s.y);return t}const Zs={string:oe,number:j,boolean:fe,object:qi};var ti=class c_{constructor(t,r,i){this.type=t,this.args=r,this.key=i}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let i=1,a,n=t[0];if(n==="array"){let o;if(t.length>2){let u=t[1];if(typeof u!="string"||!(u in Zs)||u==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);o=Zs[u],i++}else o=ue;let l;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);l=t[2],i++}a=kt(o,l)}else{if(!Zs[n])throw Error(`Types doesn't contain name = ${n}`);a=Zs[n]}let s=[];for(;i<t.length;i++){let o=r.parse(t[i],i,ue);if(!o)return null;s.push(o)}return new c_(a,s,r.key)}evaluate(t){for(let r=0;r<this.args.length;r++){let i=this.args[r].evaluate(t);if(!qn(this.type,at(i)))return i;if(r===this.args.length-1)throw new qe(`Expected value to be of type ${Ke(this.type)}, but found ${Ke(at(i))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};const Wp={"to-boolean":fe,"to-color":Er,"to-number":j,"to-string":oe};var Ia=class d_{constructor(t,r,i){this.type=t,this.args=r,this.key=i}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let i=t[0];if(!Wp[i])throw Error(`Can't parse ${i} as it is not part of the known types`);if((i==="to-boolean"||i==="to-string")&&t.length!==2)return r.error("Expected one argument.");let a=Wp[i],n=[];for(let s=1;s<t.length;s++){let o=r.parse(t[s],s,ue);if(!o)return null;n.push(o)}return new d_(a,n,r.key)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let r,i;for(let a of this.args){if(r=a.evaluate(t),i=null,r instanceof se)return r;if(typeof r=="string"){let n=t.parseColor(r);if(n)return n}else if(Array.isArray(r)&&(i=r.length<3||r.length>4?`Invalid rgba value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:a_(r[0],r[1],r[2],r[3]),!i))return new se(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new qe(i||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"padding":{let r;for(let i of this.args){r=i.evaluate(t);let a=Hr.parse(r);if(a)return a}throw new qe(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"numberArray":{let r;for(let i of this.args){r=i.evaluate(t);let a=Xr.parse(r);if(a)return a}throw new qe(`Could not parse numberArray from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"colorArray":{let r;for(let i of this.args){r=i.evaluate(t);let a=_r.parse(r);if(a)return a}throw new qe(`Could not parse colorArray from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"variableAnchorOffsetCollection":{let r;for(let i of this.args){r=i.evaluate(t);let a=Zr.parse(r);if(a)return a}throw new qe(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}case"number":{let r=null;for(let i of this.args){if(r=i.evaluate(t),r===null)return 0;let a=Number(r);if(!isNaN(a))return a}throw new qe(`Could not convert ${JSON.stringify(r)} to number.`,this.key)}case"formatted":return ui.fromString(Ln(this.args[0].evaluate(t)));case"resolvedImage":return Wr.fromString(Ln(this.args[0].evaluate(t)));case"projectionDefinition":{let r=this.args[0].evaluate(t);if(Ii.parse(r))return r;throw new qe(`Could not parse projectionDefinition from value '${typeof r=="string"?r:JSON.stringify(r)}'`,this.key)}default:return Ln(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}},p_=class f_{constructor(t,r){this.type=r.type,this.bindings=[].concat(t),this.result=r}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let r of this.bindings)t(r[1]);t(this.result)}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let i=[];for(let n=1;n<t.length-1;n+=2){let s=t[n];if(typeof s!="string")return r.error(`Expected string, but found ${typeof s} instead.`,n);if(/[^a-zA-Z0-9_]/.test(s))return r.error("Variable names must contain only alphanumeric characters or '_'.",n);let o=r.parse(t[n+1],n+1);if(!o)return null;i.push([s,o])}let a=r.parse(t[t.length-1],t.length-1,r.expectedType,i);return a?new f_(i,a):null}outputDefined(){return this.result.outputDefined()}},m_=class g_{constructor(t,r){this.type=r.type,this.name=t,this.boundExpression=r}static parse(t,r){if(t.length!==2||typeof t[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");let i=t[1];return r.scope.has(i)?new g_(i,r.scope.get(i)):r.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}},Jv=class __{constructor(t,r,i,a){this.type=t,this.index=r,this.input=i,this.key=a}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let i=r.parse(t[1],1,j),a=r.parse(t[2],2,kt(r.expectedType||ue));if(!i||!a)return null;let n=a.type;return new __(n.itemType,i,a,r.key)}evaluate(t){let r=this.index.evaluate(t),i=this.input.evaluate(t);if(r<0)throw new qe(`Array index out of bounds: ${r} < 0.`,this.key);if(r>=i.length)throw new qe(`Array index out of bounds: ${r} > ${i.length-1}.`,this.key);if(r!==Math.floor(r))throw new qe(`Array index must be an integer, but found ${r} instead.`,this.key);return i[r]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},Qv=class y_{constructor(t,r,i){this.needle=t,this.haystack=r,this.key=i,this.type=fe}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let i=r.parse(t[1],1,ue),a=r.parse(t[2],2,ue);return!i||!a?null:Wc(i.type,[fe,oe,j,cs,ue])?new y_(i,a,r.key):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`)}evaluate(t){let r=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!Zi(r,["boolean","string","number","null"]))throw new qe(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(at(r))} instead.`,this.key);if(!Zi(i,["string","array"]))throw new qe(`Expected second argument to be of type array or string, but found ${Ke(at(i))} instead.`,this.key);return i.indexOf(r)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},eb=class xh{constructor(t,r,i,a){this.needle=t,this.haystack=r,this.key=i,this.fromIndex=a,this.type=j}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let i=r.parse(t[1],1,ue),a=r.parse(t[2],2,ue);if(!i||!a)return null;if(!Wc(i.type,[fe,oe,j,cs,ue]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(t.length===4){let n=r.parse(t[3],3,j);return n?new xh(i,a,r.key,n):null}return new xh(i,a,r.key)}evaluate(t){let r=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Zi(r,["boolean","string","number","null"]))throw new qe(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(at(r))} instead.`,this.key);let a;if(this.fromIndex&&(a=this.fromIndex.evaluate(t)),Zi(i,["string"])){let n=i.indexOf(r,a);return n===-1?-1:[...i.slice(0,n)].length}if(Zi(i,["array"]))return i.indexOf(r,a);throw new qe(`Expected second argument to be of type array or string, but found ${Ke(at(i))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},tb=class x_{constructor(t,r,i,a,n,s){this.inputType=t,this.type=r,this.input=i,this.cases=a,this.outputs=n,this.otherwise=s}static parse(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");let i,a;r.expectedType&&r.expectedType.kind!=="value"&&(a=r.expectedType);let n={},s=[];for(let u=2;u<t.length-1;u+=2){let h=t[u],c=t[u+1];Array.isArray(h)||(h=[h]);let d=r.concat(u);if(h.length===0)return d.error("Expected at least one branch label.");for(let f of h){if(typeof f!="number"&&typeof f!="string")return d.error("Branch labels must be numbers or strings.");if(typeof f=="number"&&Math.abs(f)>2**53-1)return d.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof f=="number"&&Math.floor(f)!==f)return d.error("Numeric branch labels must be integer values.");if(!i)i=at(f);else if(d.checkSubtype(i,at(f)))return null;if(n[String(f)]!==void 0)return d.error("Branch labels must be unique.");n[String(f)]=s.length}let p=r.parse(c,u,a);if(!p)return null;a||(a=p.type),s.push(p)}let o=r.parse(t[1],1,ue);if(!o)return null;let l=r.parse(t[t.length-1],t.length-1,a);return!l||o.type.kind!=="value"&&r.concat(1).checkSubtype(i,o.type)?null:new x_(i,a,o,n,s,l)}evaluate(t){let r=this.input.evaluate(t);return(at(r)===this.inputType&&this.outputs[this.cases[r]]||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()}},rb=class v_{constructor(t,r,i){this.type=t,this.branches=r,this.otherwise=i}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");let i;r.expectedType&&r.expectedType.kind!=="value"&&(i=r.expectedType);let a=[];for(let s=1;s<t.length-1;s+=2){let o=r.parse(t[s],s,fe);if(!o)return null;let l=r.parse(t[s+1],s+1,i);if(!l)return null;a.push([o,l]),i||(i=l.type)}let n=r.parse(t[t.length-1],t.length-1,i);if(!n)return null;if(!i)throw Error("Can't infer output type");return new v_(i,a,n)}evaluate(t){for(let[r,i]of this.branches)if(r.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[r,i]of this.branches)t(r),t(i);t(this.otherwise)}outputDefined(){return this.branches.every(([t,r])=>r.outputDefined())&&this.otherwise.outputDefined()}},ib=class vh{constructor(t,r,i,a,n){this.type=t,this.input=r,this.beginIndex=i,this.key=a,this.endIndex=n}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let i=r.parse(t[1],1,ue),a=r.parse(t[2],2,j);if(!i||!a)return null;if(!Wc(i.type,[kt(ue),oe,ue]))return r.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(t.length===4){let n=r.parse(t[3],3,j);return n?new vh(i.type,i,a,r.key,n):null}return new vh(i.type,i,a,r.key)}evaluate(t){let r=this.input.evaluate(t),i=this.beginIndex.evaluate(t),a;if(this.endIndex&&(a=this.endIndex.evaluate(t)),Zi(r,["string"]))return[...r].slice(i,a).join("");if(Zi(r,["array"]))return r.slice(i,a);throw new qe(`Expected first argument to be of type array or string, but found ${Ke(at(r))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},b_=class bh{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let i=null,a=r.expectedType;a&&a.kind!=="value"&&(i=a);let n=[];for(let s of t.slice(1)){let o=r.parse(s,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!o)return null;i||(i=o.type),n.push(o)}if(!i)throw Error("No output type");return a&&n.some(s=>qn(a,s.type))?new bh(ue,n):new bh(i,n)}evaluate(t){let r=null,i=0,a;for(let n of this.args)if(i++,r=n.evaluate(t),r&&r instanceof Wr&&!r.available&&(a||(a=r.name),r=null,i===this.args.length&&(r=a)),r!==null)break;return r}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function Hp(e,t){return e==="=="||e==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function ab(e,t,r){return t===r}function nb(e,t,r){return t!==r}function sb(e,t,r){return t<r}function ob(e,t,r){return t>r}function lb(e,t,r){return t<=r}function ub(e,t,r){return t>=r}function w_(e,t,r,i){return i.compare(t,r)===0}function hb(e,t,r,i){return!w_(e,t,r,i)}function cb(e,t,r,i){return i.compare(t,r)<0}function db(e,t,r,i){return i.compare(t,r)>0}function pb(e,t,r,i){return i.compare(t,r)<=0}function fb(e,t,r,i){return i.compare(t,r)>=0}function Qa(e,t,r){let i=e!=="=="&&e!=="!=";return class T_{constructor(n,s,o,l){this.lhs=n,this.rhs=s,this.key=o,this.collator=l,this.type=fe,this.hasUntypedArgument=n.type.kind==="value"||s.type.kind==="value"}static parse(n,s){if(n.length!==3&&n.length!==4)return s.error("Expected two or three arguments.");let o=n[0],l=s.parse(n[1],1,ue);if(!l)return null;if(!Hp(o,l.type))return s.concat(1).error(`"${o}" comparisons are not supported for type '${Ke(l.type)}'.`);let u=s.parse(n[2],2,ue);if(!u)return null;if(!Hp(o,u.type))return s.concat(2).error(`"${o}" comparisons are not supported for type '${Ke(u.type)}'.`);if(l.type.kind!==u.type.kind&&l.type.kind!=="value"&&u.type.kind!=="value")return s.error(`Cannot compare types '${Ke(l.type)}' and '${Ke(u.type)}'.`);i&&(l.type.kind==="value"&&u.type.kind!=="value"?l=new ti(u.type,[l],s.key):l.type.kind!=="value"&&u.type.kind==="value"&&(u=new ti(l.type,[u],s.key)));let h=null;if(n.length===4){if(l.type.kind!=="string"&&u.type.kind!=="string"&&l.type.kind!=="value"&&u.type.kind!=="value")return s.error("Cannot use collator to compare non-string types.");if(h=s.parse(n[3],3,xl),!h)return null}return new T_(l,u,s.key,h)}evaluate(n){let s=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(i&&this.hasUntypedArgument){let l=at(s),u=at(o);if(l.kind!==u.kind||l.kind!=="string"&&l.kind!=="number")throw new qe(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${l.kind}, ${u.kind}) instead.`,this.key)}if(this.collator&&!i&&this.hasUntypedArgument){let l=at(s),u=at(o);if(l.kind!=="string"||u.kind!=="string")return t(n,s,o)}return this.collator?r(n,s,o,this.collator.evaluate(n)):t(n,s,o)}eachChild(n){n(this.lhs),n(this.rhs),this.collator&&n(this.collator)}outputDefined(){return!0}}}const mb=Qa("==",ab,w_),gb=Qa("!=",nb,hb),_b=Qa("<",sb,cb),yb=Qa(">",ob,db),xb=Qa("<=",lb,pb),vb=Qa(">=",ub,fb);var D_=class S_{constructor(t,r,i){this.type=xl,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=r}static parse(t,r){if(t.length!==2)return r.error("Expected one argument.");let i=t[1];if(typeof i!="object"||Array.isArray(i))return r.error("Collator options argument must be an object.");let a=r.parse(i["case-sensitive"]!==void 0&&i["case-sensitive"],1,fe);if(!a)return null;let n=r.parse(i["diacritic-sensitive"]!==void 0&&i["diacritic-sensitive"],1,fe);if(!n)return null;let s=null;return i.locale&&(s=r.parse(i.locale,1,oe),!s)?null:new S_(a,n,s)}evaluate(t){return new Hc(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}},bb=class E_{constructor(t,r,i,a,n,s){this.type=oe,this.number=t,this.locale=r,this.currency=i,this.unit=a,this.minFractionDigits=n,this.maxFractionDigits=s}static parse(t,r){if(t.length!==3)return r.error("Expected two arguments.");let i=r.parse(t[1],1,j);if(!i)return null;let a=t[2];if(typeof a!="object"||Array.isArray(a))return r.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&(n=r.parse(a.locale,1,oe),!n))return null;let s=null;if(a.currency&&(s=r.parse(a.currency,1,oe),!s))return null;let o=null;if(a.unit&&(o=r.parse(a.unit,1,oe),!o))return null;if(s&&o)return r.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(a["min-fraction-digits"]&&(l=r.parse(a["min-fraction-digits"],1,j),!l))return null;let u=null;return a["max-fraction-digits"]&&(u=r.parse(a["max-fraction-digits"],1,j),!u)?null:new E_(i,n,s,o,l,u)}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}},wb=class P_{constructor(t){this.type=ps,this.input=t}static parse(t,r){if(t.length!==2)return r.error("Expected two arguments.");let i=r.parse(t[1],1,oe);return i?new P_(i):r.error("No image name provided.")}evaluate(t){let r=this.input.evaluate(t),i=Wr.fromString(r);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(r)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}},Tb=class A_{constructor(t,r){this.input=t,this.key=r,this.type=j}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);let i=r.parse(t[1],1);return i?i.type.kind!=="array"&&i.type.kind!=="string"&&i.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${Ke(i.type)} instead.`):new A_(i,r.key):null}evaluate(t){let r=this.input.evaluate(t);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new qe(`Expected value to be of type string or array, but found ${Ke(at(r))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}};const Ur=8192;function Db(e,t){let r=Sb(e[0]),i=Pb(e[1]),a=2**t.z;return[Math.round(r*a*Ur),Math.round(i*a*Ur)]}function Yc(e,t){let r=2**t.z,i=(e[0]/Ur+t.x)/r,a=(e[1]/Ur+t.y)/r;return[Eb(i),Ab(a)]}function Sb(e){return(180+e)/360}function Eb(e){return e*360-180}function Pb(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Ab(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}function fs(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Zn(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Cb(e,t,r){return t[1]>e[1]!=r[1]>e[1]&&e[0]<(r[0]-t[0])*(e[1]-t[1])/(r[1]-t[1])+t[0]}function Ib(e,t,r){let i=e[0]-t[0],a=e[1]-t[1],n=e[0]-r[0],s=e[1]-r[1];return i*s-n*a===0&&i*n<=0&&a*s<=0}function Sl(e,t,r,i){let a=[t[0]-e[0],t[1]-e[1]];return Rb([i[0]-r[0],i[1]-r[1]],a)!==0&&!!(Xp(e,t,r,i)&&Xp(r,i,e,t))}function Mb(e,t,r){for(let i of r)for(let a=0;a<i.length-1;++a)if(Sl(e,t,i[a],i[a+1]))return!0;return!1}function en(e,t,r=!1){let i=!1;for(let a of t)for(let n=0;n<a.length-1;n++){if(Ib(e,a[n],a[n+1]))return r;Cb(e,a[n],a[n+1])&&(i=!i)}return i}function zb(e,t){for(let r of t)if(en(e,r))return!0;return!1}function C_(e,t){for(let r of e)if(!en(r,t))return!1;for(let r=0;r<e.length-1;++r)if(Mb(e[r],e[r+1],t))return!1;return!0}function Fb(e,t){for(let r of t)if(C_(e,r))return!0;return!1}function Rb(e,t){return e[0]*t[1]-e[1]*t[0]}function Xp(e,t,r,i){let a=e[0]-r[0],n=e[1]-r[1],s=t[0]-r[0],o=t[1]-r[1],l=i[0]-r[0],u=i[1]-r[1],h=a*u-l*n,c=s*u-l*o;return h>0&&c<0||h<0&&c>0}function Kc(e,t,r){let i=[];for(let a=0;a<e.length;a++){let n=[];for(let s=0;s<e[a].length;s++){let o=Db(e[a][s],r);fs(t,o),n.push(o)}i.push(n)}return i}function I_(e,t,r){let i=[];for(let a=0;a<e.length;a++){let n=Kc(e[a],t,r);i.push(n)}return i}function M_(e,t,r,i){if(e[0]<r[0]||e[0]>r[2]){let a=i*.5,n=e[0]-r[0]>a?-i:r[0]-e[0]>a?i:0;n===0&&(n=e[0]-r[2]>a?-i:r[2]-e[0]>a?i:0),e[0]+=n}fs(t,e)}function kb(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}function Yp(e,t,r,i){let a=2**i.z*Ur,n=[i.x*Ur,i.y*Ur],s=[];for(let o of e)for(let l of o){let u=[l.x+n[0],l.y+n[1]];M_(u,t,r,a),s.push(u)}return s}function Kp(e,t,r,i){let a=2**i.z*Ur,n=[i.x*Ur,i.y*Ur],s=[];for(let o of e){let l=[];for(let u of o){let h=[u.x+n[0],u.y+n[1]];fs(t,h),l.push(h)}s.push(l)}if(t[2]-t[0]<=a/2){kb(t);for(let o of s)for(let l of o)M_(l,t,r,a)}return s}function Lb(e,t){let r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=Kc(t.coordinates,i,a),s=Yp(e.geometry(),r,i,a);if(!Zn(r,i))return!1;for(let o of s)if(!en(o,n))return!1}if(t.type==="MultiPolygon"){let n=I_(t.coordinates,i,a),s=Yp(e.geometry(),r,i,a);if(!Zn(r,i))return!1;for(let o of s)if(!zb(o,n))return!1}return!0}function Bb(e,t){let r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=Kc(t.coordinates,i,a),s=Kp(e.geometry(),r,i,a);if(!Zn(r,i))return!1;for(let o of s)if(!C_(o,n))return!1}if(t.type==="MultiPolygon"){let n=I_(t.coordinates,i,a),s=Kp(e.geometry(),r,i,a);if(!Zn(r,i))return!1;for(let o of s)if(!Fb(o,n))return!1}return!0}var Jc=class So{constructor(t,r){this.type=fe,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ga(t[1])){let i=t[1];if(i.type==="FeatureCollection"){let a=[];for(let n of i.features){let{type:s,coordinates:o}=n.geometry;s==="Polygon"&&a.push(o),s==="MultiPolygon"&&a.push(...o)}if(a.length)return new So(i,{type:"MultiPolygon",coordinates:a})}else if(i.type==="Feature"){let a=i.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new So(i,i.geometry)}else if(i.type==="Polygon"||i.type==="MultiPolygon")return new So(i,i)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return Lb(t,this.geometries);if(t.geometryType()==="LineString")return Bb(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},z_=class{constructor(t=[],r=(i,a)=>i<a?-1:+(i>a)){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:r,compare:i}=this,a=r[t];for(;t>0;){let n=t-1>>1,s=r[n];if(i(a,s)>=0)break;r[t]=s,t=n}r[t]=a}_down(t){let{data:r,compare:i}=this,a=this.length>>1,n=r[t];for(;t<a;){let s=(t<<1)+1,o=s+1;if(o<this.length&&i(r[o],r[s])<0&&(s=o),i(r[s],n)>=0)break;r[t]=r[s],t=s}r[t]=n}};const Jp=Math.PI/180;var Qc=class{constructor(t){let r=Jp*6378.137*1e3,i=Math.cos(t*Jp),a=1/(1-.0066943799901413165*(1-i*i)),n=Math.sqrt(a);this.kx=r*n*i,this.ky=r*n*a*.9933056200098587}distance(t,r){let i=this.wrap(t[0]-r[0])*this.kx,a=(t[1]-r[1])*this.ky;return Math.sqrt(i*i+a*a)}pointOnLine(t,r){let i=1/0,a,n,s,o;for(let l=0;l<t.length-1;l++){let u=t[l][0],h=t[l][1],c=this.wrap(t[l+1][0]-u)*this.kx,d=(t[l+1][1]-h)*this.ky,p=0;(c!==0||d!==0)&&(p=(this.wrap(r[0]-u)*this.kx*c+(r[1]-h)*this.ky*d)/(c*c+d*d),p>1?(u=t[l+1][0],h=t[l+1][1]):p>0&&(u+=c/this.kx*p,h+=d/this.ky*p)),c=this.wrap(r[0]-u)*this.kx,d=(r[1]-h)*this.ky;let f=c*c+d*d;f<i&&(i=f,a=u,n=h,s=l,o=p)}return{point:[a,n],index:s,t:Math.max(0,Math.min(1,o))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}};function F_(e,t){return t[0]-e[0]}function jo(e){return e[1]-e[0]+1}function hi(e,t){return e[1]>=e[0]&&e[1]<t}function wh(e,t){if(e[0]>e[1])return[null,null];let r=jo(e);if(t){if(r===2)return[e,null];let a=Math.floor(r/2);return[[e[0],e[0]+a],[e[0]+a,e[1]]]}if(r===1)return[e,null];let i=Math.floor(r/2)-1;return[[e[0],e[0]+i],[e[0]+i+1,e[1]]]}function Th(e,t){if(!hi(t,e.length))return[1/0,1/0,-1/0,-1/0];let r=[1/0,1/0,-1/0,-1/0];for(let i=t[0];i<=t[1];++i)fs(r,e[i]);return r}function Dh(e){let t=[1/0,1/0,-1/0,-1/0];for(let r of e)for(let i of r)fs(t,i);return t}function Qp(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function ed(e,t,r){if(!Qp(e)||!Qp(t))return NaN;let i=0,a=0;return e[2]<t[0]&&(i=t[0]-e[2]),e[0]>t[2]&&(i=e[0]-t[2]),e[1]>t[3]&&(a=e[1]-t[3]),e[3]<t[1]&&(a=t[1]-e[3]),r.distance([0,0],[i,a])}function ji(e,t,r){let i=r.pointOnLine(t,e);return r.distance(e,i.point)}function td(e,t,r,i,a){let n=Math.min(ji(e,[r,i],a),ji(t,[r,i],a)),s=Math.min(ji(r,[e,t],a),ji(i,[e,t],a));return Math.min(n,s)}function Ob(e,t,r,i,a){if(!(hi(t,e.length)&&hi(i,r.length)))return 1/0;let n=1/0;for(let s=t[0];s<t[1];++s){let o=e[s],l=e[s+1];for(let u=i[0];u<i[1];++u){let h=r[u],c=r[u+1];if(Sl(o,l,h,c))return 0;n=Math.min(n,td(o,l,h,c,a))}}return n}function $b(e,t,r,i,a){if(!(hi(t,e.length)&&hi(i,r.length)))return NaN;let n=1/0;for(let s=t[0];s<=t[1];++s)for(let o=i[0];o<=i[1];++o)if(n=Math.min(n,a.distance(e[s],r[o])),n===0)return n;return n}function jb(e,t,r){if(en(e,t,!0))return 0;let i=1/0;for(let a of t){let n=a[0],s=a[a.length-1];if(n!==s&&(i=Math.min(i,ji(e,[s,n],r)),i===0))return i;let o=r.pointOnLine(a,e);if(i=Math.min(i,r.distance(e,o.point)),i===0)return i}return i}function Vb(e,t,r,i){if(!hi(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(en(e[n],r,!0))return 0;let a=1/0;for(let n=t[0];n<t[1];++n){let s=e[n],o=e[n+1];for(let l of r)for(let u=0,h=l.length,c=h-1;u<h;c=u++){let d=l[c],p=l[u];if(Sl(s,o,d,p))return 0;a=Math.min(a,td(s,o,d,p,i))}}return a}function ef(e,t){for(let r of e)for(let i of r)if(en(i,t,!0))return!0;return!1}function Nb(e,t,r,i=1/0){let a=Dh(e),n=Dh(t);if(i!==1/0&&ed(a,n,r)>=i)return i;if(Zn(a,n)){if(ef(e,t))return 0}else if(ef(t,e))return 0;let s=1/0;for(let o of e)for(let l=0,u=o.length,h=u-1;l<u;h=l++){let c=o[h],d=o[l];for(let p of t)for(let f=0,m=p.length,g=m-1;f<m;g=f++){let _=p[g],y=p[f];if(Sl(c,d,_,y))return 0;s=Math.min(s,td(c,d,_,y,r))}}return s}function tf(e,t,r,i,a,n){if(!n)return;let s=ed(Th(i,n),a,r);s<t&&e.push([s,n,[0,0]])}function Ws(e,t,r,i,a,n,s){if(!n||!s)return;let o=ed(Th(i,n),Th(a,s),r);o<t&&e.push([o,n,s])}function Vo(e,t,r,i,a=1/0){let n=Math.min(i.distance(e[0],r[0][0]),a);if(n===0)return n;let s=new z_([[0,[0,e.length-1],[0,0]]],F_),o=Dh(r);for(;s.length>0;){let l=s.pop();if(l[0]>=n)continue;let u=l[1],h=t?50:100;if(jo(u)<=h){if(!hi(u,e.length))return NaN;if(t){let c=Vb(e,u,r,i);if(isNaN(c)||c===0)return c;n=Math.min(n,c)}else for(let c=u[0];c<=u[1];++c){let d=jb(e[c],r,i);if(n=Math.min(n,d),n===0)return 0}}else{let c=wh(u,t);tf(s,n,i,e,o,c[0]),tf(s,n,i,e,o,c[1])}}return n}function No(e,t,r,i,a,n=1/0){let s=Math.min(n,a.distance(e[0],r[0]));if(s===0)return s;let o=new z_([[0,[0,e.length-1],[0,r.length-1]]],F_);for(;o.length>0;){let l=o.pop();if(l[0]>=s)continue;let u=l[1],h=l[2],c=t?50:100,d=i?50:100;if(jo(u)<=c&&jo(h)<=d){if(!hi(u,e.length)&&hi(h,r.length))return NaN;let p;if(t&&i)p=Ob(e,u,r,h,a),s=Math.min(s,p);else if(t&&!i){let f=e.slice(u[0],u[1]+1);for(let m=h[0];m<=h[1];++m)if(p=ji(r[m],f,a),s=Math.min(s,p),s===0)return s}else if(!t&&i){let f=r.slice(h[0],h[1]+1);for(let m=u[0];m<=u[1];++m)if(p=ji(e[m],f,a),s=Math.min(s,p),s===0)return s}else p=$b(e,u,r,h,a),s=Math.min(s,p)}else{let p=wh(u,t),f=wh(h,i);Ws(o,s,a,e,r,p[0],f[0]),Ws(o,s,a,e,r,p[0],f[1]),Ws(o,s,a,e,r,p[1],f[0]),Ws(o,s,a,e,r,p[1],f[1])}}return s}function Ub(e,t){let r=e.geometry(),i=r.flat().map(s=>Yc([s.x,s.y],e.canonical));if(r.length===0)return NaN;let a=new Qc(i[0][1]),n=1/0;for(let s of t){switch(s.type){case"Point":n=Math.min(n,No(i,!1,[s.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,No(i,!1,s.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Vo(i,!1,s.coordinates,a,n))}if(n===0)return n}return n}function Gb(e,t){let r=e.geometry(),i=r.flat().map(s=>Yc([s.x,s.y],e.canonical));if(r.length===0)return NaN;let a=new Qc(i[0][1]),n=1/0;for(let s of t){switch(s.type){case"Point":n=Math.min(n,No(i,!0,[s.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,No(i,!0,s.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Vo(i,!0,s.coordinates,a,n))}if(n===0)return n}return n}function qb(e,t){let r=e.geometry();if(r.length===0||r[0].length===0)return NaN;let i=Dl(r,0).map(s=>s.map(o=>o.map(l=>Yc([l.x,l.y],e.canonical)))),a=new Qc(i[0][0][0][1]),n=1/0;for(let s of t)for(let o of i){switch(s.type){case"Point":n=Math.min(n,Vo([s.coordinates],!1,o,a,n));break;case"LineString":n=Math.min(n,Vo(s.coordinates,!0,o,a,n));break;case"Polygon":n=Math.min(n,Nb(o,s.coordinates,a,n))}if(n===0)return n}return n}function Cu(e){return e.type==="MultiPolygon"?e.coordinates.map(t=>({type:"Polygon",coordinates:t})):e.type==="MultiLineString"?e.coordinates.map(t=>({type:"LineString",coordinates:t})):e.type==="MultiPoint"?e.coordinates.map(t=>({type:"Point",coordinates:t})):[e]}var rd=class Eo{constructor(t,r){this.type=j,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ga(t[1])){let i=t[1];if(i.type==="FeatureCollection")return new Eo(i,i.features.map(a=>Cu(a.geometry)).flat());if(i.type==="Feature")return new Eo(i,Cu(i.geometry));if("type"in i&&"coordinates"in i)return new Eo(i,Cu(i))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return Ub(t,this.geometries);if(t.geometryType()==="LineString")return Gb(t,this.geometries);if(t.geometryType()==="Polygon")return qb(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},Zb=class R_{constructor(t){let r=null;for(let i of t)if(!r)r=i.type;else{if(r===i.type)continue;r=ue;break}this.type=kt(r??ue,t.length),this.arr=t}static parse(t,r){if(t.length!==2)return r.error(`'semiliteral' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ga(t[1]))return r.error(`invalid value of type "${typeof t[1]}"`);let i=t[1],a=at(i);if(a.kind==="array"){let n=i,s=r.concat(1),o=[];for(let l=0;l<n.length;l++){let u=s.parse(n[l],l,ue);if(!u)return null;o.push(u)}return new R_(o)}return new qa(a,i)}evaluate(t){return this.arr.map(r=>r.evaluate(t))}eachChild(t){this.arr.forEach(t)}outputDefined(){return this.arr.every(t=>t.outputDefined())}},id=class k_{constructor(t){this.key=t,this.type=ue}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);let i=t[1];return i==null?r.error("Global state property must be defined."):typeof i=="string"?new k_(i):r.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(t){var i;let r=(i=t.globals)==null?void 0:i.globalState;return!r||Object.keys(r).length===0?null:kn(r,this.key)??null}eachChild(){}outputDefined(){return!1}};const Ra={"==":mb,"!=":gb,">":yb,"<":_b,">=":vb,"<=":xb,array:ti,at:Jv,boolean:ti,case:rb,coalesce:b_,collator:D_,format:l_,image:wb,in:Qv,"index-of":eb,interpolate:yr,"interpolate-hcl":yr,"interpolate-lab":yr,length:Tb,let:p_,literal:qa,match:tb,number:ti,"number-format":bb,object:ti,semiliteral:Zb,slice:ib,step:Xc,string:ti,"to-boolean":Ia,"to-color":Ia,"to-number":Ia,"to-string":Ia,var:m_,within:Jc,distance:rd,"global-state":id};var $r=class extends Error{constructor(t,r){super(r),this.message=r,this.key=t}},Wb=class L_{constructor(t,r=[]){this.parent=t,this.bindings={};for(let[i,a]of r)this.bindings[i]=a}concat(t){return new L_(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]?!0:this.parent?this.parent.has(t):!1}},B_=class O_{constructor(t,r,i=[],a,n=new Wb,s=[]){this.registry=t,this.path=i,this.key=i.map(o=>`[${o}]`).join(""),this.scope=n,this.errors=s,this.expectedType=a,this._isConstant=r}parse(t,r,i,a,n={}){return r==null?this._parse(t,n):this.concat(r,i,a)._parse(t,n)}_parse(t,r){(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number")&&(t=["literal",t]);let i=this.key;function a(n,s,o){return o==="assert"?new ti(s,[n],i):o==="coerce"?new Ia(s,[n],i):n}if(Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let n=t[0];if(typeof n!="string")return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let s=this.registry[n];if(s){let o=s.parse(t,this);if(!o)return null;if(this.expectedType){let l=this.expectedType,u=o.type;if((l.kind==="string"||l.kind==="number"||l.kind==="boolean"||l.kind==="object"||l.kind==="array")&&u.kind==="value")o=a(o,l,r.typeAnnotation||"assert");else if(l.kind==="projectionDefinition"&&["string","array","value"].includes(u.kind)||["color","formatted","resolvedImage"].includes(l.kind)&&["value","string"].includes(u.kind)||["padding","numberArray"].includes(l.kind)&&["value","number","array"].includes(u.kind)||l.kind==="colorArray"&&["value","string","array"].includes(u.kind)||l.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(u.kind))o=a(o,l,r.typeAnnotation||"coerce");else if(this.checkSubtype(l,u))return null}if(!(o instanceof qa)&&o.type.kind!=="resolvedImage"&&this._isConstant(o)){let l=new s_;try{o=new qa(o.type,o.evaluate(l))}catch(u){return this.error(u.message),null}}return o}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return t===void 0?this.error("'undefined' value invalid. Use null instead."):typeof t=="object"?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof t} instead.`)}concat(t,r,i){let a=typeof t=="number"?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new O_(this.registry,this._isConstant,a,r||null,n,this.errors)}error(t,...r){let i=`${this.key}${r.map(a=>`[${a}]`).join("")}`;this.errors.push(new $r(i,t))}checkSubtype(t,r){let i=qn(t,r);return i&&this.error(i),i}},aa=class Mn{constructor(t,r,i,a,n){this.name=t,this.type=r,this._evaluate=i,this.args=a,this.key=n}evaluate(t){return this._evaluate(t,this.args,this.key)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,r){let i=t[0],a=Mn.definitions[i];if(!a)return r.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,s=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,o=s.filter(([u])=>!Array.isArray(u)||u.length===t.length-1),l=null;for(let[u,h]of o){l=new B_(r.registry,Uo,r.path,null,r.scope);let c=[],d=!1;for(let p=1;p<t.length;p++){let f=t[p],m=Array.isArray(u)?u[p-1]:u.type,g=l.parse(f,1+c.length,m);if(!g){d=!0;break}c.push(g)}if(!d){if(Array.isArray(u)&&u.length!==c.length){l.error(`Expected ${u.length} arguments, but found ${c.length} instead.`);continue}for(let p=0;p<c.length;p++){let f=Array.isArray(u)?u[p]:u.type,m=c[p];l.concat(p+1).checkSubtype(f,m.type)}if(l.errors.length===0)return new Mn(i,n,h,c,r.key)}}if(o.length===1)r.errors.push(...l.errors);else{let u=(o.length?o:s).map(([c])=>Xb(c)).join(" | "),h=[];for(let c=1;c<t.length;c++){let d=r.parse(t[c],1+h.length);if(!d)return null;h.push(Ke(d.type))}r.error(`Expected arguments of type ${u}, but found (${h.join(", ")}) instead.`)}return null}static register(t,r){Mn.definitions=r;for(let i in r)t[i]=Mn}};function rf(e,[t,r,i,a],n){t=t.evaluate(e),r=r.evaluate(e),i=i.evaluate(e);let s=a?a.evaluate(e):1,o=a_(t,r,i,s);if(o)throw new qe(o,n);return new se(t/255,r/255,i/255,s,!1)}function af(e,t){return e in t&&t[e]!==void 0}function Iu(e,t){let r=t[e];return r===void 0?null:r}function Hb(e,t,r,i){for(;r<=i;){let a=r+i>>1;if(t[a]===e)return!0;t[a]>e?i=a-1:r=a+1}return!1}function Fi(e){return{type:e}}aa.register(Ra,{error:[Rv,[oe],(e,[t],r)=>{throw new qe(t.evaluate(e),r)}],typeof:[oe,[ue],(e,[t])=>Ke(at(t.evaluate(e)))],"to-rgba":[kt(j,4),[Er],(e,[t])=>{let[r,i,a,n]=t.evaluate(e).rgb;return[r*255,i*255,a*255,n]}],rgb:[Er,[j,j,j],rf],rgba:[Er,[j,j,j,j],rf],has:{type:fe,overloads:[[[oe],(e,[t])=>af(t.evaluate(e),e.properties())],[[oe,qi],(e,[t,r])=>af(t.evaluate(e),r.evaluate(e))]]},get:{type:ue,overloads:[[[oe],(e,[t])=>Iu(t.evaluate(e),e.properties())],[[oe,qi],(e,[t,r])=>Iu(t.evaluate(e),r.evaluate(e))]]},"feature-state":[ue,[oe],(e,[t])=>Iu(t.evaluate(e),e.featureState||{})],properties:[qi,[],e=>e.properties()],"geometry-type":[oe,[],e=>e.geometryType()],id:[ue,[],e=>e.id()],zoom:[j,[],e=>e.globals.zoom],"heatmap-density":[j,[],e=>e.globals.heatmapDensity||0],elevation:[j,[],e=>e.globals.elevation||0],"line-progress":[j,[],e=>e.globals.lineProgress||0],accumulated:[ue,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[j,Fi(j),(e,t)=>{let r=0;for(let i of t)r+=i.evaluate(e);return r}],"*":[j,Fi(j),(e,t)=>{let r=1;for(let i of t)r*=i.evaluate(e);return r}],"-":{type:j,overloads:[[[j,j],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[j],(e,[t])=>-t.evaluate(e)]]},"/":[j,[j,j],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[j,[j,j],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[j,[],()=>Math.LN2],pi:[j,[],()=>Math.PI],e:[j,[],()=>Math.E],"^":[j,[j,j],(e,[t,r])=>t.evaluate(e)**+r.evaluate(e)],sqrt:[j,[j],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[j,[j],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[j,[j],(e,[t])=>Math.log(t.evaluate(e))],log2:[j,[j],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[j,[j],(e,[t])=>Math.sin(t.evaluate(e))],cos:[j,[j],(e,[t])=>Math.cos(t.evaluate(e))],tan:[j,[j],(e,[t])=>Math.tan(t.evaluate(e))],asin:[j,[j],(e,[t])=>Math.asin(t.evaluate(e))],acos:[j,[j],(e,[t])=>Math.acos(t.evaluate(e))],atan:[j,[j],(e,[t])=>Math.atan(t.evaluate(e))],min:[j,Fi(j),(e,t)=>Math.min(...t.map(r=>r.evaluate(e)))],max:[j,Fi(j),(e,t)=>Math.max(...t.map(r=>r.evaluate(e)))],abs:[j,[j],(e,[t])=>Math.abs(t.evaluate(e))],round:[j,[j],(e,[t])=>{let r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[j,[j],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[j,[j],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[fe,[oe,ue],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[fe,[ue],(e,[t])=>e.id()===t.value],"filter-type-==":[fe,[oe],(e,[t])=>e.geometryType()===t.value],"filter-<":[fe,[oe,ue],(e,[t,r])=>{let i=e.properties()[t.value],a=r.value;return typeof i==typeof a&&i<a}],"filter-id-<":[fe,[ue],(e,[t])=>{let r=e.id(),i=t.value;return typeof r==typeof i&&r<i}],"filter->":[fe,[oe,ue],(e,[t,r])=>{let i=e.properties()[t.value],a=r.value;return typeof i==typeof a&&i>a}],"filter-id->":[fe,[ue],(e,[t])=>{let r=e.id(),i=t.value;return typeof r==typeof i&&r>i}],"filter-<=":[fe,[oe,ue],(e,[t,r])=>{let i=e.properties()[t.value],a=r.value;return typeof i==typeof a&&i<=a}],"filter-id-<=":[fe,[ue],(e,[t])=>{let r=e.id(),i=t.value;return typeof r==typeof i&&r<=i}],"filter->=":[fe,[oe,ue],(e,[t,r])=>{let i=e.properties()[t.value],a=r.value;return typeof i==typeof a&&i>=a}],"filter-id->=":[fe,[ue],(e,[t])=>{let r=e.id(),i=t.value;return typeof r==typeof i&&r>=i}],"filter-has":[fe,[ue],(e,[t])=>{let r=t.value,i=e.properties();return r in i&&i[r]!==void 0}],"filter-has-id":[fe,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[fe,[kt(oe)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[fe,[kt(ue)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[fe,[oe,kt(ue)],(e,[t,r])=>r.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[fe,[oe,kt(ue)],(e,[t,r])=>Hb(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:fe,overloads:[[[fe,fe],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[Fi(fe),(e,t)=>{for(let r of t)if(!r.evaluate(e))return!1;return!0}]]},any:{type:fe,overloads:[[[fe,fe],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[Fi(fe),(e,t)=>{for(let r of t)if(r.evaluate(e))return!0;return!1}]]},"!":[fe,[fe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[fe,[oe],(e,[t])=>{let r=e.globals&&e.globals.isSupportedScript;return!r||r(t.evaluate(e))}],upcase:[oe,[oe],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[oe,[oe],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[oe,Fi(ue),(e,t)=>t.map(r=>Ln(r.evaluate(e))).join("")],split:[kt(oe),[oe,oe],(e,[t,r])=>t.evaluate(e).split(r.evaluate(e))],join:[oe,[kt(oe),oe],(e,[t,r])=>t.evaluate(e).join(r.evaluate(e))],"resolved-locale":[oe,[xl],(e,[t])=>t.evaluate(e).resolvedLocale()]});function Xb(e){return Array.isArray(e)?`(${e.map(Ke).join(", ")})`:`(${Ke(e.type)}...)`}function Uo(e){if(e instanceof m_)return Uo(e.boundExpression);if(e instanceof aa&&e.name==="error"||e instanceof D_||e instanceof Jc||e instanceof rd||e instanceof id)return!1;let t=e instanceof Ia||e instanceof ti,r=!0;return e.eachChild(i=>{r&&(r=t?Uo(i):i instanceof qa)}),r?El(e)&&Pl(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]):!1}function El(e){if(e instanceof aa&&(e.name==="get"&&e.args.length===1||e.name==="feature-state"||e.name==="has"&&e.args.length===1||e.name==="properties"||e.name==="geometry-type"||e.name==="id"||/^filter-/.test(e.name))||e instanceof Jc||e instanceof rd)return!1;let t=!0;return e.eachChild(r=>{t&&!El(r)&&(t=!1)}),t}function Wn(e){if(e instanceof aa&&e.name==="feature-state")return!1;let t=!0;return e.eachChild(r=>{t&&!Wn(r)&&(t=!1)}),t}function Pl(e,t){if(e instanceof aa&&t.indexOf(e.name)>=0)return!1;let r=!0;return e.eachChild(i=>{r&&!Pl(i,t)&&(r=!1)}),r}function Za(e){return e["property-type"]==="data-driven"||e["property-type"]==="cross-faded-data-driven"}function $_(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function ad(e){return!!e.expression&&e.expression.interpolated}const nd=/^(.*)-transition$/;function Hn(e,...t){for(let r of t)for(let i in r)e[i]=r[i];return e}function de(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":e===null?"null":typeof e}function Al(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&at(e)===qi}function Yb(e){return e}function Kb(e){switch(e.type){case"color":return se.parse;case"padding":return Hr.parse;case"numberArray":return Xr.parse;case"colorArray":return _r.parse;default:return null}}function Jb(e){switch(e){case"exponential":return V_;case"interval":return e2;case"categorical":return Qb;case"identity":return t2;default:throw Error(`Unknown function type "${e}"`)}}function j_(e,t){let r=e.stops&&typeof e.stops[0][0]=="object",i=r||e.property!==void 0,a=r||!i,n=e.type||(ad(t)?"exponential":"interval"),s=Kb(t);if(s&&(e=Hn({},e),e.stops&&(e.stops=e.stops.map(h=>[h[0],s(h[1])])),e.default?e.default=s(e.default):e.default=s(t.default)),e.colorSpace&&!Gv(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let o=Jb(n),l,u;if(n==="categorical"){l=Object.create(null);for(let h of e.stops)l[h[0]]=h[1];u=typeof e.stops[0][0]}if(r){let h={},c=[];for(let f=0;f<e.stops.length;f++){let m=e.stops[f],g=m[0].zoom;h[g]===void 0&&(h[g]={zoom:g,type:e.type,property:e.property,default:e.default,stops:[]},c.push(g)),h[g].stops.push([m[0].value,m[1]])}let d=[];for(let f of c)d.push([h[f].zoom,j_(h[f],t)]);let p={name:"linear"};return{kind:"composite",interpolationType:p,interpolationFactor:yr.interpolationFactor.bind(void 0,p),zoomStops:d.map(f=>f[0]),evaluate({zoom:f},m){return V_({stops:d,base:e.base},t,f).evaluate(f,m)}}}if(a){let h=n==="exponential"?{name:"exponential",base:e.base===void 0?1:e.base}:null;return{kind:"camera",interpolationType:h,interpolationFactor:yr.interpolationFactor.bind(void 0,h),zoomStops:e.stops.map(c=>c[0]),evaluate:({zoom:c})=>o(e,t,c,l,u)}}return{kind:"source",evaluate(h,c){let d=c&&c.properties?c.properties[e.property]:void 0;return d===void 0?ms(e.default,t.default):o(e,t,d,l,u)}}}function ms(e,t,r){if(e!==void 0)return e;if(t!==void 0)return t;if(r!==void 0)return r}function Qb(e,t,r,i,a){return ms(typeof r===a?i[r]:void 0,e.default,t.default)}function e2(e,t,r){if(de(r)!=="number")return ms(e.default,t.default);let i=e.stops.length;if(i===1||r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[i-1][0])return e.stops[i-1][1];let a=Tl(e.stops.map(n=>n[0]),r,"");return e.stops[a][1]}function V_(e,t,r){let i=e.base===void 0?1:e.base;if(de(r)!=="number")return ms(e.default,t.default);let a=e.stops.length;if(a===1||r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[a-1][0])return e.stops[a-1][1];let n=Tl(e.stops.map(h=>h[0]),r,""),s=r2(r,i,e.stops[n][0],e.stops[n+1][0]),o=e.stops[n][1],l=e.stops[n+1][1],u=We[t.type]||Yb;return typeof o.evaluate=="function"?{evaluate(...h){let c=o.evaluate.apply(void 0,h),d=l.evaluate.apply(void 0,h);if(c!==void 0&&d!==void 0)return u(c,d,s,e.colorSpace)}}:u(o,l,s,e.colorSpace)}function t2(e,t,r){switch(t.type){case"color":r=se.parse(r);break;case"formatted":r=ui.fromString(r.toString());break;case"resolvedImage":r=Wr.fromString(r.toString());break;case"padding":r=Hr.parse(r);break;case"colorArray":r=_r.parse(r);break;case"numberArray":r=Xr.parse(r);break;default:de(r)!==t.type&&(t.type!=="enum"||!t.values[r])&&(r=void 0)}return ms(r,e.default,t.default)}function r2(e,t,r,i){let a=i-r,n=e-r;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}function Sh(e){return{result:"success",value:e}}function Pa(e){return{result:"error",value:e}}var sd=class{constructor(t,r,i,a){this.expression=t,this._warningHistory={},this._evaluator=new s_,this._defaultValue=i?W_(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=a,this._rootKey=r}evaluateWithoutErrorHandling(t,r,i,a,n,s){return this._globalState&&(t=Wa(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=r,this._evaluator.featureState=i,this._evaluator.canonical=a,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,r,i,a,n,s){this._globalState&&(t=Wa(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=r||null,this._evaluator.featureState=i||null,this._evaluator.canonical=a,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s||null;try{let o=this.expression.evaluate(this._evaluator);if(o==null||typeof o=="number"&&o!==o)return this._defaultValue;if(this._enumValues&&!(o in this._enumValues))throw new qe(`Expected value to be one of ${Object.keys(this._enumValues).map(l=>JSON.stringify(l)).join(", ")}, but found ${JSON.stringify(o)} instead.`,"");return o}catch(o){let l=o instanceof qe?o.path:"",u=`${l}|${o.message}`;return this._warningHistory[u]||(this._warningHistory[u]=!0,typeof console<"u"&&console.warn(N_(this._rootKey,l,o.message,this._defaultValue))),this._defaultValue}}};function N_(e,t,r,i){return`${e}${t}: ${r}${i==null?"":` Falling back to ${String(i)}.`}`}function U_(e){if(!e)throw Error('rootKey must identify the location of the expression in the style JSON, e.g. "layers[3].paint.line-width".')}function Cl(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"&&e[0]in Ra}function Il(e,t,r,i){U_(t);let a=new B_(Ra,Uo,[],r?n2(r):void 0),n=a.parse(e,void 0,void 0,void 0,r&&r.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?Sh(new sd(n,t,r,i)):Pa(a.errors)}var Xn=class{constructor(t,r,i){this.kind=t,this._styleExpression=r,this.isStateDependent=t!=="constant"&&!Wn(r.expression),this.globalStateRefs=gs(r.expression),this._globalState=i}evaluateWithoutErrorHandling(t,r,i,a,n,s){return this._globalState&&(t=Wa(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,r,i,a,n,s)}evaluate(t,r,i,a,n,s){return this._globalState&&(t=Wa(t,this._globalState)),this._styleExpression.evaluate(t,r,i,a,n,s)}},Go=class{constructor(t,r,i,a,n){this.kind=t,this.zoomStops=i,this._styleExpression=r,this.isStateDependent=t!=="camera"&&!Wn(r.expression),this.globalStateRefs=gs(r.expression),this.interpolationType=a,this._globalState=n}evaluateWithoutErrorHandling(t,r,i,a,n,s){return this._globalState&&(t=Wa(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,r,i,a,n,s)}evaluate(t,r,i,a,n,s){return this._globalState&&(t=Wa(t,this._globalState)),this._styleExpression.evaluate(t,r,i,a,n,s)}interpolationFactor(t,r,i){return this.interpolationType?yr.interpolationFactor(this.interpolationType,t,r,i):0}};function i2(e){return e._styleExpression!==void 0}function G_(e,t,r,i){let a=Il(e,t,r,i);if(a.result==="error")return a;let n=a.value.expression,s=El(n);if(!s&&!Za(r))return Pa([new $r("","data expressions not supported")]);let o=Pl(n,["zoom"]);if(!o&&!$_(r))return Pa([new $r("","zoom expressions not supported")]);let l=Po(n);if(!l&&!o)return Pa([new $r("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof $r)return Pa([l]);if(l instanceof yr&&!ad(r))return Pa([new $r("",'"interpolate" expressions cannot be used with this property')]);if(!l)return Sh(s?new Xn("constant",a.value,i):new Xn("source",a.value,i));let u=l instanceof yr?l.interpolation:void 0;return Sh(s?new Go("camera",a.value,l.labels,u,i):new Go("composite",a.value,l.labels,u,i))}var q_=class Z_{constructor(t,r,i){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,U_(r),this._parameters=t,this._specification=i,this._rootKey=r,this._defaultValue=W_(i),this._warningHistory={};let a=j_(this._parameters,this._specification);this.kind=a.kind,this.interpolationFactor=a.interpolationFactor,this.zoomStops=a.zoomStops,this.interpolationType=a.interpolationType,this._innerEvaluate=a.evaluate}evaluate(t,r){try{return this._innerEvaluate(t,r)}catch(i){let a=i instanceof Error?i.message:String(i),n=`|${a}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<"u"&&console.warn(N_(this._rootKey,"",a,this._defaultValue))),this._defaultValue}}static deserialize(t){return new Z_(t._parameters,t._rootKey,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification,_rootKey:t._rootKey}}};function a2(e,t,r,i){if(Al(e))return new q_(e,t,r);if(Cl(e)){let a=G_(e,t,r,i);if(a.result==="error")throw Error(a.value.map(n=>`${n.key}: ${n.message}`).join(", "));return a.value}{let a=e;return r.type==="color"&&typeof e=="string"?a=se.parse(e):r.type==="padding"&&(typeof e=="number"||Array.isArray(e))?a=Hr.parse(e):r.type==="numberArray"&&(typeof e=="number"||Array.isArray(e))?a=Xr.parse(e):r.type==="colorArray"&&(typeof e=="string"||Array.isArray(e))?a=_r.parse(e):r.type==="variableAnchorOffsetCollection"&&Array.isArray(e)?a=Zr.parse(e):r.type==="projectionDefinition"&&typeof e=="string"&&(a=Ii.parse(e)),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>a}}}function Po(e){let t=null;if(e instanceof p_)t=Po(e.result);else if(e instanceof b_){for(let r of e.args)if(t=Po(r),t)break}else(e instanceof Xc||e instanceof yr)&&e.input instanceof aa&&e.input.name==="zoom"&&(t=e);return t instanceof $r||e.eachChild(r=>{let i=Po(r);i instanceof $r?t=i:!t&&i?t=new $r("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new $r("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function gs(e,t=new Set){return e instanceof id&&t.add(e.key),e.eachChild(r=>{gs(r,t)}),t}function n2(e){let t={color:Er,string:oe,number:j,enum:oe,boolean:fe,formatted:ds,padding:vl,numberArray:bl,colorArray:Gn,projectionDefinition:yl,resolvedImage:ps,variableAnchorOffsetCollection:wl};return e.type==="array"?kt(t[e.value]||ue,e.length):t[e.type]}function W_(e){if(e.type==="color"&&Al(e.default))return new se(0,0,0,0);switch(e.type){case"color":return se.parse(e.default)||null;case"padding":return Hr.parse(e.default)||null;case"numberArray":return Xr.parse(e.default)||null;case"colorArray":return _r.parse(e.default)||null;case"variableAnchorOffsetCollection":return Zr.parse(e.default)||null;case"projectionDefinition":return Ii.parse(e.default)||null;default:return e.default===void 0?null:e.default}}function Wa(e,t){let{zoom:r,heatmapDensity:i,elevation:a,lineProgress:n,isSupportedScript:s,accumulated:o}=e??{};return{zoom:r,heatmapDensity:i,elevation:a,lineProgress:n,isSupportedScript:s,accumulated:o,globalState:t}}function s2(e){let t=!1;for(let r of e){let i=H_(r);if(i==="expression")return"expression";i==="legacy"&&(t=!0)}return t?"legacy":"neutral"}function H_(e){if(typeof e=="boolean")return"neutral";if(!Array.isArray(e)||e.length===0)return"legacy";switch(e[0]){case"has":return e.length<2||e[1]==="$id"||e[1]==="$type"?"legacy":e.length===2?"neutral":"expression";case"in":return e.length>=3&&(typeof e[1]!="string"||Array.isArray(e[2]))?"expression":"legacy";case"!in":case"!has":return"legacy";case"==":case"!=":case">":case">=":case"<":case"<=":return e.length!==3||Array.isArray(e[1])||Array.isArray(e[2])?"expression":"legacy";case"none":return"legacy";case"any":case"all":return s2(e.slice(1));default:return"expression"}}function od(e){return H_(e)!=="legacy"}function nf(e){return e==="$type"?["geometry-type"]:e==="$id"?["id"]:["get",e]}function o2(e){switch(e[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return e.length!==3||typeof e[1]!="string"?null:[e[0],nf(e[1]),e[2]];case"in":case"!in":{if(e.length<2||typeof e[1]!="string")return null;let t=["in",nf(e[1]),["literal",e.slice(2)]];return e[0]==="!in"?["!",t]:t}case"has":case"!has":{if(e.length!==2||typeof e[1]!="string"||e[1]==="$type"||e[1]==="$id")return null;let t=["has",e[1]];return e[0]==="!has"?["!",t]:t}default:return null}}function X_(e){if((e[0]==="<"||e[0]==="<="||e[0]===">"||e[0]===">=")&&e[1]==="$type")return`"$type" cannot be use with operator "${e[0]}"`;let t=o2(e);return t?`Mixing deprecated filter syntax with expression syntax is not supported. Replace ${JSON.stringify(e)} with ${JSON.stringify(t)}.`:`Mixing deprecated filter syntax with expression syntax is not supported. Convert ${JSON.stringify(e)} to expression syntax.`}function Mu(e,t,r){let i=r[e];return Array.isArray(i)?od(i)?ld(i,t.concat(e)):{path:t.concat(e),legacyFilter:i}:null}function ld(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case"all":case"any":case"none":for(let r=1;r<e.length;r++){let i=Mu(r,t,e);if(i)return i}break;case"!":{let r=Mu(1,t,e);if(r)return r;break}case"case":for(let r=1;r<e.length-1;r+=2){let i=Mu(r,t,e);if(i)return i}}return null}function l2(e,t){let r=ld(e);if(!r||typeof console>"u")return;let i=r.path.map(a=>`[${a}]`).join("");console.warn(`${t}${i}: ${X_(r.legacyFilter)}`)}const u2={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Yn(e,t,r){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};od(e)?l2(e,t):e=qo(e);let i=Il(e,t,u2,r);if(i.result==="error")throw Error(i.value.map(a=>`${a.key}: ${a.message}`).join(", "));return{filter:(a,n,s)=>i.value.evaluate(a,n,{},s),needGeometry:Y_(e),getGlobalStateRefs:()=>gs(i.value.expression)}}function h2(e,t){return e<t?-1:+(e>t)}function Y_(e){if(!Array.isArray(e))return!1;if(e[0]==="within"||e[0]==="distance")return!0;for(let t=1;t<e.length;t++)if(Y_(e[t]))return!0;return!1}function qo(e){if(!e)return!0;let t=e[0];return e.length<=1?t!=="any":t==="=="?zu(e[1],e[2],"=="):t==="!="?Hs(zu(e[1],e[2],"==")):t==="<"||t===">"||t==="<="||t===">="?zu(e[1],e[2],t):t==="any"?c2(e.slice(1)):t==="all"?["all"].concat(e.slice(1).map(qo)):t==="none"?["all"].concat(e.slice(1).map(qo).map(Hs)):t==="in"?sf(e[1],e.slice(2)):t==="!in"?Hs(sf(e[1],e.slice(2))):t==="has"?of(e[1]):t!=="!has"||Hs(of(e[1]))}function zu(e,t,r){switch(e){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,e,t]}}function c2(e){return["any"].concat(e.map(qo))}function sf(e,t){if(t.length===0)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(r=>typeof r!=typeof t[0])?["filter-in-large",e,["literal",t.sort(h2)]]:["filter-in-small",e,["literal",t]]}}function of(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Hs(e){return["!",e]}function K_(e){let t=e.key,r=e.value;return r?[new O(t,r,"constants have been deprecated as of v8")]:[]}function it(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ji(e){if(Array.isArray(e))return e.map(Ji);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let r in e)t[r]=Ji(e[r]);return t}return it(e)}function ar(e){let t=e.key,r=e.value,i=e.valueSpec||{},a=e.objectElementValidators||{},n=e.style,s=e.styleSpec,o=e.validateSpec,l=[],u=de(r);if(u!=="object")return[new O(t,r,`object expected, ${u} found`)];for(let h in r){let c=h.split(".")[0],d=kn(i,c)||i["*"],p;if(kn(a,c))p=a[c];else if(kn(i,c)){if(r[h]===void 0)continue;p=o}else if(a["*"])p=a["*"];else if(i["*"])p=o;else{l.push(new O(t,r[h],`unknown property "${h}"`));continue}l=l.concat(p({key:(t&&`${t}.`)+h,value:r[h],valueSpec:d,style:n,styleSpec:s,object:r,objectKey:h,validateSpec:o},r))}for(let h in i)a[h]||i[h].required&&i[h].default===void 0&&r[h]===void 0&&l.push(new O(t,r,`missing required property "${h}"`));return l}function ud(e){let t=e.value,r=e.valueSpec,i=e.validateSpec,a=e.style,n=e.styleSpec,s=e.key,o=e.arrayElementValidator||i;if(de(t)!=="array")return[new O(s,t,`array expected, ${de(t)} found`)];if(r.length&&t.length!==r.length)return[new O(s,t,`array length ${r.length} expected, length ${t.length} found`)];let l={type:r.value,values:r.values};n.$version<7&&(l.function=r.function),de(r.value)==="object"&&(l=r.value);let u=[];for(let h=0;h<t.length;h++)u=u.concat(o({array:t,arrayIndex:h,value:t[h],valueSpec:l,validateSpec:e.validateSpec,style:a,styleSpec:n,key:`${s}[${h}]`}));return u}function Ml(e){let t=e.key,r=e.value,i=e.valueSpec,a=de(r);return a==="number"&&r!==r&&(a="NaN"),a==="number"?"minimum"in i&&r<i.minimum?[new O(t,r,`${r} is less than the minimum value ${i.minimum}`)]:"maximum"in i&&r>i.maximum?[new O(t,r,`${r} is greater than the maximum value ${i.maximum}`)]:[]:[new O(t,r,`number expected, ${a} found`)]}function J_(e){let t=e.valueSpec,r=it(e.value.type),i,a={},n,s,o=r!=="categorical"&&e.value.property===void 0,l=!o,u=de(e.value.stops)==="array"&&de(e.value.stops[0])==="array"&&de(e.value.stops[0][0])==="object",h=ar({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:c,default:f}});return r==="identity"&&o&&h.push(new O(e.key,e.value,'missing required property "property"')),r!=="identity"&&!e.value.stops&&h.push(new O(e.key,e.value,'missing required property "stops"')),r==="exponential"&&e.valueSpec.expression&&!ad(e.valueSpec)&&h.push(new O(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Za(e.valueSpec)?h.push(new O(e.key,e.value,"property functions not supported")):o&&!$_(e.valueSpec)&&h.push(new O(e.key,e.value,"zoom functions not supported"))),(r==="categorical"||u)&&e.value.property===void 0&&h.push(new O(e.key,e.value,'"property" property is required')),h;function c(m){if(r==="identity")return[new O(m.key,m.value,'identity function may not have a "stops" property')];let g=[],_=m.value;return g=g.concat(ud({key:m.key,value:_,valueSpec:m.valueSpec,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,arrayElementValidator:d})),de(_)==="array"&&_.length===0&&g.push(new O(m.key,_,"array must have at least one stop")),g}function d(m){let g=[],_=m.value,y=m.key;if(de(_)!=="array")return[new O(y,_,`array expected, ${de(_)} found`)];if(_.length!==2)return[new O(y,_,`array length 2 expected, length ${_.length} found`)];if(u){if(de(_[0])!=="object")return[new O(y,_,`object expected, ${de(_[0])} found`)];if(_[0].zoom===void 0)return[new O(y,_,"object stop key must have zoom")];if(_[0].value===void 0)return[new O(y,_,"object stop key must have value")];if(s&&s>it(_[0].zoom))return[new O(y,_[0].zoom,"stop zoom values must appear in ascending order")];it(_[0].zoom)!==s&&(s=it(_[0].zoom),n=void 0,a={}),g=g.concat(ar({key:`${y}[0]`,value:_[0],valueSpec:{zoom:{}},validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,objectElementValidators:{zoom:Ml,value:p}}))}else g=g.concat(p({key:`${y}[0]`,value:_[0],validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec},_));return Cl(Ji(_[1]))?g.concat([new O(`${y}[1]`,_[1],"expressions are not allowed in function stops.")]):g.concat(m.validateSpec({key:`${y}[1]`,value:_[1],valueSpec:t,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec}))}function p(m,g){let _=de(m.value),y=it(m.value),v=m.value===null?g:m.value;if(!i)i=_;else if(_!==i)return[new O(m.key,v,`${_} stop domain type must match previous stop domain type ${i}`)];if(_!=="number"&&_!=="string"&&_!=="boolean")return[new O(m.key,v,"stop domain value must be a number, string, or boolean")];if(_!=="number"&&r!=="categorical"){let x=`number expected, ${_} found`;return Za(t)&&r===void 0&&(x+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new O(m.key,v,x)]}return r==="categorical"&&_==="number"&&(!isFinite(y)||Math.floor(y)!==y)?[new O(m.key,v,`integer expected, found ${y}`)]:r!=="categorical"&&_==="number"&&n!==void 0&&y<n?[new O(m.key,v,"stop domain values must appear in ascending order")]:(n=y,r==="categorical"&&y in a?[new O(m.key,v,"stop domain values must be unique")]:(a[y]=!0,[]))}function f(m){return m.validateSpec({key:m.key,value:m.value,valueSpec:t,validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec})}}function Ha(e){let t=(e.expressionContext==="property"?G_:Il)(Ji(e.value),e.key,e.valueSpec);if(t.result==="error")return t.value.map(i=>new O(`${e.key}${i.key}`,e.value,i.message));let r=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext==="property"&&e.propertyKey==="text-font"&&!r.outputDefined())return[new O(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if(e.expressionContext==="property"&&e.propertyType==="layout"&&!Wn(r))return[new O(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if(e.expressionContext==="filter"&&!Wn(r))return[new O(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&e.expressionContext.indexOf("cluster")===0){if(!Pl(r,["zoom","feature-state"]))return[new O(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(e.expressionContext==="cluster-initial"&&!El(r))return[new O(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function d2(e){let t=e.value,r=e.key,i=de(t);return i==="boolean"?[]:[new O(r,t,`boolean expected, ${i} found`)]}function Eh(e){let t=e.key,r=e.value,i=de(r);return i==="string"?se.parse(String(r))?[]:[new O(t,r,`color expected, "${r}" found`)]:[new O(t,r,`color expected, ${i} found`)]}function Kn(e){let t=e.key,r=e.value,i=e.valueSpec,a=[];return Array.isArray(i.values)?i.values.indexOf(it(r))===-1&&a.push(new O(t,r,`expected one of [${i.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(i.values).indexOf(it(r))===-1&&a.push(new O(t,r,`expected one of [${Object.keys(i.values).join(", ")}], ${JSON.stringify(r)} found`)),a}function p2(e,t){let r=e;for(let i of t)r=r[i];return r}function f2(e,t){let r=ld(t);return r?[new O(`${e.key}${r.path.map(i=>`[${i}]`).join("")}`,p2(e.value,r.path),X_(r.legacyFilter),null,"warning")]:[]}function hd(e){let t=Ji(e.value);return od(t)?[...f2(e,t),...Ha(Hn({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:Q_(e)}function Q_(e){let t=e.value,r=e.key;if(de(t)!=="array")return[new O(r,t,`array expected, ${de(t)} found`)];let i=e.styleSpec,a,n=[];if(t.length<1)return[new O(r,t,"filter array must have at least 1 element")];switch(n=n.concat(Kn({key:`${r}[0]`,value:t[0],valueSpec:i.filter_operator,style:e.style,styleSpec:e.styleSpec})),it(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&it(t[1])==="$type"&&n.push(new O(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&n.push(new O(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(a=de(t[1]),a!=="string"&&n.push(new O(`${r}[1]`,t[1],`string expected, ${a} found`)));for(let s=2;s<t.length;s++)a=de(t[s]),it(t[1])==="$type"?n=n.concat(Kn({key:`${r}[${s}]`,value:t[s],valueSpec:i.geometry_type,style:e.style,styleSpec:e.styleSpec})):a!=="string"&&a!=="number"&&a!=="boolean"&&n.push(new O(`${r}[${s}]`,t[s],`string, number, or boolean expected, ${a} found`));break;case"any":case"all":case"none":for(let s=1;s<t.length;s++)n=n.concat(Q_({key:`${r}[${s}]`,value:t[s],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":a=de(t[1]),t.length===2?a!=="string"&&n.push(new O(`${r}[1]`,t[1],`string expected, ${a} found`)):n.push(new O(r,t,`filter array for "${t[0]}" operator must have 2 elements`))}return n}function ey(e,t){let r=e.key,i=e.validateSpec,a=e.style,n=e.styleSpec,s=e.value,o=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];let u=o.match(nd);if(t==="paint"&&u&&l[u[1]]&&l[u[1]].transition)return i({key:r,value:s,valueSpec:n.transition,style:a,styleSpec:n});let h=e.valueSpec||l[o];if(!h)return[new O(r,s,`unknown property "${o}"`)];let c;if(de(s)==="string"&&Za(h)&&!h.tokens&&(c=/^{([^}]+)}$/.exec(s)))return[new O(r,s,`"${o}" does not support interpolation syntax
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(c[1])} }\`.`)];let d=[];return e.layerType==="symbol"&&o==="text-font"&&Al(Ji(s))&&it(s.type)==="identity"&&d.push(new O(r,s,'"text-font" does not support identity functions')),d.concat(i({key:e.key,value:s,valueSpec:h,style:a,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:o}))}function ty(e){return ey(e,"paint")}function ry(e){return ey(e,"layout")}function iy(e){var l,u;let t=[],r=e.value,i=e.key,a=e.style,n=e.styleSpec;if(de(r)!=="object")return[new O(i,r,`object expected, ${de(r)} found`)];!r.type&&!r.ref&&t.push(new O(i,r,'either "type" or "ref" is required'));let s=it(r.type),o=it(r.ref);if(r.id){let h=it(r.id);for(let c=0;c<e.arrayIndex;c++){let d=a.layers[c];it(d.id)===h&&t.push(new O(i,r.id,`duplicate layer id "${r.id}", previously used at line ${d.id.__line__}`))}}if("ref"in r){["type","source","source-layer","filter","layout"].forEach(c=>{c in r&&t.push(new O(i,r[c],`"${c}" is prohibited for ref layers`))});let h;a.layers.forEach(c=>{it(c.id)===o&&(h=c)}),h?h.ref?t.push(new O(i,r.ref,"ref cannot reference another ref layer")):s=it(h.type):t.push(new O(i,r.ref,`ref layer "${o}" not found`))}else if(s!=="background")if(!r.source)t.push(new O(i,r,'missing required property "source"'));else{let h=a.sources&&a.sources[r.source],c=h&&it(h.type);h?c==="vector"&&s==="raster"?t.push(new O(i,r.source,`layer "${r.id}" requires a raster source`)):c!=="raster-dem"&&s==="hillshade"||c!=="raster-dem"&&s==="color-relief"?t.push(new O(i,r.source,`layer "${r.id}" requires a raster-dem source`)):c==="raster"&&s!=="raster"?t.push(new O(i,r.source,`layer "${r.id}" requires a vector source`)):c==="vector"&&!r["source-layer"]?t.push(new O(i,r,`layer "${r.id}" must specify a "source-layer"`)):c==="raster-dem"&&s!=="hillshade"&&s!=="color-relief"?t.push(new O(i,r.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):s==="line"&&r.paint&&r.paint["line-gradient"]&&(c!=="geojson"||!h.lineMetrics)&&t.push(new O(i,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new O(i,r.source,`source "${r.source}" not found`))}return s==="raster"&&((l=r.paint)!=null&&l.resampling)&&((u=r.paint)!=null&&u["raster-resampling"])&&t.push(new O(i,r.paint,`layer "${r.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(ar({key:i,value:r,valueSpec:n.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(){return[]},type(){return e.validateSpec({key:`${i}.type`,value:r.type,valueSpec:n.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:r,objectKey:"type"})},filter:hd,layout(h){return ar({layer:r,key:h.key,value:h.value,style:h.style,styleSpec:h.styleSpec,validateSpec:h.validateSpec,objectElementValidators:{"*"(c){return ry(Hn({layerType:s},c))}}})},paint(h){return ar({layer:r,key:h.key,value:h.value,style:h.style,styleSpec:h.styleSpec,validateSpec:h.validateSpec,objectElementValidators:{"*"(c){return ty(Hn({layerType:s},c))}}})}}})),t}function Pi(e){let t=e.value,r=e.key,i=de(t);return i==="string"?[]:[new O(r,t,`string expected, ${i} found`)]}function m2(e){let t=e.sourceName??"",r=e.value,i=e.styleSpec,a=i.source_raster_dem,n=e.style,s=[],o=de(r);if(r===void 0)return s;if(o!=="object")return s.push(new O("source_raster_dem",r,`object expected, ${o} found`)),s;let l=it(r.encoding)==="custom",u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(let c in r)!l&&u.includes(c)?s.push(new O(c,r[c],`In "${t}": "${c}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):a[c]?s=s.concat(e.validateSpec({key:c,value:r[c],valueSpec:a[c],validateSpec:e.validateSpec,style:n,styleSpec:i})):s.push(new O(c,r[c],`unknown property "${c}"`));return s}const lf={promoteId:g2};function ay(e){let t=e.value,r=e.key,i=e.styleSpec,a=e.style,n=e.validateSpec;if(!t.type)return[new O(r,t,'"type" is required')];let s=it(t.type),o;switch(s){case"vector":case"raster":return o=ar({key:r,value:t,valueSpec:i[`source_${s.replace("-","_")}`],style:e.style,styleSpec:i,objectElementValidators:lf,validateSpec:n}),o;case"raster-dem":return o=m2({sourceName:r,value:t,style:e.style,styleSpec:i,validateSpec:n}),o;case"geojson":if(o=ar({key:r,value:t,valueSpec:i.source_geojson,style:a,styleSpec:i,validateSpec:n,objectElementValidators:lf}),t.cluster)for(let l in t.clusterProperties){let[u,h]=t.clusterProperties[l],c=typeof u=="string"?[u,["accumulated"],["get",l]]:u;o.push(...Ha({key:`${r}.${l}.map`,value:h,expressionContext:"cluster-map"})),o.push(...Ha({key:`${r}.${l}.reduce`,value:c,expressionContext:"cluster-reduce"}))}return o;case"video":return ar({key:r,value:t,valueSpec:i.source_video,style:a,validateSpec:n,styleSpec:i});case"image":return ar({key:r,value:t,valueSpec:i.source_image,style:a,validateSpec:n,styleSpec:i});case"canvas":return[new O(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Kn({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function g2({key:e,value:t}){if(de(t)==="string")return Pi({key:e,value:t});{let r=[];for(let i in t)r.push(...Pi({key:`${e}.${i}`,value:t[i]}));return r}}function ny(e){let t=e.value,r=e.styleSpec,i=r.light,a=e.style,n=[],s=de(t);if(t===void 0)return n;if(s!=="object")return n=n.concat([new O("light",t,`object expected, ${s} found`)]),n;for(let o in t){let l=o.match(nd);n=l&&i[l[1]]&&i[l[1]].transition?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:r.transition,validateSpec:e.validateSpec,style:a,styleSpec:r})):i[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:i[o],validateSpec:e.validateSpec,style:a,styleSpec:r})):n.concat([new O(o,t[o],`unknown property "${o}"`)])}return n}function sy(e){let t=e.value,r=e.styleSpec,i=r.sky,a=e.style,n=de(t);if(t===void 0)return[];if(n!=="object")return[new O("sky",t,`object expected, ${n} found`)];let s=[];for(let o in t){let l=o.match(nd);s=l&&i[l[1]]&&i[l[1]].transition?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:r.transition,style:a,styleSpec:r})):i[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:i[o],style:a,styleSpec:r})):s.concat([new O(o,t[o],`unknown property "${o}"`)])}return s}function oy(e){let t=e.value,r=e.styleSpec,i=r.terrain,a=e.style,n=[],s=de(t);if(t===void 0)return n;if(s!=="object")return n=n.concat([new O("terrain",t,`object expected, ${s} found`)]),n;for(let o in t)n=i[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:i[o],validateSpec:e.validateSpec,style:a,styleSpec:r})):n.concat([new O(o,t[o],`unknown property "${o}"`)]);return n}function _2(e){return Pi(e).length===0?[]:Ha(e)}function y2(e){return Pi(e).length===0?[]:Ha(e)}function x2(e){let t=e.key,r=e.value;if(de(r)==="array"){if(r.length<1||r.length>4)return[new O(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];let i={type:"number"},a=[];for(let n=0;n<r.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:r[n],validateSpec:e.validateSpec,valueSpec:i}));return a}return Ml({key:t,value:r,valueSpec:{}})}function v2(e){let t=e.key,r=e.value;if(de(r)==="array"){let i={type:"number"};if(r.length<1)return[new O(t,r,"array length at least 1 expected, length 0 found")];let a=[];for(let n=0;n<r.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:r[n],validateSpec:e.validateSpec,valueSpec:i}));return a}return Ml({key:t,value:r,valueSpec:{}})}function b2(e){let t=e.key,r=e.value;if(de(r)==="array"){if(r.length<1)return[new O(t,r,"array length at least 1 expected, length 0 found")];let i=[];for(let a=0;a<r.length;a++)i=i.concat(Eh({key:`${t}[${a}]`,value:r[a]}));return i}return Eh({key:t,value:r})}function w2(e){let t=e.key,r=e.value,i=de(r),a=e.styleSpec;if(i!=="array"||r.length<1||r.length%2!=0)return[new O(t,r,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let s=0;s<r.length;s+=2)n=n.concat(Kn({key:`${t}[${s}]`,value:r[s],valueSpec:a.layout_symbol["text-anchor"]})),n=n.concat(ud({key:`${t}[${s+1}]`,value:r[s+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:a}));return n}function ly(e){let t=[],r=e.value,i=e.key;if(Array.isArray(r)){let a=[],n=[];for(let s in r)r[s].id&&a.includes(r[s].id)&&t.push(new O(i,r,`all the sprites' ids must be unique, but ${r[s].id} is duplicated`)),a.push(r[s].id),r[s].url&&n.includes(r[s].url)&&t.push(new O(i,r,`all the sprites' URLs must be unique, but ${r[s].url} is duplicated`)),n.push(r[s].url),t=t.concat(ar({key:`${i}[${s}]`,value:r[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return Pi({key:i,value:r})}function T2(e){let t=e.value,r=e.styleSpec,i=r.projection,a=e.style,n=de(t);if(t===void 0)return[];if(n!=="object")return[new O("projection",t,`object expected, ${n} found`)];let s=[];for(let o in t)s=i[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:i[o],style:a,styleSpec:r})):s.concat([new O(o,t[o],`unknown property "${o}"`)]);return s}function D2(e){let t=e.key,r=e.value;r=r instanceof String?r.valueOf():r;let i=de(r);return i==="array"&&!E2(r)&&!S2(r)?[new O(t,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]:["array","string"].includes(i)?[]:[new O(t,r,`projection expected, invalid type "${i}" found`)]}function S2(e){return!!["interpolate","step","literal"].includes(e[0])}function E2(e){return Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"}function Ph(e){return!!e&&e.constructor===Object}function uy(e){return Ph(e.value)?[]:[new O(e.key,e.value,`object expected, ${de(e.value)} found`)]}const uf=1114111,P2=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function A2(e,t){if(de(t)!=="string")return[];let r=`${t}`,i=()=>[new O(e,t,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],a=r.match(P2);if(!a)return i();let[,n,s,o]=a;if(o!==void 0)return o.length>6?i():[];let l=parseInt(n,16),u=s===void 0?l:parseInt(s,16);return l>uf||u>uf?[new O(e,t,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>u?[new O(e,t,`unicode range start must not be greater than its end, but ${r} is`)]:[]}function hy(e){let t=e.key??"font-faces",r=e.value,i=e.validateSpec,a=e.styleSpec??Xg,n=e.style;if(!Ph(r))return[new O(t,r,`object expected, ${de(r)} found`)];let s=[];for(let o in r){let l=r[o],u=de(l);if(u==="string")s.push(...Pi({key:`${t}.${o}`,value:l}));else if(u==="array"){let h={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[c,d]of l.entries()){let p=`${t}.${o}[${c}]`;s.push(...ar({key:p,value:d,valueSpec:h,styleSpec:a,style:n,validateSpec:i}));let f=Ph(d)?d["unicode-range"]:void 0;if(de(f)==="array")for(let[m,g]of f.entries())s.push(...A2(`${p}.unicode-range[${m}]`,g))}}else s.push(new O(`${t}.${o}`,l,`string or array expected, ${u} found`))}return s}const hf={"*"(){return[]},array:ud,boolean:d2,number:Ml,color:Eh,constants:K_,enum:Kn,filter:hd,function:J_,layer:iy,object:ar,source:ay,light:ny,sky:sy,terrain:oy,projection:T2,projectionDefinition:D2,string:Pi,formatted:_2,resolvedImage:y2,padding:x2,numberArray:v2,colorArray:b2,variableAnchorOffsetCollection:w2,sprite:ly,state:uy,fontFaces:hy};function Zo(e){let t=e.value,r=e.valueSpec,i=e.styleSpec;return e.validateSpec=Zo,r.expression&&Al(it(t))?J_(e):r.expression&&Cl(Ji(t))?Ha(e):r.type&&hf[r.type]?hf[r.type](e):ar(Hn({},e,{valueSpec:r.type?i[r.type]:r}))}function cy(e){let t=e.value,r=e.key,i=Pi(e);return i.length||(t.indexOf("{fontstack}")===-1&&i.push(new O(r,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&i.push(new O(r,t,'"glyphs" url must include a "{range}" token'))),i}function Qt(e,t=M){let r=[];return r=r.concat(Zo({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:Zo,objectElementValidators:{glyphs:cy,"*"(){return[]}}})),e.constants&&(r=r.concat(K_({key:"constants",value:e.constants}))),dy(r)}Qt.source=hr(ur(ay)),Qt.sprite=hr(ur(ly)),Qt.glyphs=hr(ur(cy)),Qt.fontFaces=hr(ur(hy)),Qt.light=hr(ur(ny)),Qt.sky=hr(ur(sy)),Qt.terrain=hr(ur(oy)),Qt.state=hr(ur(uy)),Qt.layer=hr(ur(iy)),Qt.filter=hr(ur(hd)),Qt.paintProperty=hr(ur(ty)),Qt.layoutProperty=hr(ur(ry));function ur(e){return function(t){return e(Object.assign({},t,{validateSpec:Zo}))}}function dy(e){return[].concat(e).sort((t,r)=>t.line-r.line)}function hr(e){return function(...t){return dy(e.apply(this,t))}}const C2={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var I2=class{constructor(t,r,i){this._rootKey=r,this._globalState=i,this.setValue(t)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(t){if(t==null||t==="visible"||t==="none"){this._literalValue=t==="none"?"none":"visible",this._compiledValue=void 0,this._globalStateRefs=new Set;return}let r=Il(t,this._rootKey,C2,this._globalState);if(r.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,Error(r.value.map(i=>`${i.key}: ${i.message}`).join(", "));this._literalValue=void 0,this._compiledValue=r.value,this._globalStateRefs=gs(r.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function M2(e,t,r){return new I2(e,t,r)}const Zt=Qt,py=new Set(Object.keys(M).filter(e=>e.startsWith("source_")).map(e=>e.slice(7).replaceAll("_","-")));function z2(e){return Object.entries(e.sources??{}).filter(([,t])=>!py.has(t.type)).map(([t])=>`sources.${t}`)}function cf(e,t){let r=z2(t);return cd(e,Zt(t).filter(({message:i})=>!r.some(a=>i.startsWith(`${a}:`)||i.startsWith(`${a}.`))))}function cd(e,t){let r=!1;for(let i of t){if(i.severity==="warning"){_e(i.message);continue}e.fire(new X(Error(i.message))),r=!0}return r}function _s(e,t,r,i){return(i==null?void 0:i.validate)!==!1&&cd(e,t({styleSpec:M,...r}))}var Ah=class fy{constructor(t,r,i){let a=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let s=new Int32Array(this.arrayBuffer);t=s[0],r=s[1],i=s[2],this.d=r+2*i;for(let u=0;u<this.d*this.d;u++){let h=s[3+u],c=s[3+u+1];a.push(h===c?null:s.subarray(h,c))}let o=s[3+a.length],l=s[3+a.length+1];this.keys=s.subarray(o,l),this.bboxes=s.subarray(l),this.insert=this._insertReadonly}else{this.d=r+2*i;for(let s=0;s<this.d*this.d;s++)a.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=t,this.padding=i,this.scale=r/t,this.uid=0;let n=i/r*t;this.min=-n,this.max=t+n}insert(t,r,i,a,n){this._forEachCell(r,i,a,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(a),this.bboxes.push(n)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,r,i,a,n,s){this.cells[n].push(s)}query(t,r,i,a,n){let s=this.min,o=this.max;if(t<=s&&r<=s&&o<=i&&o<=a&&!n)return[...this.keys];{let l=[];return this._forEachCell(t,r,i,a,this._queryCell,l,{},n),l}}_queryCell(t,r,i,a,n,s,o,l){let u=this.cells[n];if(u!==null){let h=this.keys,c=this.bboxes;for(let d of u)if(o[d]===void 0){let p=d*4;(l?l(c[p+0],c[p+1],c[p+2],c[p+3]):t<=c[p+2]&&r<=c[p+3]&&i>=c[p+0]&&a>=c[p+1])?(o[d]=!0,s.push(h[d])):o[d]=!1}}}_forEachCell(t,r,i,a,n,s,o,l){let u=this._convertToCellCoord(t),h=this._convertToCellCoord(r),c=this._convertToCellCoord(i),d=this._convertToCellCoord(a);for(let p=u;p<=c;p++)for(let f=h;f<=d;f++){let m=this.d*f+p;if((!l||l(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&n.call(this,t,r,i,a,m,s,o,l))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let t=this.cells,r=3+this.cells.length+1+1,i=0;for(let s of this.cells)i+=s.length;let a=new Int32Array(r+i+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;let n=r;for(let s=0;s<t.length;s++){let o=t[s];a[3+s]=n,a.set(o,n),n+=o.length}return a[3+t.length]=n,a.set(this.keys,n),n+=this.keys.length,a[3+t.length+1]=n,a.set(this.bboxes,n),n+=this.bboxes.length,a.buffer}static serialize(t,r){let i=t.toArrayBuffer();return r&&r.push(i),{buffer:i}}static deserialize(t){return new fy(t.buffer)}};const ri={};function G(e,t,r={}){if(ri[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ri[e]={klass:t,omit:r.omit||[],shallow:r.shallow||[]}}G("Object",Object),G("Set",Set),G("TransferableGridIndex",Ah),G("Color",se),G("Error",Error),G("AJAXError",$o),G("ResolvedImage",Wr),G("StylePropertyFunction",q_),G("StyleExpression",sd,{omit:["_evaluator"]}),G("ZoomDependentExpression",Go),G("ZoomConstantExpression",Xn),G("CompoundExpression",aa,{omit:["_evaluate"]});for(let e in Ra)Ra[e]._classRegistryKey||G(`Expression_${e}`,Ra[e]);function my(e){var t;return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||((t=e.constructor)==null?void 0:t.name)==="ArrayBuffer")}function dd(e){let t=e.constructor;return e.$name||t._classRegistryKey}function F2(e){if(typeof e!="object"||!e)return!1;let t=dd(e);return t&&t!=="Object"}function gy(e){return!F2(e)&&(e==null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||my(e)||Gi(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function Bn(e,t){if(gy(e))return(my(e)||Gi(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){let n=[];for(let s of e)n.push(Bn(s,t));return n}if(typeof e!="object")throw Error(`can't serialize object of type ${typeof e}`);let r=dd(e);if(!r)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!ri[r])throw Error(`${r} is not registered.`);let{klass:i}=ri[r],a=i.serialize?i.serialize(e,t):{};if(i.serialize){if(a===(t==null?void 0:t[t.length-1]))throw Error("statically serialized object won't survive transfer of $name property")}else{for(let n in e){if(!e.hasOwnProperty(n)||ri[r].omit.includes(n))continue;let s=e[n];s!==void 0&&(a[n]=ri[r].shallow.includes(n)?s:Bn(s,t))}e instanceof Error&&(a.message=e.message)}if(a.$name)throw Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(a.$name=r),a}function On(e){if(gy(e))return e;if(Array.isArray(e))return e.map(On);if(typeof e!="object")throw Error(`can't deserialize object of type ${typeof e}`);let t=dd(e)||"Object";if(!ri[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:r}=ri[t];if(!r)throw Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(e);let i=Object.create(r.prototype);for(let a of Object.keys(e)){if(a==="$name")continue;let n=e[a];i[a]=ri[t].shallow.includes(a)?n:On(n)}return i}var Ch=class{constructor(){this.first=!0}update(t,r){let i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=r),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}},ze=class{constructor(t,r){this.zoom=t,r?(this.now=r.now||0,this.fadeDuration=r.fadeDuration||0,this.zoomHistory=r.zoomHistory||new Ch,this.transition=r.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ch,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,r=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*r}}},Jn=class{constructor(t,r,i,a){this.property=t,this.value=r,this.expression=a2(r===void 0?t.specification.default:r,i,t.specification,a)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}readsGlobalState(t){let r=this.getGlobalStateRefs();return t.some(i=>r.has(i))}possiblyEvaluate(t,r,i){return this.property.possiblyEvaluate(this,t,r,i)}},Ih=class{constructor(t,r,i){this.property=t,this.value=new Jn(t,void 0,r,i)}transitioned(t,r){return r.value===this.value?r:new df(this.property,this.value,r,W({},t.transition,this.transition),t.now)}untransitioned(){return new df(this.property,this.value,null,{},0)}},zl=class{constructor(t,r,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=i,this._rootKey=r}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasProperty(t){return t in this._properties.defaultTransitionablePropertyValues}getValue(t){return Wt(this._values[t].value.value)}setValue(t,r){Object.hasOwn(this._values,t)||(this._values[t]=new Ih(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new Jn(this._values[t].property,r===null?void 0:Wt(r),this._propertyRootKey(t),this._globalState)}setValues(t){for(let r in t){let i=t[r];r.endsWith("-transition")?this.setTransition(r.slice(0,-11),i):Or(this._values[r].value.value,i)||this.setValue(r,i)}}getTransition(t){return Wt(this._values[t].transition)}setTransition(t,r){Object.hasOwn(this._values,t)||(this._values[t]=new Ih(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].transition=Wt(r)||void 0}retainPriorGlobalState(t,r,i){for(let a of Object.keys(i._values))for(let n=i._values[a];n;n=n.prior){let{value:s}=n;s.property.specification.transition&&!s.isDataDriven()&&s.expression._globalState===this._globalState&&s.readsGlobalState(t)&&(n.value=new Jn(s.property,s.value,this._propertyRootKey(a),r))}}applyGlobalStateChange(t,r,i,a){this.retainPriorGlobalState(t,r,i);let n=!1;for(let s of Object.keys(this._values)){let{value:o}=this._values[s];o.readsGlobalState(t)&&(this.setValue(s,o.value),n=!0)}return n?this.transitioned(a,i):i}serialize(){let t={};for(let r of Object.keys(this._values)){let i=this.getValue(r);i!==void 0&&(t[r]=i);let a=this.getTransition(r);a!==void 0&&(t[`${r}-transition`]=a)}return t}transitioned(t,r){let i=new pf(this._properties);for(let a of Object.keys(this._values))i._values[a]=this._values[a].transitioned(t,r._values[a]);return i}untransitioned(){let t=new pf(this._properties);for(let r of Object.keys(this._values))t._values[r]=this._values[r].untransitioned();return t}},df=class{constructor(t,r,i,a,n){this.property=t,this.value=r,this.begin=n+a.delay||0,this.end=this.begin+a.duration||0,t.specification.transition&&(a.delay||a.duration)&&(this.prior=i)}possiblyEvaluate(t,r,i){let a=t.now||0,n=this.value.possiblyEvaluate(t,r,i),s=this.prior;if(!s)return n;if(a>this.end||this.value.isDataDriven())return this.prior=null,n;if(a<this.begin)return s.possiblyEvaluate(t,r,i);{let o=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(t,r,i),n,dv(o))}}},pf=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,r,i){let a=new Fl(this._properties);for(let n of Object.keys(this._values))a._values[n]=this._values[n].possiblyEvaluate(t,r,i);return a}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}},R2=class{constructor(t,r,i){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=i,this._rootKey=r}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasValue(t){return this._values[t].value!==void 0}hasProperty(t){return t in this._properties.defaultPropertyValues}getValue(t){return Wt(this._values[t].value)}setValue(t,r){this._values[t]=new Jn(this._values[t].property,r===null?void 0:Wt(r),this._propertyRootKey(t),this._globalState)}serialize(){let t={};for(let r of Object.keys(this._values)){let i=this.getValue(r);i!==void 0&&(t[r]=i)}return t}possiblyEvaluate(t,r,i){let a=new Fl(this._properties);for(let n of Object.keys(this._values))a._values[n]=this._values[n].possiblyEvaluate(t,r,i);return a}},gr=class{constructor(t,r,i){this.property=t,this.value=r,this.parameters=i}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,r,i,a){return this.property.evaluate(this.value,this.parameters,t,r,i,a)}},Fl=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}};function ff(e){if(Array.isArray(e))return e.length;let t=e==null?void 0:e.values;return Array.isArray(t)?t.length:void 0}function _y(e,t){let r=ff(e),i=ff(t);return r!==void 0&&i!==void 0&&r!==i}var N=class{constructor(t,r){this.specification=t,this.name=r}possiblyEvaluate(t,r){if(t.isDataDriven())throw Error("Value should not be data driven");return t.expression.evaluate(r)}interpolate(t,r,i){if(_y(t,r))return _e(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),r;let a=this.specification.type,n=We[a];return n?n(t,r,i):t}},Y=class{constructor(t,r,i){this.specification=t,this.name=r,this.overrides=i}possiblyEvaluate(t,r,i,a){return t.expression.kind==="constant"||t.expression.kind==="camera"?new gr(this,{kind:"constant",value:t.expression.evaluate(r,null,{},i,a)},r):new gr(this,t.expression,r)}interpolate(t,r,i){if(t.value.kind!=="constant"||r.value.kind!=="constant")return t;if(t.value.value===void 0||r.value.value===void 0)return new gr(this,{kind:"constant",value:void 0},t.parameters);if(_y(t.value.value,r.value.value))return _e(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),r;let a=this.specification.type,n=We[a];if(n){let s=n(t.value.value,r.value.value,i);return new gr(this,{kind:"constant",value:s},t.parameters)}return t}evaluate(t,r,i,a,n,s){return t.kind==="constant"?t.value:t.evaluate(r,i,a,n,s)}},Qn=class extends Y{possiblyEvaluate(t,r,i,a){if(t.value===void 0)return new gr(this,{kind:"constant",value:void 0},r);if(t.expression.kind==="constant"){let n=t.expression.evaluate(r,null,{},i,a),s=t.property.specification.type==="resolvedImage"&&typeof n!="string"?n.name:n,o=this._calculate(s,s,s,r);return new gr(this,{kind:"constant",value:o},r)}if(t.expression.kind==="camera"){let n=this._calculate(t.expression.evaluate({zoom:r.zoom-1}),t.expression.evaluate({zoom:r.zoom}),t.expression.evaluate({zoom:r.zoom+1}),r);return new gr(this,{kind:"constant",value:n},r)}return new gr(this,t.expression,r)}evaluate(t,r,i,a,n,s){if(t.kind==="source"){let o=t.evaluate(r,i,a,n,s);return this._calculate(o,o,o,r)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(r.zoom)-1},i,a),t.evaluate({zoom:Math.floor(r.zoom)},i,a),t.evaluate({zoom:Math.floor(r.zoom)+1},i,a),r):t.value}_calculate(t,r,i,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:i,to:r}}interpolate(t){return t}},yy=class{constructor(t,r){this.specification=t,this.name=r}possiblyEvaluate(t,r,i,a){if(t.value!==void 0){if(t.expression.kind==="constant"){let n=t.expression.evaluate(r,null,{},i,a);return this._calculate(n,n,n,r)}return this._calculate(t.expression.evaluate(new ze(Math.floor(r.zoom-1),r)),t.expression.evaluate(new ze(Math.floor(r.zoom),r)),t.expression.evaluate(new ze(Math.floor(r.zoom+1),r)),r)}}_calculate(t,r,i,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:i,to:r}}interpolate(t){return t}},Rl=class{constructor(t,r){this.specification=t,this.name=r}possiblyEvaluate(t,r,i,a){return!!t.expression.evaluate(r,null,{},i,a)}interpolate(){return!1}},wt=class{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let r in t){let i=t[r];i.specification.overridable&&this.overridableProperties.push(r);let a=this.defaultPropertyValues[r]=new Jn(i,void 0,i.name,void 0),n=this.defaultTransitionablePropertyValues[r]=new Ih(i,i.name,void 0);this.defaultTransitioningPropertyValues[r]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=a.possiblyEvaluate({})}}};G("DataDrivenProperty",Y),G("DataConstantProperty",N),G("CrossFadedDataDrivenProperty",Qn),G("CrossFadedProperty",yy),G("ColorRampProperty",Rl);const mf=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Fu=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var Mr=class extends Rt{constructor(t,r,i){if(super(),this.id=t.id,this.type=t.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=M2(this.visibility,`layers[${this.id}].layout.visibility`,i),t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=Yn(t.filter,`layers[${this.id}].filter`,i)),r.layout&&(this._unevaluatedLayout=new R2(r.layout,`layers[${this.id}].layout`,i)),r.paint)){this._transitionablePaint=new zl(r.paint,`layers[${this.id}].paint`,i);for(let a in t.paint)this.setPaintProperty(a,t.paint[a],{validate:!1});for(let a in t.layout)this.setLayoutProperty(a,t.layout[a],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Fl(r.paint)}}setFilter(t){this.filter=t,this._featureFilter=Yn(t,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){var r;if(t==="visibility")return this.visibility;if((r=this._transitionablePaint)!=null&&r.hasProperty(t))throw Error(t+mf);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${t}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){let t=new Set;for(let r of this._visibilityExpression.getGlobalStateRefs())t.add(r);if(this._unevaluatedLayout)for(let r in this._unevaluatedLayout._values){let i=this._unevaluatedLayout._values[r];for(let a of i.getGlobalStateRefs())t.add(a)}for(let r of this._featureFilter.getGlobalStateRefs())t.add(r);return t}getPaintAffectingGlobalStateRefs(){let t=new globalThis.Map;if(this._transitionablePaint)for(let r in this._transitionablePaint._values){let i=this._transitionablePaint._values[r].value;for(let a of i.getGlobalStateRefs()){let n=t.get(a)??[];n.push({name:r,value:i.value}),t.set(a,n)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,r,i={}){var a;if(t==="visibility"){this.visibility=r,this._visibilityExpression.setValue(r),this.recalculateVisibility();return}if((a=this._transitionablePaint)!=null&&a.hasProperty(t)){this.fire(new X(Error(t+mf)));return}r!=null&&this._validate(Zt.layoutProperty,`layers.${this.id}.layout.${t}`,t,r,i)||this._unevaluatedLayout.setValue(t,r)}getPaintProperty(t){var r,i;if(t.endsWith("-transition")){let a=t.slice(0,-11);if(a==="visibility"||(r=this._unevaluatedLayout)!=null&&r.hasProperty(a))throw Error(t+Fu);return this._transitionablePaint.getTransition(a)}if(t==="visibility"||(i=this._unevaluatedLayout)!=null&&i.hasProperty(t))throw Error(t+Fu);return this._transitionablePaint.getValue(t)}setPaintProperty(t,r,i={}){var a;if(t==="visibility"||(a=this._unevaluatedLayout)!=null&&a.hasProperty(t))return this.fire(new X(Error(t+Fu))),!1;if(r!=null&&this._validate(Zt.paintProperty,`layers.${this.id}.paint.${t}`,t,r,i))return!1;if(t.endsWith("-transition"))return this._transitionablePaint.setTransition(t.slice(0,-11),r||void 0),!1;{let n=this._transitionablePaint._values[t],s=n.property.specification["property-type"]==="cross-faded-data-driven",o=n.value.isDataDriven(),l=n.value;this._transitionablePaint.setValue(t,r),this._handleSpecialPaintPropertyUpdate(t);let u=this._transitionablePaint._values[t].value;return u.isDataDriven()||o||s||this._handleOverridablePaintPropertyUpdate(t,l,u)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,r,i){return!1}isHidden(t=this.minzoom,r=!1){return this.minzoom&&t<(r?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&t>=this.maxzoom?!0:this._evaluatedVisibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}retainPriorGlobalState(t,r){var i;(i=this._transitionablePaint)==null||i.retainPriorGlobalState(t,r,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(t,r){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,r)}serialize(){var r,i;let t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:(r=this._unevaluatedLayout)==null?void 0:r.serialize(),paint:(i=this._transitionablePaint)==null?void 0:i.serialize()};return this.visibility&&(t.layout||(t.layout={}),t.layout.visibility=this.visibility),Ng(t,(a,n)=>a!==void 0&&!(n==="layout"&&!Object.keys(a).length)&&!(n==="paint"&&!Object.keys(a).length))}_validate(t,r,i,a,n={}){return _s(this,t,{key:r,layerType:this.type,objectKey:i,value:a},n)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let r=this.paint.get(t);if(r instanceof gr&&Za(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}};let k2;const L2=()=>k2||(k2=new wt({"raster-opacity":new N(M.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new N(M.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new N(M.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new N(M.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new N(M.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new N(M.paint_raster["raster-contrast"],"raster-contrast"),resampling:new N(M.paint_raster.resampling,"resampling"),"raster-resampling":new N(M.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new N(M.paint_raster["raster-fade-duration"],"raster-fade-duration")}));var B2={get paint(){return L2()}};const Mh=e=>e.type==="raster";var O2=class extends Mr{constructor(t,r){super(t,B2,r)}};const $2={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var ys=class{constructor(t,r){this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},Qe=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,r){return t._trim(),r&&(t.isTransferred=!0,r.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let r=Object.create(this.prototype);return r.arrayBuffer=t.arrayBuffer,r.length=t.length,r.capacity=t.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(this.capacity*5),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function Ye(e,t=1){let r=0,i=0;return{members:e.map(a=>{let n=j2(a.type),s=r=gf(r,Math.max(t,n)),o=a.components||1;return i=Math.max(i,n),r+=n*o,{name:a.name,type:a.type,components:o,offset:s}}),size:gf(r,Math.max(i,t)),alignment:t}}function j2(e){return $2[e].BYTES_PER_ELEMENT}function gf(e,t){return Math.ceil(e/t)*t}var es=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,r)}emplace(t,r,i){let a=t*2;return this.int16[a+0]=r,this.int16[a+1]=i,t}};es.prototype.bytesPerElement=4,G("StructArrayLayout2i4",es);var Wo=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*3;return this.int16[n+0]=r,this.int16[n+1]=i,this.int16[n+2]=a,t}};Wo.prototype.bytesPerElement=6,G("StructArrayLayout3i6",Wo);var zh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,r,i,a)}emplace(t,r,i,a,n){let s=t*4;return this.int16[s+0]=r,this.int16[s+1]=i,this.int16[s+2]=a,this.int16[s+3]=n,t}};zh.prototype.bytesPerElement=8,G("StructArrayLayout4i8",zh);var Fh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,r,i,a,n,s)}emplace(t,r,i,a,n,s,o){let l=t*6;return this.int16[l+0]=r,this.int16[l+1]=i,this.int16[l+2]=a,this.int16[l+3]=n,this.int16[l+4]=s,this.int16[l+5]=o,t}};Fh.prototype.bytesPerElement=12,G("StructArrayLayout2i4i12",Fh);var Rh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,r,i,a,n,s)}emplace(t,r,i,a,n,s,o){let l=t*4,u=t*8;return this.int16[l+0]=r,this.int16[l+1]=i,this.uint8[u+4]=a,this.uint8[u+5]=n,this.uint8[u+6]=s,this.uint8[u+7]=o,t}};Rh.prototype.bytesPerElement=8,G("StructArrayLayout2i4ub8",Rh);var ts=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,r)}emplace(t,r,i){let a=t*2;return this.float32[a+0]=r,this.float32[a+1]=i,t}};ts.prototype.bytesPerElement=8,G("StructArrayLayout2f8",ts);var kh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s,o,l,u,h){let c=this.length;return this.resize(c+1),this.emplace(c,t,r,i,a,n,s,o,l,u,h)}emplace(t,r,i,a,n,s,o,l,u,h,c){let d=t*10;return this.uint16[d+0]=r,this.uint16[d+1]=i,this.uint16[d+2]=a,this.uint16[d+3]=n,this.uint16[d+4]=s,this.uint16[d+5]=o,this.uint16[d+6]=l,this.uint16[d+7]=u,this.uint16[d+8]=h,this.uint16[d+9]=c,t}};kh.prototype.bytesPerElement=20,G("StructArrayLayout10ui20",kh);var Lh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s,o,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,r,i,a,n,s,o,l)}emplace(t,r,i,a,n,s,o,l,u){let h=t*8;return this.uint16[h+0]=r,this.uint16[h+1]=i,this.uint16[h+2]=a,this.uint16[h+3]=n,this.uint16[h+4]=s,this.uint16[h+5]=o,this.uint16[h+6]=l,this.uint16[h+7]=u,t}};Lh.prototype.bytesPerElement=16,G("StructArrayLayout8ui16",Lh);var Bh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s,o,l,u,h,c,d,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,i,a,n,s,o,l,u,h,c,d,p)}emplace(t,r,i,a,n,s,o,l,u,h,c,d,p,f){let m=t*14,g=t*7;return this.int16[m+0]=r,this.int16[m+1]=i,this.int16[m+2]=a,this.int16[m+3]=n,this.uint16[m+4]=s,this.uint16[m+5]=o,this.uint16[m+6]=l,this.uint16[m+7]=u,this.int16[m+8]=h,this.int16[m+9]=c,this.int16[m+10]=d,this.int16[m+11]=p,this.float32[g+6]=f,t}};Bh.prototype.bytesPerElement=28,G("StructArrayLayout4i4ui4i1f28",Bh);var Oh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*3;return this.float32[n+0]=r,this.float32[n+1]=i,this.float32[n+2]=a,t}};Oh.prototype.bytesPerElement=12,G("StructArrayLayout3f12",Oh);var $h=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){let i=t*1;return this.uint32[i+0]=r,t}};$h.prototype.bytesPerElement=4,G("StructArrayLayout1ul4",$h);var jh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s,o,l,u){let h=this.length;return this.resize(h+1),this.emplace(h,t,r,i,a,n,s,o,l,u)}emplace(t,r,i,a,n,s,o,l,u,h){let c=t*10,d=t*5;return this.int16[c+0]=r,this.int16[c+1]=i,this.int16[c+2]=a,this.int16[c+3]=n,this.int16[c+4]=s,this.int16[c+5]=o,this.uint32[d+3]=l,this.uint16[c+8]=u,this.uint16[c+9]=h,t}};jh.prototype.bytesPerElement=20,G("StructArrayLayout6i1ul2ui20",jh);var Vh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,r,i,a,n,s)}emplace(t,r,i,a,n,s,o){let l=t*6;return this.int16[l+0]=r,this.int16[l+1]=i,this.int16[l+2]=a,this.int16[l+3]=n,this.int16[l+4]=s,this.int16[l+5]=o,t}};Vh.prototype.bytesPerElement=12,G("StructArrayLayout2i2i2i12",Vh);var Nh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n){let s=this.length;return this.resize(s+1),this.emplace(s,t,r,i,a,n)}emplace(t,r,i,a,n,s){let o=t*4,l=t*8;return this.float32[o+0]=r,this.float32[o+1]=i,this.float32[o+2]=a,this.int16[l+6]=n,this.int16[l+7]=s,t}};Nh.prototype.bytesPerElement=16,G("StructArrayLayout2f1f2i16",Nh);var Uh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,r,i,a,n,s)}emplace(t,r,i,a,n,s,o){let l=t*16,u=t*4,h=t*8;return this.uint8[l+0]=r,this.uint8[l+1]=i,this.float32[u+1]=a,this.float32[u+2]=n,this.int16[h+6]=s,this.int16[h+7]=o,t}};Uh.prototype.bytesPerElement=16,G("StructArrayLayout2ub2f2i16",Uh);var Ho=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*3;return this.uint16[n+0]=r,this.uint16[n+1]=i,this.uint16[n+2]=a,t}};Ho.prototype.bytesPerElement=6,G("StructArrayLayout3ui6",Ho);var Gh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y){let v=this.length;return this.resize(v+1),this.emplace(v,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y)}emplace(t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v){let x=t*26,w=t*13,b=t*52;return this.int16[x+0]=r,this.int16[x+1]=i,this.uint16[x+2]=a,this.uint16[x+3]=n,this.uint32[w+2]=s,this.uint32[w+3]=o,this.uint32[w+4]=l,this.uint16[x+10]=u,this.uint16[x+11]=h,this.uint16[x+12]=c,this.float32[w+7]=d,this.float32[w+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=m,this.uint8[b+38]=g,this.uint32[w+10]=_,this.int16[x+22]=y,this.float32[w+12]=v,t}};Gh.prototype.bytesPerElement=52,G("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",Gh);var qh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w,b,T,P,S,I,R,F,D){let A=this.length;return this.resize(A+1),this.emplace(A,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w,b,T,P,S,I,R,F,D)}emplace(t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w,b,T,P,S,I,R,F,D,A){let E=t*34,z=t*17;return this.int16[E+0]=r,this.int16[E+1]=i,this.int16[E+2]=a,this.int16[E+3]=n,this.int16[E+4]=s,this.int16[E+5]=o,this.int16[E+6]=l,this.int16[E+7]=u,this.uint16[E+8]=h,this.uint16[E+9]=c,this.uint16[E+10]=d,this.uint16[E+11]=p,this.uint16[E+12]=f,this.uint16[E+13]=m,this.uint16[E+14]=g,this.uint16[E+15]=_,this.uint16[E+16]=y,this.uint16[E+17]=v,this.uint16[E+18]=x,this.uint16[E+19]=w,this.uint16[E+20]=b,this.uint16[E+21]=T,this.uint16[E+22]=P,this.uint32[z+12]=S,this.float32[z+13]=I,this.float32[z+14]=R,this.uint16[E+30]=F,this.uint16[E+31]=D,this.float32[z+16]=A,t}};qh.prototype.bytesPerElement=68,G("StructArrayLayout8i15ui1ul2f2ui1f68",qh);var Xo=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){let i=t*1;return this.float32[i+0]=r,t}};Xo.prototype.bytesPerElement=4,G("StructArrayLayout1f4",Xo);var Zh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*6,s=t*3;return this.uint16[n+0]=r,this.float32[s+1]=i,this.float32[s+2]=a,t}};Zh.prototype.bytesPerElement=12,G("StructArrayLayout1ui2f12",Zh);var Wh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,t,r,i)}emplace(t,r,i,a){let n=t*2,s=t*4;return this.uint32[n+0]=r,this.uint16[s+2]=i,this.uint16[s+3]=a,t}};Wh.prototype.bytesPerElement=8,G("StructArrayLayout1ul2ui8",Wh);var Hh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r){let i=this.length;return this.resize(i+1),this.emplace(i,t,r)}emplace(t,r,i){let a=t*2;return this.uint16[a+0]=r,this.uint16[a+1]=i,t}};Hh.prototype.bytesPerElement=4,G("StructArrayLayout2ui4",Hh);var Xh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){let i=t*1;return this.uint16[i+0]=r,t}};Xh.prototype.bytesPerElement=2,G("StructArrayLayout1ui2",Xh);var Yh=class extends Qe{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,i,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,r,i,a)}emplace(t,r,i,a,n){let s=t*4;return this.float32[s+0]=r,this.float32[s+1]=i,this.float32[s+2]=a,this.float32[s+3]=n,t}};Yh.prototype.bytesPerElement=16,G("StructArrayLayout4f16",Yh);var xy=class extends ys{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new C(this.anchorPointX,this.anchorPointY)}};xy.prototype.size=20;var vy=class extends jh{get(t){return new xy(this,t)}};G("CollisionBoxArray",vy);var by=class extends ys{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}get heightOffset(){return this._structArray.float32[this._pos4+12]}};by.prototype.size=52;var wy=class extends Gh{get(t){return new by(this,t)}};G("PlacedSymbolArray",wy);var Ty=class extends ys{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}get heightOffset(){return this._structArray.float32[this._pos4+16]}};Ty.prototype.size=68;var Dy=class extends qh{get(t){return new Ty(this,t)}};G("SymbolInstanceArray",Dy);var Sy=class extends Xo{getoffsetX(t){return this.float32[t*1+0]}};G("GlyphOffsetArray",Sy);var Ey=class extends Wo{getx(t){return this.int16[t*3+0]}gety(t){return this.int16[t*3+1]}gettileUnitDistanceFromAnchor(t){return this.int16[t*3+2]}};G("SymbolLineVertexArray",Ey);var Py=class extends ys{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}};Py.prototype.size=12;var Ay=class extends Zh{get(t){return new Py(this,t)}};G("TextAnchorOffsetArray",Ay);var Cy=class extends ys{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]}};Cy.prototype.size=8;var Iy=class extends Wh{get(t){return new Cy(this,t)}};G("FeatureIndexArray",Iy);var bi=class extends es{},V2=class extends Wo{},N2=class extends zh{},U2=class extends es{},G2=class extends es{},q2=class extends Fh{},Z2=class extends Rh{},W2=class extends ts{},xa=class extends kh{},_f=class extends Lh{},H2=class extends Bh{},X2=class extends Oh{},Y2=class extends $h{},yf=class extends Vh{},K2=class extends Nh{},J2=class extends Uh{},Q2=class extends Ho{},Yr=class extends Ho{},Kh=class extends Hh{},ew=class extends Xh{};const tw=Ye([{name:"a_pos",components:2,type:"Int16"}],4),rw=tw.members;var Ze=class Aa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,r,i,a){let n=this.segments[this.segments.length-1];return t>Aa.MAX_VERTEX_ARRAY_LENGTH&&_e(`Max vertices per segment is ${Aa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Aa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>Aa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==a?this.createNewSegment(r,i,a):n}createNewSegment(t,r,i){let a={vertexOffset:t.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0,vaos:{}};return i!==void 0&&(a.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(a),a}getOrCreateLatestSegment(t,r,i){return this.prepareSegment(0,t,r,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let t of this.segments)for(let r in t.vaos)t.vaos[r].destroy()}static simpleSegment(t,r,i,a){return new Aa([{vertexOffset:t,primitiveOffset:r,vertexLength:i,primitiveLength:a,vaos:{},sortKey:0}])}};Ze.MAX_VERTEX_ARRAY_LENGTH=2**16-1,G("SegmentVector",Ze);function xf(e,t){return e=ne(Math.floor(e),0,255),t=ne(Math.floor(t),0,255),256*e+t}const iw=Ye([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),aw=Ye([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var nw=$c((e,t)=>{function r(i,a){for(var n=i.length&3,s=i.length-n,o=a,l,u=3432918353,h=461845907,c,d=0;d<s;)c=i.charCodeAt(d)&255|(i.charCodeAt(++d)&255)<<8|(i.charCodeAt(++d)&255)<<16|(i.charCodeAt(++d)&255)<<24,++d,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)&4294967295,o^=c,o=o<<13|o>>>19,l=(o&65535)*5+(((o>>>16)*5&65535)<<16)&4294967295,o=(l&65535)+27492+(((l>>>16)+58964&65535)<<16);switch(c=0,n){case 3:c^=(i.charCodeAt(d+2)&255)<<16;case 2:c^=(i.charCodeAt(d+1)&255)<<8;case 1:c^=i.charCodeAt(d)&255,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)&4294967295,o^=c}return o^=i.length,o^=o>>>16,o=(o&65535)*2246822507+(((o>>>16)*2246822507&65535)<<16)&4294967295,o^=o>>>13,o=(o&65535)*3266489909+(((o>>>16)*3266489909&65535)<<16)&4294967295,o^=o>>>16,o>>>0}t!==void 0&&(t.exports=r)}),sw=$c((e,t)=>{function r(i,a){for(var n=i.length,s=a^n,o=0,l;n>=4;)l=i.charCodeAt(o)&255|(i.charCodeAt(++o)&255)<<8|(i.charCodeAt(++o)&255)<<16|(i.charCodeAt(++o)&255)<<24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),l^=l>>>24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16)^l,n-=4,++o;switch(n){case 3:s^=(i.charCodeAt(o+2)&255)<<16;case 2:s^=(i.charCodeAt(o+1)&255)<<8;case 1:s^=i.charCodeAt(o)&255,s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16)}return s^=s>>>13,s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16),s^=s>>>15,s>>>0}t.exports=r}),Yo=kx($c((e,t)=>{var r=nw(),i=sw();t.exports=r,t.exports.murmur3=r,t.exports.murmur2=i})()),My=class zy{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,r,i,a){this.ids.push(vf(t)),this.positions.push(r,i,a)}getPositions(t){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let r=vf(t),i=0,a=this.ids.length-1;for(;i<a;){let s=i+a>>1;this.ids[s]>=r?a=s:i=s+1}let n=[];for(;this.ids[i]===r;){let s=this.positions[3*i],o=this.positions[3*i+1],l=this.positions[3*i+2];n.push({index:s,start:o,end:l}),i++}return n}static serialize(t,r){let i=new Float64Array(t.ids),a=new Uint32Array(t.positions);return Jh(i,a,0,i.length-1),r&&r.push(i.buffer,a.buffer),{ids:i,positions:a}}static deserialize(t){let r=new zy;return r.ids=t.ids,r.positions=t.positions,r.indexed=!0,r}};function vf(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,Yo.default)(String(e))}function Jh(e,t,r,i){for(;r<i;){let a=e[r+i>>1],n=r-1,s=i+1;for(;;){do n++;while(e[n]<a);do s--;while(e[s]>a);if(n>=s)break;Xs(e,n,s),Xs(t,3*n,3*s),Xs(t,3*n+1,3*s+1),Xs(t,3*n+2,3*s+2)}s-r<i-s?(Jh(e,t,r,s),r=s+1):(Jh(e,t,s+1,i),i=s)}}function Xs(e,t,r){let i=e[t];e[t]=e[r],e[r]=i}G("FeaturePositionMap",My);var di=class{constructor(t,r){this.gl=t.gl,this.location=r}},H=class extends di{constructor(t,r){super(t,r),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},U=class extends di{constructor(t,r){super(t,r),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}},ce=class extends di{constructor(t,r){super(t,r),this.current=[0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1])&&(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},jt=class extends di{constructor(t,r){super(t,r),this.current=[0,0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1]||t[2]!==this.current[2])&&(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},rs=class extends di{constructor(t,r){super(t,r),this.current=[0,0,0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1]||t[2]!==this.current[2]||t[3]!==this.current[3])&&(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}},Ai=class extends di{constructor(t,r){super(t,r),this.current=se.transparent}set(t){(t.r!==this.current.r||t.g!==this.current.g||t.b!==this.current.b||t.a!==this.current.a)&&(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}},bf=class extends di{constructor(t,r){super(t,r),this.current=[]}set(t){if(t!=this.current){this.current=t;let r=new Float32Array(t.length*4);for(let i=0;i<t.length;i++)r[4*i]=t[i].r,r[4*i+1]=t[i].g,r[4*i+2]=t[i].b,r[4*i+3]=t[i].a;this.gl.uniform4fv(this.location,r)}}},wf=class extends di{constructor(t,r){super(t,r),this.current=[]}set(t){if(t!=this.current){this.current=t;let r=new Float32Array(t);this.gl.uniform1fv(this.location,r)}}};const ow=new Float32Array(16);var Cr=class extends di{constructor(t,r){super(t,r),this.current=ow}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);return}for(let r=1;r<16;r++)if(t[r]!==this.current[r]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}};function Qh(e){return[xf(255*e.r,255*e.g),xf(255*e.b,255*e.a)]}var zn=class{constructor(t,r,i){this.value=t,this.uniformNames=r.map(a=>`u_${a}`),this.type=i}setUniform(t,r,i){t.set(i.constantOr(this.value))}getBinding(t,r,i){return this.type==="color"?new Ai(t,r):new U(t,r)}},Li=class{constructor(t,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,r){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,r.y,r.height,r.width]}setUniform(t,r,i,a){let n=null;a==="u_pattern_to"?n=this.patternTo:a==="u_pattern_from"?n=this.patternFrom:a==="u_dasharray_to"?n=this.dashTo:a==="u_dasharray_from"?n=this.dashFrom:a==="u_pixel_ratio_to"?n=this.pixelRatioTo:a==="u_pixel_ratio_from"&&(n=this.pixelRatioFrom),n!==null&&t.set(n)}getBinding(t,r,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new rs(t,r):new U(t,r)}},Jr=class{constructor(t,r,i,a){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=r.map(n=>({name:`a_${n}`,type:"Float32",components:i==="color"?2:1,offset:0})),this.paintVertexArray=new a}populatePaintArray(t,r,i){let a=this.paintVertexArray.length,n=this.expression.evaluate(new ze(0,i),r,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(a,t,n)}updatePaintArray(t,r,i,a,n){let s=this.expression.evaluate(new ze(0,n),i,a);this._setPaintValue(t,r,s)}_setPaintValue(t,r,i){if(this.type==="color"){let a=Qh(i);for(let n=t;n<r;n++)this.paintVertexArray.emplace(n,a[0],a[1])}else{for(let a=t;a<r;a++)this.paintVertexArray.emplace(a,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){var r,i;(r=this.paintVertexArray)!=null&&r.arrayBuffer.byteLength&&((i=this.paintVertexBuffer)!=null&&i.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},Tr=class{constructor(t,r,i,a,n,s){this.expression=t,this.uniformNames=r.map(o=>`u_${o}_t`),this.type=i,this.useIntegerZoom=a,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=r.map(o=>({name:`a_${o}`,type:"Float32",components:i==="color"?4:2,offset:0})),this.paintVertexArray=new s}populatePaintArray(t,r,i){let a=this.expression.evaluate(new ze(this.zoom,i),r,{},i.canonical,[],i.formattedSection),n=this.expression.evaluate(new ze(this.zoom+1,i),r,{},i.canonical,[],i.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,a,n)}updatePaintArray(t,r,i,a,n){let s=this.expression.evaluate(new ze(this.zoom,n),i,a),o=this.expression.evaluate(new ze(this.zoom+1,n),i,a);this._setPaintValue(t,r,s,o)}_setPaintValue(t,r,i,a){if(this.type==="color"){let n=Qh(i),s=Qh(a);for(let o=t;o<r;o++)this.paintVertexArray.emplace(o,n[0],n[1],s[0],s[1])}else{for(let n=t;n<r;n++)this.paintVertexArray.emplace(n,i,a);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(a))}}upload(t){var r,i;(r=this.paintVertexArray)!=null&&r.arrayBuffer.byteLength&&((i=this.paintVertexBuffer)!=null&&i.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,r){let i=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,a=ne(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(a)}getBinding(t,r,i){return new U(t,r)}},_i=class{constructor(t,r,i,a,n,s){this.expression=t,this.type=r,this.useIntegerZoom=i,this.zoom=a,this.layerId=s,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(t,r,i){let a=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(a,t,this.getPositionIds(r),i)}updatePaintArray(t,r,i,a,n){this._setPaintValues(t,r,this.getPositionIds(i),n)}_setPaintValues(t,r,i,a){let n=this.getPositions(a);if(!n||!i)return;let s=n[i.min],o=n[i.mid],l=n[i.max];if(s&&o&&l)for(let u=t;u<r;u++)this.emplace(this.zoomInPaintVertexArray,u,s,o),this.emplace(this.zoomOutPaintVertexArray,u,l,o)}upload(t){var r,i;if((r=this.zoomInPaintVertexArray)!=null&&r.arrayBuffer.byteLength&&((i=this.zoomOutPaintVertexArray)!=null&&i.arrayBuffer.byteLength)){let a=this.getVertexAttributes();this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,a,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,a,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}},Fy=class extends _i{getPositions(t){return t.imagePositions}getPositionIds(t){var r;return(r=t.patterns)==null?void 0:r[this.layerId]}getVertexAttributes(){return iw.members}emplace(t,r,i,a){t.emplace(r,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],a.tlbr[0],a.tlbr[1],a.tlbr[2],a.tlbr[3],i.pixelRatio,a.pixelRatio)}},Ry=class extends _i{getPositions(t){return t.dashPositions}getPositionIds(t){var r;return(r=t.dashes)==null?void 0:r[this.layerId]}getVertexAttributes(){return aw.members}emplace(t,r,i,a){t.emplace(r,0,i.y,i.height,i.width,0,a.y,a.height,a.width)}},ky=class{constructor(t,r,i){this.binders={},this._buffers=[];let a=[];for(let n in t.paint._values){if(!i(n))continue;let s=t.paint.get(n);if(!(s instanceof gr)||!Za(s.property.specification))continue;let o=lw(n,t.type),l=s.value,u=s.property.specification.type,h=s.property.useIntegerZoom,c=s.property.specification["property-type"],d=c==="cross-faded"||c==="cross-faded-data-driven";if(l.kind==="constant")this.binders[n]=d?new Li(l.value,o):new zn(l.value,o,u),a.push(`/u_${n}`);else if(l.kind==="source"||d){let p=Tf(n,u,"source");this.binders[n]=d?n==="line-dasharray"?new Ry(l,u,h,r,p,t.id):new Fy(l,u,h,r,p,t.id):new Jr(l,o,u,p),a.push(`/a_${n}`)}else{let p=Tf(n,u,"composite");this.binders[n]=new Tr(l,o,u,h,r,p),a.push(`/z_${n}`)}}this.cacheKey=a.sort().join("")}getMaxValue(t){let r=this.binders[t];return r instanceof Jr||r instanceof Tr?r.maxValue:0}populatePaintArrays(t,r,i){for(let a in this.binders){let n=this.binders[a];(n instanceof Jr||n instanceof Tr||n instanceof _i)&&n.populatePaintArray(t,r,i)}}setConstantPatternPositions(t,r){for(let i in this.binders){let a=this.binders[i];a instanceof Li&&a.setConstantPatternPositions(t,r)}}setConstantDashPositions(t,r){for(let i in this.binders){let a=this.binders[i];a instanceof Li&&a.setConstantDashPositions(t,r)}}updatePaintArrays(t,r,i,a,n){let s=!1;for(let o of t){let l=r.getPositions(o.id);for(let u of l){let h=i.feature(u.index);for(let c in this.binders){let d=this.binders[c];(d instanceof Jr||d instanceof Tr||d instanceof _i)&&d.expression.isStateDependent===!0&&(d.expression=a.paint.get(c).value,d.updatePaintArray(u.start,u.end,h,o.state,n),s=!0)}}}return s}defines(){let t=[];for(let r in this.binders){let i=this.binders[r];(i instanceof zn||i instanceof Li)&&t.push(...i.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return t}getBinderAttributes(){let t=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof Jr||i instanceof Tr)for(let a of i.paintVertexAttributes)t.push(a.name);else if(i instanceof _i){let a=i.getVertexAttributes();for(let n of a)t.push(n.name)}}return t}getBinderUniforms(){let t=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof zn||i instanceof Li||i instanceof Tr)for(let a of i.uniformNames)t.push(a)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,r){let i=[];for(let a in this.binders){let n=this.binders[a];if(n instanceof zn||n instanceof Li||n instanceof Tr){for(let s of n.uniformNames)if(r[s]){let o=n.getBinding(t,r[s],s);i.push({name:s,property:a,binding:o})}}}return i}setUniforms(t,r,i,a){for(let{name:n,property:s,binding:o}of r)this.binders[s].setUniform(o,a,i.get(s),n)}updatePaintBuffers(t){this._buffers=[];for(let r in this.binders){let i=this.binders[r];if(t&&i instanceof _i){let a=t.fromScale===2?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;a&&this._buffers.push(a)}else(i instanceof Jr||i instanceof Tr)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(let r in this.binders){let i=this.binders[r];(i instanceof Jr||i instanceof Tr||i instanceof _i)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let r=this.binders[t];(r instanceof Jr||r instanceof Tr||r instanceof _i)&&r.destroy()}}},Qi=class{constructor(t,r,i=()=>!0){this.programConfigurations={};for(let a of t)this.programConfigurations[a.id]=new ky(a,r,i);this.needsUpload=!1,this._featureMap=new My,this._bufferOffset=0}populatePaintArrays(t,r,i,a){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(t,r,a);r.id!==void 0&&this._featureMap.add(r.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,r,i,a){for(let n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,r,n,a)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let r in this.programConfigurations)this.programConfigurations[r].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}};function lw(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function uw(e){return{"line-pattern":{source:xa,composite:xa},"fill-pattern":{source:xa,composite:xa},"fill-extrusion-pattern":{source:xa,composite:xa},"line-dasharray":{source:_f,composite:_f}}[e]}function Tf(e,t,r){var a;let i={color:{source:ts,composite:Yh},number:{source:Xo,composite:ts}};return((a=uw(e))==null?void 0:a[r])||i[t][r]}G("ConstantBinder",zn),G("CrossFadedConstantBinder",Li),G("SourceExpressionBinder",Jr),G("CrossFadedPatternBinder",Fy),G("CrossFadedDasharrayBinder",Ry),G("CompositeExpressionBinder",Tr),G("ProgramConfiguration",ky,{omit:["_buffers"]}),G("ProgramConfigurationSet",Qi);const ec=2**14-1,Df=-ec-1;function na(e){let t=k/e.extent,r=e.loadGeometry();for(let i of r)for(let a of i){let n=Math.round(a.x*t),s=Math.round(a.y*t);a.x=ne(n,Df,ec),a.y=ne(s,Df,ec),(n<a.x||n>a.x+1||s<a.y||s>a.y+1)&&_e("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return r}function sa(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?na(e):[]}}const Sf=-32768;function hw(e,t,r,i,a){e.emplaceBack(Sf+t*8+i,Sf+r*8+a)}var pd=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new U2,this.indexArray=new Yr,this.segments=new Ze,this.programConfigurations=new Qi(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,i){let a=this.layers[0],n=[],s=null,o=!1,l=a.type==="heatmap";if(a.type==="circle"){let d=a;s=d.layout.get("circle-sort-key"),o=!s.isConstant(),l||(l=d.paint.get("circle-pitch-alignment")==="map")}let u=l?r.subdivisionGranularity.circle:1,h=new ze(this.zoom),c=this.layers[0]._featureFilter.needGeometry;for(let{feature:d,id:p,index:f,sourceLayerIndex:m}of t){let g=sa(d,c);if(!this.layers[0]._featureFilter.filter(h,g,i))continue;let _=o?s.evaluate(g,{},i):void 0,y={id:p,properties:d.properties,type:d.type,sourceLayerIndex:m,index:f,geometry:c?g.geometry:na(d),patterns:{},sortKey:_};n.push(y)}o&&n.sort((d,p)=>d.sortKey-p.sortKey);for(let d of n){let{geometry:p,index:f,sourceLayerIndex:m}=d,g=t[f].feature;this.addFeature(d,p,f,i,u),r.featureIndex.insert(g,p,f,m,this.index)}}update(t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,{imagePositions:i})}addFeatures(t){}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,rw),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,r,i,a,n=1){let s;switch(n){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}let o=s.length;for(let l of r)for(let u of l){let h=u.x,c=u.y;if(h<0||h>=8192||c<0||c>=8192)continue;let d=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,t.sortKey),p=d.vertexLength;for(let f=0;f<o;f++)for(let m=0;m<o;m++)hw(this.layoutVertexArray,h,c,s[m],s[f]);for(let f=0;f<o-1;f++)for(let m=0;m<o-1;m++){let g=p+f*o+m,_=p+(f+1)*o+m;this.indexArray.emplaceBack(g,_+1,g+1),this.indexArray.emplaceBack(g,_,_+1)}d.vertexLength+=o*o,d.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:{},canonical:a})}};G("CircleBucket",pd,{omit:["layers"]});function Ly(e,t){for(let r of e)if(Xa(t,r))return!0;for(let r of t)if(Xa(e,r))return!0;return fd(e,t)}function kl(e,t,r){return Xa(e,t)?!0:tc(t,e,r)}function By(e,t){if(e.length===1)return Ef(t,e[0]);for(let r of t)for(let i of r)if(Xa(e,i))return!0;for(let r of e)if(Ef(t,r))return!0;for(let r of t)if(fd(e,r))return!0;return!1}function cw(e,t,r){for(let i of t){if(e.length>=3){for(let a of i)if(Xa(e,a))return!0}if(dw(e,i,r))return!0}return!1}function dw(e,t,r){if(e.length>1){if(fd(e,t))return!0;for(let i of t)if(tc(i,e,r))return!0}for(let i of e)if(tc(i,t,r))return!0;return!1}function fd(e,t){if(e.length===0||t.length===0)return!1;for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1];for(let n=0;n<t.length-1;n++){let s=t[n],o=t[n+1];if(pw(i,a,s,o))return!0}}return!1}function pw(e,t,r,i){return vi(e,r,i)!==vi(t,r,i)&&vi(e,t,r)!==vi(e,t,i)}function tc(e,t,r){let i=r*r;if(t.length===1)return e.distSqr(t[0])<i;for(let a=1;a<t.length;a++){let n=t[a-1],s=t[a];if(Oy(e,n,s)<i)return!0}return!1}function Oy(e,t,r){let i=t.distSqr(r);if(i===0)return e.distSqr(t);let a=((e.x-t.x)*(r.x-t.x)+(e.y-t.y)*(r.y-t.y))/i;return a<0?e.distSqr(t):a>1?e.distSqr(r):e.distSqr(r.sub(t)._mult(a)._add(t))}function Ef(e,t){let r=!1,i,a,n;for(let s of e){i=s;for(let o=0,l=i.length-1;o<i.length;l=o++)a=i[o],n=i[l],a.y>t.y!=n.y>t.y&&t.x<(n.x-a.x)*(t.y-a.y)/(n.y-a.y)+a.x&&(r=!r)}return r}function Xa(e,t){let r=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){let n=e[i],s=e[a];n.y>t.y!=s.y>t.y&&t.x<(s.x-n.x)*(t.y-n.y)/(s.y-n.y)+n.x&&(r=!r)}return r}function fw(e,t,r,i,a){for(let s of e)if(t<=s.x&&r<=s.y&&i>=s.x&&a>=s.y)return!0;let n=[new C(t,r),new C(t,a),new C(i,a),new C(i,r)];if(e.length>2){for(let s of n)if(Xa(e,s))return!0}for(let s=0;s<e.length-1;s++){let o=e[s],l=e[s+1];if(mw(o,l,n))return!0}return!1}function mw(e,t,r){let i=r[0],a=r[2];if(e.x<i.x&&t.x<i.x||e.x>a.x&&t.x>a.x||e.y<i.y&&t.y<i.y||e.y>a.y&&t.y>a.y)return!1;let n=vi(e,t,r[0]);return n!==vi(e,t,r[1])||n!==vi(e,t,r[2])||n!==vi(e,t,r[3])}function ka(e,t,r){let i=t.paint.get(e).value;return i.kind==="constant"?i.value:r.programConfigurations.get(t.id).getMaxValue(e)}function Ll(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Bl(e,t,r,i,a){if(!t[0]&&!t[1])return e;let n=C.convert(t)._mult(a);r==="viewport"&&n._rotate(-i);let s=[];for(let o of e)s.push(o.sub(n));return s}function gw(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.at(-1);(r===0||a&&!i.equals(a))&&t.push(i)}return t}function _w(e,t){let r=[];for(let i of e){let a=gw(i),n=[];for(let s=0;s<a.length;s++){let o=a[s],l=a[s-1],u=a[s+1],h=s===0?new C(0,0):o.sub(l)._unit()._perp(),c=s===a.length-1?new C(0,0):u.sub(o)._unit()._perp(),d=h._add(c)._unit(),p=d.x*c.x+d.y*c.y;p!==0&&d._mult(1/p),n.push(d._mult(t)._add(o))}r.push(n)}return r}function yw({queryGeometry:e,size:t},r){return kl(e,r,t)}function xw({queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a},n){return kl(e,n,t*(r.projectTileCoordinates(n.x,n.y,i,a==null?void 0:a(n.x,n.y)).signedDistanceFromCamera/r.cameraToCenterDistance))}function vw({queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a},n){let s=r.projectTileCoordinates(n.x,n.y,i,a==null?void 0:a(n.x,n.y)).signedDistanceFromCamera,o=t*(r.cameraToCenterDistance/s);return kl(e,md(n,r,i,a),o)}function bw({queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a},n){return kl(e,md(n,r,i,a),t)}function $y({queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a,pitchAlignment:n="map",pitchScale:s="map"},o){let l=n==="map"?s==="map"?yw:xw:s==="map"?vw:bw,u={queryGeometry:e,size:t,transform:r,unwrappedTileID:i,getElevation:a};for(let h of o)for(let c of h)if(l(u,c))return!0;return!1}function md(e,t,r,i){let a=t.projectTileCoordinates(e.x,e.y,r,i==null?void 0:i(e.x,e.y)).point;return new C((a.x*.5+.5)*t.width,(-a.y*.5+.5)*t.height)}function ww(e,t,r,i){return e.map(a=>md(a,t,r,i))}let Tw;const Dw=()=>Tw||(Tw=new wt({"circle-sort-key":new Y(M.layout_circle["circle-sort-key"],"circle-sort-key")}));let Sw;const Ew=()=>Sw||(Sw=new wt({"circle-radius":new Y(M.paint_circle["circle-radius"],"circle-radius"),"circle-color":new Y(M.paint_circle["circle-color"],"circle-color"),"circle-blur":new Y(M.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new Y(M.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new N(M.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new N(M.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new N(M.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new N(M.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new Y(M.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new Y(M.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new Y(M.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")}));var Pw={get paint(){return Ew()},get layout(){return Dw()}};const Aw=e=>e.type==="circle";var Cw=class extends Mr{constructor(t,r){super(t,Pw,r)}createBucket(t){return new pd(t)}queryRadius(t){let r=t;return ka("circle-radius",this,r)+ka("circle-stroke-width",this,r)+Ll(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:i,geometry:a,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:l}){let u=Bl(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,s),h=this.paint.get("circle-radius").evaluate(r,i)+this.paint.get("circle-stroke-width").evaluate(r,i),c=this.paint.get("circle-pitch-scale"),d=this.paint.get("circle-pitch-alignment"),p,f;return d==="map"?(p=u,f=h*s):(p=ww(u,n,o,l),f=h),$y({queryGeometry:p,size:f,transform:n,unwrappedTileID:o,getElevation:l,pitchAlignment:d,pitchScale:c},a)}},jy=class extends pd{};G("HeatmapBucket",jy,{omit:["layers"]});let Iw;const Mw=()=>Iw||(Iw=new wt({"heatmap-radius":new Y(M.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new Y(M.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new N(M.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new Rl(M.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new N(M.paint_heatmap["heatmap-opacity"],"heatmap-opacity")}));var zw={get paint(){return Mw()}};function gd(e,{width:t,height:r},i,a){if(!a)a=new Uint8Array(t*r*i);else if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==t*r*i)throw RangeError(`mismatched image size. expected: ${a.length} but got: ${t*r*i}`);return e.width=t,e.height=r,e.data=a,e}function Vy(e,{width:t,height:r},i){if(t===e.width&&r===e.height)return;let a=gd({},{width:t,height:r},i);_d(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,r)},i),e.width=t,e.height=r,e.data=a.data}function _d(e,t,r,i,a,n){if(a.width===0||a.height===0)return t;if(a.width>e.width||a.height>e.height||r.x>e.width-a.width||r.y>e.height-a.height)throw RangeError("out of range source coordinates for image copy");if(a.width>t.width||a.height>t.height||i.x>t.width-a.width||i.y>t.height-a.height)throw RangeError("out of range destination coordinates for image copy");let s=e.data,o=t.data;if(s===o)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<a.height;l++){let u=((r.y+l)*e.width+r.x)*n,h=((i.y+l)*t.width+i.x)*n;for(let c=0;c<a.width*n;c++)o[h+c]=s[u+c]}return t}var yd=class Ny{constructor(t,r){gd(this,t,1,r)}resize(t){Vy(this,t,1)}clone(){return new Ny({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,i,a,n){_d(t,r,i,a,n,1)}},$e=class Uy{constructor(t,r){gd(this,t,4,r)}resize(t){Vy(this,t,4)}replace(t,r){r?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Uy({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,r,i,a,n){_d(t,r,i,a,n,4)}setPixel(t,r,i){let a=(t*this.width+r)*4;this.data[a+0]=Math.round(i.r*255/i.a),this.data[a+1]=Math.round(i.g*255/i.a),this.data[a+2]=Math.round(i.b*255/i.a),this.data[a+3]=Math.round(i.a*255)}};function Ru(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=4){let i=e[r+3];t[r+0]=Math.round(e[r+0]*i/255),t[r+1]=Math.round(e[r+1]*i/255),t[r+2]=Math.round(e[r+2]*i/255),t[r+3]=i}return t}G("AlphaImage",yd),G("RGBAImage",$e);function Gy(e){let t={},r=e.resolution||256,i=e.clips?e.clips.length:1,a=e.image||new $e({width:r,height:i});if(!fv(r))throw Error(`width is not a power of 2 - ${r}`);let n=(s,o,l)=>{t[e.evaluationKey]=l;let u=e.expression.evaluate(t);a.setPixel(s/4/r,o/4,u)};if(e.clips)for(let s=0,o=0;s<i;++s,o+=r*4)for(let l=0,u=0;l<r;l++,u+=4){let h=l/(r-1),{start:c,end:d}=e.clips[s],p=c*(1-h)+d*h;n(o,u,p)}else for(let s=0,o=0;s<r;s++,o+=4){let l=s/(r-1);n(0,o,l)}return a}const Ko="big-fb",Fw=e=>e.type==="heatmap";var Rw=class extends Mr{createBucket(t){return new jy(t)}constructor(t,r){super(t,zw,r),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){let t=this._transitionablePaint._values["heatmap-color"].value.expression;this.colorRamp=Gy({expression:t,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(Ko)}queryRadius(t){return ka("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:i,geometry:a,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:l}){return $y({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(r,i)*s,transform:n,unwrappedTileID:o,getElevation:l},a)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}};let kw;const Lw=()=>kw||(kw=new wt({"hillshade-illumination-direction":new N(M.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new N(M.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new N(M.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new N(M.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new N(M.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new N(M.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new N(M.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new N(M.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new N(M.paint_hillshade.resampling,"resampling")}));var Bw={get paint(){return Lw()}};const Ow=e=>e.type==="hillshade";var $w=class extends Mr{constructor(t,r){super(t,Bw,r),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,r=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,a=this.paint.get("hillshade-shadow-color").values,n=Math.max(t.length,r.length,i.length,a.length);t=t.concat(Array(n-t.length).fill(t.at(-1))),r=r.concat(Array(n-r.length).fill(r.at(-1))),i=i.concat(Array(n-i.length).fill(i.at(-1))),a=a.concat(Array(n-a.length).fill(a.at(-1)));let s=r.map(Ge);return{directionRadians:t.map(Ge),altitudeRadians:s,shadowColor:a,highlightColor:i}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}};let jw;const Vw=()=>jw||(jw=new wt({"color-relief-opacity":new N(M["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new Rl(M["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new N(M["paint_color-relief"].resampling,"resampling")}));var Nw={get paint(){return Vw()}};function Ys(e){return"data"in e}var dt=class{constructor(t,r,i,a){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(r,a)}update(t,r,i){var h;let{width:a,height:n}=t,s=(((h=this.size)==null?void 0:h[0])!==a||this.size[1]!==n)&&!i,{context:o}=this,{gl:l}=o;this.useMipmap=!!(r!=null&&r.useMipmap),s&&this.size&&this.format===l.RGBA&&(l.deleteTexture(this.texture),this.texture=l.createTexture(),this._ownedHandle=this.texture,this.magFilter=void 0,this.minFilter=void 0,this.wrap=void 0),l.bindTexture(l.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let u=this.format===l.RGBA&&(r==null?void 0:r.premultiply)!==!1;if(s)if(this.size=[a,n],this.format===l.RGBA&&a>0&&n>0){let c=this.useMipmap?Math.floor(Math.log2(Math.max(a,n)))+1:1;if(l.texStorage2D(l.TEXTURE_2D,c,l.RGBA8,a,n),Ys(t)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:d}=t;u&&d&&(d=Ru(d)),d&&l.texSubImage2D(l.TEXTURE_2D,0,0,0,a,n,l.RGBA,l.UNSIGNED_BYTE,d)}else o.pixelStoreUnpackPremultiplyAlpha.set(u),l.texSubImage2D(l.TEXTURE_2D,0,0,0,l.RGBA,l.UNSIGNED_BYTE,t)}else Ys(t)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(t,u,a,n,l)):(o.pixelStoreUnpackPremultiplyAlpha.set(u),this._uploadDomImage(t,l));else{let{x:c,y:d}=i||{x:0,y:0};Ys(t)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(t,u,c,d,a,n,l)):(o.pixelStoreUnpackPremultiplyAlpha.set(u),this._updateDomImage(t,c,d,l))}this.useMipmap&&!(Ys(t)&&t.data===null)&&l.generateMipmap(l.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(t,r){r.texImage2D(r.TEXTURE_2D,0,this.format,this.format,r.UNSIGNED_BYTE,t)}_uploadRawData(t,r,i,a,n){let{data:s}=t;r&&s&&(s=Ru(s)),n.texImage2D(n.TEXTURE_2D,0,this.format,i,a,0,this.format,n.UNSIGNED_BYTE,s)}_updateDomImage(t,r,i,a){a.texSubImage2D(a.TEXTURE_2D,0,r,i,a.RGBA,a.UNSIGNED_BYTE,t)}_updateRawData(t,r,i,a,n,s,o){let{data:l}=t;r&&l&&(l=Ru(l)),o.texSubImage2D(o.TEXTURE_2D,0,i,a,n,s,o.RGBA,o.UNSIGNED_BYTE,l)}bind(t,r,i){let{context:a}=this,{gl:n}=a;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),n.bindTexture(n.TEXTURE_2D,this.texture),(i===n.LINEAR_MIPMAP_NEAREST||i===n.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(i=n.LINEAR);let s=i||t;t!==this.magFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),this.magFilter=t),s!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,s),this.minFilter=s),r!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,r),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,r),this.wrap=r)}generateMipmap(){if(!this.useMipmap)return;let{gl:t}=this.context;t.bindTexture(t.TEXTURE_2D,this.texture),t.generateMipmap(t.TEXTURE_2D)}destroy(){let{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},si,Uw=(si=class{constructor(t,r,i,a=1,n=1,s=1,o=0){if(this.uid=t,r.height!==r.width)throw RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i)){_e(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=r.height;let l=this.dim=r.height-4;switch(this.data=new Uint32Array(r.data.buffer),si.byteViewCache.set(this,new Uint8Array(this.data.buffer)),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=a,this.greenFactor=n,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let h=-2;h<l+2;h++){let c=this._idx(0,Math.max(0,Math.min(l-1,h)));(h<0||h>=l)&&this.data.copyWithin(this._idx(0,h),c,c+l),this.data.fill(this.data[c],this._idx(-2,h),this._idx(0,h)),this.data.fill(this.data[c+l-1],this._idx(l,h),this._idx(l+1,h)+1)}let u=this._getByteView();this.min=2**53-1,this.max=-9007199254740991;for(let h=0;h<l;h++)for(let c=0;c<l;c++){let d=this._idx(h,c)*4,p=this._unpackAtIndex(u,d);p>this.max&&(this.max=p),p<this.min&&(this.min=p)}}get(t,r){let i=this._getByteView(),a=this._idx(t,r)*4;return this._unpackAtIndex(i,a)}sampleBilinear(t,r){let i=Math.floor(t),a=Math.floor(r);if(i<-1||i>=this.dim||a<-1||a>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${r}, dim: ${this.dim}`);let n=this._getByteView(),s=((a+2)*this.stride+i+2)*4,o=this.stride*4,l=t-i,u=r-a,h=this._unpackAtIndex(n,s),c=this._unpackAtIndex(n,s+4),d=this._unpackAtIndex(n,s+o),p=this._unpackAtIndex(n,s+o+4);return h*(1-l)*(1-u)+c*l*(1-u)+d*(1-l)*u+p*l*u}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,r){if(t<-2||t>=this.dim+2||r<-2||r>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${r}, dim: ${this.dim}`);return(r+2)*this.stride+(t+2)}unpack(t,r,i){return t*this.redFactor+r*this.greenFactor+i*this.blueFactor-this.baseShift}pack(t){return qy(t,this.getUnpackVector())}getPixels(){return new $e({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(t,r,i){if(this.dim!==t.dim)throw Error("dem dimension mismatch");let a=r*this.dim,n=r*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(r){case-1:a=n-2;break;case 1:n=a+2}switch(i){case-1:s=o-2;break;case 1:o=s+2}let l=-r*this.dim,u=-i*this.dim;for(let h=s;h<o;h++)for(let c=a;c<n;c++)this.data[this._idx(c,h)]=t.data[this._idx(c+l,h+u)]}_getByteView(){let t=si.byteViewCache.get(this);return(t==null?void 0:t.buffer)!==this.data.buffer&&(t=new Uint8Array(this.data.buffer),si.byteViewCache.set(this,t)),t}_unpackAtIndex(t,r){return this.unpack(t[r],t[r+1],t[r+2])}},si.byteViewCache=new WeakMap,si);function qy(e,t){let r=t[0],i=t[1],a=t[2],n=t[3],s=Math.min(r,i,a),o=Math.round((e+n)/s);return{r:Math.floor(o*s/r)%256,g:Math.floor(o*s/i)%256,b:Math.floor(o*s/a)%256}}G("DEMData",Uw);const Gw=e=>e.type==="color-relief";var qw=class extends Mr{constructor(t,r){super(t,Nw,r)}_createColorRamp(t){let r={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof Xn&&i._styleExpression.expression instanceof yr){this.colorRampExpression=i;let s=i._styleExpression.expression;r.elevationStops=s.labels,r.colorStops=[];for(let o of r.elevationStops)r.colorStops.push(s.evaluate({globals:{elevation:o}}))}if(r.elevationStops.length<1&&(r.elevationStops=[0],r.colorStops=[se.transparent]),r.elevationStops.length<2&&(r.elevationStops.push(r.elevationStops[0]+1),r.colorStops.push(r.colorStops[0])),r.elevationStops.length<=t)return r;let a={elevationStops:[],colorStops:[]},n=(r.elevationStops.length-1)/(t-1);for(let s=0;s<r.elevationStops.length-.5;s+=n)a.elevationStops.push(r.elevationStops[Math.round(s)]),a.colorStops.push(r.colorStops[Math.round(s)]);return _e(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${r.elevationStops.length}`),a}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,r,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let a=this._createColorRamp(r),n=new $e({width:a.colorStops.length,height:1}),s=new $e({width:a.colorStops.length,height:1});for(let o=0;o<a.elevationStops.length;o++){let l=qy(a.elevationStops[o],i);s.setPixel(0,o,new se(l.r/255,l.g/255,l.b/255,1)),n.setPixel(0,o,a.colorStops[o])}return this.colorRampTextures={elevationTexture:new dt(t,s,t.gl.RGBA),colorTexture:new dt(t,n,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const Zw=Ye([{name:"a_pos",components:2,type:"Int16"}],4),Ww=Zw.members;function Jo(e,t,r){let i=r.patternDependencies,a=!1;for(let n of t){let s=n.paint.get(`${e}-pattern`);s.isConstant()||(a=!0);let o=s.constantOr(null);o&&(a=!0,i[o.to]=!0,i[o.from]=!0)}return a}function xd(e,t,r,i,a){let{zoom:n}=i,s=a.patternDependencies;for(let o of t){let l=o.paint.get(`${e}-pattern`).value;if(l.kind!=="constant"){let u=l.evaluate({zoom:n-1},r,{},a.availableImages),h=l.evaluate({zoom:n},r,{},a.availableImages),c=l.evaluate({zoom:n+1},r,{},a.availableImages);u=u!=null&&u.name?u.name:u,h=h!=null&&h.name?h.name:h,c=c!=null&&c.name?c.name:c,s[u]=!0,s[h]=!0,s[c]=!0,r.patterns[o.id]={min:u,mid:h,max:c}}}return r}const is=new Set;let rc=!1;function Hw(e,t,r=2){let i=t&&t.length,a=i?t[0]*r:e.length;is.size&&is.clear();let n=Zy(e,0,a,r,!0),s=[];if(!n||n.next===n.prev)return s;let o=0,l=0,u=0;if(i&&(n=Qw(e,t,n,r)),e.length>80*r){o=e[0],l=e[1];let h=o,c=l;for(let d=r;d<a;d+=r){let p=e[d],f=e[d+1];p<o&&(o=p),f<l&&(l=f),p>h&&(h=p),f>c&&(c=f)}u=Math.max(h-o,c-l),u=u===0?0:32767/u}return ic(n,s,o,l,u),s}function Zy(e,t,r,i,a){let n=null;if(a===dT(e,t,r,i)>0)for(let s=t;s<r;s+=i)n=Cf(s/i|0,e[s],e[s+1],n);else for(let s=r-i;s>=t;s-=i)n=Cf(s/i|0,e[s],e[s+1],n);return n&&as(n,n.next)&&(ss(n),n=n.next),n}function ea(e,t=e){let r=t===e,i=e,a;do a=!1,i!==i.next&&(is.size===0||!is.has(i))&&(as(i,i.next)||ct(i.prev,i,i.next)===0)?((r||i===t)&&(t=i.prev),rc=!0,ss(i),i=i.prev,a=!0):(r||i!==t)&&(i=i.next,a=!r);while(a||i!==t);return t}function ic(e,t,r,i,a){a&&sT(e,r,i,a);let n=e,s=!1;for(;e.prev!==e.next;){let o=e.prev,l=e.next;if(ct(o,e,l)<0&&(a?Yw(e,r,i,a):Xw(e))){t.push(o.i,e.i,l.i),ss(e),e=l,n=l;continue}if(e=l,e===n){if(rc=!1,e=ea(e),rc){n=e;continue}if(!s){e=Kw(e,t),n=e,s=!0;continue}Jw(e,t,r,i,a);break}}}function Xw(e){let t=e.prev,r=e,i=e.next,a=t.x,n=r.x,s=i.x,o=t.y,l=r.y,u=i.y,h=Math.min(a,n,s),c=Math.min(o,l,u),d=Math.max(a,n,s),p=Math.max(o,l,u),f=i.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&(a!==f.x||o!==f.y)&&el(a,o,n,l,s,u,f.x,f.y)&&ct(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Yw(e,t,r,i){let a=e.prev,n=e,s=e.next,o=a.x,l=n.x,u=s.x,h=a.y,c=n.y,d=s.y,p=Math.min(o,l,u),f=Math.min(h,c,d),m=Math.max(o,l,u),g=Math.max(h,c,d),_=oc(p,f,t,r,i),y=oc(m,g,t,r,i),v=e.prevZ;for(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&(o!==v.x||h!==v.y)&&el(o,h,l,c,u,d,v.x,v.y)&&ct(v.prev,v,v.next)>=0)return!1;v=v.prevZ}let x=e.nextZ;for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&(o!==x.x||h!==x.y)&&el(o,h,l,c,u,d,x.x,x.y)&&ct(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Kw(e,t){let r=e,i=!1;do{let a=r.prev,n=r.next.next;Hy(a,r,r.next,n,!1)&&ns(a,n)&&ns(n,a)&&(t.push(a.i,r.i,n.i),ss(r),ss(r.next),r=e=n,i=!0),r=r.next}while(r!==e);return i?ea(r):r}function Jw(e,t,r,i,a){let n=e;do{let s=n.next.next;for(;s!==n.prev;){if(n.i!==s.i&&uT(n,s)){let o=Xy(n,s);n=ea(n,n.next),o=ea(o,o.next),ic(n,t,r,i,a),ic(o,t,r,i,a);return}s=s.next}n=n.next}while(n!==e)}let ac=!1;function Qw(e,t,r,i){let a=[];for(let n=0,s=t.length;n<s;n++){let o=Zy(e,t[n]*i,n<s-1?t[n+1]*i:e.length,i,!1);o===o.next&&is.add(o),a.push(lT(o))}a.sort(eT),rT(e.length/i,t.length),Wy(r,r),ac=!0;for(let n=0;n<a.length;n++)r=tT(a[n],r);return ac=!1,ea(r)}function eT(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function tT(e,t){let r=aT(e,t);if(!r)return t;let i=Xy(r,e),a=i.next;return Wy(r,a.next),ea(i,i.next),ea(r,r.next)}let rt=new Float64Array,Qo=0;const nc=[],sc=[];function rT(e,t){let r=Math.ceil((e+2*t)/16)+t+2;rt.length<r*4&&(rt=new Float64Array(r*4)),Qo=0}function Wy(e,t){let r=e;do{let i=Qo++;nc[i]=r;let a=1/0,n=1/0,s=-1/0,o=-1/0,l=0;do{let h=r.next;r.z=i,r.x<a&&(a=r.x),r.x>s&&(s=r.x),r.y<n&&(n=r.y),r.y>o&&(o=r.y),h.x<a&&(a=h.x),h.x>s&&(s=h.x),h.y<n&&(n=h.y),h.y>o&&(o=h.y),r=h}while(++l<16&&r!==t);sc[i]=r;let u=i*4;rt[u]=a,rt[u+1]=n,rt[u+2]=s,rt[u+3]=o}while(r!==t)}function iT(e,t){let r=e.z*4;t.x<rt[r]&&(rt[r]=t.x),t.y<rt[r+1]&&(rt[r+1]=t.y),t.x>rt[r+2]&&(rt[r+2]=t.x),t.y>rt[r+3]&&(rt[r+3]=t.y)}function Pf(e){let t=sc[e];for(;t.prev.next!==t;)t=t.next;return sc[e]=t,t}function Af(e){let t=nc[e];for(;t.prev.next!==t;)t=t.next;return nc[e]=t,t}function aT(e,t){let r=t,i=e.x,a=e.y,n=-1/0,s;if(as(e,r))return r;for(let d=0,p=0;d<Qo;d++,p+=4){if(a<rt[p+1]||a>rt[p+3]||rt[p]>i||rt[p+2]<=n)continue;let f=Pf(d);r=Af(d);do{if(r.prev.next===r){if(as(e,r.next))return r.next;if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){let m=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(m<=i&&m>n&&(n=m,s=r.x<r.next.x?r:r.next,m===i))return s}}r=r.next}while(r!==f)}if(!s)return null;let o=s.x,l=s.y,u=Math.min(a,l),h=Math.max(a,l),c=1/0;for(let d=0,p=0;d<Qo;d++,p+=4){if(rt[p+2]<o||rt[p]>i||rt[p+3]<u||rt[p+1]>h)continue;let f=Pf(d);r=Af(d);do{if(r.prev.next===r&&i>=r.x&&r.x>=o&&i!==r.x&&el(a<l?i:n,a,o,l,a<l?n:i,a,r.x,r.y)){let m=Math.abs(a-r.y)/(i-r.x);(ns(r,e)||r.y===a&&r.next.y===a&&r.next.x>i)&&(m<c||m===c&&(r.x>s.x||r.x===s.x&&nT(s,r)))&&(s=r,c=m)}r=r.next}while(r!==f)}return s}function nT(e,t){return ct(e.prev,e,t.prev)<0&&ct(t.next,e,e.next)<0}const pr=[];let _n=[],Ri=new Uint32Array,yn=new Uint32Array;const xn=new Uint32Array(256);function sT(e,t,r,i){let a=e,n=0;do a.z=oc(a.x,a.y,t,r,i),pr[n++]=a,a=a.next;while(a!==e);oT(n);let s=null;for(let o=0;o<n;o++){let l=pr[o];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null}function oT(e){if(e<=32){for(let t=1;t<e;t++){let r=pr[t],i=r.z,a=t-1;for(;a>=0&&pr[a].z>i;)pr[a+1]=pr[a],a--;pr[a+1]=r}return}Ri.length<e&&(Ri=new Uint32Array(e),yn=new Uint32Array(e),_n=Array(e));for(let t=0;t<e;t++)Ri[t]=pr[t].z;Ks(e,pr,Ri,_n,yn,0),Ks(e,_n,yn,pr,Ri,8),Ks(e,pr,Ri,_n,yn,16),Ks(e,_n,yn,pr,Ri,24)}function Ks(e,t,r,i,a,n){xn.fill(0);for(let o=0;o<e;o++)xn[r[o]>>>n&255]++;let s=0;for(let o=0;o<256;o++){let l=xn[o];xn[o]=s,s+=l}for(let o=0;o<e;o++){let l=r[o],u=xn[l>>>n&255]++;i[u]=t[o],a[u]=l}}function oc(e,t,r,i,a){return e=(e-r)*a|0,t=(t-i)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function lT(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function el(e,t,r,i,a,n,s,o){return(a-s)*(t-o)>=(e-s)*(n-o)&&(e-s)*(i-o)>=(r-s)*(t-o)&&(r-s)*(n-o)>=(a-s)*(i-o)}function uT(e,t){let r=as(e,t)&&ct(e.prev,e,e.next)>0&&ct(t.prev,t,t.next)>0;return e.next.i!==t.i&&(r||ns(e,t)&&ns(t,e)&&(ct(e.prev,e,t.prev)!==0||ct(e,t.prev,t)!==0))&&!hT(e,t)&&(r||cT(e,t))}function ct(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function as(e,t){return e.x===t.x&&e.y===t.y}function Hy(e,t,r,i,a=!0){let n=ct(e,t,r),s=ct(e,t,i),o=ct(r,i,e),l=ct(r,i,t);return(n>0&&s<0||n<0&&s>0)&&(o>0&&l<0||o<0&&l>0)?!0:a?!!(n===0&&Js(e,r,t)||s===0&&Js(e,i,t)||o===0&&Js(r,e,i)||l===0&&Js(r,t,i)):!1}function Js(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function hT(e,t){let r=Math.min(e.x,t.x),i=Math.max(e.x,t.x),a=Math.min(e.y,t.y),n=Math.max(e.y,t.y),s=e;do{let o=s.next;if(s.x>i&&o.x>i||s.x<r&&o.x<r||s.y>n&&o.y>n||s.y<a&&o.y<a){s=o;continue}if(s.i!==e.i&&o.i!==e.i&&s.i!==t.i&&o.i!==t.i&&Hy(s,o,e,t))return!0;s=o}while(s!==e);return!1}function ns(e,t){return ct(e.prev,e,e.next)<0?ct(e,t,e.next)>=0&&ct(e,e.prev,t)>=0:ct(e,t,e.prev)<0||ct(e,e.next,t)<0}function cT(e,t){let r=e,i=!1,a=(e.x+t.x)/2,n=(e.y+t.y)/2;do{let s=r.next;r.y>n!=s.y>n&&a<(s.x-r.x)*(n-r.y)/(s.y-r.y)+r.x&&(i=!i),r=s}while(r!==e);return i}function Xy(e,t){let r=lc(e.i,e.x,e.y),i=lc(t.i,t.x,t.y),a=e.next,n=t.prev;return e.next=t,t.prev=e,r.next=a,a.prev=r,i.next=r,r.prev=i,n.next=i,i.prev=n,i}function Cf(e,t,r,i){let a=lc(e,t,r);return i?(a.next=i.next,a.prev=i,i.next.prev=a,i.next=a):(a.prev=a,a.next=a),a}function ss(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),ac&&iT(e.prev,e.next)}function lc(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function dT(e,t,r,i){let a=0;for(let n=t,s=r-i;n<r;n+=i)a+=(e[s]-e[n])*(e[n+1]+e[s+1]),s=n;return a}var ii=class{constructor(t,r){if(r>t)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=r}getGranularityForZoomLevel(t){let r=1<<t;return Math.max(Math.floor(this._baseZoomGranularity/r),this._minGranularity,1)}},Xi,vd=(Xi=class{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}},Xi.noSubdivision=new Xi({fill:new ii(0,0),line:new ii(0,0),tile:new ii(0,0),stencil:new ii(0,0),circle:1}),Xi);G("SubdivisionGranularityExpression",ii),G("SubdivisionGranularitySetting",vd);const $n=-32768,jn=32767;var pT=class{constructor(t,r){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=k/t,this._canonical=r}_getKey(t,r){return t+=32768,r+=32768,t<<16|r<<0}_vertexToIndex(t,r){if(t<-32768||r<-32768||t>32767||r>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let i=Math.round(t)|0,a=Math.round(r)|0,n=this._getKey(i,a),s=this._vertexDictionary.get(n);if(s!==void 0)return s;let o=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,o),this._vertexBuffer.push(i,a),o}_subdivideTrianglesScanline(t,r){if(this._granularity<2)return gT(this._vertexBuffer,mT(t,r));let i=[],a=t.length;for(let n=0;n<a;n+=3){let s=[r[t[n+0]],r[t[n+1]],r[t[n+2]]],o=[this._vertexBuffer[s[0]*2+0],this._vertexBuffer[s[0]*2+1],this._vertexBuffer[s[1]*2+0],this._vertexBuffer[s[1]*2+1],this._vertexBuffer[s[2]*2+0],this._vertexBuffer[s[2]*2+1]],l=1/0,u=1/0,h=-1/0,c=-1/0;for(let g=0;g<3;g++){let _=o[g*2],y=o[g*2+1];l=Math.min(l,_),h=Math.max(h,_),u=Math.min(u,y),c=Math.max(c,y)}if(l===h||u===c)continue;let d=Math.floor(l/this._granularityCellSize),p=Math.ceil(h/this._granularityCellSize),f=Math.floor(u/this._granularityCellSize),m=Math.ceil(c/this._granularityCellSize);if(d===p&&f===m){i.push(...s);continue}for(let g=f;g<m;g++){let _=this._scanlineGenerateVertexRingForCellRow(g,o,s);_T(this._vertexBuffer,_,i)}}return i}_scanlineGenerateVertexRingForCellRow(t,r,i){let a=t*this._granularityCellSize,n=a+this._granularityCellSize,s=[];for(let o=0;o<3;o++){let l=r[o*2],u=r[o*2+1],h=r[(o+1)*2%6],c=r[((o+1)*2+1)%6],d=r[(o+2)*2%6],p=r[((o+2)*2+1)%6],f=h-l,m=c-u,g=f===0,_=m===0,y=(a-u)/m,v=(n-u)/m,x=Math.min(y,v),w=Math.max(y,v);if(!_&&(x>=1||w<=0)||_&&(u<a||u>n)){c>=a&&c<=n&&s.push(i[(o+1)%3]);continue}if(!_&&x>0){let P=l+f*x,S=u+m*x;s.push(this._vertexToIndex(P,S))}let b=l+f*Math.max(x,0),T=l+f*Math.min(w,1);if(g||this._generateIntraEdgeVertices(s,l,u,h,c,b,T),!_&&w<1){let P=l+f*w,S=u+m*w;s.push(this._vertexToIndex(P,S))}(_||c>=a&&c<=n)&&s.push(i[(o+1)%3]),!_&&(c<=a||c>=n)&&this._generateInterEdgeVertices(s,l,u,h,c,d,p,T,a,n)}return s}_generateIntraEdgeVertices(t,r,i,a,n,s,o){let l=a-r,u=n-i,h=u===0,c=h?Math.min(r,a):Math.min(s,o),d=h?Math.max(r,a):Math.max(s,o),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(d/this._granularityCellSize)-1;if(h?r<a:s<o)for(let m=p;m<=f;m++){let g=m*this._granularityCellSize,_=i+u*(g-r)/l;t.push(this._vertexToIndex(g,_))}else for(let m=f;m>=p;m--){let g=m*this._granularityCellSize,_=i+u*(g-r)/l;t.push(this._vertexToIndex(g,_))}}_generateInterEdgeVertices(t,r,i,a,n,s,o,l,u,h){let c=n-i,d=s-a,p=o-n,f=(u-n)/p,m=(h-n)/p,g=Math.min(f,m),_=Math.max(f,m),y=a+d*g,v=Math.floor(Math.min(y,l)/this._granularityCellSize)+1,x=Math.ceil(Math.max(y,l)/this._granularityCellSize)-1,w=l<y,b=p===0;if(b&&(o===u||o===h))return;if(b||g>=1||_<=0){let P=r-s,S=i-o,I=(u-o)/S,R=(h-o)/S,F=s+P*Math.min(I,R);v=Math.floor(Math.min(F,l)/this._granularityCellSize)+1,x=Math.ceil(Math.max(F,l)/this._granularityCellSize)-1,w=l<F}let T=c>0?h:u;if(w)for(let P=v;P<=x;P++){let S=P*this._granularityCellSize;t.push(this._vertexToIndex(S,T))}else for(let P=x;P>=v;P--){let S=P*this._granularityCellSize;t.push(this._vertexToIndex(S,T))}}_generateOutline(t,r){let i=[],a=0;for(let n of t){let s=this._granularity<2?this._ringPathIndices(n,a,r):this._pointArrayToIndices(Vi(n,this._granularity,!0));a+=n.length;let o=[];for(let l=1;l<s.length;l++)o.push(s[l-1]),o.push(s[l]);i.push(o)}return i}_ringPathIndices(t,r,i){let a=i.slice(r,r+t.length);return a.length>=2&&Ky(t)&&a.push(a[0]),a}_handlePoles(t){let r=!1,i=!1;this._canonical&&(this._canonical.y===0&&(r=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(r||i)&&this._fillPoles(t,r,i)}_ensureNoPoleVertices(){let t=this._vertexBuffer;for(let r=0;r<t.length;r+=2){let i=t[r+1];i===-32768&&(t[r+1]=-32767),i===32767&&(t[r+1]=32766)}}_generatePoleQuad(t,r,i,a,n,s){a>n==(s===-32768)?(t.push(i),t.push(r),t.push(this._vertexToIndex(a,s)),t.push(this._vertexToIndex(n,s)),t.push(i),t.push(this._vertexToIndex(a,s))):(t.push(r),t.push(i),t.push(this._vertexToIndex(a,s)),t.push(i),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(a,s)))}_fillPoles(t,r,i){let a=this._vertexBuffer,n=k,s=t.length;for(let o=2;o<s;o+=3){let l=t[o-2],u=t[o-1],h=t[o],c=a[l*2],d=a[l*2+1],p=a[u*2],f=a[u*2+1],m=a[h*2],g=a[h*2+1];r&&(d===0&&f===0&&this._generatePoleQuad(t,l,u,c,p,$n),f===0&&g===0&&this._generatePoleQuad(t,u,h,p,m,$n),g===0&&d===0&&this._generatePoleQuad(t,h,l,m,c,$n)),i&&(d===n&&f===n&&this._generatePoleQuad(t,l,u,c,p,jn),f===n&&g===n&&this._generatePoleQuad(t,u,h,p,m,jn),g===n&&d===n&&this._generatePoleQuad(t,h,l,m,c,jn))}}_initializeVertices(t){let r=[];for(let i=0;i<t.length;i+=2)r.push(this._vertexToIndex(t[i],t[i+1]));return r}subdividePolygonInternal(t,r){var l;if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let{flattened:i,holeIndices:a}=fT(t),n=this._initializeVertices(i),s;try{let u=Hw(i,a);s=this._subdivideTrianglesScanline(u,n)}catch(u){console.error(u)}let o=[];return r&&(o=this._generateOutline(t,n)),this._ensureNoPoleVertices(),this._handlePoles(s),this._granularity>=2&&((l=this._canonical)==null?void 0:l.z)===0&&(s=this._removeTrianglesOutsideTileX(s),o=o.map(u=>this._removeLinesOutsideTileX(u))),{verticesFlattened:this._vertexBuffer,indicesTriangles:s,indicesLineList:o}}_vertexOutsideTileX(t){let r=this._vertexBuffer[t*2];return r<0||r>8192}_removeTrianglesOutsideTileX(t){let r=[];for(let i=0;i<t.length;i+=3)this._vertexOutsideTileX(t[i])||this._vertexOutsideTileX(t[i+1])||this._vertexOutsideTileX(t[i+2])||r.push(t[i],t[i+1],t[i+2]);return r}_removeLinesOutsideTileX(t){let r=[];for(let i=0;i<t.length;i+=2)this._vertexOutsideTileX(t[i])||this._vertexOutsideTileX(t[i+1])||r.push(t[i],t[i+1]);return r}_pointArrayToIndices(t){let r=[];for(let i of t)r.push(this._vertexToIndex(i.x,i.y));return r}};function Yy(e,t,r,i=!0){return new pT(r,t).subdividePolygonInternal(e,i)}function Vi(e,t,r=!1){if(!e||e.length<1||e.length<2)return[];let i=r&&Ky(e);if(t<2)return i?[...e,e[0]]:[...e];let a=Math.floor(k/t),n=[];n.push(new C(e[0].x,e[0].y));let s=e.length,o=i?s:s-1;for(let l=0;l<o;l++){let u=e[l],h=l<s-1?e[l+1]:e[0],c=u.x,d=u.y,p=h.x,f=h.y,m=c!==p,g=d!==f;if(!m&&!g)continue;let _=p-c,y=f-d,v=Math.abs(_),x=Math.abs(y),w=c,b=d;for(;;){let P=_>0?(Math.floor(w/a)+1)*a:(Math.ceil(w/a)-1)*a,S=y>0?(Math.floor(b/a)+1)*a:(Math.ceil(b/a)-1)*a,I=Math.abs(w-P),R=Math.abs(b-S),F=Math.abs(w-p),D=Math.abs(b-f),A=m?I/v:1/0,E=g?R/x:1/0;if((F<=I||!m)&&(D<=R||!g))break;if(A<E&&m||!g){w=P,b+=y*A;let z=new C(w,Math.round(b));(n[n.length-1].x!==z.x||n[n.length-1].y!==z.y)&&n.push(z)}else{w+=_*E,b=S;let z=new C(Math.round(w),b);(n[n.length-1].x!==z.x||n[n.length-1].y!==z.y)&&n.push(z)}}let T=new C(p,f);(n[n.length-1].x!==T.x||n[n.length-1].y!==T.y)&&n.push(T)}return n}function Ky(e){return!e[0].equals(e[e.length-1])}function fT(e){let t=[],r=[];for(let i of e)if(i.length!==0){i!==e[0]&&t.push(r.length/2);for(let a of i)r.push(a.x),r.push(a.y)}return{flattened:r,holeIndices:t}}function mT(e,t){let r=Array(e.length);for(let i=0;i<e.length;i++)r[i]=t[e[i]];return r}function gT(e,t){let r=[];for(let i=0;i<t.length;i+=3){let a=t[i],n=t[i+1],s=t[i+2],o=e[a*2],l=e[a*2+1],u=e[n*2],h=e[n*2+1],c=e[s*2],d=e[s*2+1],p=u-o,f=h-l,m=c-o;p*(d-l)-f*m>0?(r.push(a),r.push(s),r.push(n)):(r.push(a),r.push(n),r.push(s))}return r}function _T(e,t,r){if(t.length===0)throw Error("Subdivision vertex ring is empty.");let i=0,a=e[t[0]*2];for(let l=1;l<t.length;l++){let u=e[t[l]*2];u<a&&(a=u,i=l)}let n=t.length,s=i,o=(s+1)%n;for(;;){let l=s-1>=0?s-1:n-1,u=(o+1)%n,h=e[t[l]*2],c=e[t[l]*2+1],d=e[t[u]*2],p=e[t[u]*2+1],f=e[t[s]*2],m=e[t[s]*2+1],g=e[t[o]*2],_=e[t[o]*2+1],y=!1;if(h<d)y=!0;else if(h>d)y=!1;else{let v=_-m,x=-(g-f),w=m<_?1:-1;((h-f)*v+(c-m)*x)*w>((d-f)*v+(p-m)*x)*w&&(y=!0)}if(y){let v=t[l],x=t[s],w=t[o];v!==x&&v!==w&&x!==w&&r.push(w,x,v),s--,s<0&&(s=n-1)}else{let v=t[u],x=t[s],w=t[o];v!==x&&v!==w&&x!==w&&r.push(w,x,v),o++,o>=n&&(o=0)}if(l===u)break}}function Jy(e,t,r,i,a,n,s,o,l){let u=a.length/2,h=s&&o&&l;if(u<Ze.MAX_VERTEX_ARRAY_LENGTH){let c=t.prepareSegment(u,r,i),d=c.vertexLength;for(let m=0;m<n.length;m+=3)i.emplaceBack(d+n[m],d+n[m+1],d+n[m+2]);c.vertexLength+=u,c.primitiveLength+=n.length/3;let p,f;h&&(f=s.prepareSegment(u,r,o),p=f.vertexLength,f.vertexLength+=u);for(let m=0;m<a.length;m+=2)e(a[m],a[m+1]);if(h)for(let m of l){for(let g=1;g<m.length;g+=2)o.emplaceBack(p+m[g-1],p+m[g]);f.primitiveLength+=m.length/2}}else yT(t,r,i,a,n,e),h&&xT(s,r,o,a,l,e),t.forceNewSegmentOnNextPrepare(),s==null||s.forceNewSegmentOnNextPrepare()}function Vn(e,t,r,i,a,n,s){if(n){let o=i.count;return r(t[a*2],t[a*2+1]),e[a]=i.count,i.count++,s.vertexLength++,o}return e[a]}function yT(e,t,r,i,a,n){let s=[];for(let c=0;c<i.length/2;c++)s.push(-1);let o={count:0},l=0,u=e.getOrCreateLatestSegment(t,r),h=u.vertexLength;for(let c=2;c<a.length;c+=3){let d=a[c-2],p=a[c-1],f=a[c],m=s[d]<l,g=s[p]<l,_=s[f]<l,y=+!!m+ +!!g+ +!!_;u.vertexLength+y>Ze.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,r),l=o.count,m=!0,g=!0,_=!0,h=0);let v=Vn(s,i,n,o,d,m,u),x=Vn(s,i,n,o,p,g,u),w=Vn(s,i,n,o,f,_,u);r.emplaceBack(h+v-l,h+x-l,h+w-l),u.primitiveLength++}}function xT(e,t,r,i,a,n){let s=[];for(let c=0;c<i.length/2;c++)s.push(-1);let o={count:0},l=0,u=e.getOrCreateLatestSegment(t,r),h=u.vertexLength;for(let c of a)for(let d=1;d<c.length;d+=2){let p=c[d-1],f=c[d],m=s[p]<l,g=s[f]<l,_=+!!m+ +!!g;u.vertexLength+_>Ze.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,r),l=o.count,m=!0,g=!0,h=0);let y=Vn(s,i,n,o,p,m,u),v=Vn(s,i,n,o,f,g,u);r.emplaceBack(h+y-l,h+v-l),u.primitiveLength++}}var Qy=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasDependencies=!1,this.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new G2,this.indexArray=new Yr,this.indexArray2=new Kh,this.programConfigurations=new Qi(t.layers,t.zoom),this.segments=new Ze,this.segments2=new Ze,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,i){this.hasDependencies=Jo("fill",this.layers,r);let a=this.layers[0].layout.get("fill-sort-key"),n=!a.isConstant(),s=[],o=new ze(this.zoom),l=this.layers[0]._featureFilter.needGeometry;for(let{feature:u,id:h,index:c,sourceLayerIndex:d}of t){let p=sa(u,l);if(!this.layers[0]._featureFilter.filter(o,p,i))continue;let f=n?a.evaluate(p,{},i,r.availableImages):void 0,m={id:h,properties:u.properties,type:u.type,sourceLayerIndex:d,index:c,geometry:l?p.geometry:na(u),patterns:{},sortKey:f};s.push(m)}n&&s.sort((u,h)=>u.sortKey-h.sortKey);for(let u of s){let{geometry:h,index:c,sourceLayerIndex:d}=u;if(this.hasDependencies){let f=xd("fill",this.layers,u,{zoom:this.zoom},r);this.patternFeatures.push(f)}else this.addFeature(u,h,c,i,{},r.subdivisionGranularity);let p=t[c].feature;r.featureIndex.insert(p,h,c,d,this.index)}}update(t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,{imagePositions:i})}addFeatures({options:t,canonical:r,patternPositions:i,patternMap:a}){this.detectSdfPatterns(a);for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,r,i,t.subdivisionGranularity)}detectSdfPatterns(t){for(let r of this.patternFeatures)for(let i in r.patterns){let a=r.patterns[i];this.recordSdfPattern(i,t[a.min]),this.recordSdfPattern(i,t[a.mid]),this.recordSdfPattern(i,t[a.max])}for(let r of this.layers){let i=r.paint.get("fill-pattern").constantOr(null);i&&(this.recordSdfPattern(r.id,t[i.from.toString()]),this.recordSdfPattern(r.id,t[i.to.toString()]))}}recordSdfPattern(t,r){if(!r)return;let i=r.sdf===!0,a=this.sdfPatterns[t];a===void 0?this.sdfPatterns[t]=i:a!==i&&_e(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${t}"`)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ww),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,r,i,a,n,s){for(let o of Dl(r,500)){let l=Yy(o,a,s.fill.getGranularityForZoomLevel(a.z)),u=this.layoutVertexArray;Jy((h,c)=>{u.emplaceBack(h,c)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles,this.segments2,this.indexArray2,l.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,canonical:a})}};G("FillBucket",Qy,{omit:["layers","patternFeatures"]});let vT;const bT=()=>vT||(vT=new wt({"fill-sort-key":new Y(M.layout_fill["fill-sort-key"],"fill-sort-key")}));let wT;const TT=()=>wT||(wT=new wt({"fill-antialias":new N(M.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new Y(M.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new N(M.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new Y(M.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new Y(M.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new N(M.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new N(M.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new Qn(M.paint_fill["fill-pattern"],"fill-pattern")}));var DT={get paint(){return TT()},get layout(){return bT()}};const ST=e=>e.type==="fill";var ET=class extends Mr{constructor(t,r){super(t,DT,r)}recalculate(t,r){super.recalculate(t,r);let i=this.paint._values["fill-outline-color"];i.value.kind==="constant"&&i.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Qy(t)}queryRadius(){return Ll(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:r,transform:i,pixelsToTileUnits:a}){return By(Bl(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,a),r)}isTileClipped(){return!0}};const PT=Ye([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),AT=Ye([{name:"a_centroid",components:2,type:"Int16"}],4),CT=PT.members;var Pr=class uc{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(t){return this.expandBy(-t)}map(t){let r=new uc;return r.extend(t(new C(this.minX,this.minY))),r.extend(t(new C(this.maxX,this.minY))),r.extend(t(new C(this.minX,this.maxY))),r.extend(t(new C(this.maxX,this.maxY))),r}static fromPoints(t){let r=new uc;for(let i of t)r.extend(i);return r}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}};const IT=Pr.fromPoints([new C(0,0),new C(k,k)]);function hc(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function If(e){return e.every(t=>t.x<0)||e.every(t=>t.x>8192)||e.every(t=>t.y<0)||e.every(t=>t.y>8192)}var xs=class{constructor(t,r,i,a,n){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=a,this._values=n;t.pos<r;){let s=t.readVarint();if(s===8)this.id=t.readVarint();else if(s===18){let o=t.readVarint()+t.pos;for(;t.pos<o;){let l=a[t.readVarint()],u=n[t.readVarint()];this.properties[l]=u}}else s===24?this.type=t.readVarint():(s===34&&(this._geometry=t.pos),t.skip(s))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,i=[],a,n=1,s=0,o=0,l=0;for(;t.pos<r;){if(s<=0){let u=t.readVarint();if(n=u&7,s=u>>3,s===0)continue}if(s--,n===1)o+=t.readSVarint(),l+=t.readSVarint(),a&&i.push(a),a=[new C(o,l)];else if(n===2)o+=t.readSVarint(),l+=t.readSVarint(),a&&a.push(new C(o,l));else if(n===7)a&&a.push(a[0].clone());else throw Error(`unknown command ${n}`)}return a&&i.push(a),i}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,i=1,a=0,n=0,s=0,o=1/0,l=-1/0,u=1/0,h=-1/0;for(;t.pos<r;){if(a<=0){let c=t.readVarint();if(i=c&7,a=c>>3,a===0)continue}if(a--,i===1||i===2)n+=t.readSVarint(),s+=t.readSVarint(),n<o&&(o=n),n>l&&(l=n),s<u&&(u=s),s>h&&(h=s);else if(i!==7)throw Error(`unknown command ${i}`)}return[o,u,l,h]}toGeoJSON(t,r,i){let a=this.extent*2**i,n=this.extent*t,s=this.extent*r,o=this.loadGeometry();function l(d){return[(d.x+n)*360/a-180,360/Math.PI*Math.atan(Math.exp((1-(d.y+s)*2/a)*Math.PI))-90]}function u(d){return d.map(l)}let h;if(this.type===1){let d=[];for(let f of o)d.push(f[0]);let p=u(d);h=d.length===1?{type:"Point",coordinates:p[0]}:{type:"MultiPoint",coordinates:p}}else if(this.type===2){let d=o.map(u);h=d.length===1?{type:"LineString",coordinates:d[0]}:{type:"MultiLineString",coordinates:d}}else if(this.type===3){let d=e0(o),p=[];for(let f of d)p.push(f.map(u));h=p.length===1?{type:"Polygon",coordinates:p[0]}:{type:"MultiPolygon",coordinates:p}}else throw Error("unknown feature type");let c={type:"Feature",geometry:h,properties:this.properties};return this.id!=null&&(c.id=this.id),c}};xs.types=["Unknown","Point","LineString","Polygon"];function e0(e){let t=e.length;if(t<=1)return[e];let r=[],i,a;for(let n=0;n<t;n++){let s=MT(e[n]);s!==0&&(a===void 0&&(a=s<0),a===s<0?(i&&r.push(i),i=[e[n]]):i&&i.push(e[n]))}return i&&r.push(i),r}function MT(e){let t=0;for(let r=0,i=e.length,a=i-1,n,s;r<i;a=r++)n=e[r],s=e[a],t+=(s.x-n.x)*(n.y+s.y);return t}var zT=class{constructor(t,r){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],r===void 0&&(r=t.length);t.pos<r;){let i=t.readVarint();i===10?this.name=t.readString():i===18?(this._features.push(t.pos),t.skip(i)):i===26?this._keys.push(t.readString()):i===34?this._values.push(FT(t)):i===40?this.extent=t.readVarint():i===120?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 r=this._pbf.readVarint()+this._pbf.pos;return new xs(this._pbf,r,this.extent,this._keys,this._values)}};function FT(e){let t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let i=e.readVarint();t=i===10?e.readString():i===21?e.readFloat():i===25?e.readDouble():i===32?e.readVarint(!0):i===40?e.readVarint():i===48?e.readSVarint():i===56?e.readBoolean():(e.skip(i),null)}if(t==null)throw Error("unknown feature value");return t}var RT=class{constructor(t,r=t.length){let i=Object.create(null);for(;t.pos<r;){let a=t.readVarint();if(a===26){let n=new zT(t,t.readVarint()+t.pos);n.length&&(i[n.name]=n)}else t.skip(a)}this.layers=i}};const Lt=63710088e-1;var J=class Fn{constructor(t,r){if(isNaN(t)||isNaN(r))throw Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Fn(mr(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let r=Math.PI/180,i=this.lat*r,a=t.lat*r,n=Math.sin(i)*Math.sin(a)+Math.cos(i)*Math.cos(a)*Math.cos((t.lng-this.lng)*r);return Lt*Math.acos(Math.min(n,1))}static convert(t){if(t instanceof Fn)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new Fn(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t)return new Fn(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>]")}};const t0=2*Math.PI*Lt;function r0(e){return t0*Math.cos(e*Math.PI/180)}function Ya(e){return(180+e)/360}function Ka(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Wi(e,t){return e/r0(t)}function cc(e){return e*360-180}function os(e){let t=180-e*360;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function i0(e,t){return e*r0(os(t))}function kT(e){return 1/Math.cos(e*Math.PI/180)}var Ie=class a0{constructor(t,r,i=0){this.x=+t,this.y=+r,this.z=+i}static fromLngLat(t,r=0){let i=J.convert(t);return new a0(Ya(i.lng),Ka(i.lat),Wi(r,i.lat))}toLngLat(){return new J(cc(this.x),os(this.y))}toAltitude(){return i0(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/t0*kT(os(this.y))}};const Hi=89.25;function n0(e,t,r){let i=1/(1<<r.z);return new Ie(e/k*i+r.x*i,t/k*i+r.y*i)}function LT(e,t,r){return n0(e,t,r).toLngLat()}function Vr(e,t){let r=ne(t.lat,-85.051129,qr);return new C(Ya(t.lng)*e,Ka(r)*e)}function ls(e,t){return new Ie(t.x/e,t.y/e).toLngLat()}function Nn(e){return e.cameraToCenterDistance*Math.min(Math.tan(Ge(90-e.pitch))*.85,Math.tan(Ge(Hi-e.pitch)))}function ku(e,t){let r=e.canonical,i=t/$t(r.z),a=r.x+2**r.z*e.wrap,n=new Float64Array(16);return Ar(n),ot(n,n,[a*i,r.y*i,0]),Et(n,n,[i/k,i/k,1]),n}function s0(e,t,r,i,a){let n=Ie.fromLngLat(e,t),s=a*Wi(1,e.lat),{x:o,y:l,z:u}=dc(r,i),h=s*-o,c=s*-l,d=s*u;return new Ie(n.x+h,n.y+c,n.z+d)}function BT(e){let t=Wi(1,e.center.lat)*e.worldSize;return s0(e.center,e.elevation,e.pitch,e.bearing,e.cameraToCenterDistance/t)}function dc(e,t){let r=Ge(e),i=Ge(t),a=Math.cos(-r),n=Math.sin(r);return{x:n*Math.sin(i),y:-n*Math.cos(i),z:a}}function OT(e,t){return t<=0||!e||e.length===0?e:e.map(r=>jT(r,t))}function $T(e,t){let r=LT(k/2,k/2,t),i=Ie.fromLngLat(r).meterInMercatorCoordinateUnits(),a=(1<<t.z)*k;return e*i*a}function jT(e,t){if(!e||e.length<3)return e;let r=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,i=r?e.length-1:e.length;if(i<3)return e;let a=[],n=hc(e[i-1],e[0]);for(let o=0;o<i;o++){let l=e[(o-1+i)%i],u=e[o],h=e[(o+1)%i],c=hc(u,h);n||c?a.push(u.clone()):NT(a,l,u,h,t),n=c}let s=VT(a);return s.length<3?e:(r&&s.push(s[0].clone()),s)}function VT(e){let t=[];for(let r of e){let i=r.round(),a=t[t.length-1];((a==null?void 0:a.x)!==i.x||(a==null?void 0:a.y)!==i.y)&&t.push(i)}for(;t.length>1&&t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y;)t.pop();return t}function NT(e,t,r,i,a){let n=t.sub(r),s=i.sub(r),o=n.mag(),l=s.mag();if(o<1e-6||l<1e-6){e.push(r.clone());return}n._div(o),s._div(l);let u=n.x*s.x+n.y*s.y;if(Math.abs(u)>Math.cos(5*Math.PI/180)){e.push(r.clone());return}let h=.2,c=Math.min(a,o*h,l*h),d=r.add(n.mult(c)),p=r.add(s.mult(c)),f=Math.sqrt((1+u)/2),m=r.add(n.add(s)._unit()._mult(c/f)),g=d.sub(m).angleWith(p.sub(m)),_=Math.max(2,Math.ceil(Math.abs(g)/(Math.PI/6)-1e-6));for(let y=0;y<=_;y++)e.push(d.rotateAround(y/_*g,m))}const Lu=8192;function vn(e,t,r,i,a,n,s,o){e.emplaceBack(t,r,Math.floor(i*Lu)*2+s,a*Lu*2,n*Lu*2,Math.round(o))}var o0=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new q2,this.centroidVertexArray=new bi,this.indexArray=new Yr,this.programConfigurations=new Qi(t.layers,t.zoom),this.segments=new Ze,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,i){this.features=[],this.hasDependencies=Jo("fill-extrusion",this.layers,r);let a=new ze(this.zoom),n=this.layers[0],s=n.layout.get("fill-extrusion-rounded-corner-distance"),o=s>0?$T(s,i):0,l=n._featureFilter.needGeometry;for(let{feature:u,id:h,index:c,sourceLayerIndex:d}of t){let p=sa(u,l);if(!n._featureFilter.filter(a,p,i))continue;let f={id:h,sourceLayerIndex:d,index:c,geometry:OT(l?p.geometry:na(u),o),properties:u.properties,type:u.type,patterns:{}};this.hasDependencies?this.features.push(xd("fill-extrusion",this.layers,f,{zoom:this.zoom},r)):this.addFeature(f,f.geometry,c,i,{},r.subdivisionGranularity),r.featureIndex.insert(u,f.geometry,c,d,this.index,!0)}}addFeatures({options:t,canonical:r,patternPositions:i}){for(let a of this.features){let{geometry:n}=a;this.addFeature(a,n,a.index,r,i,t.subdivisionGranularity)}}update(t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,CT),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,AT.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,r,i,a,n,s){for(let o of Dl(r,500)){let l={x:0,y:0,sampleCount:0},u=this.layoutVertexArray.length;this.processPolygon(l,a,t,o,s);let h=this.layoutVertexArray.length-u,c=Math.floor(l.x/l.sampleCount),d=Math.floor(l.y/l.sampleCount);for(let p=0;p<h;p++)this.centroidVertexArray.emplaceBack(c,d)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,canonical:a})}processPolygon(t,r,i,a,n){if(a.length<1||If(a[0]))return;for(let c of a)c.length!==0&&UT(t,c);let s={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=n.fill.getGranularityForZoomLevel(r.z),l=xs.types[i.type]==="Polygon";for(let c of a){if(c.length===0||If(c))continue;let d=Vi(c,o,l);this._generateSideFaces(d,s)}if(!l)return;let u=Yy(a,r,o,!1),h=this.layoutVertexArray;Jy((c,d)=>{vn(h,c,d,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,u.verticesFlattened,u.indicesTriangles)}_generateSideFaces(t,r){let i=0;for(let a=1;a<t.length;a++){let n=t[a],s=t[a-1];if(hc(n,s))continue;r.segment.vertexLength+4>Ze.MAX_VERTEX_ARRAY_LENGTH&&(r.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=n.sub(s)._perp()._unit(),l=s.dist(n);i+l>32768&&(i=0),vn(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,i),vn(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,1,i),i+=l,vn(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,i),vn(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,i);let u=r.segment.vertexLength;this.indexArray.emplaceBack(u,u+2,u+1),this.indexArray.emplaceBack(u+1,u+2,u+3),r.segment.vertexLength+=4,r.segment.primitiveLength+=2}}};function UT(e,t){for(let r=0;r<t.length;r++){let i=t[r];(r!==t.length-1||t[0].x!==i.x||t[0].y!==i.y)&&(e.x+=i.x,e.y+=i.y,e.sampleCount++)}}G("FillExtrusionBucket",o0,{omit:["layers","features"]});let GT;const qT=()=>GT||(GT=new wt({"fill-extrusion-rounded-corner-distance":new N(M["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")}));let ZT;const WT=()=>ZT||(ZT=new wt({"fill-extrusion-opacity":new N(M["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new Y(M["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new N(M["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new N(M["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new Qn(M["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new Y(M["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new Y(M["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new N(M["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")}));var HT={get paint(){return WT()},get layout(){return qT()}};const XT=e=>e.type==="fill-extrusion";var YT=class extends Mr{constructor(t,r){super(t,HT,r)}createBucket(t){return new o0(t)}queryRadius(){return Ll(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:r,featureState:i,geometry:a,transform:n,pixelsToTileUnits:s,pixelPosMatrix:o}){let l=Bl(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-n.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(r,i),h=this.paint.get("fill-extrusion-base").evaluate(r,i),c=QT(l,o,0),d=JT(a,h,u,o),p=d[0],f=d[1];return KT(p,f,c)}};function bn(e,t){return e.x*t.x+e.y*t.y}function Mf(e,t){if(e.length===1){let r=0,i=t[r++],a;for(;!a||i.equals(a);)if(a=t[r++],!a)return 1/0;for(;r<t.length;r++){let n=t[r],s=e[0],o=a.sub(i),l=n.sub(i),u=s.sub(i),h=bn(o,o),c=bn(o,l),d=bn(l,l),p=bn(u,o),f=bn(u,l),m=h*d-c*c,g=(d*p-c*f)/m,_=(h*f-c*p)/m,y=1-g-_,v=i.z*y+a.z*g+n.z*_;if(isFinite(v))return v}return 1/0}{let r=1/0;for(let i of t)r=Math.min(r,i.z);return r}}function KT(e,t,r){let i=1/0;By(r,t)&&(i=Mf(r,t[0]));for(let a=0;a<t.length;a++){let n=t[a],s=e[a];for(let o=0;o<n.length-1;o++){let l=n[o],u=n[o+1],h=s[o],c=[l,u,s[o+1],h,l];Ly(r,c)&&(i=Math.min(i,Mf(r,c)))}}return i!==1/0&&i}function JT(e,t,r,i){let a=[],n=[],s=i[8]*t,o=i[9]*t,l=i[10]*t,u=i[11]*t,h=i[8]*r,c=i[9]*r,d=i[10]*r,p=i[11]*r;for(let f of e){let m=[],g=[];for(let _ of f){let y=_.x,v=_.y,x=i[0]*y+i[4]*v+i[12],w=i[1]*y+i[5]*v+i[13],b=i[2]*y+i[6]*v+i[14],T=i[3]*y+i[7]*v+i[15],P=x+s,S=w+o,I=b+l,R=T+u,F=x+h,D=w+c,A=b+d,E=T+p,z=new C(P/R,S/R);z.z=I/R,m.push(z);let L=new C(F/E,D/E);L.z=A/E,g.push(L)}a.push(m),n.push(g)}return[a,n]}function QT(e,t,r){let i=[];for(let a of e){let n=[a.x,a.y,r,1];Pt(n,n,t),i.push(new C(n[0]/n[3],n[1]/n[3]))}return i}const eD="geojsonvt_clip_start",tD="geojsonvt_clip_end",rD=Ye([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),iD=rD.members,aD=Ye([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),nD=aD.members,sD=Math.cos(75/2*(Math.PI/180)),l0=1/2,zf=2**14/l0;var u0=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let t of this.layers)this.gradients[t.id]={};this.layoutVertexArray=new Z2,this.layoutVertexArray2=new W2,this.indexArray=new Yr,this.programConfigurations=new Qi(e.layers,e.zoom),this.segments=new Ze,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,r){this.hasDependencies=Jo("line",this.layers,t)||this.hasLineDasharray(this.layers);let i=this.layers[0].layout.get("line-sort-key"),a=!i.isConstant(),n=[],s=new ze(this.zoom),o=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=sa(l,o);if(!this.layers[0]._featureFilter.filter(s,d,r))continue;let p=a?i.evaluate(d,{},r):void 0,f={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:o?d.geometry:na(l),patterns:{},dashes:{},sortKey:p};n.push(f)}a&&n.sort((l,u)=>l.sortKey-u.sortKey);for(let l of n){let{geometry:u,index:h,sourceLayerIndex:c}=l;this.hasDependencies?(Jo("line",this.layers,t)?xd("line",this.layers,l,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,l,this.zoom,t),this.patternFeatures.push(l)):this.addFeature(l,u,h,r,{},{},t.subdivisionGranularity);let d=e[h].feature;t.featureIndex.insert(d,u,h,c,this.index)}}update(e,t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:r,dashPositions:i})}addFeatures({options:e,canonical:t,patternPositions:r,dashPositions:i}){for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,r,i,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,nD)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,iD),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.hasOwn(e.properties,"geojsonvt_clip_start")&&Object.hasOwn(e.properties,"geojsonvt_clip_end"))return{start:+e.properties[eD],end:+e.properties[tD]}}addFeature(e,t,r,i,a,n,s){let o=this.layers[0].layout,l=o.get("line-join").evaluate(e,{}),u=o.get("line-cap").evaluate(e,{}),h=o.get("line-miter-limit").evaluate(e,{}),c=o.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let d of t)this.addLine(d,e,l,u,h,c,i,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{imagePositions:a,dashPositions:n,canonical:i})}addLine(e,t,r,i,a,n,s,o){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let l=s?o.line.getGranularityForZoomLevel(s.z):1;if(e=Vi(e,l),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let v=0;v<e.length-1;v++)this.totalDistance+=e[v].dist(e[v+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let u=xs.types[t.type]==="Polygon",h=e.length;for(;h>=2&&e[h-1].equals(e[h-2]);)h--;let c=0;for(;c<h-1&&e[c].equals(e[c+1]);)c++;if(h-c<(u?3:2))return;r==="bevel"&&(a=1.05);let d=this.overscaling<=16?15*k/(512*this.overscaling):0,p=this.segments.prepareSegment(h*10,this.layoutVertexArray,this.indexArray),f,m,g,_,y;this.e1=this.e2=-1,u&&(f=e[h-2],y=e[c].sub(f)._unit()._perp());for(let v=c;v<h;v++){if(g=v===h-1?u?e[c+1]:void 0:e[v+1],g&&e[v].equals(g))continue;y&&(_=y),f&&(m=f),f=e[v],y=g?g.sub(f)._unit()._perp():_,_||(_=y);let x=_.add(y);(x.x!==0||x.y!==0)&&x._unit();let w=_.x*y.x+_.y*y.y,b=x.x*y.x+x.y*y.y,T=b===0?1/0:1/b,P=2*Math.sqrt(2-2*b),S=b<sD&&m&&g,I=_.x*y.y-_.y*y.x>0;if(S&&v>c){let D=f.dist(m);if(D>2*d){let A=f.sub(f.sub(m)._mult(d/D)._round());this.updateDistance(m,A),this.addCurrentVertex(A,_,0,0,p),m=A}}let R=m&&g,F=R?r:u?"butt":i;if(R&&F==="round"&&(T<n?F="miter":T<=2&&(F="fakeround")),F==="miter"&&T>a&&(F="bevel"),F==="bevel"&&(T>2&&(F="flipbevel"),T<a&&(F="miter")),m&&this.updateDistance(m,f),F==="miter")x._mult(T),this.addCurrentVertex(f,x,0,0,p);else if(F==="flipbevel"){if(T>100)x=y.mult(-1);else{let D=T*_.add(y).mag()/_.sub(y).mag();x._perp()._mult(D*(I?-1:1))}this.addCurrentVertex(f,x,0,0,p),this.addCurrentVertex(f,x.mult(-1),0,0,p)}else if(F==="bevel"||F==="fakeround"){let D=-Math.sqrt(T*T-1),A=I?D:0,E=I?0:D;if(m&&this.addCurrentVertex(f,_,A,E,p),F==="fakeround"){let z=Math.round(P*180/Math.PI/20);for(let L=1;L<z;L++){let B=L/z;if(B!==.5){let Q=B-.5,le=1.0904+w*(-3.2452+w*(3.55645-w*1.43519)),De=.848013+w*(-1.06021+w*.215638);B+=B*Q*(B-1)*(le*Q*Q+De)}let V=y.sub(_)._mult(B)._add(_)._unit()._mult(I?-1:1);this.addHalfVertex(f,V.x,V.y,!1,I,0,p)}}g&&this.addCurrentVertex(f,y,-A,-E,p)}else if(F==="butt")this.addCurrentVertex(f,x,0,0,p);else if(F==="square"){let D=m?1:-1;this.addCurrentVertex(f,x,D,D,p)}else F==="round"&&(m&&(this.addCurrentVertex(f,_,0,0,p),this.addCurrentVertex(f,_,1,1,p,!0)),g&&(this.addCurrentVertex(f,y,-1,-1,p,!0),this.addCurrentVertex(f,y,0,0,p)));if(S&&v<h-1){let D=f.dist(g);if(D>2*d){let A=f.add(g.sub(f)._mult(d/D)._round());this.updateDistance(f,A),this.addCurrentVertex(A,y,0,0,p),f=A}}}}addCurrentVertex(e,t,r,i,a,n=!1){let s=t.x+t.y*r,o=t.y-t.x*r,l=-t.x+t.y*i,u=-t.y-t.x*i;this.addHalfVertex(e,s,o,n,!1,r,a),this.addHalfVertex(e,l,u,n,!0,-i,a),this.distance>zf/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,r,i,a,n))}addHalfVertex({x:e,y:t},r,i,a,n,s,o){let l=(this.lineClips?this.scaledDistance*(zf-1):this.scaledDistance)*l0;if(this.layoutVertexArray.emplaceBack((e<<1)+ +!!a,(t<<1)+ +!!n,Math.round(63*r)+128,Math.round(63*i)+128,(s===0?0:s<0?-1:1)+1|(l&63)<<2,l>>6),this.lineClips){let h=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(h,this.lineClipsArray.length)}let u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),n?this.e2=u:this.e1=u}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(let t of e){let r=t.paint.get("line-dasharray");if(r&&!r.isConstant())return!0}return!1}addLineDashDependencies(e,t,r,i){for(let a of e){let n=a.paint.get("line-dasharray");if(!n||n.value.kind==="constant")continue;let s=a.layout.get("line-cap").evaluate(t,{})==="round",o={dasharray:n.value.evaluate({zoom:r-1},t,{}),round:s},l={dasharray:n.value.evaluate({zoom:r},t,{}),round:s},u={dasharray:n.value.evaluate({zoom:r+1},t,{}),round:s},h=`${o.dasharray.join(",")},${o.round}`,c=`${l.dasharray.join(",")},${l.round}`,d=`${u.dasharray.join(",")},${u.round}`;i.dashDependencies[h]=o,i.dashDependencies[c]=l,i.dashDependencies[d]=u,t.dashes[a.id]={min:h,mid:c,max:d}}}};G("LineBucket",u0,{omit:["layers","patternFeatures"]});let oD;const lD=()=>oD||(oD=new wt({"line-cap":new Y(M.layout_line["line-cap"],"line-cap"),"line-join":new Y(M.layout_line["line-join"],"line-join"),"line-miter-limit":new Y(M.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new Y(M.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new Y(M.layout_line["line-sort-key"],"line-sort-key")}));let uD;const hD=()=>uD||(uD=new wt({"line-opacity":new Y(M.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new N(M.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new Y(M.paint_line["line-color"],"line-color"),"line-translate":new N(M.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new N(M.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new Y(M.paint_line["line-width"],"line-width"),"line-gap-width":new Y(M.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new Y(M.paint_line["line-offset"],"line-offset"),"line-blur":new Y(M.paint_line["line-blur"],"line-blur"),"line-dasharray":new Qn(M.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new Qn(M.paint_line["line-pattern"],"line-pattern"),"line-gradient":new Rl(M.paint_line["line-gradient"],"line-gradient")}));var Ff={get paint(){return hD()},get layout(){return lD()}},cD=class extends Y{possiblyEvaluate(e,t){return t=new ze(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,i){return t=W({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,r,i)}};let Qs;const dD=e=>e.type==="line";var pD=class extends Mr{constructor(e,t){super(e,Ff,t),this.gradientVersion=0,Qs||(Qs=new cD(Ff.paint.properties["line-width"].specification,"line-floorwidth"),Qs.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){let t=this.gradientExpression();this.stepInterpolant=i2(t)?t._styleExpression.expression instanceof Xc:!1,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Qs.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new u0(e)}queryRadius(e){let t=e,r=Rf(ka("line-width",this,t),ka("line-gap-width",this,t)),i=ka("line-offset",this,t);return r/2+Math.abs(i)+Ll(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:i,transform:a,pixelsToTileUnits:n}){let s=Bl(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-a.bearingInRadians,n),o=n/2*Rf(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),l=this.paint.get("line-offset").evaluate(t,r);return l&&(i=_w(i,l*n)),cw(s,i,o)}isTileClipped(){return!0}};function Rf(e,t){return t>0?t+2*e:e}const fD=Ye([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_height_offset",components:1,type:"Float32"}],4),mD=Ye([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ye([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const gD=Ye([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ye([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const kf=Ye([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),_D=Ye([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ye([{name:"triangle",components:3,type:"Uint16"}]),Ye([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Float32",name:"heightOffset"}]),Ye([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"},{type:"Float32",name:"heightOffset"}]),Ye([{type:"Float32",name:"offsetX"}]),Ye([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ye([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const tl=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(tl.isParsed())throw Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(e,t){if(this.isParsed())return this.getState();if(e.pluginStatus!=="loading")return this.setState(e),e;let r=e.pluginURL,i=new Promise(n=>{this.loadScriptResolve=n}),a=new Promise(n=>setTimeout(()=>n(),this.TIMEOUT));if(await t(r),await Promise.race([i,a]),this.isParsed()){let n={pluginStatus:"loaded",pluginURL:r};return this.setState(n),n}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${r}`)}};function yD(e){return/[\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u077F\u07C0-\u07FA\u07FD-\u07FF\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\u1800\u1801\u1804\u1806-\u1819\u1820-\u1878\u1880-\u18AA\uA840-\uA877\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF80-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDD00-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDEFF\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB]|\uD805[\uDE60-\uDE6C]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9C-\uDC9F]|\uD83A[\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}function xD(e){return/[\u0591-\u05C7\u05D0-\u05EA\u05EF-\u05F4\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u07B1\u07C0-\u07FA\u07FD-\u082D\u0830-\u083E\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\uFB1D-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC57-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD1F-\uDD39\uDD3F-\uDD59\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE50-\uDE58\uDE60-\uDE9F\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF00-\uDF35\uDF39-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD85\uDD8E\uDD8F\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB-\uDEAD\uDEB0\uDEB1\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDF27\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}function vD(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function bD(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function Ol(e){return/[\u02EA\u02EB\u1100-\u11FF\u1401-\u167F\u18B0-\u18FF\u2065\u20DD-\u20E0\u20E2-\u20E4\u2B97\u2BF0-\u2BFF\u2E50\u2E51\u2E80-\u3007\u3012\u3013\u3020-\u302F\u3031-\u30FB\u30FD-\uA4CF\uA960-\uA97F\uAC00-\uD7FF\uF900-\uFAFF\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7\uFFF0-\uFFF8]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|[\uD80C-\uD810\uD81C-\uD822\uD83C\uD83D\uD840-\uD87E\uD880-\uD8BE][\uDC00-\uDFFF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFFF]|\uD823[\uDC00-\uDDFF]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFF]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83E[\uDD00-\uDEFF]|[\uD87F\uD8BF][\uDC00-\uDFFD]/gim.test(String.fromCodePoint(e))}function wD(e){return/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))}function TD(e){return/[\r\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0600-\u0605\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DD\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0890\u0891\u0897-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E33-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB3-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1037\u1039-\u103E\u1056-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1084-\u1086\u108D\u109D\u1100-\u11FF\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60\u1A62\u1A65-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA960-\uA97C\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCBD\uDCC2\uDCCD\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC2\uDDC3\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDE41\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDFB8-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD2\uDFE1\uDFE2]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF1F\uDF22-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE84-\uDE99\uDF60-\uDF67]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6\uDF00-\uDF03\uDF34-\uDF3A\uDF3E-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDD63\uDD67-\uDD6A\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDDE6-\uDDFF\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF]/.test(e)}function Lf(e){return/[\u0E01-\u0E3A\u0E40-\u0E4E\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0EDC-\u0EDF\u0F00-\u0F47\u0F49-\u0F6C\u0F71-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FD4\u0FD9\u0FDA\u1000-\u103F\u1050-\u108F\u109A-\u109F\u1780-\u17D3\u17D7\u17DC\u17DD\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19DE\u19DF\u1A20-\u1A5E\u1A60-\u1A7C\u1AA0-\u1AAD\u1B00-\u1B4C\u1B4E-\u1B7F\uA980-\uA9CD\uA9D0-\uA9D9\uA9DE-\uA9EF\uA9FA-\uA9FE\uAA60-\uAAC2\uAADB-\uAADF]|\uD805[\uDF00-\uDF1A\uDF1D-\uDF2B\uDF3A\uDF3B\uDF3F-\uDF46]/gim.test(String.fromCodePoint(e))}function DD(e,t){return/(?:[\u1039\u17D2\u1A60\u1BAB\u200D\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807[\uDD45\uDD97\uDF42])$/.test(e)||new RegExp("^\\p{gc=Mc}","u").test(t)}const SD={C:"18g,1;g2,3;4nb,1",D:"17k,1;5,1;1,1;1,5;4,d;1,7;1,2;z,2;8,g;i,12;1,2;9,1;1,1;1,2;14,3;2,1;28,9;3,f;2,4;1,1;2,3;2,6;7a,1;2,5;1,1;g,a;5,2;2,6;1,f",R:"17m,4;1,1;1,1;5,4;l,1;14,3;1,3;g,i;12,1;2,9;1,1;1,1;2,2;1,1;o,2;2x,3;f,2;4,1;1,2;3,2;6u,j;b,1;r,3;1,1;2,2;6,1",T:"174,b;1,1;1a,l;g,1;2t,7;2,6;2,2;1,4;bt,9;16,o;1,t;1clb,1"},ED={1569:[65152,0,0,0],1570:[65153,65154,0,0],1571:[65155,65156,0,0],1572:[65157,65158,0,0],1573:[65159,65160,0,0],1574:[65161,65162,65163,65164],1575:[65165,65166,0,0],1576:[65167,65168,65169,65170],1577:[65171,65172,0,0],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194,0,0],1584:[65195,65196,0,0],1585:[65197,65198,0,0],1586:[65199,65200,0,0],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262,0,0],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1611:[65136,0,0,65137],1612:[65138,0,0,0],1613:[65140,0,0,0],1614:[65142,0,0,65143],1615:[65144,0,0,65145],1616:[65146,0,0,65147],1617:[65148,0,0,65149],1618:[65150,0,0,65151],1649:[64336,64337,0,0],1655:[64477,0,0,0],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393,0,0],1676:[64388,64389,0,0],1677:[64386,64387,0,0],1678:[64390,64391,0,0],1681:[64396,64397,0,0],1688:[64394,64395,0,0],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415,0,0],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421,0,0],1729:[64422,64423,64424,64425],1733:[64480,64481,0,0],1734:[64473,64474,0,0],1735:[64471,64472,0,0],1736:[64475,64476,0,0],1737:[64482,64483,0,0],1739:[64478,64479,0,0],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431,0,0],1747:[64432,64433,0,0]},PD={لآ:[65269,65270],لأ:[65271,65272],لإ:[65273,65274],لا:[65275,65276]},Bf=1604,AD=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function CD(e,t,r){let i=0;for(let a of e.split(";")){let[n,s]=a.split(",").map(l=>parseInt(l,36)),o=i+n;for(let l=o;l<o+s;l++)r.set(l,t);i=o+s}}const h0=new Map;for(let[e,t]of Object.entries(SD))CD(t,e,h0);function ID(e){return h0.get(e)??"U"}function MD(e){return e==="D"||e==="L"||e==="C"}function zD(e){return e==="D"||e==="R"||e==="C"}function FD(e,t,r){return e==="D"?t&&r?3:t?1:r?2:0:e==="R"?+!!t:e==="L"?r?2:0:null}function RD(e){return[...e].map(t=>{let r=t.codePointAt(0);return{codePoint:r,type:ID(r),form:null}})}function kD(e){let t=e.filter(r=>r.type!=="T");for(let r=0;r<t.length;r++){let i=t[r],a=r>0&&MD(t[r-1].type),n=r+1<t.length&&zD(t[r+1].type);i.form=FD(i.type,a,n)}}function LD(e){let t=!1;for(let r of e)r.type==="T"?r.form=t?3:0:t=r.form===2||r.form===3}function BD(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.codePoint!==Bf){t.push(i);continue}let a=r+1;for(;a<e.length&&e[a].type==="T";)a++;let n=e[a],s=n&&PD[String.fromCodePoint(Bf,n.codePoint)];if(!s){t.push(i);continue}let o=i.form===3||i.form===1;t.push({codePoint:s[+!!o],type:"R",form:0}),t.push(...e.slice(r+1,a)),r=a}return t}function OD(e){if(e.form===null)return e.codePoint;let t=ED[e.codePoint];return t&&(t[e.form]||t[0])||e.codePoint}function $D(e){if(!AD.test(e))return e;let t=RD(e);return kD(t),LD(t),BD(t).map(r=>String.fromCodePoint(OD(r))).join("")}function jD(e,t,r){let i=t.layout.get("text-transform").evaluate(r,{});return i==="uppercase"?e=e.toLocaleUpperCase():i==="lowercase"&&(e=e.toLocaleLowerCase()),(tl.applyArabicShaping??$D)(e)}function VD(e,t,r){for(let i of e.sections)i.text=jD(i.text,t,r);return e}function Bu(e,t,r){let i=r?t.last.points:t.first.points,a=r?i[i.length-1]:i[0];return`${e}:${a.x}:${a.y}`}function ND(e){let t=e.first.points,r=t.length;for(let n=e.first.next;n;n=n.next)r+=n.points.length-1;let i=Array(r);for(let n=0;n<t.length;n++)i[n]=t[n];let a=t.length;for(let n=e.first.next;n;n=n.next){let s=n.points;for(let o=1;o<s.length;o++)i[a++]=s[o]}return i}function Of(e,t,r,i,a){let n=t[r];delete t[r],t[i]=n;let s=e[n];return s.last.next=a.first,s.last=a.last,n}function $f(e,t,r,i,a){let n=t[i];delete t[i],t[r]=n;let s=e[n];return a.last.next=s.first,s.first=a.first,n}function UD(e){let t={},r={},i=[];for(let n of e){let s=n.text?n.text.toString():null,o={points:n.geometry[0],next:null},l={feature:n,first:o,last:o};if(!s){i.push(l);continue}let u=Bu(s,l),h=Bu(s,l,!0);if(u in r&&h in t&&r[u]!==t[h]){let c=$f(i,t,u,h,l),d=Of(i,r,u,h,i[c]);delete t[u],delete r[h],r[Bu(s,i[d],!0)]=d,i[c].feature.geometry=null}else if(u in r)Of(i,r,u,h,l);else if(h in t)$f(i,t,u,h,l);else{let c=i.push(l)-1;t[u]=c,r[h]=c}}let a=[];for(let n of i){let s=n.feature;s.geometry&&(n.first.next&&(s.geometry[0]=ND(n)),a.push(s))}return a}const c0=typeof Intl<"u"&&"Segmenter"in Intl;let jf,Vf;function pc(e){if(!c0||!TD(e))return[...e];jf??(jf=new Intl.Segmenter(void 0,{granularity:"grapheme"}));let t=[];for(let{segment:r}of jf.segment(e)){let i=t.length-1;i>=0&&DD(t[i],r)?t[i]+=r:t.push(r)}return t}function GD(e){let t=new Set;if(c0){Vf??(Vf=new Intl.Segmenter(void 0,{granularity:"word"}));for(let{index:i}of Vf.segment(e))t.add(i);return t}let r=0;for(let i of e.split(new RegExp("\\b|(?=\\p{Ideo})","u")))t.add(r),r+=i.length;return t}function rl(e){let t=e.codePointAt(0);return e.length>(t>65535?2:1)}function bd(e){return/\s/u.test(String.fromCodePoint(e))}function fc(e){for(let t of e)if(Ol(t.codePointAt(0)))return!0;return!1}function qD(e){for(let t of e)if(!ZD(t.codePointAt(0)))return!1;return!0}function ZD(e){return!yD(e)}function Nf(e){return!(Ol(e)||wD(e))}function d0(e){return new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(e))}function p0(e){return xD(e)}function f0(e){for(let t of e)if(p0(t.codePointAt(0)))return!0;return!1}const Ma={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function WD(e){let t="",r={premature:!0,value:void 0},i=e[Symbol.iterator](),a=i.next(),n=e[Symbol.iterator]();n.next();let s=n.next();for(;!a.done;)(s.done||!Nf(s.value.codePointAt(0))||Ma[s.value])&&(r.premature||!Nf(r.value.codePointAt(0))||Ma[r.value])&&Ma[a.value]?t+=Ma[a.value]:t+=a.value,r={value:a.value,premature:!1},a=i.next(),s=n.next();return t}const HD={10:!0,13:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},XD={40:!0};function Uf(e,t,r,i,a,n){var s;if("fontStack"in t){let o=(s=r[t.fontStack])==null?void 0:s.default,l=o==null?void 0:o[e];if(l)return l.metrics.advance*t.scale+a;let u=0;for(let h of e){let c=o==null?void 0:o[h];c&&(u+=c.metrics.advance*t.scale+a)}return u}{let o=i[t.imageName];return o?o.displaySize[0]*t.scale*24/n+a:0}}function Gf(e,t,r,i){let a=(e-t)**2;return i?e<t?a/2:a*2:a+Math.abs(r)*r}function qf(e){return/^\s+$/u.test(e)}function YD(e,t,r){let i=0;return(e===10||e===13)&&(i-=1e4),r&&(i+=150),(e===40||e===65288)&&(i+=50),(t===41||t===65289)&&(i+=50),i}function Zf(e,t,r,i,a,n){let s=null,o=Gf(t,r,a,n);for(let l of i){let u=Gf(t-l.x,r,a,n)+l.badness;u<=o&&(s=l,o=u)}return{index:e,x:t,priorBreak:s,badness:o}}function m0(e){return e?m0(e.priorBreak).concat(e.index):[]}var wd=class mc{constructor(t="",r=[],i=[]){this.text=t,this.sections=r,this.sectionIndex=i,this.imageSectionID=null,this._graphemes=null}graphemes(){return this._graphemes??(this._graphemes=pc(this.text)),this._graphemes}static fromFeature(t,r){let i=new mc;for(let a of t.sections)a.image?i.addImageSection(a):i.addTextSection(a,r);return i}length(){return this.graphemes().length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}verticalizePunctuation(){this.text=WD(this.text),this._graphemes=null}hasZeroWidthSpaces(){return this.text.includes("")}trim(){let t=this.graphemes(),r=0;for(;r<t.length&&qf(t[r]);)r++;let i=t.length;for(;i>r&&qf(t[i-1]);)i--;this.text=t.slice(r,i).join(""),this.sectionIndex=this.sectionIndex.slice(r,i),this._graphemes=null}substring(t,r){let i=this.graphemes().slice(t,r).join(""),a=this.sectionIndex.slice(t,r);return new mc(i,this.sections,a)}toCodeUnitIndex(t){return this.graphemes().slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,r)=>Math.max(t,this.sections[r].scale),0)}getMaxImageSize(t){let r=0,i=0;for(let a=0;a<this.length();a++){let n=this.getSection(a);if("imageName"in n){let s=t[n.imageName];if(!s)continue;let o=s.displaySize;r=Math.max(r,o[0]),i=Math.max(i,o[1])}}return{maxImageWidth:r,maxImageHeight:i}}_appendSection(t,r){let i=this.graphemes(),a=i.length>0?i[i.length-1]:"",n=pc(a+t);this.text+=t,this._graphemes=i.slice(0,a?-1:void 0).concat(n);let s=n.length-+!!a;for(let o=0;o<s;o++)this.sectionIndex.push(r)}addTextSection(t,r){this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||r}),this._appendSection(t.text,this.sections.length-1)}addImageSection(t){let r=t.image?t.image.name:"";if(r.length===0){_e("Can't add FormattedSection with an empty image.");return}let i=this.getNextImageSectionCharCode();if(!i){_e("Reached maximum number of images 6401");return}this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:r}),this._appendSection(String.fromCharCode(i),this.sections.length-1)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,r,i,a,n){let s=[],o=this.determineAverageLineWidth(t,r,i,a,n),l=this.hasZeroWidthSpaces(),u=this.graphemes(),h=null,c=0,d=0;for(let p=0;p<u.length;p++){let f=u[p];if(p>0){let m=u[p-1].codePointAt(0),g=f.codePointAt(0),_=bD(m),y=Lf(m)&&Lf(g);(HD[m]||_||"imageName"in this.getSection(p-1)||u[p+1]!==void 0&&XD[g]||y&&(h??(h=GD(this.text))).has(d))&&s.push(Zf(p,c,o,s,YD(m,g,_&&l),!1))}bd(f.codePointAt(0))||(c+=Uf(f,this.getSection(p),i,a,t,n)),d+=f.length}return m0(Zf(this.length(),c,o,s,0,!0))}determineAverageLineWidth(t,r,i,a,n){let s=0,o=0;for(let u of this.graphemes()){let h=this.getSection(o);s+=Uf(u,h,i,a,t,n),o++}let l=Math.max(1,Math.ceil(s/r));return s/l}};function KD(){return function(e){var t={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},r={},i={};r.L=1,i[1]="L",Object.keys(t).forEach(function(Z,ge){r[Z]=1<<ge+1,i[r[Z]]=Z}),Object.freeze(r);var a=r.LRI|r.RLI|r.FSI,n=r.L|r.R|r.AL,s=r.B|r.S|r.WS|r.ON|r.FSI|r.LRI|r.RLI|r.PDI,o=r.BN|r.RLE|r.LRE|r.RLO|r.LRO|r.PDF,l=r.S|r.WS|r.B|a|r.PDI|o,u=null;function h(){if(!u){u=new Map;var Z=0;for(var ge in t)if(t.hasOwnProperty(ge))for(var re=t[ge],$="",ye=void 0,ee=!1,ie=0,q=0;q<=re.length+1;q+=1){var be=re[q];if(be!==","&&q!==re.length)be==="+"?(ee=!0,ie=Z=ie+parseInt($,36),$=""):$+=be;else{ee?ye=Z+parseInt($,36):(ie=Z=ie+parseInt($,36),ye=Z),ee=!1,$="",ie=ye;for(var we=Z;we<ye+1;we+=1)u.set(we,r[ge])}}}}function c(Z){return h(),u.get(Z.codePointAt(0))||r.L}function d(Z){return i[c(Z)]}var p={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function f(Z,ge){var re=0,$=new Map,ye=ge&&new Map,ee;return Z.split(",").forEach(function ie(q){if(q.indexOf("+")!==-1)for(var be=+q;be--;)ie(ee);else{ee=q;var we=q.split(">"),ae=we[0],et=we[1];ae=String.fromCodePoint(re+=parseInt(ae,36)),et=String.fromCodePoint(re+=parseInt(et,36)),$.set(ae,et),ge&&ye.set(et,ae)}}),{map:$,reverseMap:ye}}var m,g,_;function y(){if(!m){var Z=f(p.pairs,!0),ge=Z.map,re=Z.reverseMap;m=ge,g=re,_=f(p.canonical,!1).map}}function v(Z){return y(),m.get(Z)||null}function x(Z){return y(),g.get(Z)||null}function w(Z){return y(),_.get(Z)||null}var b=r.L,T=r.R,P=r.EN,S=r.ES,I=r.ET,R=r.AN,F=r.CS,D=r.B,A=r.S,E=r.ON,z=r.BN,L=r.NSM,B=r.AL,V=r.LRO,Q=r.RLO,le=r.LRE,De=r.RLE,pe=r.PDF,Be=r.LRI,xe=r.RLI,Ue=r.FSI,Ee=r.PDI;function pt(Z,ge){for(var re=125,$=new Uint32Array(Z.length),ye=0;ye<Z.length;ye++)$[ye]=c(Z[ye]);var ee=new Map;function ie(Gt,wr){var qt=$[Gt];$[Gt]=wr,ee.set(qt,ee.get(qt)-1),qt&s&&ee.set(s,ee.get(s)-1),ee.set(wr,(ee.get(wr)||0)+1),wr&s&&ee.set(s,(ee.get(s)||0)+1)}for(var q=new Uint8Array(Z.length),be=new Map,we=[],ae=null,et=0;et<Z.length;et++)ae||we.push(ae={start:et,end:Z.length-1,level:ge==="rtl"?1:ge==="ltr"?0:Ip(et,!1)}),$[et]&D&&(ae.end=et,ae=null);for(var Mi=De|le|Q|V|a|Ee|pe|D,Kr=function(Gt){return Gt+(Gt&1?1:2)},zr=function(Gt){return Gt+(Gt&1?2:1)},Fr=0;Fr<we.length;Fr++){ae=we[Fr];var Oe=[{_level:ae.level,_override:0,_isolate:0}],ke=void 0,or=0,br=0,ha=0;ee.clear();for(var st=ae.start;st<=ae.end;st++){var ht=$[st];if(ke=Oe[Oe.length-1],ee.set(ht,(ee.get(ht)||0)+1),ht&s&&ee.set(s,(ee.get(s)||0)+1),ht&Mi)if(ht&(De|le)){q[st]=ke._level;var ca=(ht===De?zr:Kr)(ke._level);ca<=re&&!or&&!br?Oe.push({_level:ca,_override:0,_isolate:0}):or||br++}else if(ht&(Q|V)){q[st]=ke._level;var np=(ht===Q?zr:Kr)(ke._level);np<=re&&!or&&!br?Oe.push({_level:np,_override:ht&Q?T:b,_isolate:0}):or||br++}else if(ht&a){ht&Ue&&(ht=Ip(st+1,!0)===1?xe:Be),q[st]=ke._level,ke._override&&ie(st,ke._override);var sp=(ht===xe?zr:Kr)(ke._level);sp<=re&&or===0&&br===0?(ha++,Oe.push({_level:sp,_override:0,_isolate:1,_isolInitIndex:st})):or++}else if(ht&Ee){if(or>0)or--;else if(ha>0){for(br=0;!Oe[Oe.length-1]._isolate;)Oe.pop();var Xl=Oe[Oe.length-1]._isolInitIndex;Xl!=null&&(be.set(Xl,st),be.set(st,Xl)),Oe.pop(),ha--}ke=Oe[Oe.length-1],q[st]=ke._level,ke._override&&ie(st,ke._override)}else ht&pe?(or===0&&(br>0?br--:!ke._isolate&&Oe.length>1&&(Oe.pop(),ke=Oe[Oe.length-1])),q[st]=ke._level):ht&D&&(q[st]=ae.level);else q[st]=ke._level,ke._override&&ht!==z&&ie(st,ke._override)}for(var da=[],Rr=null,zi=ae.start;zi<=ae.end;zi++){var Yl=$[zi];if(!(Yl&o)){var op=q[zi],lp=Yl&a,Tx=Yl===Ee;Rr&&op===Rr._level?(Rr._end=zi,Rr._endsWithIsolInit=lp):da.push(Rr={_start:zi,_end:zi,_level:op,_startsWithPDI:Tx,_endsWithIsolInit:lp})}}for(var Kl=[],Ss=0;Ss<da.length;Ss++){var Es=da[Ss];if(!Es._startsWithPDI||Es._startsWithPDI&&!be.has(Es._start)){for(var Jl=[Rr=Es],up=void 0;Rr&&Rr._endsWithIsolInit&&(up=be.get(Rr._end))!=null;)for(var Ps=Ss+1;Ps<da.length;Ps++)if(da[Ps]._start===up){Jl.push(Rr=da[Ps]);break}for(var pa=[],Ql=0;Ql<Jl.length;Ql++)for(var hp=Jl[Ql],eu=hp._start;eu<=hp._end;eu++)pa.push(eu);for(var Dx=q[pa[0]],cp=ae.level,As=pa[0]-1;As>=0;As--)if(!($[As]&o)){cp=q[As];break}var tu=pa[pa.length-1],Sx=q[tu],dp=ae.level;if(!($[tu]&a)){for(var Cs=tu+1;Cs<=ae.end;Cs++)if(!($[Cs]&o)){dp=q[Cs];break}}Kl.push({_seqIndices:pa,_sosType:Math.max(cp,Dx)%2?T:b,_eosType:Math.max(dp,Sx)%2?T:b})}}for(var ru=0;ru<Kl.length;ru++){var iu=Kl[ru],te=iu._seqIndices,nn=iu._sosType,Ex=iu._eosType,fa=q[te[0]]&1?T:b;if(ee.get(L))for(var Is=0;Is<te.length;Is++){var pp=te[Is];if($[pp]&L){for(var au=nn,Ms=Is-1;Ms>=0;Ms--)if(!($[te[Ms]]&o)){au=$[te[Ms]];break}ie(pp,au&(a|Ee)?E:au)}}if(ee.get(P))for(var zs=0;zs<te.length;zs++){var fp=te[zs];if($[fp]&P)for(var Fs=zs-1;Fs>=-1;Fs--){var mp=Fs===-1?nn:$[te[Fs]];if(mp&n){mp===B&&ie(fp,R);break}}}if(ee.get(B))for(var nu=0;nu<te.length;nu++){var gp=te[nu];$[gp]&B&&ie(gp,T)}if(ee.get(S)||ee.get(F))for(var sn=1;sn<te.length-1;sn++){var su=te[sn];if($[su]&(S|F)){for(var ma=0,ou=0,lu=sn-1;lu>=0&&(ma=$[te[lu]],ma&o);lu--);for(var uu=sn+1;uu<te.length&&(ou=$[te[uu]],ou&o);uu++);ma===ou&&($[su]===S?ma===P:ma&(P|R))&&ie(su,ma)}}if(ee.get(P)){for(var kr=0;kr<te.length;kr++)if($[te[kr]]&P){for(var Rs=kr-1;Rs>=0&&$[te[Rs]]&(I|o);Rs--)ie(te[Rs],P);for(kr++;kr<te.length&&$[te[kr]]&(I|o|P);kr++)$[te[kr]]!==P&&ie(te[kr],P)}}if(ee.get(I)||ee.get(S)||ee.get(F))for(var on=0;on<te.length;on++){var _p=te[on];if($[_p]&(I|S|F)){ie(_p,E);for(var ks=on-1;ks>=0&&$[te[ks]]&o;ks--)ie(te[ks],E);for(var Ls=on+1;Ls<te.length&&$[te[Ls]]&o;Ls++)ie(te[Ls],E)}}if(ee.get(P))for(var hu=0,yp=nn;hu<te.length;hu++){var xp=te[hu],cu=$[xp];cu&P?yp===b&&ie(xp,b):cu&n&&(yp=cu)}if(ee.get(s)){for(var ln=T|P|R,vp=ln|b,Bs=[],ga=[],_a=0;_a<te.length;_a++)if($[te[_a]]&s){var un=Z[te[_a]],bp=void 0;if(v(un)!==null)if(ga.length<63)ga.push({char:un,seqIndex:_a});else break;else if((bp=x(un))!==null)for(var hn=ga.length-1;hn>=0;hn--){var du=ga[hn].char;if(du===bp||du===x(w(un))||v(w(du))===un){Bs.push([ga[hn].seqIndex,_a]),ga.length=hn;break}}}Bs.sort(function(Gt,wr){return Gt[0]-wr[0]});for(var pu=0;pu<Bs.length;pu++){for(var wp=Bs[pu],Os=wp[0],fu=wp[1],Tp=!1,Lr=0,mu=Os+1;mu<fu;mu++){var Dp=te[mu];if($[Dp]&vp){Tp=!0;var Sp=$[Dp]&ln?T:b;if(Sp===fa){Lr=Sp;break}}}if(Tp&&!Lr){Lr=nn;for(var gu=Os-1;gu>=0;gu--){var Ep=te[gu];if($[Ep]&vp){var Pp=$[Ep]&ln?T:b;Lr=Pp===fa?fa:Pp;break}}}if(Lr){if($[te[Os]]=$[te[fu]]=Lr,Lr!==fa){for(var cn=Os+1;cn<te.length;cn++)if(!($[te[cn]]&o)){c(Z[te[cn]])&L&&($[te[cn]]=Lr);break}}if(Lr!==fa){for(var dn=fu+1;dn<te.length;dn++)if(!($[te[dn]]&o)){c(Z[te[dn]])&L&&($[te[dn]]=Lr);break}}}}for(var pi=0;pi<te.length;pi++)if($[te[pi]]&s){for(var Ap=pi,_u=pi,yu=nn,pn=pi-1;pn>=0;pn--)if($[te[pn]]&o)Ap=pn;else{yu=$[te[pn]]&ln?T:b;break}for(var Cp=Ex,fn=pi+1;fn<te.length;fn++)if($[te[fn]]&(s|o))_u=fn;else{Cp=$[te[fn]]&ln?T:b;break}for(var xu=Ap;xu<=_u;xu++)$[te[xu]]=yu===Cp?yu:fa;pi=_u}}}for(var Kt=ae.start;Kt<=ae.end;Kt++){var Px=q[Kt],$s=$[Kt];if(Px&1?$s&(b|P|R)&&q[Kt]++:$s&T?q[Kt]++:$s&(R|P)&&(q[Kt]+=2),$s&o&&(q[Kt]=Kt===0?ae.level:q[Kt-1]),Kt===ae.end||c(Z[Kt])&(A|D))for(var js=Kt;js>=0&&c(Z[js])&l;js--)q[js]=ae.level}}return{levels:q,paragraphs:we};function Ip(Gt,wr){for(var qt=Gt;qt<Z.length;qt++){var fi=$[qt];if(fi&(T|B))return 1;if(fi&(D|b)||wr&&fi===Ee)return 0;if(fi&a){var Mp=Ax(qt);qt=Mp===-1?Z.length:Mp}}return 0}function Ax(Gt){for(var wr=1,qt=Gt+1;qt<Z.length;qt++){var fi=$[qt];if(fi&D)break;if(fi&Ee){if(--wr===0)return qt}else fi&a&&wr++}return-1}}var yt="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",Nt;function Ut(){if(!Nt){var Z=f(yt,!0),ge=Z.map;Z.reverseMap.forEach(function(re,$){ge.set($,re)}),Nt=ge}}function Tt(Z){return Ut(),Nt.get(Z)||null}function nt(Z,ge,re,$){var ye=Z.length;re=Math.max(0,re==null?0:+re),$=Math.min(ye-1,$==null?ye-1:+$);for(var ee=new Map,ie=re;ie<=$;ie++)if(ge[ie]&1){var q=Tt(Z[ie]);q!==null&&ee.set(ie,q)}return ee}function Yt(Z,ge,re,$){var ye=Z.length;re=Math.max(0,re==null?0:+re),$=Math.min(ye-1,$==null?ye-1:+$);var ee=[];return ge.paragraphs.forEach(function(ie){var q=Math.max(re,ie.start),be=Math.min($,ie.end);if(q<be){for(var we=ge.levels.slice(q,be+1),ae=be;ae>=q&&c(Z[ae])&l;ae--)we[ae]=ie.level;for(var et=ie.level,Mi=1/0,Kr=0;Kr<we.length;Kr++){var zr=we[Kr];zr>et&&(et=zr),zr<Mi&&(Mi=zr|1)}for(var Fr=et;Fr>=Mi;Fr--)for(var Oe=0;Oe<we.length;Oe++)if(we[Oe]>=Fr){for(var ke=Oe;Oe+1<we.length&&we[Oe+1]>=Fr;)Oe++;Oe>ke&&ee.push([ke+q,Oe+q])}}}),ee}function vr(Z,ge,re,$){var ye=sr(Z,ge,re,$),ee=[].concat(Z);return ye.forEach(function(ie,q){ee[q]=(ge.levels[ie]&1?Tt(Z[ie]):null)||Z[ie]}),ee.join("")}function sr(Z,ge,re,$){for(var ye=Yt(Z,ge,re,$),ee=[],ie=0;ie<Z.length;ie++)ee[ie]=ie;return ye.forEach(function(q){for(var be=q[0],we=q[1],ae=ee.slice(be,we+1),et=ae.length;et--;)ee[we-et]=ae[et]}),ee}return e.closingToOpeningBracket=x,e.getBidiCharType=c,e.getBidiCharTypeName=d,e.getCanonicalBracket=w,e.getEmbeddingLevels=pt,e.getMirroredCharacter=Tt,e.getMirroredCharactersMap=nt,e.getReorderSegments=Yt,e.getReorderedIndices=sr,e.getReorderedString=vr,e.openingToClosingBracket=v,Object.defineProperty(e,"__esModule",{value:!0}),e}({})}const Td=KD(),JD=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/,QD=new Set(["WS","FSI","LRI","RLI","PDI"]),eS=new Set(["S","B"]);function tS(e,t,r,i){let a=[],n=r;for(let s of pc(e.slice(r,i)))a.push({index:n,text:s,level:t[n]}),n+=s.length;return a}function rS(e,t){let r=!0;for(let i=e.length-1;i>=0;i--){let a=Td.getBidiCharTypeName(e[i].text[0]);eS.has(a)?(e[i].level=t,r=!0):r&&QD.has(a)?e[i].level=t:r=!1}}function iS(e,t){let r=t,i=1/0;for(let{level:n}of e)n>r&&(r=n),(n|1)<i&&(i=n|1);let a=e.slice();for(let n=r;n>=i;n--)for(let s=0;s<a.length;s++){if(a[s].level<n)continue;let o=s;for(;o+1<a.length&&a[o+1].level>=n;)o++;for(let l=s,u=o;l<u;l++,u--)[a[l],a[u]]=[a[u],a[l]];s=o}return a}function aS(e){return e.level%2==0?e.text:Td.getMirroredCharacter(e.text)??e.text}function nS(e,t){var r;return((r=e.find(i=>t>=i.start&&t<=i.end))==null?void 0:r.level)??0}function sS(e,t,r,i,a){let n=tS(e,t,i,a);rS(n,r);let s="",o=[];for(let l of iS(n,r)){if(JD.test(l.text))continue;let u=aS(l);s+=u,o.push(...Array(u.length).fill(l.index))}return{text:s,sourceIndices:o}}function oS(e,t){let r=t.filter(n=>n>0&&n<e.length),i=[...new Set([0,...r,e.length])].sort((n,s)=>n-s),a=[];for(let n=0;n+1<i.length;n++)a.push([i[n],i[n+1]]);return a}function g0(e,t){let{levels:r,paragraphs:i}=Td.getEmbeddingLevels(e);return oS(e,t.concat(i.map(a=>a.start))).map(([a,n])=>sS(e,r,nS(i,a),a,n))}function lS(e,t){return g0(e,t).map(r=>r.text)}function uS(e,t,r){return g0(e,r).map(i=>[i.text,i.sourceIndices.map(a=>t[a]??0)])}const Wf=4294967296,Hf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var _0=class{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(e,t,r=this.length){let i;for(;i=this.nextField(r);)e(i,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Wf;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Wf;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,r=t[this.pos++];if(r<128)return r;let i=r&127,a;return a=t[this.pos++],i|=(a&127)<<7,a<128||(a=t[this.pos++],i|=(a&127)<<14,a<128)||(a=t[this.pos++],i|=(a&127)<<21,a<128)?i:(a=t[this.pos],i|=(a&15)<<28,hS(i,e,this))}readSVarint(){let e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Hf?Hf.decode(this.buf.subarray(t,e)):dS(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}nextField(e=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=e)return 0;let t=this.readVarint();return this.type=t&7,this._valueStart=this.pos,t>>>3}skip(e){let t=e&7;if(t===0)for(;this.buf[this.pos++]>127;);else if(t===2)this.pos=this.readVarint()+this.pos;else if(t===5)this.pos+=4;else if(t===1)this.pos+=8;else throw Error(`Unimplemented type: ${t}`)}};function hS(e,t,r){let i=r.buf,a,n;if(n=i[r.pos++],a=(n&112)>>4,n<128||(n=i[r.pos++],a|=(n&127)<<3,n<128)||(n=i[r.pos++],a|=(n&127)<<10,n<128)||(n=i[r.pos++],a|=(n&127)<<17,n<128)||(n=i[r.pos++],a|=(n&127)<<24,n<128)||(n=i[r.pos++],a|=(n&1)<<31,n<128))return cS(e,a,t);throw Error("Expected varint not more than 10 bytes")}function cS(e,t,r){return r?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function dS(e,t,r){let i="",a=t;for(;a<r;){let n=e[a],s=null,o=n>239?4:n>223?3:n>191?2:1;if(a+o>r)break;let l,u,h;o===1?n<128&&(s=n):o===2?(l=e[a+1],(l&192)==128&&(s=(n&31)<<6|l&63,s<=127&&(s=null))):o===3?(l=e[a+1],u=e[a+2],(l&192)==128&&(u&192)==128&&(s=(n&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):o===4&&(l=e[a+1],u=e[a+2],h=e[a+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(s=(n&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,o=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),a+=o}return i}function pS(e,t,r){e===1&&r.readMessage(fS,t)}function fS(e,t,r){if(e===3){let{id:i,bitmap:a,width:n,height:s,left:o,top:l,advance:u}=r.readMessage(mS,{});t.push({id:i,bitmap:new yd({width:n+6,height:s+6},a),metrics:{width:n,height:s,left:o,top:l,advance:u}})}}function mS(e,t,r){e===1?t.id=r.readVarint():e===2?t.bitmap=r.readBytes():e===3?t.width=r.readVarint():e===4?t.height=r.readVarint():e===5?t.left=r.readSVarint():e===6?t.top=r.readSVarint():e===7&&(t.advance=r.readVarint())}function gS(e){return new _0(e).readFields(pS,[])}function il(e){return typeof(e==null?void 0:e.renderWithWebGL)=="function"}function _S(e){let{userImage:t}=e;return!(t!=null&&t.render)||!t.render()?!1:(il(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),!0)}function y0(e){let t=0,r=0;for(let s of e)t+=s.w*s.h,r=Math.max(r,s.w);e.sort((s,o)=>o.h-s.h);let i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}],a=0,n=0;for(let s of e)for(let o=i.length-1;o>=0;o--){let l=i[o];if(!(s.w>l.w||s.h>l.h)){if(s.x=l.x,s.y=l.y,n=Math.max(n,s.y+s.h),a=Math.max(a,s.x+s.w),s.w===l.w&&s.h===l.h){let u=i.pop();u&&o<i.length&&(i[o]=u)}else s.h===l.h?(l.x+=s.w,l.w-=s.w):s.w===l.w?(l.y+=s.h,l.h-=s.h):(i.push({x:l.x+s.w,y:l.y,w:l.w-s.w,h:s.h}),l.y+=s.h,l.h-=s.h);break}}return{w:a,h:n,fill:t/(a*n)||0}}var Dd=class{constructor(e,{pixelRatio:t,version:r,isWebGLImage:i=!1,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=a,this.stretchY=n,this.content=s,this.version=r,this.needsFirstWebGLRender=i,this.textFitWidth=o,this.textFitHeight=l}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}},yS=class{constructor(e,t){let r={},i={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let a=[];this.addImages(e,r,a),this.addImages(t,i,a);let{w:n,h:s}=y0(a),o=new $e({width:n||1,height:s||1});for(let l in e){let u=e[l];if(u.isWebGLImage)continue;let h=r[l].paddedRect;$e.copy(u.data,o,{x:0,y:0},{x:h.x+1,y:h.y+1},u.data)}for(let l in t){let u=t[l],h=i[l].paddedRect,c=h.x+1,d=h.y+1,p=u.data.width,f=u.data.height;$e.copy(u.data,o,{x:0,y:0},{x:c,y:d},u.data),$e.copy(u.data,o,{x:0,y:f-1},{x:c,y:d-1},{width:p,height:1}),$e.copy(u.data,o,{x:0,y:0},{x:c,y:d+f},{width:p,height:1}),$e.copy(u.data,o,{x:p-1,y:0},{x:c-1,y:d},{width:1,height:f}),$e.copy(u.data,o,{x:0,y:0},{x:c+p,y:d},{width:1,height:f})}this.image=o,this.iconPositions=r,this.patternPositions=i}addImages(e,t,r){for(let i in e){let a=e[i],n={x:0,y:0,w:a.data.width+2,h:a.data.height+2};r.push(n),t[i]=new Dd(n,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(i)}}patchUpdatedImages(e,t){if(e.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==e.updateVersion){this.patchedUpdateVersion=e.updateVersion;for(let r in this.iconPositions)this.patchUpdatedImage(this.iconPositions[r],e.getImage(r),t);for(let r in this.patternPositions)this.patchUpdatedImage(this.patternPositions[r],e.getImage(r),t)}}patchUpdatedImage(e,t,r){var l;if(!e||!t||!e.needsFirstWebGLRender&&e.version===t.version)return;e.needsFirstWebGLRender=!1,e.version=t.version;let[i,a]=e.tl,n=(l=t.userImage)==null?void 0:l.data;if(!il(n)){r.update(t.data,void 0,{x:i,y:a});return}let{width:s,height:o}=t.data;r.context.setCustomLayerDefaults(),n.renderWithWebGL({gl:r.context.gl,texture:r.texture,x:i,y:a,width:s,height:o}),r.context.setDirty()}};G("ImagePosition",Dd),G("ImageAtlas",yS);var x0=function(e){return e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly",e}(x0||{});function xS(e){for(let t of e)if(t.positionedGlyphs.length!==0)return!1;return!0}function vS(e,t){let r=[],i=0;for(let a of t)r.push(e.substring(i,a)),i=a;return i<e.length()&&r.push(e.substring(i,e.length())),r}const Xf=new RegExp("^\\p{gc=M}$","u");function bS(e){let t=[],r=0;for(;r<e.length;){if(!Xf.test(e[r])){t.push(r),r++;continue}let i=r;for(;i<e.length&&Xf.test(e[i]);)i++;let a=e[i];if(a!==void 0&&p0(a.codePointAt(0))){t.push(i);for(let n=i-1;n>=r;n--)t.push(n);r=i+1}else{for(let n=r;n<i;n++)t.push(n);r=i}}return t}function wS(e){let t=[],r=0;for(let i of e.graphemes())t.push(...Array(i.length).fill(e.sectionIndex[r])),r++;return t}function TS(e,t){let r=t.map(n=>e.toCodeUnitIndex(n)),i=tl.isParsed()?tl:null;if(e.sections.length===1)return i?i.processBidirectionalText(e.toString(),r).map(n=>Yf(n,e.sections,[...n].map(()=>0))):lS(e.toString(),r).map(n=>gc([...n],e.sections,[...n].map(()=>0)));let a=wS(e);return i?i.processStyledBidirectionalText(e.text,a,r).map(([n,s])=>Yf(n,e.sections,s)):uS(e.text,a,r).map(([n,s])=>{let o=[...n];return gc(o,e.sections,v0(o).map(l=>s[l]??0))})}function gc(e,t,r){let i=new wd(e.join(""),t,[]),a=0;for(let n of i.graphemes())i.sectionIndex.push(r[a]??0),a+=[...n].length;return i}function v0(e){let t=[],r=0;for(let i of e)t.push(r),r+=i.length;return t}function Yf(e,t,r){let i=[...e],a=v0(i),n=bS(i);return gc(n.map(s=>i[s]),t,n.map(s=>r[a[s]]??0))}function eo(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f){let m=wd.fromFeature(e,a);c===2&&m.verticalizePunctuation();let g=m.determineLineBreaks(u,n,t,i,p),_=f0(m.text)?TS(m,g):vS(m,g),y=[],v={positionedLines:y,text:m.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:c,iconsInText:!1,verticalizable:!1};return zS(v,t,r,i,_,s,o,l,c,u,d,f),!xS(y)&&v}function $l(e){let t=.5,r=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:t,verticalAlign:r}}function DS(e,t,r){let i=t.getMaxScale()*24,{maxImageWidth:a,maxImageHeight:n}=t.getMaxImageSize(e),s=Math.max(i,n*r);return{verticalLineContentWidth:Math.max(i,a*r),horizontalLineContentHeight:s}}function b0(e){switch(e){case"top":return 0;case"center":return .5;default:return 1}}function SS(e,t,r,i){var n,s;if(e!=null&&e.rect)return e;let a=(s=(n=t[r.fontStack])==null?void 0:n.default)==null?void 0:s[i];return a?{rect:null,metrics:a.metrics}:null}function ES(e,t,r){return!(e===1||!t&&!Ol(r)||t&&(bd(r)||d0(r)))}function Ao(e){return new RegExp("\\p{Nd}","u").test(String.fromCodePoint(e))}function w0(e){return new RegExp("\\p{Lu}","u").test(String.fromCodePoint(e))}function PS(e){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function AS(e){let t=e.some(Ao)&&e.every(i=>Ao(i)||PS(i)),r=e.length<=3&&e.every(i=>w0(i)||Ao(i));return t||r}function CS(e){return(Ao(e)||w0(e))&&!d0(e)}function IS(e,t){let r=!1;for(let i=0;i<e.length;i++){if(t[i])continue;let a=Ma[e[i]];a&&(i===0||t[i-1])&&(i===e.length-1||t[i+1])&&(e[i]=a,t[i]=!0,r=!0)}return r}function MS(e){let t=e.graphemes().slice(),r=t.map(n=>n.codePointAt(0)),i=r.map(Ol),a=n=>!i[n]&&!bd(r[n])&&!("imageName"in e.getSection(n));for(let n=0;n<r.length;n++){if(!a(n))continue;let s=n;for(;s+1<r.length&&a(s+1);)s++;if(AS(r.slice(n,s+1)))for(let o=n;o<=s;o++)i[o]=CS(r[o]);n=s}return IS(t,i)&&(e.text=t.join(""),e._graphemes=null),i}function zS(e,t,r,i,a,n,s,o,l,u,h,c){var w,b;let d=0,p=0,f=0,m=0,g=o==="right"?1:o==="left"?0:.5,_=24/c,y=0;for(let T of a){T.trim();let P=T.getMaxScale(),S={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=S;let I=S.positionedGlyphs,R=0;if(!T.length()){p+=n,++y;continue}let F=DS(i,T,_),D=l===2&&!h?MS(T):null,A=T.graphemes();for(let L=0;L<A.length;L++){let B=T.getSection(L),V=A[L],Q=V.codePointAt(0),le=D?D[L]:ES(l,h,Q),De="fontStack"in B&&rl(V)&&!((b=(w=t[B.fontStack])==null?void 0:w.default)!=null&&b[V])?[...V]:[V];for(let pe of De){let Be={glyph:pe.codePointAt(0),grapheme:pe,imageName:null,x:d,y:p+-17,vertical:le,scale:1,fontStack:"",sectionIndex:T.getSectionIndex(L),metrics:null,rect:null},xe;if("fontStack"in B){if(xe=FS(B,pe,le,F,t,r),!xe)continue;Be.fontStack=B.fontStack}else{if(e.iconsInText=!0,B.scale*=_,xe=RS(B,le,P,F,i),!xe)continue;R=Math.max(R,xe.imageOffset),Be.imageName=B.imageName}let{rect:Ue,metrics:Ee,baselineOffset:pt}=xe;if(Be.y+=pt,Be.scale=B.scale,Be.metrics=Ee,Be.rect=Ue,I.push(Be),!le)d+=Ee.advance*B.scale+u;else{e.verticalizable=!0;let yt="imageName"in B?Ee.advance:24;d+=yt*B.scale+u}}}if(I.length!==0){let L=d-u;f=Math.max(L,f),kS(I,0,I.length-1,g)}d=0;let E=(P-1)*24;S.lineOffset=Math.max(R,E);let z=n*P+R;p+=z,m=Math.max(z,m),++y}let{horizontalAlign:v,verticalAlign:x}=$l(s);LS(e.positionedLines,g,v,x,f,m,n,p,a.length),e.top+=-x*p,e.bottom=e.top+p,e.left+=-v*f,e.right=e.left+f}function FS(e,t,r,i,a,n){var u,h;let s=(h=(u=n[e.fontStack])==null?void 0:u.default)==null?void 0:h[t],o=SS(s,a,e,t);if(o===null)return null;let l;if(r)l=i.verticalLineContentWidth-e.scale*24;else{let c=b0(e.verticalAlign);l=(i.horizontalLineContentHeight-e.scale*24)*c}return{rect:o.rect,metrics:o.metrics,baselineOffset:l}}function RS(e,t,r,i,a){let n=a[e.imageName];if(!n)return null;let s=n.paddedRect,o=n.displaySize,l={width:o[0],height:o[1],left:1,top:-3,advance:t?o[1]:o[0]},u;if(t)u=i.verticalLineContentWidth-o[1]*e.scale;else{let c=b0(e.verticalAlign);u=(i.horizontalLineContentHeight-o[1]*e.scale)*c}let h=(t?o[0]:o[1])*e.scale-24*r;return{rect:s,metrics:l,baselineOffset:u,imageOffset:h}}function kS(e,t,r,i){if(i===0)return;let a=e[r],n=a.metrics.advance*a.scale,s=(e[r].x+n)*i;for(let o=t;o<=r;o++)e[o].x-=s}function LS(e,t,r,i,a,n,s,o,l){let u=(t-r)*a,h=0;h=n===s?-i*l*s+.5*s:-o*i- -17;for(let c of e)for(let d of c.positionedGlyphs)d.x+=u,d.y+=h}function BS(e,t,r){let{horizontalAlign:i,verticalAlign:a}=$l(r),n=t[0],s=t[1],o=n-e.displaySize[0]*i,l=o+e.displaySize[0],u=s-e.displaySize[1]*a;return{image:e,top:u,bottom:u+e.displaySize[1],left:o,right:l}}function T0(e){let t=e.left,r=e.top,i=e.right-t,a=e.bottom-r,n=e.image.content[2]-e.image.content[0],s=e.image.content[3]-e.image.content[1],o=e.image.textFitWidth??"stretchOrShrink",l=e.image.textFitHeight??"stretchOrShrink",u=n/s;if(l==="proportional"){if(o==="stretchOnly"&&i/a<u||o==="proportional"){let h=Math.ceil(a*u);t*=h/i,i=h}}else if(o==="proportional"&&l==="stretchOnly"&&u!==0&&i/a>u){let h=Math.ceil(i/u);r*=h/a,a=h}return{x1:t,y1:r,x2:t+i,y2:r+a}}function Kf(e,t,r,i,a,n){let s=e.image,o;if(s.content){let g=s.content,_=s.pixelRatio||1;o=[g[0]/_,g[1]/_,s.displaySize[0]-g[2]/_,s.displaySize[1]-g[3]/_]}let l=t.left*n,u=t.right*n,h,c,d,p;r==="width"||r==="both"?(p=a[0]+l-i[3],c=a[0]+u+i[1]):(p=a[0]+(l+u-s.displaySize[0])/2,c=p+s.displaySize[0]);let f=t.top*n,m=t.bottom*n;return r==="height"||r==="both"?(h=a[1]+f-i[0],d=a[1]+m+i[2]):(h=a[1]+(f+m-s.displaySize[1])/2,d=h+s.displaySize[1]),{image:s,top:h,right:c,bottom:d,left:p,collisionPadding:o}}const Jf=32640;function Qf(e,t){let{expression:r}=t;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new ze(e+1))};if(r.kind==="source")return{kind:"source"};if(r.kind==="composite"){let{minZoom:i,maxZoom:a}=OS(r.zoomStops,e);return{kind:"composite",minZoom:i,maxZoom:a,interpolationType:r.interpolationType}}{let i=$S(r),a=r.evaluate(new ze(e+1));return{kind:"camera",zoomStops:r.zoomStops,sizes:i,layoutSize:a,interpolationType:r.interpolationType}}}function OS(e,t){let r=0;for(;r<e.length&&e[r]<=t;)r++;r=Math.max(0,r-1);let i=r;for(;i<e.length&&e[i]<t+1;)i++;return i=Math.min(e.length-1,i),{minZoom:e[r],maxZoom:e[i]}}function $S(e){return e.zoomStops.map(t=>e.evaluate(new ze(t===-1/0?e.zoomStops[1]-1:t)))}function Sd(e,{uSize:t,uSizeT:r},{lowerSize:i,upperSize:a}){return e.kind==="source"?i/128:e.kind==="composite"?We.number(i/128,a/128,r):t}function jl(e,t){let r=0,i=0;return e.kind==="constant"?i=e.layoutSize:e.kind==="camera"?i=jS(e,t):e.kind==="composite"&&(r=VS(e,t)),{uSizeT:r,uSize:i}}function jS({zoomStops:e,sizes:t,layoutSize:r,interpolationType:i},a){let n=e.length-1;for(;n>0&&e[n]>a;)n--;let s=Math.min(n+1,e.length-1),o=i?ne(yr.interpolationFactor(i,a,e[n],e[s]),0,1):0;return Math.min(We.number(t[n],t[s],o),r)}function VS({interpolationType:e,minZoom:t,maxZoom:r},i){return e?ne(yr.interpolationFactor(e,i,t,r),0,1):0}var La=class D0 extends C{constructor(t,r,i,a){super(t,r),this.angle=i,a!==void 0&&(this.segment=a)}clone(){return new D0(this.x,this.y,this.angle,this.segment)}};G("Anchor",La);function S0(e,t,r,i,a){if(t.segment===void 0||r===0)return!0;let n=t,s=t.segment+1,o=0;for(;o>-r/2;){if(s--,s<0)return!1;o-=e[s].dist(n),n=e[s]}o+=e[s].dist(e[s+1]),s++;let l=[],u=0;for(;o<r/2;){let h=e[s-1],c=e[s],d=e[s+1];if(!d)return!1;let p=h.angleTo(c)-c.angleTo(d);for(p=Math.abs((p+3*Math.PI)%(Math.PI*2)-Math.PI),l.push({distance:o,angleDelta:p}),u+=p;o-l[0].distance>i;)u-=l.shift().angleDelta;if(u>a)return!1;s++,o+=c.dist(d)}return!0}function E0(e){let t=0;for(let r=0;r<e.length-1;r++)t+=e[r].dist(e[r+1]);return t}function P0(e,t,r){return e?3/5*t*r:0}function A0(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function NS(e,t,r,i,a,n){let s=P0(r,a,n),o=A0(r,i)*n,l=0,u=E0(e)/2;for(let h=0;h<e.length-1;h++){let c=e[h],d=e[h+1],p=c.dist(d);if(l+p>u){let f=(u-l)/p,m=new La(We.number(c.x,d.x,f),We.number(c.y,d.y,f),d.angleTo(c),h);return m._round(),!s||S0(e,m,o,s,t)?m:void 0}l+=p}}function US(e,t,r,i,a,n,s,o,l){let u=P0(i,n,s),h=A0(i,a),c=h*s,d=e[0].x===0||e[0].x===l||e[0].y===0||e[0].y===l;t-c<t/4&&(t=c+t/4);let p=n*2;return C0(e,d?t/2*o%t:(h/2+p)*s*o%t,t,u,r,c,d,!1,l)}function C0(e,t,r,i,a,n,s,o,l){let u=n/2,h=E0(e),c=0,d=t-r,p=[];for(let f=0;f<e.length-1;f++){let m=e[f],g=e[f+1],_=m.dist(g),y=g.angleTo(m);for(;d+r<c+_;){d+=r;let v=(d-c)/_,x=We.number(m.x,g.x,v),w=We.number(m.y,g.y,v);if(x>=0&&x<l&&w>=0&&w<l&&d-u>=0&&d+u<=h){let b=new La(x,w,y,f);b._round(),(!i||S0(e,b,n,i,a))&&p.push(b)}}c+=_}return!o&&!p.length&&!s&&(p=C0(e,c/2,r,i,a,n,s,!0,l)),p}function I0(e,t,r,i,a){let n=[];for(let s of e){let o;for(let l=0;l<s.length-1;l++){let u=s[l],h=s[l+1];u.x<t&&h.x<t||(u.x<t?u=new C(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round():h.x<t&&(h=new C(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round()),!(u.y<r&&h.y<r)&&(u.y<r?u=new C(u.x+(h.x-u.x)*((r-u.y)/(h.y-u.y)),r)._round():h.y<r&&(h=new C(u.x+(h.x-u.x)*((r-u.y)/(h.y-u.y)),r)._round()),!(u.x>=i&&h.x>=i)&&(u.x>=i?u=new C(i,u.y+(h.y-u.y)*((i-u.x)/(h.x-u.x)))._round():h.x>=i&&(h=new C(i,u.y+(h.y-u.y)*((i-u.x)/(h.x-u.x)))._round()),!(u.y>=a&&h.y>=a)&&(u.y>=a?u=new C(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round():h.y>=a&&(h=new C(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round()),(!o||!u.equals(o[o.length-1]))&&(o=[u],n.push(o)),o.push(h)))))}}return n}function em(e,t,r,i){let a=[],n=e.image,s=n.pixelRatio,o=n.paddedRect.w-2,l=n.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},h=n.stretchX||[[0,o]],c=n.stretchY||[[0,l]],d=(A,E)=>A+E[1]-E[0],p=h.reduce(d,0),f=c.reduce(d,0),m=o-p,g=l-f,_=0,y=p,v=0,x=f,w=0,b=m,T=0,P=g;if(n.content&&i){let A=n.content,E=A[2]-A[0],z=A[3]-A[1];(n.textFitWidth||n.textFitHeight)&&(u=T0(e)),_=to(h,0,A[0]),v=to(c,0,A[1]),y=to(h,A[0],A[2]),x=to(c,A[1],A[3]),w=A[0]-_,T=A[1]-v,b=E-y,P=z-x}let S=u.x1,I=u.y1,R=u.x2-S,F=u.y2-I,D=(A,E,z,L)=>{let B=ro(A.stretch-_,y,R,S),V=io(A.fixed-w,b,A.stretch,p),Q=ro(E.stretch-v,x,F,I),le=io(E.fixed-T,P,E.stretch,f),De=ro(z.stretch-_,y,R,S),pe=io(z.fixed-w,b,z.stretch,p),Be=ro(L.stretch-v,x,F,I),xe=io(L.fixed-T,P,L.stretch,f),Ue=new C(B,Q),Ee=new C(De,Q),pt=new C(De,Be),yt=new C(B,Be),Nt=new C(V/s,le/s),Ut=new C(pe/s,xe/s),Tt=t*Math.PI/180;if(Tt){let Z=Math.sin(Tt),ge=Math.cos(Tt),re=[ge,-Z,Z,ge];Ue._matMult(re),Ee._matMult(re),yt._matMult(re),pt._matMult(re)}let nt=A.stretch+A.fixed,Yt=z.stretch+z.fixed,vr=E.stretch+E.fixed,sr=L.stretch+L.fixed;return{tl:Ue,tr:Ee,bl:yt,br:pt,tex:{x:n.paddedRect.x+1+nt,y:n.paddedRect.y+1+vr,w:Yt-nt,h:sr-vr},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Nt,pixelOffsetBR:Ut,minFontScaleX:b/s/R,minFontScaleY:P/s/F,isSDF:r}};if(!i||!n.stretchX&&!n.stretchY)a.push(D({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:o+1},{fixed:0,stretch:l+1}));else{let A=tm(h,m,p),E=tm(c,g,f);for(let z=0;z<A.length-1;z++){let L=A[z],B=A[z+1];for(let V=0;V<E.length-1;V++){let Q=E[V],le=E[V+1];a.push(D(L,Q,B,le))}}}return a}function to(e,t,r){let i=0;for(let a of e)i+=Math.max(t,Math.min(r,a[1]))-Math.max(t,Math.min(r,a[0]));return i}function tm(e,t,r){let i=[{fixed:-1,stretch:0}];for(let[a,n]of e){let s=i[i.length-1];i.push({fixed:a-s.stretch,stretch:s.stretch}),i.push({fixed:a-s.stretch,stretch:s.stretch+(n-a)})}return i.push({fixed:t+1,stretch:r}),i}function ro(e,t,r,i){return e/t*r+i}function io(e,t,r,i){return e-t*r/i}function GS(e,t,r,i,a,n,s,o){let l=i.layout.get("text-rotate").evaluate(n,{})*Math.PI/180,u=[];for(let h of t.positionedLines)for(let c of h.positionedGlyphs){if(!c.rect)continue;let d=c.rect||{},p=4,f=!0,m=1,g=0,_=(a||o)&&c.vertical,y=c.metrics.advance*c.scale/2;if(o&&t.verticalizable){let L=(c.scale-1)*24,B=(24-c.metrics.width*c.scale)/2;g=h.lineOffset/2-(c.imageName?-B:L)}if(c.imageName){let L=s[c.imageName];f=L.sdf,m=L.pixelRatio,p=1/m}let v=a?[c.x+y,c.y]:[0,0],x=a?[0,0]:[c.x+y+r[0],c.y+r[1]-g],w=[0,0];_&&(w=x,x=[0,0]);let b=c.metrics.isDoubleResolution?2:1,T=(c.metrics.left-p)*c.scale-y+x[0],P=(-c.metrics.top-p)*c.scale+x[1],S=T+d.w/b*c.scale/m,I=P+d.h/b*c.scale/m,R=new C(T,P),F=new C(S,P),D=new C(T,I),A=new C(S,I);if(_){let L=new C(-y,y- -17),B=-Math.PI/2,V=12-y,Q=c.imageName?V:0,le=new C(22-V,-Q),De=new C(...w);R._rotateAround(B,L)._add(le)._add(De),F._rotateAround(B,L)._add(le)._add(De),D._rotateAround(B,L)._add(le)._add(De),A._rotateAround(B,L)._add(le)._add(De)}if(l){let L=Math.sin(l),B=Math.cos(l),V=[B,-L,L,B];R._matMult(V),F._matMult(V),D._matMult(V),A._matMult(V)}let E=new C(0,0),z=new C(0,0);u.push({tl:R,tr:F,bl:D,br:A,tex:d,writingMode:t.writingMode,glyphOffset:v,sectionIndex:c.sectionIndex,isSDF:f,pixelOffsetTL:E,pixelOffsetBR:z,minFontScaleX:0,minFontScaleY:0})}return u}var ao=class{constructor(e,t,r,i,a,n,s,o,l,u){var h;if(this.boxStartIndex=e.length,l){let c=n.top,d=n.bottom,p=n.collisionPadding;p&&(c-=p[1],d+=p[3]);let f=d-c;f>0&&(f=Math.max(10,f),this.circleDiameter=f)}else{let c=(h=n.image)!=null&&h.content&&(n.image.textFitWidth||n.image.textFitHeight)?T0(n):{x1:n.left,y1:n.top,x2:n.right,y2:n.bottom};c.y1=c.y1*s-o[0],c.y2=c.y2*s+o[2],c.x1=c.x1*s-o[3],c.x2=c.x2*s+o[1];let d=n.collisionPadding;if(d&&(c.x1-=d[0]*s,c.y1-=d[1]*s,c.x2+=d[2]*s,c.y2+=d[3]*s),u){let p=new C(c.x1,c.y1),f=new C(c.x2,c.y1),m=new C(c.x1,c.y2),g=new C(c.x2,c.y2),_=u*Math.PI/180;p._rotate(_),f._rotate(_),m._rotate(_),g._rotate(_),c.x1=Math.min(p.x,f.x,m.x,g.x),c.x2=Math.max(p.x,f.x,m.x,g.x),c.y1=Math.min(p.y,f.y,m.y,g.y),c.y2=Math.max(p.y,f.y,m.y,g.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,r,i,a)}this.boxEndIndex=e.length}},qS=class{constructor(e=[],t=(r,i)=>r<i?-1:+(r>i)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:r}=this,i=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(r(i,n)>=0)break;t[e]=n,e=a}t[e]=i}_down(e){let{data:t,compare:r}=this,i=this.length>>1,a=t[e];for(;e<i;){let n=(e<<1)+1,s=n+1;if(s<this.length&&r(t[s],t[n])<0&&(n=s),r(t[n],a)>=0)break;t[e]=t[n],e=n}t[e]=a}};function ZS(e,t=1){let r=Pr.fromPoints(e[0]),i=Math.min(r.width(),r.height()),a=i/2,n=new qS([],WS),{minX:s,minY:o,maxX:l,maxY:u}=r;if(i===0)return new C(s,o);for(let d=s;d<l;d+=i)for(let p=o;p<u;p+=i)n.push(new Ca(d+a,p+a,a,e));let h=XS(e),c=h;for(;n.length;){let d=n.pop();(d.d>c.d||!c.d)&&(c=d),!(d.max-c.d<=t)&&(a=d.h/2,n.push(new Ca(d.p.x-a,d.p.y-a,a,e)),n.push(new Ca(d.p.x+a,d.p.y-a,a,e)),n.push(new Ca(d.p.x-a,d.p.y+a,a,e)),n.push(new Ca(d.p.x+a,d.p.y+a,a,e)))}return h.d>0&&c.d-h.d<=t?h.p:c.p}function WS(e,t){return t.max-e.max}var Ca=class{constructor(e,t,r,i){this.p=new C(e,t),this.h=r,this.d=HS(this.p,i),this.max=this.d+this.h*Math.SQRT2}};function HS(e,t){let r=!1,i=1/0;for(let a of t)for(let n=0,s=a.length,o=s-1;n<s;o=n++){let l=a[n],u=a[o];l.y>e.y!=u.y>e.y&&e.x<(u.x-l.x)*(e.y-l.y)/(u.y-l.y)+l.x&&(r=!r),i=Math.min(i,Oy(e,l,u))}return(r?1:-1)*Math.sqrt(i)}function XS(e){let t=0,r=0,i=0,a=e[0];for(let n=0,s=a.length,o=s-1;n<s;o=n++){let l=a[n],u=a[o],h=l.x*u.y-u.x*l.y;r+=(l.x+u.x)*h,i+=(l.y+u.y)*h,t+=h*3}return new Ca(r/t,i/t,0,e)}let _c=function(e){return e[e.center=1]="center",e[e.left=2]="left",e[e.right=3]="right",e[e.top=4]="top",e[e.bottom=5]="bottom",e[e["top-left"]=6]="top-left",e[e["top-right"]=7]="top-right",e[e["bottom-left"]=8]="bottom-left",e[e["bottom-right"]=9]="bottom-right",e}({});const Ed=1/0;function M0(e,t){function r(a,n){let s=0,o=0;n<0&&(n=0);let l=n/Math.SQRT2;switch(a){case"top-right":case"top-left":o=l-7;break;case"bottom-right":case"bottom-left":o=-l+7;break;case"bottom":o=-n+7;break;case"top":o=n-7}switch(a){case"top-right":case"bottom-right":s=-l;break;case"top-left":case"bottom-left":s=l;break;case"left":s=n;break;case"right":s=-n}return[s,o]}function i(a,n,s){let o=0,l=0;switch(n=Math.abs(n),s=Math.abs(s),a){case"top-right":case"top-left":case"top":l=s-7;break;case"bottom-right":case"bottom-left":case"bottom":l=-s+7}switch(a){case"top-right":case"bottom-right":case"right":o=-n;break;case"top-left":case"bottom-left":case"left":o=n}return[o,l]}return t[1]===Ed?r(e,t[0]):i(e,t[0],t[1])}function z0(e,t,r){var s;let i=e.layout,a=(s=i.get("text-variable-anchor-offset"))==null?void 0:s.evaluate(t,{},r);if(a){let o=a.values,l=[];for(let u=0;u<o.length;u+=2){let h=l[u]=o[u],c=o[u+1].map(d=>d*24);h.startsWith("top")?c[1]-=7:h.startsWith("bottom")&&(c[1]+=7),l[u+1]=c}return new Zr(l)}let n=i.get("text-variable-anchor");if(n){let o;o=e._unevaluatedLayout.getValue("text-radial-offset")===void 0?i.get("text-offset").evaluate(t,{},r).map(u=>u*24):[i.get("text-radial-offset").evaluate(t,{},r)*24,Ed];let l=[];for(let u of n)l.push(u,M0(u,o));return new Zr(l)}return null}function YS(e){var h,c;e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=k/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let r=e.bucket.layers[0],i=r.layout,a=r._unevaluatedLayout._values,n={layoutIconSize:a["icon-size"].possiblyEvaluate(new ze(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new ze(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new ze(18))};if(e.bucket.textSizeData.kind==="composite"){let{minZoom:d,maxZoom:p}=e.bucket.textSizeData;n.compositeTextSizes=[a["text-size"].possiblyEvaluate(new ze(d),e.canonical),a["text-size"].possiblyEvaluate(new ze(p),e.canonical)]}if(e.bucket.iconSizeData.kind==="composite"){let{minZoom:d,maxZoom:p}=e.bucket.iconSizeData;n.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new ze(d),e.canonical),a["icon-size"].possiblyEvaluate(new ze(p),e.canonical)]}let s=i.get("text-line-height")*24,o=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",l=i.get("text-keep-upright"),u=i.get("text-size");for(let d of e.bucket.features){let p=i.get("text-font").evaluate(d,{},e.canonical).join(","),f=u.evaluate(d,{},e.canonical),m=n.layoutTextSize.evaluate(d,{},e.canonical),g=n.layoutIconSize.evaluate(d,{},e.canonical),_={horizontal:{},vertical:void 0},y=d.text,v=[0,0];if(y){let T=y.toString(),P=i.get("text-letter-spacing").evaluate(d,{},e.canonical)*24,S=qD(T)?P:0,I=i.get("text-anchor").evaluate(d,{},e.canonical),R=z0(r,d,e.canonical);if(!R){let E=i.get("text-radial-offset").evaluate(d,{},e.canonical);v=E?M0(I,[E*24,Ed]):i.get("text-offset").evaluate(d,{},e.canonical).map(z=>z*24)}let F=o?"center":i.get("text-justify").evaluate(d,{},e.canonical),D=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(d,{},e.canonical)*24:1/0,A=()=>{e.bucket.allowVerticalPlacement&&fc(T)&&(_.vertical=eo(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,D,s,I,"left",S,v,2,!0,m,f))};if(!o&&R){let E=new Set;if(F==="auto")for(let L=0;L<R.values.length;L+=2)E.add(yc(R.values[L]));else E.add(F);let z=!1;for(let L of E)if(!_.horizontal[L])if(z)_.horizontal[L]=_.horizontal[0];else{let B=eo(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,D,s,"center",L,S,v,1,!1,m,f);B&&(_.horizontal[L]=B,z=B.positionedLines.length===1)}A()}else{F==="auto"&&(F=yc(I));let E=eo(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,D,s,I,F,S,v,1,!1,m,f);E&&(_.horizontal[F]=E),A(),fc(T)&&o&&l&&(_.vertical=eo(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,D,s,I,F,S,v,2,!1,m,f))}}let x,w=!1;if((h=d.icon)!=null&&h.name){let T=e.imageMap[d.icon.name];T&&(x=BS(e.imagePositions[d.icon.name],i.get("icon-offset").evaluate(d,{},e.canonical),i.get("icon-anchor").evaluate(d,{},e.canonical)),w=!!T.sdf,e.bucket.sdfIcons===void 0?e.bucket.sdfIcons=w:e.bucket.sdfIcons!==w&&_e("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),T.pixelRatio===e.bucket.pixelRatio?i.get("icon-rotate").constantOr(1)!==0&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let b=F0(_.horizontal)||_.vertical;(c=e.bucket).iconsInText||(c.iconsInText=b?b.iconsInText:!1),(b||x)&&KS(e.bucket,d,_,x,e.imageMap,n,m,g,v,w,e.canonical,e.subdivisionGranularity,e.hasPromoteId)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}function yc(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function KS(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=n.textMaxSize.evaluate(t,{});p===void 0&&(p=s);let f=e.layers[0].layout,m=f.get("icon-offset").evaluate(t,{},h),g=F0(r.horizontal),_=s/24,y=e.tilePixelRatio*_,v=e.tilePixelRatio*p/24,x=e.tilePixelRatio*o,w=e.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*e.tilePixelRatio,T=hE(f,t,h,e.tilePixelRatio),P=f.get("text-max-angle")/180*Math.PI,S=f.get("text-rotation-alignment")!=="viewport"&&f.get("symbol-placement")!=="point",I=f.get("icon-rotation-alignment").constantOr("viewport")==="map"&&f.get("symbol-placement")!=="point",R=f.get("symbol-placement"),F=w/2,D=f.get("icon-text-fit"),A;i&&D!=="none"&&(e.allowVerticalPlacement&&r.vertical&&(A=Kf(i,r.vertical,D,f.get("icon-text-fit-padding"),m,_)),g&&(i=Kf(i,g,D,f.get("icon-text-fit-padding"),m,_)));let E=h?c.line.getGranularityForZoomLevel(h.z):1,z=(L,B)=>{B.x<0||B.x>=8192||B.y<0||B.y>=8192||QS(e,B,L,r,i,a,A,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,y,[b,b,b,b],S,l,x,T,I,m,t,n,u,h,s,d)};if(R==="line")for(let L of I0(t.geometry,0,0,k,k)){let B=Vi(L,E),V=US(B,w,P,r.vertical||g,i,24,v,e.overscaling,k);for(let Q of V){let le=g;(!le||!eE(e,le.text,F,Q))&&z(B,Q)}}else if(R==="line-center"){for(let L of t.geometry)if(L.length>1){let B=Vi(L,E),V=NS(B,P,r.vertical||g,i,24,v);V&&z(B,V)}}else if(t.type==="Polygon")for(let L of Dl(t.geometry,0)){let B=ZS(L,16);z(Vi(L[0],E,!0),new La(B.x,B.y,0))}else if(t.type==="LineString")for(let L of t.geometry){let B=Vi(L,E);z(B,new La(B[0].x,B[0].y,0))}else if(t.type==="Point")for(let L of t.geometry)for(let B of L)z([B],new La(B.x,B.y,0))}function JS(e,t){let r=e.length,i=t==null?void 0:t.values;if((i==null?void 0:i.length)>0)for(let a=0;a<i.length;a+=2){let n=_c[i[a]],s=i[a+1];e.emplaceBack(n,s[0],s[1])}return[r,e.length]}function rm(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m){let g=GS(t,r,o,a,n,s,i,e.allowVerticalPlacement),_=e.textSizeData,y=null;_.kind==="source"?(y=[128*a.layout.get("text-size").evaluate(s,{})],y[0]>32640&&_e(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):_.kind==="composite"&&(y=[128*f.compositeTextSizes[0].evaluate(s,{},m),128*f.compositeTextSizes[1].evaluate(s,{},m)],(y[0]>32640||y[1]>32640)&&_e(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,y,o,n,s,h,t,u.lineStartIndex,u.lineLength,p,m,l);for(let v of c)d[v]=e.text.placedSymbolArray.length-1;return g.length*4}function F0(e){for(let t in e)return e[t];return null}function QS(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w,b,T,P,S){let I=e.addToLineVertexArray(t,r),R=o.layout.get("symbol-height-offset").evaluate(x,{},T);R>e.maxHeightOffset&&(e.maxHeightOffset=R);let F,D,A,E,z=0,L=0,B=0,V=0,Q=-1,le=-1,De={},pe=(0,Yo.default)("");if(e.allowVerticalPlacement&&i.vertical){let re=o.layout.get("text-rotate").evaluate(x,{},T)+90,$=i.vertical;A=new ao(l,t,u,h,c,$,d,p,f,re),s&&(E=new ao(l,t,u,h,c,s,g,_,f,re))}if(a){let re=o.layout.get("icon-rotate").evaluate(x,{}),$=o.layout.get("icon-text-fit")!=="none",ye=em(a,re,b,$),ee=s?em(s,re,b,$):void 0;D=new ao(l,t,u,h,c,a,g,_,!1,re),z=ye.length*4;let ie=e.iconSizeData,q=null;ie.kind==="source"?(q=[128*o.layout.get("icon-size").evaluate(x,{})],q[0]>32640&&_e(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):ie.kind==="composite"&&(q=[128*w.compositeIconSizes[0].evaluate(x,{},T),128*w.compositeIconSizes[1].evaluate(x,{},T)],(q[0]>32640||q[1]>32640)&&_e(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,ye,q,v,y,x,0,t,I.lineStartIndex,I.lineLength,-1,T,R),Q=e.icon.placedSymbolArray.length-1,ee&&(L=ee.length*4,e.addSymbols(e.icon,ee,q,v,y,x,2,t,I.lineStartIndex,I.lineLength,-1,T,R),le=e.icon.placedSymbolArray.length-1)}let Be=Object.keys(i.horizontal);for(let re of Be){let $=i.horizontal[re];F||(F=(pe=(0,Yo.default)($.text),new ao(l,t,u,h,c,$,d,p,f,o.layout.get("text-rotate").evaluate(x,{},T))));let ye=$.positionedLines.length===1;if(B+=rm(e,t,$,n,o,f,x,m,R,I,i.vertical?1:3,ye?Be:[re],De,Q,w,T),ye)break}i.vertical&&(V+=rm(e,t,i.vertical,n,o,f,x,m,R,I,2,["vertical"],De,le,w,T));let xe=F?F.boxStartIndex:e.collisionBoxArray.length,Ue=F?F.boxEndIndex:e.collisionBoxArray.length,Ee=A?A.boxStartIndex:e.collisionBoxArray.length,pt=A?A.boxEndIndex:e.collisionBoxArray.length,yt=D?D.boxStartIndex:e.collisionBoxArray.length,Nt=D?D.boxEndIndex:e.collisionBoxArray.length,Ut=E?E.boxStartIndex:e.collisionBoxArray.length,Tt=E?E.boxEndIndex:e.collisionBoxArray.length,nt=-1,Yt=(re,$)=>re!=null&&re.circleDiameter?Math.max(re.circleDiameter,$):$;nt=Yt(F,nt),nt=Yt(A,nt),nt=Yt(D,nt),nt=Yt(E,nt);let vr=+(nt>-1);vr&&(nt*=P/24),e.glyphOffsetArray.length>=e.maxGlyphs&&_e("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),x.sortKey!==void 0&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey);let sr=z0(o,x,T),[Z,ge]=JS(e.textAnchorOffsets,sr);S&&(pe=tE(pe,x)),e.symbolInstances.emplaceBack(t.x,t.y,De.right>=0?De.right:-1,De.center>=0?De.center:-1,De.left>=0?De.left:-1,De.vertical||-1,Q,le,pe,xe,Ue,Ee,pt,yt,Nt,Ut,Tt,u,B,V,z,L,vr,0,d,nt,Z,ge,R)}function eE(e,t,r,i){let a=e.compareText;if(!(t in a))a[t]=[];else{let n=a[t];for(let s=n.length-1;s>=0;s--)if(i.dist(n[s])<r)return!0}return a[t].push(i),!1}function tE(e,t){var r;return t.id==null||(r=t.properties)!=null&&r.cluster?e:(0,Yo.default)(String(t.id),e)}function al(e,t,r){let i="never",a=e.get(t);return a?i=a:e.get(r)&&(i="always"),i}const rE=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function no(e,t,r,i,a,n,s,o,l,u,h,c,d,p){let f=o?Math.min(Jf,Math.round(o[0])):0,m=o?Math.min(Jf,Math.round(o[1])):0;e.emplaceBack(t,r,Math.round(i*32),Math.round(a*32),n,s,(f<<1)+ +!!l,m,u*16,h*16,c*256,d*256,p)}function nl(e,t,r){e.emplaceBack(t.x,t.y,r),e.emplaceBack(t.x,t.y,r),e.emplaceBack(t.x,t.y,r),e.emplaceBack(t.x,t.y,r)}function iE(e){for(let t of e.sections)if(f0(t.text))return!0;return!1}var xc=class{constructor(e){this.layoutVertexArray=new H2,this.indexArray=new Yr,this.programConfigurations=e,this.segments=new Ze,this.dynamicLayoutVertexArray=new X2,this.opacityVertexArray=new Y2,this.hasVisibleVertices=!1,this.placedSymbolArray=new wy}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,r,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,fD.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,mD.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,rE,!0),this.opacityVertexBuffer.itemSize=1),(r||i)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}};G("SymbolBuffers",xc);var vc=class{constructor(e,t,r){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new r,this.segments=new Ze,this.collisionVertexArray=new J2}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,gD.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};G("CollisionBuffers",vc);var sl=class{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(s=>s.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!0,this.hasRTLText=!1,this.maxHeightOffset=0,this.sortKeyRanges=[],this.collisionCircleArray=[],this.maxGlyphs=65535;let t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Qf(this.zoom,t["text-size"]),this.iconSizeData=Qf(this.zoom,t["icon-size"]);let r=this.layers[0].layout,i=r.get("symbol-sort-key"),a=r.get("symbol-z-order");this.canOverlap=al(r,"text-overlap","text-allow-overlap")!=="never"||al(r,"icon-overlap","icon-allow-overlap")!=="never"||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey=a!=="viewport-y"&&!i.isConstant();let n=a==="viewport-y"||a==="auto"&&!this.sortFeaturesByKey;this.sortFeaturesByY=n&&this.canOverlap,r.get("symbol-placement")==="point"&&(this.writingModes=r.get("text-writing-mode").map(s=>x0[s])),this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.sourceID=e.sourceID}createArrays(){this.text=new xc(new Qi(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new xc(new Qi(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new Sy,this.lineVertexArray=new Ey,this.symbolInstances=new Dy,this.textAnchorOffsets=new Ay}calculateGlyphDependencies(e,t,r,i,a){var l;let n=(i||this.allowVerticalPlacement)&&a,s=wd.fromFeature(e,r),o=s.graphemes();for(let u=0;u<o.length;u++){let h=s.getSection(u);if("imageName"in h)continue;let c=(t[l=h.fontStack]||(t[l]={default:{}})).default,d=o[u];rl(d)&&(c[d]=!0);for(let p of d){if(c[p]=!0,!n)continue;let f=Ma[p];f&&(c[f]=!0)}}}populate(e,t,r){var m;let i=this.layers[0],a=i.layout,n=a.get("text-font"),s=a.get("text-field"),o=a.get("icon-image"),l=(s.value.kind!=="constant"||s.value.value instanceof ui&&!s.value.value.isEmpty()||s.value.value.toString().length>0)&&(n.value.kind!=="constant"||n.value.value.length>0),u=o.value.kind!=="constant"||!!o.value.value||Object.keys(o.parameters).length>0,h=a.get("symbol-sort-key");if(this.features=[],!l&&!u)return;let c=t.iconDependencies,d=t.glyphDependencies,p=t.availableImages,f=new ze(this.zoom);for(let{feature:g,id:_,index:y,sourceLayerIndex:v}of e){let x=i._featureFilter.needGeometry,w=sa(g,x);if(!i._featureFilter.filter(f,w,r))continue;x||(w.geometry=na(g));let b;if(l){let I=i.getValueAndResolveTokens("text-field",w,r,p),R=ui.factory(I);this.hasRTLText||(this.hasRTLText=iE(R)),b=VD(R,i,w)}let T;if(u){let I=i.getValueAndResolveTokens("icon-image",w,r,p);T=I instanceof Wr?I:Wr.fromString(I)}if(!b&&!T)continue;let P=this.sortFeaturesByKey?h.evaluate(w,{},r):void 0,S={id:_,text:b,icon:T,index:y,sourceLayerIndex:v,geometry:w.geometry,properties:g.properties,type:xs.types[g.type],sortKey:P};if(this.features.push(S),T&&(c[T.name]=!0),b){let I=n.evaluate(w,{},r).join(","),R=a.get("text-rotation-alignment")!=="viewport"&&a.get("symbol-placement")!=="point";this.allowVerticalPlacement=(m=this.writingModes)==null?void 0:m.includes(2);let F=fc(b.toString());this.calculateGlyphDependencies(b,d,I,R,F);for(let D of b.sections)D.image&&(c[D.image.name]=!0)}}a.get("symbol-placement")==="line"&&(this.features=UD(this.features)),this.sortFeaturesByKey&&this.features.sort((g,_)=>g.sortKey-_.sortKey)}update(e,t,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:r}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:r}))}addFeatures({options:e,canonical:t,glyphMap:r,glyphPositions:i,iconMap:a,iconPositions:n,showCollisionBoxes:s}){YS({bucket:this,glyphMap:r,glyphPositions:i,imageMap:a,imagePositions:n,showCollisionBoxes:s,canonical:t,subdivisionGranularity:e.subdivisionGranularity,hasPromoteId:e.featureIndex.promoteId!=null})}isEmpty(){return this.symbolInstances.length===0}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let r=this.lineVertexArray.length;if(e.segment!==void 0){let i=e.dist(t[e.segment+1]),a=e.dist(t[e.segment]),n={};for(let s=e.segment+1;s<t.length;s++)n[s]={x:t[s].x,y:t[s].y,tileUnitDistanceFromAnchor:i},s<t.length-1&&(i+=t[s+1].dist(t[s]));for(let s=e.segment||0;s>=0;s--)n[s]={x:t[s].x,y:t[s].y,tileUnitDistanceFromAnchor:a},s>0&&(a+=t[s-1].dist(t[s]));for(let s=0;s<t.length;s++){let o=n[s];this.lineVertexArray.emplaceBack(o.x,o.y,o.tileUnitDistanceFromAnchor)}}return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=e.indexArray,f=e.layoutVertexArray,m=e.segments.prepareSegment(4*t.length,f,p,this.canOverlap?n.sortKey:void 0),g=this.glyphOffsetArray.length,_=m.vertexLength,y=this.allowVerticalPlacement&&s===2?Math.PI/2:0,v=n.text&&n.text.sections;for(let x=0;x<t.length;x++){let{tl:w,tr:b,bl:T,br:P,tex:S,pixelOffsetTL:I,pixelOffsetBR:R,minFontScaleX:F,minFontScaleY:D,glyphOffset:A,isSDF:E,sectionIndex:z}=t[x],L=m.vertexLength,B=A[1];no(f,o.x,o.y,w.x,B+w.y,S.x,S.y,r,E,I.x,I.y,F,D,d),no(f,o.x,o.y,b.x,B+b.y,S.x+S.w,S.y,r,E,R.x,I.y,F,D,d),no(f,o.x,o.y,T.x,B+T.y,S.x,S.y+S.h,r,E,I.x,R.y,F,D,d),no(f,o.x,o.y,P.x,B+P.y,S.x+S.w,S.y+S.h,r,E,R.x,R.y,F,D,d),nl(e.dynamicLayoutVertexArray,o,y),p.emplaceBack(L,L+2,L+1),p.emplaceBack(L+1,L+2,L+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(A[0]),(x===t.length-1||z!==t[x+1].sectionIndex)&&e.programConfigurations.populatePaintArrays(f.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:v==null?void 0:v[z]})}e.placedSymbolArray.emplaceBack(o.x,o.y,g,this.glyphOffsetArray.length-g,_,l,u,o.segment,r?r[0]:0,r?r[1]:0,i[0],i[1],s,0,!1,0,h,d)}_addCollisionDebugVertex(e,t,r,i,a,n){return t.emplaceBack(0,0),e.emplaceBack(r.x,r.y,i,a,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(e,t,r,i,a,n,s){let o=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=o.vertexLength,u=a.layoutVertexArray,h=a.collisionVertexArray,c=s.anchorX,d=s.anchorY;this._addCollisionDebugVertex(u,h,n,c,d,new C(e,t)),this._addCollisionDebugVertex(u,h,n,c,d,new C(r,t)),this._addCollisionDebugVertex(u,h,n,c,d,new C(r,i)),this._addCollisionDebugVertex(u,h,n,c,d,new C(e,i)),o.vertexLength+=4;let p=a.indexArray;p.emplaceBack(l,l+1),p.emplaceBack(l+1,l+2),p.emplaceBack(l+2,l+3),p.emplaceBack(l+3,l),o.primitiveLength+=4}addDebugCollisionBoxes(e,t,r,i){for(let a=e;a<t;a++){let n=this.collisionBoxArray.get(a),s=n.x1,o=n.y1,l=n.x2,u=n.y2;this.addCollisionDebugVertices(s,o,l,u,i?this.textCollisionBox:this.iconCollisionBox,n.anchorPoint,r)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new vc(yf,kf.members,Kh),this.iconCollisionBox=new vc(yf,kf.members,Kh);for(let e=0;e<this.symbolInstances.length;e++){let t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,r,i,a,n,s,o,l){let u={};for(let h=t;h<r;h++){let c=e.get(h);u.textBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.textFeatureIndex=c.featureIndex;break}for(let h=i;h<a;h++){let c=e.get(h);u.verticalTextBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.verticalTextFeatureIndex=c.featureIndex;break}for(let h=n;h<s;h++){let c=e.get(h);u.iconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.iconFeatureIndex=c.featureIndex;break}for(let h=o;h<l;h++){let c=e.get(h);u.verticalIconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,anchorPointX:c.anchorPointX,anchorPointY:c.anchorPointY},u.verticalIconFeatureIndex=c.featureIndex;break}return u}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){let r=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let r=e.placedSymbolArray.get(t),i=r.vertexStartIndex+r.numGlyphs*4;for(let a=r.vertexStartIndex;a<i;a+=4)e.indexArray.emplaceBack(a,a+2,a+1),e.indexArray.emplaceBack(a+1,a+2,a+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let t=Math.sin(e),r=Math.cos(e),i=[],a=[],n=[];for(let s=0;s<this.symbolInstances.length;++s){n.push(s);let o=this.symbolInstances.get(s);i.push(Math.round(t*o.anchorX+r*o.anchorY)|0),a.push(o.featureIndex)}return n.sort((s,o)=>i[s]-i[o]||a[o]-a[s]),n}addToSortKeyRanges(e,t){let r=this.sortKeyRanges[this.sortKeyRanges.length-1];(r==null?void 0:r.sortKey)===t?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let t of this.symbolInstanceIndexes){let r=this.symbolInstances.get(t);this.featureSortOrder.push(r.featureIndex);let i=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(let a=0;a<i.length;a++){let n=i[a];n>=0&&i.indexOf(n)===a&&this.addIndicesForPlacedSymbol(this.text,n)}r.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,r.verticalPlacedTextSymbolIndex),r.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.placedIconSymbolIndex),r.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,r.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};G("SymbolBucket",sl,{omit:["layers","collisionBoxArray","features","compareText"]});function aE(e,t){return t.replace(/{([^{}]+)}/g,(r,i)=>e&&i in e?String(e[i]):"")}let nE;const sE=()=>nE||(nE=new wt({"symbol-placement":new N(M.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new N(M.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new N(M.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new Y(M.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new N(M.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new N(M.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new N(M.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new N(M.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new N(M.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new Y(M.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new Y(M.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new N(M.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new N(M.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new Y(M.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new Y(M.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new Y(M.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new N(M.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new Y(M.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new Y(M.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new N(M.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new N(M.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new N(M.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new Y(M.layout_symbol["text-field"],"text-field"),"text-font":new Y(M.layout_symbol["text-font"],"text-font"),"text-size":new Y(M.layout_symbol["text-size"],"text-size"),"text-max-width":new Y(M.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new N(M.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new Y(M.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new Y(M.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new Y(M.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new N(M.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new Y(M.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new Y(M.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new N(M.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new N(M.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new Y(M.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new N(M.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new N(M.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new Y(M.layout_symbol["text-transform"],"text-transform"),"text-offset":new Y(M.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new N(M.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new N(M.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new N(M.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new N(M.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new Y(M.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new N(M.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")}));let oE;const lE=()=>oE||(oE=new wt({"icon-opacity":new Y(M.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new Y(M.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new Y(M.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new Y(M.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new Y(M.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new N(M.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new N(M.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new Y(M.paint_symbol["text-opacity"],"text-opacity"),"text-color":new Y(M.paint_symbol["text-color"],"text-color",{runtimeType:Er,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Y(M.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new Y(M.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new Y(M.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new N(M.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new N(M.paint_symbol["text-translate-anchor"],"text-translate-anchor")}));var Ou={get paint(){return lE()},get layout(){return sE()}},R0=class{constructor(e){if(e.property.overrides===void 0)throw Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:cs,this.defaultValue=e}evaluate(e){if(e.formattedSection){let t=this.defaultValue.property.overrides;if(t!=null&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){if(!this.defaultValue.isConstant()){let t=this.defaultValue.value;e(t._styleExpression.expression)}}outputDefined(){return!1}serialize(){return null}};G("FormatSectionOverride",R0,{omit:["defaultValue"]});const k0=e=>e.type==="symbol";var uE=class bc extends Mr{constructor(t,r){super(t,Ou,r)}recalculate(t,r){super.recalculate(t,r);let i=this.layout.get("icon-rotation-alignment");if((i.value.kind!=="constant"||i.value.value==="auto")&&(this.layout._values["icon-rotation-alignment"]=new gr(i.property,{kind:"constant",value:this.layout.get("symbol-placement")==="point"?"viewport":"map"},i.parameters)),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout.get("symbol-placement")==="point"?this.layout._values["text-rotation-alignment"]="viewport":this.layout._values["text-rotation-alignment"]="map"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment").constantOr("viewport")),this.layout.get("symbol-placement")==="point"){let a=this.layout.get("text-writing-mode");if(a){let n=[];for(let s of a)n.includes(s)||n.push(s);this.layout._values["text-writing-mode"]=n}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,r,i,a){let n=this.layout.get(t).evaluate(r,{},i,a),s=this._unevaluatedLayout._values[t];return!s.isDataDriven()&&!Cl(s.value)&&n?aE(r.properties,n):n}createBucket(t){return new sl(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of Ou.paint.overridableProperties){if(!bc.hasPaintOverride(this.layout,t))continue;let r=this.paint.get(t),i=new sd(new R0(r),`layers[${this.id}].paint.${r.property.name}`,r.property.specification),a=null;a=r.value.kind==="constant"||r.value.kind==="source"?new Xn("source",i):new Go("composite",i,r.value.zoomStops),this.paint._values[t]=new gr(r.property,a,r.parameters)}}_handleOverridablePaintPropertyUpdate(t,r,i){return!this.layout||r.isDataDriven()||i.isDataDriven()?!1:bc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,r){let i=t.get("text-field"),a=Ou.paint.properties[r],n=!1,s=o=>{var l;for(let u of o)if((l=a.overrides)!=null&&l.hasOverride(u)){n=!0;return}};if(i.value.kind==="constant"&&i.value.value instanceof ui)s(i.value.value.sections);else if(i.value.kind==="source"||i.value.kind==="composite"){let o=u=>{if(!n)if(u instanceof qa&&at(u.value)===ds){let h=u.value;s(h.sections)}else u instanceof l_?s(u.sections):u.eachChild(o)},l=i.value;l._styleExpression&&o(l._styleExpression.expression)}return n}};function hE(e,t,r,i=1){var n;let a=(n=e.get("icon-padding").evaluate(t,{},r))==null?void 0:n.values;return[a[0]*i,a[1]*i,a[2]*i,a[3]*i]}let cE;const dE=()=>cE||(cE=new wt({"background-color":new N(M.paint_background["background-color"],"background-color"),"background-pattern":new yy(M.paint_background["background-pattern"],"background-pattern"),"background-opacity":new N(M.paint_background["background-opacity"],"background-opacity")}));var pE={get paint(){return dE()}};const fE=e=>e.type==="background";var mE=class extends Mr{constructor(e,t){super(e,pE,t)}};function gE(e){let t=[],r=e.id;return r===void 0&&t.push(new O(`layers.${r}`,null,'missing required property "id"')),e.render===void 0&&t.push(new O(`layers.${r}`,null,'missing required method "render"')),e.renderingMode&&e.renderingMode!=="2d"&&e.renderingMode!=="3d"&&t.push(new O(`layers.${r}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}const _E=e=>e.type==="custom";var yE=class extends Mr{constructor(e,t){super(e,{},t),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error("Custom layers cannot be serialized")}};function $u(e,t){if(e.type==="custom")return new yE(e,t);switch(e.type){case"background":return new mE(e,t);case"circle":return new Cw(e,t);case"color-relief":return new qw(e,t);case"fill":return new ET(e,t);case"fill-extrusion":return new YT(e,t);case"heatmap":return new Rw(e,t);case"hillshade":return new $w(e,t);case"line":return new pD(e,t);case"raster":return new O2(e,t);case"symbol":return new uE(e,t)}}var xE=class{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var e;this._triggered||(this._triggered=!0,(e=this._channel)==null||e.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}};const vE={once:!0};var bE=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new xE(()=>this.process()),this.subscription=Oo(this.target,"message",r=>this.receive(r),!1),this.globalScope=Na(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((r,i)=>{let a=Math.round(Math.random()*1e18).toString(36).substring(0,10),n=t?Oo(t.signal,"abort",()=>{n==null||n.unsubscribe(),delete this.resolveRejects[a];let l={id:a,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(l),i(new hs(t.signal.reason))},vE):null;this.resolveRejects[a]={resolve:l=>{n==null||n.unsubscribe(),r(l)},reject:l=>{n==null||n.unsubscribe(),i(l)}};let s=[],o={...e,id:a,sourceMapId:this.mapId,origin:location.origin,data:Bn(e.data,s)};this.target.postMessage(o,{transfer:s})})}receive(e){let t=e.data,r=t.id,i=["file://","resource://android","null"],a=[t.origin,location.origin],n=t.origin===location.origin,s=a.some(o=>i.includes(o));if((n||s)&&!(t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[r];let o=this.abortControllers[r];delete this.abortControllers[r],o&&o.abort();return}if(Na(self)||t.mustQueue){this.tasks[r]=t,this.taskQueue.push(r),this.invoker.trigger();return}this.processTask(r,t)}}process(){if(this.taskQueue.length===0)return;let e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}async processTask(e,t){if(t.type==="<response>"){let a=this.resolveRejects[e];if(delete this.resolveRejects[e],!a)return;t.error?a.reject(zt(On(t.error))):a.resolve(On(t.data));return}if(!this.messageHandlers[t.type]){this.completeTask(e,null,null);return}let r=On(t.data),i=new AbortController;this.abortControllers[e]=i;try{let a=await this.messageHandlers[t.type](t.sourceMapId,r,i);this.completeTask(e,null,a)}catch(a){this.completeTask(e,zt(a))}}completeTask(e,t,r){let i=[];delete this.abortControllers[e];let a={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?Bn(t):null,data:Bn(r,i)};this.target.postMessage(a,{transfer:i})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function wE(e,t,r){return!(e<0||e>25||r<0||r>=2**e||t<0||t>=2**e)}function im(e,t){let{x:r,y:i}=Ie.fromLngLat(t);return!(e<0||e>25||i<0||i>=1||r<0||r>=1)}var Vl=class{constructor(e,t,r){if(!wE(e,t,r))throw Error(`x=${t}, y=${r}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=r,this.key=Ba(0,e,e,t,r)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,r){let i=TE(this.x,this.y,this.z),a=DE(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(r==="tms"?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,a).replace(/{bbox-epsg-3857}/g,i)}isChildOf(e){let t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){let t=2**this.z;return new C((e.x*t-this.x)*k,(e.y*t-this.y)*k)}toString(){return`${this.z}/${this.x}/${this.y}`}},ol=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Ba(e,t.z,t.z,t.x,t.y)}},St=class dr{constructor(t,r,i,a,n){if(this.terrainRttPosMatrix32f=null,t<i)throw Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=r,this.canonical=new Vl(i,+a,+n),this.key=Ba(r,t,i,a,n)}clone(){return new dr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let r=this.canonical.z-t;return t>this.canonical.z?new dr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new dr(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,r){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-t;return t>this.canonical.z?Ba(this.wrap*+r,t,this.canonical.z,this.canonical.x,this.canonical.y):Ba(this.wrap*+r,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap||this.overscaledZ-t.overscaledZ<=0)return!1;if(t.overscaledZ===0)return this.overscaledZ>0;let r=this.canonical.z-t.canonical.z;return r<0?!1:t.canonical.x===this.canonical.x>>r&&t.canonical.y===this.canonical.y>>r}children(t){if(this.overscaledZ>=t)return[new dr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,i=this.canonical.x*2,a=this.canonical.y*2;return[new dr(r,this.wrap,r,i,a),new dr(r,this.wrap,r,i+1,a),new dr(r,this.wrap,r,i,a+1),new dr(r,this.wrap,r,i+1,a+1)]}isLessThan(t){return this.wrap<t.wrap?!0:this.wrap>t.wrap?!1:this.overscaledZ<t.overscaledZ?!0:this.overscaledZ>t.overscaledZ?!1:this.canonical.x<t.canonical.x?!0:this.canonical.x>t.canonical.x?!1:this.canonical.y<t.canonical.y}wrapped(){return new dr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new dr(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new ol(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Ie(t.x-this.wrap,t.y))}normalizeCoordinates(t,r,i=k){if(t>=0&&t<i&&r>=0&&r<i)return{tileID:this,x:t,y:r};let a=Math.floor(t/i),n=Math.floor(r/i),s=t-a*i,o=r-n*i,l=this.canonical.z,u=1<<l,h=this.canonical.y+n;if(h<0||h>=u)return null;let c=this.canonical.x+a,d=this.wrap;return c<0?(d-=Math.ceil(-c/u),c=(c%u+u)%u):c>=u&&(d+=Math.floor(c/u),c%=u),{tileID:new dr(this.overscaledZ,d,l,c,h),x:s,y:o}}};function Ba(e,t,r,i,a){e*=2,e<0&&(e=e*-1-1);let n=1<<r;return(n*n*e+n*a+i).toString(36)+r.toString(36)+t.toString(36)}const ju=Math.PI*6378137;function TE(e,t,r){t=2**r-t-1;let i=am(e*256,t*256,r),a=am((e+1)*256,(t+1)*256,r);return`${i[0]},${i[1]},${a[0]},${a[1]}`}function am(e,t,r){let i=2*ju/256/2**r;return[e*i-ju,t*i-ju]}function DE(e,t,r){let i="";for(let a=e;a>0;a--){let n=1<<a-1;i+=(t&n?1:0)+(r&n?2:0)}return i}function nm(e,t){let r=Math.abs(e.wrap*2)-+(e.wrap<0),i=Math.abs(t.wrap*2)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||i-r||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}G("CanonicalTileID",Vl),G("OverscaledTileID",St,{omit:["terrainRttPosMatrix32f"]});const Co="_geojsonTileLayer";var SE=class{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let r=e[t];this._stringToNumber[r]=t,this._numberToString[t]=r}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}},L0=class{constructor(e,t,r,i,a){this.type="Feature",this._vectorTileFeature=e,this._x=r,this._y=i,this._z=t;for(let n in e.properties)typeof e.properties[n]=="string"&&e.properties[n].startsWith("__$json__:")&&(e.properties[n]=JSON.parse(e.properties[n].slice(10)));this.properties=e.properties,this.id=a}projectPoint(e,t,r,i){return[(e.x+t)*360/i-180,360/Math.PI*Math.atan(Math.exp((1-(e.y+r)*2/i)*Math.PI))-90]}projectLine(e,t,r,i){return e.map(a=>this.projectPoint(a,t,r,i))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,r=e.extent*this._x,i=e.extent*this._y,a=e.loadGeometry();switch(e.type){case 1:{let n=[];for(let o of a)n.push(o[0]);let s=this.projectLine(n,r,i,t);this._geometry=n.length===1?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s};break}case 2:{let n=a.map(s=>this.projectLine(s,r,i,t));this._geometry=n.length===1?{type:"LineString",coordinates:n[0]}:{type:"MultiLineString",coordinates:n};break}case 3:{let n=e0(a),s=[];for(let o of n)s.push(o.map(l=>this.projectLine(l,r,i,t)));this._geometry=s.length===1?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s};break}default:throw Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let t in this)t!=="_geometry"&&t!=="_vectorTileFeature"&&t!=="_x"&&t!=="_y"&&t!=="_z"&&(e[t]=this[t]);return e}},oa=class{constructor(e,t,r){this._name=e,this.dataBuffer=t,typeof r=="number"?this._size=r:(this.nullabilityBuffer=r,this._size=r.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){var t;return((t=this.nullabilityBuffer)==null?void 0:t.get(e))||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},Nl=class extends oa{},Pd=class extends Nl{getValueFromBuffer(e){return this.dataBuffer[e]}},Ad=class extends Nl{getValueFromBuffer(e){return this.dataBuffer[e]}},B0=class extends oa{constructor(e,t,r,i){super(e,t,i),this.delta=r}},Cd=class extends B0{constructor(e,t,r,i,a){super(e,a?Int32Array.of(t):Uint32Array.of(t),r,i)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},Id=class extends oa{constructor(e,t,r,i){super(e,i?Int32Array.of(t):Uint32Array.of(t),r)}getValueFromBuffer(e){return this.dataBuffer[0]}},EE=class{constructor(e,t,r,i,a=4096){if(this._name=e,this._geometryVector=t,this._idVector=r,this._propertyVectors=i,this._extent=a,e.length===0)throw Error("Missing layer name")}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors??[]}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this.propertyVectors.map(t=>[t.name,t]))),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],t=this.geometryVector.getGeometries();for(let r=0;r<this.numFeatures;r++){let i;if(this.idVector){let s=this.idVector.getValue(r);s!==null&&(i=this.containsMaxSafeIntegerValues(this.idVector)?Number(s):s)}let a={coordinates:t[r],type:this.geometryVector.geometryType(r)},n={};for(let s of this.propertyVectors){if(!s)continue;let o=s.name,l=s.getValue(r);l!==null&&(n[o]=l)}e.push({id:i,geometry:a,properties:n})}return e}containsMaxSafeIntegerValues(e){return e instanceof Pd||e instanceof Id||e instanceof Cd||e instanceof Ad}};const Rn={FEATURE:0},Te={BOOLEAN:0,INT_8:1,UINT_8:2,INT_32:3,UINT_32:4,INT_64:5,UINT_64:6,FLOAT:7,DOUBLE:8,STRING:9},Ti={GEOMETRY:0,STRUCT:1,MAP:2},O0={ID:0};var $0=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}},he;(function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON"})(he||(he={}));var xr;(function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT"})(xr||(xr={}));const Md=new Uint32Array(33);Md[0]=0;for(let e=1;e<=32;e++)Md[e]=e===32?4294967295:4294967295>>>32-e;const wc=Md,j0=65536;function zd(e,t){return e-e%t}function PE(e){return zd(e+31,32)}function AE(e){if(!Number.isFinite(e)||e<=0)return j0;let t=zd(Math.floor(e),256);return t===0?256:t}function CE(e){let t=e>>>0;return((t&255)<<24|(t&65280)<<8|t>>>8&65280|t>>>24&255)>>>0}function IE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0;r[a++]=n>>>0&3,r[a++]=n>>>2&3,r[a++]=n>>>4&3,r[a++]=n>>>6&3,r[a++]=n>>>8&3,r[a++]=n>>>10&3,r[a++]=n>>>12&3,r[a++]=n>>>14&3,r[a++]=n>>>16&3,r[a++]=n>>>18&3,r[a++]=n>>>20&3,r[a++]=n>>>22&3,r[a++]=n>>>24&3,r[a++]=n>>>26&3,r[a++]=n>>>28&3,r[a++]=n>>>30&3,r[a++]=s>>>0&3,r[a++]=s>>>2&3,r[a++]=s>>>4&3,r[a++]=s>>>6&3,r[a++]=s>>>8&3,r[a++]=s>>>10&3,r[a++]=s>>>12&3,r[a++]=s>>>14&3,r[a++]=s>>>16&3,r[a++]=s>>>18&3,r[a++]=s>>>20&3,r[a++]=s>>>22&3,r[a++]=s>>>24&3,r[a++]=s>>>26&3,r[a++]=s>>>28&3,r[a]=s>>>30&3}function ME(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0;r[a++]=n>>>0&7,r[a++]=n>>>3&7,r[a++]=n>>>6&7,r[a++]=n>>>9&7,r[a++]=n>>>12&7,r[a++]=n>>>15&7,r[a++]=n>>>18&7,r[a++]=n>>>21&7,r[a++]=n>>>24&7,r[a++]=n>>>27&7,r[a++]=(n>>>30|(s&1)<<2)&7,r[a++]=s>>>1&7,r[a++]=s>>>4&7,r[a++]=s>>>7&7,r[a++]=s>>>10&7,r[a++]=s>>>13&7,r[a++]=s>>>16&7,r[a++]=s>>>19&7,r[a++]=s>>>22&7,r[a++]=s>>>25&7,r[a++]=s>>>28&7,r[a++]=(s>>>31|(o&3)<<1)&7,r[a++]=o>>>2&7,r[a++]=o>>>5&7,r[a++]=o>>>8&7,r[a++]=o>>>11&7,r[a++]=o>>>14&7,r[a++]=o>>>17&7,r[a++]=o>>>20&7,r[a++]=o>>>23&7,r[a++]=o>>>26&7,r[a]=o>>>29&7}function zE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0;r[a++]=n>>>0&15,r[a++]=n>>>4&15,r[a++]=n>>>8&15,r[a++]=n>>>12&15,r[a++]=n>>>16&15,r[a++]=n>>>20&15,r[a++]=n>>>24&15,r[a++]=n>>>28&15,r[a++]=s>>>0&15,r[a++]=s>>>4&15,r[a++]=s>>>8&15,r[a++]=s>>>12&15,r[a++]=s>>>16&15,r[a++]=s>>>20&15,r[a++]=s>>>24&15,r[a++]=s>>>28&15,r[a++]=o>>>0&15,r[a++]=o>>>4&15,r[a++]=o>>>8&15,r[a++]=o>>>12&15,r[a++]=o>>>16&15,r[a++]=o>>>20&15,r[a++]=o>>>24&15,r[a++]=o>>>28&15,r[a++]=l>>>0&15,r[a++]=l>>>4&15,r[a++]=l>>>8&15,r[a++]=l>>>12&15,r[a++]=l>>>16&15,r[a++]=l>>>20&15,r[a++]=l>>>24&15,r[a]=l>>>28&15}function FE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0;r[a++]=n>>>0&31,r[a++]=n>>>5&31,r[a++]=n>>>10&31,r[a++]=n>>>15&31,r[a++]=n>>>20&31,r[a++]=n>>>25&31,r[a++]=(n>>>30|(s&7)<<2)&31,r[a++]=s>>>3&31,r[a++]=s>>>8&31,r[a++]=s>>>13&31,r[a++]=s>>>18&31,r[a++]=s>>>23&31,r[a++]=(s>>>28|(o&1)<<4)&31,r[a++]=o>>>1&31,r[a++]=o>>>6&31,r[a++]=o>>>11&31,r[a++]=o>>>16&31,r[a++]=o>>>21&31,r[a++]=o>>>26&31,r[a++]=(o>>>31|(l&15)<<1)&31,r[a++]=l>>>4&31,r[a++]=l>>>9&31,r[a++]=l>>>14&31,r[a++]=l>>>19&31,r[a++]=l>>>24&31,r[a++]=(l>>>29|(u&3)<<3)&31,r[a++]=u>>>2&31,r[a++]=u>>>7&31,r[a++]=u>>>12&31,r[a++]=u>>>17&31,r[a++]=u>>>22&31,r[a]=u>>>27&31}function RE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0;r[a++]=n>>>0&63,r[a++]=n>>>6&63,r[a++]=n>>>12&63,r[a++]=n>>>18&63,r[a++]=n>>>24&63,r[a++]=(n>>>30|(s&15)<<2)&63,r[a++]=s>>>4&63,r[a++]=s>>>10&63,r[a++]=s>>>16&63,r[a++]=s>>>22&63,r[a++]=(s>>>28|(o&3)<<4)&63,r[a++]=o>>>2&63,r[a++]=o>>>8&63,r[a++]=o>>>14&63,r[a++]=o>>>20&63,r[a++]=o>>>26&63,r[a++]=l>>>0&63,r[a++]=l>>>6&63,r[a++]=l>>>12&63,r[a++]=l>>>18&63,r[a++]=l>>>24&63,r[a++]=(l>>>30|(u&15)<<2)&63,r[a++]=u>>>4&63,r[a++]=u>>>10&63,r[a++]=u>>>16&63,r[a++]=u>>>22&63,r[a++]=(u>>>28|(h&3)<<4)&63,r[a++]=h>>>2&63,r[a++]=h>>>8&63,r[a++]=h>>>14&63,r[a++]=h>>>20&63,r[a]=h>>>26&63}function kE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0;r[a++]=n>>>0&127,r[a++]=n>>>7&127,r[a++]=n>>>14&127,r[a++]=n>>>21&127,r[a++]=(n>>>28|(s&7)<<4)&127,r[a++]=s>>>3&127,r[a++]=s>>>10&127,r[a++]=s>>>17&127,r[a++]=s>>>24&127,r[a++]=(s>>>31|(o&63)<<1)&127,r[a++]=o>>>6&127,r[a++]=o>>>13&127,r[a++]=o>>>20&127,r[a++]=(o>>>27|(l&3)<<5)&127,r[a++]=l>>>2&127,r[a++]=l>>>9&127,r[a++]=l>>>16&127,r[a++]=l>>>23&127,r[a++]=(l>>>30|(u&31)<<2)&127,r[a++]=u>>>5&127,r[a++]=u>>>12&127,r[a++]=u>>>19&127,r[a++]=(u>>>26|(h&1)<<6)&127,r[a++]=h>>>1&127,r[a++]=h>>>8&127,r[a++]=h>>>15&127,r[a++]=h>>>22&127,r[a++]=(h>>>29|(c&15)<<3)&127,r[a++]=c>>>4&127,r[a++]=c>>>11&127,r[a++]=c>>>18&127,r[a]=c>>>25&127}function LE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0;r[a++]=n>>>0&255,r[a++]=n>>>8&255,r[a++]=n>>>16&255,r[a++]=n>>>24&255,r[a++]=s>>>0&255,r[a++]=s>>>8&255,r[a++]=s>>>16&255,r[a++]=s>>>24&255,r[a++]=o>>>0&255,r[a++]=o>>>8&255,r[a++]=o>>>16&255,r[a++]=o>>>24&255,r[a++]=l>>>0&255,r[a++]=l>>>8&255,r[a++]=l>>>16&255,r[a++]=l>>>24&255,r[a++]=u>>>0&255,r[a++]=u>>>8&255,r[a++]=u>>>16&255,r[a++]=u>>>24&255,r[a++]=h>>>0&255,r[a++]=h>>>8&255,r[a++]=h>>>16&255,r[a++]=h>>>24&255,r[a++]=c>>>0&255,r[a++]=c>>>8&255,r[a++]=c>>>16&255,r[a++]=c>>>24&255,r[a++]=d>>>0&255,r[a++]=d>>>8&255,r[a++]=d>>>16&255,r[a]=d>>>24&255}function BE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0;r[a++]=n>>>0&511,r[a++]=n>>>9&511,r[a++]=n>>>18&511,r[a++]=(n>>>27|(s&15)<<5)&511,r[a++]=s>>>4&511,r[a++]=s>>>13&511,r[a++]=s>>>22&511,r[a++]=(s>>>31|(o&255)<<1)&511,r[a++]=o>>>8&511,r[a++]=o>>>17&511,r[a++]=(o>>>26|(l&7)<<6)&511,r[a++]=l>>>3&511,r[a++]=l>>>12&511,r[a++]=l>>>21&511,r[a++]=(l>>>30|(u&127)<<2)&511,r[a++]=u>>>7&511,r[a++]=u>>>16&511,r[a++]=(u>>>25|(h&3)<<7)&511,r[a++]=h>>>2&511,r[a++]=h>>>11&511,r[a++]=h>>>20&511,r[a++]=(h>>>29|(c&63)<<3)&511,r[a++]=c>>>6&511,r[a++]=c>>>15&511,r[a++]=(c>>>24|(d&1)<<8)&511,r[a++]=d>>>1&511,r[a++]=d>>>10&511,r[a++]=d>>>19&511,r[a++]=(d>>>28|(p&31)<<4)&511,r[a++]=p>>>5&511,r[a++]=p>>>14&511,r[a]=p>>>23&511}function OE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0;r[a++]=n>>>0&1023,r[a++]=n>>>10&1023,r[a++]=n>>>20&1023,r[a++]=(n>>>30|(s&255)<<2)&1023,r[a++]=s>>>8&1023,r[a++]=s>>>18&1023,r[a++]=(s>>>28|(o&63)<<4)&1023,r[a++]=o>>>6&1023,r[a++]=o>>>16&1023,r[a++]=(o>>>26|(l&15)<<6)&1023,r[a++]=l>>>4&1023,r[a++]=l>>>14&1023,r[a++]=(l>>>24|(u&3)<<8)&1023,r[a++]=u>>>2&1023,r[a++]=u>>>12&1023,r[a++]=u>>>22&1023,r[a++]=h>>>0&1023,r[a++]=h>>>10&1023,r[a++]=h>>>20&1023,r[a++]=(h>>>30|(c&255)<<2)&1023,r[a++]=c>>>8&1023,r[a++]=c>>>18&1023,r[a++]=(c>>>28|(d&63)<<4)&1023,r[a++]=d>>>6&1023,r[a++]=d>>>16&1023,r[a++]=(d>>>26|(p&15)<<6)&1023,r[a++]=p>>>4&1023,r[a++]=p>>>14&1023,r[a++]=(p>>>24|(f&3)<<8)&1023,r[a++]=f>>>2&1023,r[a++]=f>>>12&1023,r[a]=f>>>22&1023}function $E(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0;r[a++]=n>>>0&2047,r[a++]=n>>>11&2047,r[a++]=(n>>>22|(s&1)<<10)&2047,r[a++]=s>>>1&2047,r[a++]=s>>>12&2047,r[a++]=(s>>>23|(o&3)<<9)&2047,r[a++]=o>>>2&2047,r[a++]=o>>>13&2047,r[a++]=(o>>>24|(l&7)<<8)&2047,r[a++]=l>>>3&2047,r[a++]=l>>>14&2047,r[a++]=(l>>>25|(u&15)<<7)&2047,r[a++]=u>>>4&2047,r[a++]=u>>>15&2047,r[a++]=(u>>>26|(h&31)<<6)&2047,r[a++]=h>>>5&2047,r[a++]=h>>>16&2047,r[a++]=(h>>>27|(c&63)<<5)&2047,r[a++]=c>>>6&2047,r[a++]=c>>>17&2047,r[a++]=(c>>>28|(d&127)<<4)&2047,r[a++]=d>>>7&2047,r[a++]=d>>>18&2047,r[a++]=(d>>>29|(p&255)<<3)&2047,r[a++]=p>>>8&2047,r[a++]=p>>>19&2047,r[a++]=(p>>>30|(f&511)<<2)&2047,r[a++]=f>>>9&2047,r[a++]=f>>>20&2047,r[a++]=(f>>>31|(m&1023)<<1)&2047,r[a++]=m>>>10&2047,r[a]=m>>>21&2047}function jE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0;r[a++]=n>>>0&4095,r[a++]=n>>>12&4095,r[a++]=(n>>>24|(s&15)<<8)&4095,r[a++]=s>>>4&4095,r[a++]=s>>>16&4095,r[a++]=(s>>>28|(o&255)<<4)&4095,r[a++]=o>>>8&4095,r[a++]=o>>>20&4095,r[a++]=l>>>0&4095,r[a++]=l>>>12&4095,r[a++]=(l>>>24|(u&15)<<8)&4095,r[a++]=u>>>4&4095,r[a++]=u>>>16&4095,r[a++]=(u>>>28|(h&255)<<4)&4095,r[a++]=h>>>8&4095,r[a++]=h>>>20&4095,r[a++]=c>>>0&4095,r[a++]=c>>>12&4095,r[a++]=(c>>>24|(d&15)<<8)&4095,r[a++]=d>>>4&4095,r[a++]=d>>>16&4095,r[a++]=(d>>>28|(p&255)<<4)&4095,r[a++]=p>>>8&4095,r[a++]=p>>>20&4095,r[a++]=f>>>0&4095,r[a++]=f>>>12&4095,r[a++]=(f>>>24|(m&15)<<8)&4095,r[a++]=m>>>4&4095,r[a++]=m>>>16&4095,r[a++]=(m>>>28|(g&255)<<4)&4095,r[a++]=g>>>8&4095,r[a]=g>>>20&4095}function VE(e,t,r,i){let a=i,n=e[t]>>>0,s=e[t+1]>>>0,o=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0,_=e[t+12]>>>0,y=e[t+13]>>>0,v=e[t+14]>>>0,x=e[t+15]>>>0;r[a++]=n>>>0&65535,r[a++]=n>>>16&65535,r[a++]=s>>>0&65535,r[a++]=s>>>16&65535,r[a++]=o>>>0&65535,r[a++]=o>>>16&65535,r[a++]=l>>>0&65535,r[a++]=l>>>16&65535,r[a++]=u>>>0&65535,r[a++]=u>>>16&65535,r[a++]=h>>>0&65535,r[a++]=h>>>16&65535,r[a++]=c>>>0&65535,r[a++]=c>>>16&65535,r[a++]=d>>>0&65535,r[a++]=d>>>16&65535,r[a++]=p>>>0&65535,r[a++]=p>>>16&65535,r[a++]=f>>>0&65535,r[a++]=f>>>16&65535,r[a++]=m>>>0&65535,r[a++]=m>>>16&65535,r[a++]=g>>>0&65535,r[a++]=g>>>16&65535,r[a++]=_>>>0&65535,r[a++]=_>>>16&65535,r[a++]=y>>>0&65535,r[a++]=y>>>16&65535,r[a++]=v>>>0&65535,r[a++]=v>>>16&65535,r[a++]=x>>>0&65535,r[a]=x>>>16&65535}function NE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0;r[a++]=o>>>0&1,r[a++]=o>>>1&1,r[a++]=o>>>2&1,r[a++]=o>>>3&1,r[a++]=o>>>4&1,r[a++]=o>>>5&1,r[a++]=o>>>6&1,r[a++]=o>>>7&1,r[a++]=o>>>8&1,r[a++]=o>>>9&1,r[a++]=o>>>10&1,r[a++]=o>>>11&1,r[a++]=o>>>12&1,r[a++]=o>>>13&1,r[a++]=o>>>14&1,r[a++]=o>>>15&1,r[a++]=o>>>16&1,r[a++]=o>>>17&1,r[a++]=o>>>18&1,r[a++]=o>>>19&1,r[a++]=o>>>20&1,r[a++]=o>>>21&1,r[a++]=o>>>22&1,r[a++]=o>>>23&1,r[a++]=o>>>24&1,r[a++]=o>>>25&1,r[a++]=o>>>26&1,r[a++]=o>>>27&1,r[a++]=o>>>28&1,r[a++]=o>>>29&1,r[a++]=o>>>30&1,r[a++]=o>>>31&1}}function UE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0;r[a++]=o>>>0&3,r[a++]=o>>>2&3,r[a++]=o>>>4&3,r[a++]=o>>>6&3,r[a++]=o>>>8&3,r[a++]=o>>>10&3,r[a++]=o>>>12&3,r[a++]=o>>>14&3,r[a++]=o>>>16&3,r[a++]=o>>>18&3,r[a++]=o>>>20&3,r[a++]=o>>>22&3,r[a++]=o>>>24&3,r[a++]=o>>>26&3,r[a++]=o>>>28&3,r[a++]=o>>>30&3,r[a++]=l>>>0&3,r[a++]=l>>>2&3,r[a++]=l>>>4&3,r[a++]=l>>>6&3,r[a++]=l>>>8&3,r[a++]=l>>>10&3,r[a++]=l>>>12&3,r[a++]=l>>>14&3,r[a++]=l>>>16&3,r[a++]=l>>>18&3,r[a++]=l>>>20&3,r[a++]=l>>>22&3,r[a++]=l>>>24&3,r[a++]=l>>>26&3,r[a++]=l>>>28&3,r[a++]=l>>>30&3}}function GE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0;r[a++]=o>>>0&7,r[a++]=o>>>3&7,r[a++]=o>>>6&7,r[a++]=o>>>9&7,r[a++]=o>>>12&7,r[a++]=o>>>15&7,r[a++]=o>>>18&7,r[a++]=o>>>21&7,r[a++]=o>>>24&7,r[a++]=o>>>27&7,r[a++]=(o>>>30|(l&1)<<2)&7,r[a++]=l>>>1&7,r[a++]=l>>>4&7,r[a++]=l>>>7&7,r[a++]=l>>>10&7,r[a++]=l>>>13&7,r[a++]=l>>>16&7,r[a++]=l>>>19&7,r[a++]=l>>>22&7,r[a++]=l>>>25&7,r[a++]=l>>>28&7,r[a++]=(l>>>31|(u&3)<<1)&7,r[a++]=u>>>2&7,r[a++]=u>>>5&7,r[a++]=u>>>8&7,r[a++]=u>>>11&7,r[a++]=u>>>14&7,r[a++]=u>>>17&7,r[a++]=u>>>20&7,r[a++]=u>>>23&7,r[a++]=u>>>26&7,r[a++]=u>>>29&7}}function qE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0;r[a++]=o>>>0&15,r[a++]=o>>>4&15,r[a++]=o>>>8&15,r[a++]=o>>>12&15,r[a++]=o>>>16&15,r[a++]=o>>>20&15,r[a++]=o>>>24&15,r[a++]=o>>>28&15,r[a++]=l>>>0&15,r[a++]=l>>>4&15,r[a++]=l>>>8&15,r[a++]=l>>>12&15,r[a++]=l>>>16&15,r[a++]=l>>>20&15,r[a++]=l>>>24&15,r[a++]=l>>>28&15,r[a++]=u>>>0&15,r[a++]=u>>>4&15,r[a++]=u>>>8&15,r[a++]=u>>>12&15,r[a++]=u>>>16&15,r[a++]=u>>>20&15,r[a++]=u>>>24&15,r[a++]=u>>>28&15,r[a++]=h>>>0&15,r[a++]=h>>>4&15,r[a++]=h>>>8&15,r[a++]=h>>>12&15,r[a++]=h>>>16&15,r[a++]=h>>>20&15,r[a++]=h>>>24&15,r[a++]=h>>>28&15}}function ZE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0;r[a++]=o>>>0&31,r[a++]=o>>>5&31,r[a++]=o>>>10&31,r[a++]=o>>>15&31,r[a++]=o>>>20&31,r[a++]=o>>>25&31,r[a++]=(o>>>30|(l&7)<<2)&31,r[a++]=l>>>3&31,r[a++]=l>>>8&31,r[a++]=l>>>13&31,r[a++]=l>>>18&31,r[a++]=l>>>23&31,r[a++]=(l>>>28|(u&1)<<4)&31,r[a++]=u>>>1&31,r[a++]=u>>>6&31,r[a++]=u>>>11&31,r[a++]=u>>>16&31,r[a++]=u>>>21&31,r[a++]=u>>>26&31,r[a++]=(u>>>31|(h&15)<<1)&31,r[a++]=h>>>4&31,r[a++]=h>>>9&31,r[a++]=h>>>14&31,r[a++]=h>>>19&31,r[a++]=h>>>24&31,r[a++]=(h>>>29|(c&3)<<3)&31,r[a++]=c>>>2&31,r[a++]=c>>>7&31,r[a++]=c>>>12&31,r[a++]=c>>>17&31,r[a++]=c>>>22&31,r[a++]=c>>>27&31}}function WE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0;r[a++]=o>>>0&63,r[a++]=o>>>6&63,r[a++]=o>>>12&63,r[a++]=o>>>18&63,r[a++]=o>>>24&63,r[a++]=(o>>>30|(l&15)<<2)&63,r[a++]=l>>>4&63,r[a++]=l>>>10&63,r[a++]=l>>>16&63,r[a++]=l>>>22&63,r[a++]=(l>>>28|(u&3)<<4)&63,r[a++]=u>>>2&63,r[a++]=u>>>8&63,r[a++]=u>>>14&63,r[a++]=u>>>20&63,r[a++]=u>>>26&63,r[a++]=h>>>0&63,r[a++]=h>>>6&63,r[a++]=h>>>12&63,r[a++]=h>>>18&63,r[a++]=h>>>24&63,r[a++]=(h>>>30|(c&15)<<2)&63,r[a++]=c>>>4&63,r[a++]=c>>>10&63,r[a++]=c>>>16&63,r[a++]=c>>>22&63,r[a++]=(c>>>28|(d&3)<<4)&63,r[a++]=d>>>2&63,r[a++]=d>>>8&63,r[a++]=d>>>14&63,r[a++]=d>>>20&63,r[a++]=d>>>26&63}}function HE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0,p=e[n++]>>>0;r[a++]=o>>>0&127,r[a++]=o>>>7&127,r[a++]=o>>>14&127,r[a++]=o>>>21&127,r[a++]=(o>>>28|(l&7)<<4)&127,r[a++]=l>>>3&127,r[a++]=l>>>10&127,r[a++]=l>>>17&127,r[a++]=l>>>24&127,r[a++]=(l>>>31|(u&63)<<1)&127,r[a++]=u>>>6&127,r[a++]=u>>>13&127,r[a++]=u>>>20&127,r[a++]=(u>>>27|(h&3)<<5)&127,r[a++]=h>>>2&127,r[a++]=h>>>9&127,r[a++]=h>>>16&127,r[a++]=h>>>23&127,r[a++]=(h>>>30|(c&31)<<2)&127,r[a++]=c>>>5&127,r[a++]=c>>>12&127,r[a++]=c>>>19&127,r[a++]=(c>>>26|(d&1)<<6)&127,r[a++]=d>>>1&127,r[a++]=d>>>8&127,r[a++]=d>>>15&127,r[a++]=d>>>22&127,r[a++]=(d>>>29|(p&15)<<3)&127,r[a++]=p>>>4&127,r[a++]=p>>>11&127,r[a++]=p>>>18&127,r[a++]=p>>>25&127}}function XE(e,t,r,i){let a=i,n=t;for(let s=0;s<8;s++){let o=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0,p=e[n++]>>>0,f=e[n++]>>>0;r[a++]=o>>>0&255,r[a++]=o>>>8&255,r[a++]=o>>>16&255,r[a++]=o>>>24&255,r[a++]=l>>>0&255,r[a++]=l>>>8&255,r[a++]=l>>>16&255,r[a++]=l>>>24&255,r[a++]=u>>>0&255,r[a++]=u>>>8&255,r[a++]=u>>>16&255,r[a++]=u>>>24&255,r[a++]=h>>>0&255,r[a++]=h>>>8&255,r[a++]=h>>>16&255,r[a++]=h>>>24&255,r[a++]=c>>>0&255,r[a++]=c>>>8&255,r[a++]=c>>>16&255,r[a++]=c>>>24&255,r[a++]=d>>>0&255,r[a++]=d>>>8&255,r[a++]=d>>>16&255,r[a++]=d>>>24&255,r[a++]=p>>>0&255,r[a++]=p>>>8&255,r[a++]=p>>>16&255,r[a++]=p>>>24&255,r[a++]=f>>>0&255,r[a++]=f>>>8&255,r[a++]=f>>>16&255,r[a++]=f>>>24&255}}function YE(e,t,r,i){let a=i,n=t;for(let s=0;s<128;s++){let o=e[n++]>>>0;r[a++]=o&65535,r[a++]=o>>>16&65535}}function KE(e,t,r,i,a){let n=wc[a]>>>0,s=t,o=0,l=e[s]>>>0,u=i;for(let h=0;h<8;h++){for(let c=0;c<32;c++)if(o+a<=32){let d=l>>>o&n;r[u+c]=d|0,o+=a,o===32&&(o=0,s++,c!==31&&(l=e[s]>>>0))}else{let d=32-o,p=l>>>o;s++,l=e[s]>>>0;let f=a-d,m=-1>>>32-f>>>0,g=(p|(l&m)<<d)&n;r[u+c]=g|0,o=f}u+=32,o=0,h<7&&(l=e[s]>>>0)}}const Tc=AE(j0),JE=3*Tc/256+Tc|0;function V0(){let e=new Uint8Array(JE);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function QE(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let t=Math.max(16,e|0);return{encodedWords:new Uint32Array(t),decoderWorkspace:V0()}}function eP(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let r=new Uint32Array(Math.max(16,t*2));return e.encodedWords=r,r}function tP(e,t,r,i){i.byteContainer.length<r&&(i.byteContainer=new Uint8Array(r*2),i.byteContainerI32=void 0);let a=i.byteContainer,n=r>>>2;if(a.byteOffset&3)for(let o=0;o<n;o=o+1|0){let l=e[t+o|0]|0,u=o<<2;a[u]=l&255,a[u+1|0]=l>>>8&255,a[u+2|0]=l>>>16&255,a[u+3|0]=l>>>24&255}else{let o=i.byteContainerI32;(!o||o.buffer!==a.buffer||o.byteOffset!==a.byteOffset||o.length<n)&&(o=i.byteContainerI32=new Int32Array(a.buffer,a.byteOffset,a.byteLength>>>2)),o.set(e.subarray(t,t+n))}let s=r&3;if(s>0){let o=e[t+n|0]|0,l=n<<2;for(let u=0;u<s;u=u+1|0)a[l+u|0]=o>>>(u<<3)&255}return a}function rP(e,t,r){let i=e[t++]|0,a=r.dataToBePacked;for(let n=2;n<=32;n=n+1|0){if(!(i>>>n-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${n}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let s=e[t++]>>>0,o=PE(s),l=s*n+31>>>5;if(t+l>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${n}, size=${s}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let u=a[n];(!u||u.length<o)&&(u=a[n]=new Uint32Array(o));let h=0;for(;h<s;h=h+32|0)dP(e,t,u,h,n),t=t+n|0;let c=h-s|0;t=t-(c*n>>>5)|0,r.exceptionSizes[n]=s}return t}function iP(e,t,r,i,a){switch(a){case 1:NE(e,t,r,i);break;case 2:UE(e,t,r,i);break;case 3:GE(e,t,r,i);break;case 4:qE(e,t,r,i);break;case 5:ZE(e,t,r,i);break;case 6:WE(e,t,r,i);break;case 7:HE(e,t,r,i);break;case 8:XE(e,t,r,i);break;case 16:YE(e,t,r,i);break;default:KE(e,t,r,i,a)}return t+(a<<3)|0}function aP(e,t,r,i){if(r+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${i} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${r}, byteSize=${t})`);let a=e[r++],n=e[r++];if(a>32)throw Error(`FastPFOR decode: invalid bitWidth=${a} at block=${i} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:a,exceptionCount:n,bytePosIn:r}}function nP(e,t,r,i,a,n){if(r+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${n} (need 1 byte for maxBits, bytePos=${r}, byteSize=${t})`);let s=e[r++];if(s<i||s>32)throw Error(`FastPFOR decode: invalid maxBits=${s} at block=${n} (bitWidth=${i}, expected ${i}..32)`);let o=s-i|0;if(o<1||o>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${o} at block=${n} (bitWidth=${i}, maxBits=${s})`);if(r+a>t)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${a}, have=${t-r})`);return{maxBits:s,exceptionBitWidth:o,bytePosIn:r}}function sP(e,t,r,i,a,n,s,o,l){let{maxBits:u,exceptionBitWidth:h,bytePosIn:c}=nP(a,n,s,r,i,l);if(s=c,h===1){let g=1<<r;for(let _=0;_<i;_=_+1|0){let y=a[s++];e[y+t|0]|=g}return s}let d=o.dataToBePacked[h];if(!d)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${r}, maxBits=${u}) at block ${l}`);let p=o.dataPointers,f=p[h]|0,m=o.exceptionSizes[h]|0;if(f+i>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${i}, size=${m}) at block ${l}`);for(let g=0;g<i;g=g+1|0){let _=a[s++],y=d[f++]|0;e[_+t|0]|=y<<r}return p[h]=f,s}function oP(e,t,r,i,a,n,s,o,l,u){let h=r|0,c=0;for(let d=0;d<s;d=d+1|0){let p=aP(o,l,c,d);c=p.bytePosIn;let f=p.bitWidth,m=p.exceptionCount,g=n+d*256|0;switch(f){case 0:a.fill(0,g,g+256);break;case 32:for(let _=0;_<256;_=_+1|0)a[g+_|0]=e[h+_|0]|0;h=h+256|0;break;default:h=iP(e,h,a,g,f)}m>0&&(c=sP(a,g,f,m,o,l,c,u,d))}if(h!==i)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${r}, consumedPackedEnd=${h}, expectedPackedEnd=${i}, packedWords=${i-r}, encoded.length=${e.length})`)}function lP(e,t,r,i,a,n){let s=r|0,o=e[s]|0;if(o<=0||s+o>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${o} at pageStart=${s} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let l=s+1|0,u=s+o|0,h=e[u]>>>0,c=h+3>>>2,d=u+1,p=d+c;if(p>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${h} (metaInts=${c}, pageStart=${s}, packedEnd=${u}, byteContainerStart=${d}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let f=tP(e,d,h,n),m=h,g=rP(e,p,n);return n.dataPointers.fill(0),oP(e,s,l,u,t,i|0,a/256|0,f,m,n),g}function uP(e,t,r,i,a,n){let s=i+zd(a,256),o=i,l=r;for(;o!==s;){let u=Math.min(Tc,s-o);l=lP(e,t,l,o,u,n),o=o+u|0}return l}function hP(e,t,r,i,a,n){if(n===0)return t;let s=0,o=t,l=t+r,u=a,h=a,c=a+n,d=0,p=0;for(;o<l&&h<c;){let f=e[o]>>>s&255;if(s+=8,o+=s>>>5,s&=31,d|=(f&127)<<p,f&128)i[h++]=d|0,d=0,p=0;else if(p+=7,p>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${d}, decoded=${h-u}/${n}, inPos=${o}, inEnd=${l})`)}if(h!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${h-u}, expected=${n}, consumedWords=${o-t}/${r}, vbyteStart=${t}, vbyteEnd=${l})`);return o}function cP(e,t,r){let i=0,a=0,n=new Uint32Array(t),s=r??V0();if(e.length>0){let u=e[i]|0;if(i=i+1|0,u&255)throw Error(`FastPFOR decode: invalid alignedLength=${u} (expected multiple of 256)`);if(a+u>n.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${a}, alignedLength=${u}, out.length=${n.length})`);i=uP(e,n,i,a,u,s),a=a+u|0}let o=e.length-i|0,l=t-a|0;return hP(e,i,o,n,a,l),n}function dP(e,t,r,i,a){switch(a){case 2:IE(e,t,r,i);return;case 3:ME(e,t,r,i);return;case 4:zE(e,t,r,i);return;case 5:FE(e,t,r,i);return;case 6:RE(e,t,r,i);return;case 7:kE(e,t,r,i);return;case 8:LE(e,t,r,i);return;case 9:BE(e,t,r,i);return;case 10:OE(e,t,r,i);return;case 11:$E(e,t,r,i);return;case 12:jE(e,t,r,i);return;case 16:VE(e,t,r,i);return;case 32:for(let u=0;u<32;u=u+1|0)r[i+u|0]=e[t+u|0]|0;return}let n=wc[a]>>>0,s=t,o=0,l=e[s]>>>0;for(let u=0;u<32;u++)if(o+a<=32){let h=l>>>o&n;r[i+u]=h|0,o+=a,o===32&&(o=0,s++,u!==31&&(l=e[s]>>>0))}else{let h=32-o,c=l>>>o;s++,l=e[s]>>>0;let d=wc[a-h]>>>0,p=(c|(l&d)<<h)&n;r[i+u]=p|0,o=a-h}}function pP(e,t,r,i){if(t<0||r<0||t+r>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${r}, bytes.length=${e.length})`);let a=Math.floor(r/4),n=r%4!=0,s=n?a+1:a;if(i.length<s)throw RangeError(`decodeBigEndianInt32sInto: out.length=${i.length} < ${s}`);if(a>0){let o=e.byteOffset+t;if(o&3)for(let l=0;l<a;l++){let u=t+l*4;i[l]=e[u]<<24|e[u+1]<<16|e[u+2]<<8|e[u+3]|0}else{let l=new Uint32Array(e.buffer,o,a);for(let u=0;u<a;u++)i[u]=CE(l[u])|0}}if(n){let o=t+a*4,l=r-a*4,u=0;for(let h=0;h<l;h++)u|=e[o+h]<<24-h*8;i[a]=u|0}return s}function Mt(e,t,r){let i=new Uint32Array(r),a=0,n=t.get();for(let s=0;s<i.length;s++){let o=e[n++],l=o&127;if(o<128){i[a++]=l;continue}if(o=e[n++],l|=(o&127)<<7,o<128){i[a++]=l;continue}if(o=e[n++],l|=(o&127)<<14,o<128){i[a++]=l;continue}if(o=e[n++],l|=(o&127)<<21,o<128){i[a++]=l;continue}o=e[n++],l|=(o&15)<<28,i[a++]=l}return t.set(n),i}function Fd(e,t,r){let i=new BigUint64Array(r);for(let a=0;a<i.length;a++)i[a]=fP(e,t);return i}function fP(e,t){let r=0n,i=0,a=t.get();for(;a<e.length;){let n=e[a++];if(r|=BigInt(n&127)<<BigInt(i),!(n&128))break;if(i+=7,i>=64)throw Error("Varint too long")}return t.set(a),r}function mP(e,t,r){let i=new Float64Array(r);for(let a=0;a<r;a++)i[a]=gP(e,t);return i}function gP(e,t){let r,i;return i=e[t.get()],t.increment(),r=i&127,i<128||(i=e[t.get()],t.increment(),r|=(i&127)<<7,i<128)||(i=e[t.get()],t.increment(),r|=(i&127)<<14,i<128)||(i=e[t.get()],t.increment(),r|=(i&127)<<21,i<128)?r:(i=e[t.get()],r|=(i&15)<<28,_P(r,e,t))}function _P(e,t,r){let i,a;if(a=t[r.get()],r.increment(),i=(a&112)>>4,a<128||(a=t[r.get()],r.increment(),i|=(a&127)<<3,a<128)||(a=t[r.get()],r.increment(),i|=(a&127)<<10,a<128)||(a=t[r.get()],r.increment(),i|=(a&127)<<17,a<128)||(a=t[r.get()],r.increment(),i|=(a&127)<<24,a<128)||(a=t[r.get()],r.increment(),i|=(a&1)<<31,a<128))return i*4294967296+(e>>>0);throw Error("Expected varint not more than 10 bytes")}function yP(e,t,r,i){return xP(e,t,r,i,QE(r>>>2))}function xP(e,t,r,i,a){let n=i.get();if(r&3)throw Error(`FastPFOR: invalid encodedByteLength=${r} at offset=${n} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let s=r>>>2,o=eP(a,s);pP(e,n,r,o);let l=cP(o.subarray(0,s),t,a.decoderWorkspace);return i.add(r),l}function Me(e){return e>>>1^-(e&1)}function At(e){return e>>1n^-(e&1n)}function Bi(e){return e%2==1?(e+1)/-2:e/2}function vP(e){let t=new Int32Array(e.length);for(let r=0;r<e.length;r++)t[r]=Me(e[r]);return t}function bP(e){let t=new BigInt64Array(e.length);for(let r=0;r<e.length;r++)t[r]=At(e[r]);return t}function Dc(e,t,r){if(r===void 0){r=0;for(let n=0;n<t;n++)r+=e[n]}let i=new Uint32Array(r),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];i.fill(o,a,a+s),a+=s}return i}function Sc(e,t,r){if(r===void 0){r=0;for(let n=0;n<t;n++)r+=Number(e[n])}let i=new BigUint64Array(r),a=0;for(let n=0;n<t;n++){let s=Number(e[n]),o=e[n+t];i.fill(o,a,a+s),a+=s}return i}function N0(e,t,r){let i=new Float64Array(r),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];i.fill(o,a,a+s),a+=s}return i}function sm(e){let t=new Int32Array(e.length);t[0]=Me(e[0]);let r=e.length/4*4,i=1;if(r>=4)for(;i<r-4;i+=4){let a=e[i],n=e[i+1],s=e[i+2],o=e[i+3];t[i]=Me(a)+t[i-1],t[i+1]=Me(n)+t[i],t[i+2]=Me(s)+t[i+1],t[i+3]=Me(o)+t[i+2]}for(;i!==e.length;++i)t[i]=Me(e[i])+t[i-1];return t}function om(e){let t=new BigInt64Array(e.length);t[0]=At(e[0]);let r=e.length/4*4,i=1;if(r>=4)for(;i<r-4;i+=4){let a=e[i],n=e[i+1],s=e[i+2],o=e[i+3];t[i]=At(a)+t[i-1],t[i+1]=At(n)+t[i],t[i+2]=At(s)+t[i+1],t[i+3]=At(o)+t[i+2]}for(;i!==t.length;++i)t[i]=At(e[i])+t[i-1];return t}function wP(e){e[0]=Bi(e[0]);let t=e.length/4*4,r=1;if(t>=4)for(;r<t-4;r+=4){let i=e[r],a=e[r+1],n=e[r+2],s=e[r+3];e[r]=Bi(i)+e[r-1],e[r+1]=Bi(a)+e[r],e[r+2]=Bi(n)+e[r+1],e[r+3]=Bi(s)+e[r+2]}for(;r!==e.length;++r)e[r]=Bi(e[r])+e[r-1]}function TP(e,t,r){if(r===void 0){r=0;for(let n=0;n<t;n++)r+=e[n]}let i=new Int32Array(r),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];o=Me(o),i.fill(o,a,a+s),a+=s}return i}function DP(e,t,r){if(r===void 0){r=0;for(let n=0;n<t;n++)r+=Number(e[n])}let i=new BigInt64Array(r),a=0;for(let n=0;n<t;n++){let s=Number(e[n]),o=e[n+t];o=At(o),i.fill(o,a,a+s),a+=s}return i}function SP(e,t,r){let i=new Float64Array(r),a=0;for(let n=0;n<t;n++){let s=e[n],o=e[n+t];o=Bi(o),i.fill(o,a,a+s),a+=s}return i}function Rd(e){let t=e.length/4*4,r=1;if(t>=4)for(let i=e[0];r<t-4;r+=4)i=e[r]+=i,i=e[r+1]+=i,i=e[r+2]+=i,i=e[r+3]+=i;for(;r!==e.length;)e[r]+=e[r-1],++r}function EP(e){let t=0;for(let r=0;r<e.length;r++)e[r]+=t,t=e[r]}function PP(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=Me(e[0]),t[1]=Me(e[1]);let r=e.length/4*4,i=2;if(r>=4)for(;i<r-4;i+=4){let a=e[i],n=e[i+1],s=e[i+2],o=e[i+3];t[i]=Me(a)+t[i-2],t[i+1]=Me(n)+t[i-1],t[i+2]=Me(s)+t[i],t[i+3]=Me(o)+t[i+1]}for(;i!==e.length;i+=2)t[i]=Me(e[i])+t[i-2],t[i+1]=Me(e[i+1])+t[i-1];return t}function AP(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=Me(e[0]);let r=t[1];for(let i=2;i!==t.length;++i){let a=e[i-1],n=Me(a);r+=n,t[i]=t[i-1]+r}return new Uint32Array(t)}function CP(e,t,r){let i=new Int32Array(r+1);i[0]=0;let a=1,n=i[0];for(let s=0;s<t;s++){let o=e[s],l=e[s+t];l=Me(l);for(let u=a;u<a+o;u++)i[u]=l+n,n=i[u];a+=o}return i}function IP(e,t,r){let i=new Uint32Array(r+1);i[0]=0;let a=1,n=i[0];for(let s=0;s<t;s++){let o=e[s],l=e[s+t];for(let u=a;u<a+o;u++)i[u]=l+n,n=i[u];a+=o}return i}function MP(e,t,r){let i=new Int32Array(r),a=0,n=0;for(let s=0;s<t;s++){let o=e[s],l=e[s+t],u=Me(l);for(let h=0;h<o;h++)n+=u,i[a++]=n}return i}function zP(e,t,r){let i=new BigInt64Array(r),a=0,n=0n;for(let s=0;s<t;s++){let o=Number(e[s]),l=e[s+t],u=At(l);for(let h=0;h<o;h++)n+=u,i[a++]=n}return i}function lm(e){let t=new Uint32Array(e.length);t[0]=Me(e[0])>>>0;for(let r=1;r<e.length;r++)t[r]=t[r-1]+Me(e[r])>>>0;return t}function um(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,At(e[0]));for(let r=1;r<e.length;r++)t[r]=BigInt.asUintN(64,t[r-1]+At(e[r]));return t}function FP(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=Me(e[0])>>>0,t[1]=Me(e[1])>>>0;for(let r=2;r<e.length;r+=2)t[r]=t[r-2]+Me(e[r])>>>0,t[r+1]=t[r-1]+Me(e[r+1])>>>0;return t}function RP(e){return e[1]}function kP(e){return Me(e[1])}function LP(e){if(e.length===2){let t=Me(e[1]);return[t,t]}return[Me(e[2]),Me(e[3])]}function BP(e){return e[1]}function OP(e){return At(e[1])}function $P(e){if(e.length===2){let t=At(e[1]);return[t,t]}return[At(e[2]),At(e[3])]}var ut;(function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"})(ut||(ut={}));var Ot;(function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"})(Ot||(Ot={}));var ai;(function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"})(ai||(ai={}));var gt;(function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"})(gt||(gt={}));const jP=[ut.PRESENT,ut.DATA,ut.OFFSET,ut.LENGTH],hm=[he.NONE,he.DELTA,he.COMPONENTWISE_DELTA,he.RLE,he.MORTON],VP=[xr.NONE,xr.FAST_PFOR,xr.VARINT],NP=[Ot.NONE,Ot.SINGLE,Ot.SHARED,Ot.VERTEX,Ot.MORTON,Ot.FSST],UP=[ai.VERTEX,ai.INDEX,ai.STRING,ai.KEY],GP=[gt.VAR_BINARY,gt.GEOMETRIES,gt.PARTS,gt.RINGS,gt.TRIANGLES,gt.SYMBOL,gt.DICTIONARY];function He(e,t){let r=WP(e,t);return r.logicalLevelTechnique1===he.MORTON?qP(r,e,t):(he.RLE===r.logicalLevelTechnique1||he.RLE===r.logicalLevelTechnique2)&&xr.NONE!==r.physicalLevelTechnique?ZP(r,e,t):r}function qP(e,t,r){let i=Mt(t,r,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:i[0],coordinateShift:i[1]}}function ZP(e,t,r){let i=Mt(t,r,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:i[1],runs:i[0],numRleValues:i[1]}}function WP(e,t){let r=e[t.get()],i=jP[r>>4],a={};switch(i){case ut.DATA:a={dictionaryType:NP[r&15]};break;case ut.OFFSET:a={offsetType:UP[r&15]};break;case ut.LENGTH:a={lengthType:GP[r&15]}}t.increment();let n=e[t.get()],s=hm[n>>5],o=hm[n>>2&7],l=VP[n&3];t.increment();let u=Mt(e,t,2),h=u[0],c=u[1];return{physicalStreamType:i,logicalStreamType:a,logicalLevelTechnique1:s,logicalLevelTechnique2:o,physicalLevelTechnique:l,numValues:h,byteLength:c,decompressedCount:h}}var je;(function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"})(je||(je={}));var Ir=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),r=e%8;return(this.values[t]>>r&1)==1}set(e,t){let r=Math.floor(e/8),i=e%8;this.values[r]=this.values[r]|+!!t<<i}getInt(e){let t=Math.floor(e/8),r=e%8;return this.values[t]>>r&1}size(){return this._size}getBuffer(){return this.values}};function la(e,t,r){if(!t)return e;let i=t.size(),a=e.constructor,n=new a(i),s=0;for(let o=0;o<i;o++)n[o]=t.get(o)?e[s++]:r;return n}function HP(e,t,r){if(!r)return e;let i=r.size(),a=new Ir(e,t),n=new Ir(new Uint8Array(Math.ceil(i/8)),i),s=0;for(let o=0;o<i;o++){let l=r.get(o)?a.get(s++):!1;n.set(o,l)}return n.getBuffer()}function tn(e,t,r,i,a){let n=XP(e,Math.ceil(t/8),r,i);return a?HP(n,t,a):n}function XP(e,t,r,i){let a=new Uint8Array(t),n=0,s=i.get()+r;for(;n<t&&!(i.get()>=s);){let o=e[i.increment()];if(o<=127){let l=o+3,u=e[i.increment()],h=Math.min(n+l,t);a.fill(u,n,h),n=h}else{let l=256-o;for(let u=0;u<l&&n<t;u++)a[n++]=e[i.increment()]}}return i.set(s),a}function U0(e,t,r,i){let a=t.get(),n=a+r*Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(a,n)).buffer,o=new Float32Array(s);return t.set(n),i?la(o,i,0):o}function G0(e,t,r,i){let a=t.get(),n=a+r*Float64Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(a,n)).buffer,o=new Float64Array(s);return t.set(n),i?la(o,i,0):o}function YP(e,t,r){let i=t.get(),a=r*Uint32Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),s=new Uint32Array(r);for(let o=0;o<r;o++)s[o]=n.getUint32(i+o*Uint32Array.BYTES_PER_ELEMENT,!0);return t.add(a),s}function KP(e,t,r){let i=t.get(),a=r*BigUint64Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),s=new BigUint64Array(r);for(let o=0;o<r;o++)s[o]=n.getBigUint64(i+o*BigUint64Array.BYTES_PER_ELEMENT,!0);return t.add(a),s}const JP=new TextDecoder;function kd(e,t,r){return r-t>=12?JP.decode(e.subarray(t,r)):QP(e,t,r)}function QP(e,t,r){let i="",a=t;for(;a<r;){let n=e[a],s=null,o=n>239?4:n>223?3:n>191?2:1;if(a+o>r)break;let l,u,h;o===1?n<128&&(s=n):o===2?(l=e[a+1],(l&192)==128&&(s=(n&31)<<6|l&63,s<=127&&(s=null))):o===3?(l=e[a+1],u=e[a+2],(l&192)==128&&(u&192)==128&&(s=(n&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):o===4&&(l=e[a+1],u=e[a+2],h=e[a+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(s=(n&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,o=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),a+=o}return i}function ll(e,t,r,i,a){return aA(rn(e,t,r),r,i,a)}function Dt(e,t,r,i,a){return nA(rn(e,t,r),r,i,a)}function yi(e,t,r){return lA(rn(e,t,r),r)}function rn(e,t,r){let i=r.physicalLevelTechnique;switch(i){case xr.FAST_PFOR:return yP(e,r.numValues,r.byteLength,t);case xr.VARINT:return Mt(e,t,r.numValues);case xr.NONE:return YP(e,t,r.numValues);default:throw Error(`Specified physicalLevelTechnique ${i} is not supported (yet).`)}}function vs(e,t,r){let i=r.physicalLevelTechnique;switch(i){case xr.VARINT:return Fd(e,t,r.numValues);case xr.NONE:return KP(e,t,r.numValues);default:throw Error(`Specified physicalLevelTechnique ${i} is not supported (yet).`)}}function eA(e,t,r){let i=rn(e,t,r);return i.length===1?Me(i[0]):kP(i)}function Ld(e,t,r){let i=rn(e,t,r);return i.length===1?r.logicalLevelTechnique1===he.DELTA?Me(i[0]):i[0]:RP(i)}function q0(e,t,r){return LP(rn(e,t,r))}function Z0(e,t,r){return $P(Fd(e,t,r.numValues))}function W0(e,t,r,i){return sA(vs(e,t,r),r,i)}function Bd(e,t,r,i){return X0(vs(e,t,r),r,i)}function tA(e,t,r,i){let a=rA(e,t,r,!1);return i?la(a,i,0):a}function rA(e,t,r,i){if(r.physicalLevelTechnique===xr.VARINT)return oA(mP(e,t,r.numValues),r,i);let a=vs(e,t,r),n=X0(a,r);return Float64Array.from(n,Number)}function iA(e,t,r){let i=vs(e,t,r);return i.length===1?At(i[0]):OP(i)}function H0(e,t,r){let i=vs(e,t,r);return i.length===1?r.logicalLevelTechnique1===he.DELTA?At(i[0]):i[0]:BP(i)}function aA(e,t,r,i){let a;switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let n=t;if(!i)return MP(e,n.runs,n.numRleValues);e=Dc(e,n.runs,n.numRleValues),a=sm(e)}else a=sm(e);break;case he.RLE:a=TP(e,t.runs,t.numRleValues);break;case he.MORTON:Rd(e),a=new Int32Array(e);break;case he.COMPONENTWISE_DELTA:a=PP(e);break;case he.NONE:a=vP(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?la(a,i,0):a}function nA(e,t,r,i){let a;switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let n=t;a=lm(Dc(e,n.runs,n.numRleValues))}else a=lm(e);break;case he.RLE:a=Dc(e,t.runs,t.numRleValues);break;case he.MORTON:Rd(e),a=e;break;case he.COMPONENTWISE_DELTA:a=FP(e);break;case he.NONE:a=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?la(a,i,0):a}function sA(e,t,r){let i;switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let a=t;if(!r)return zP(e,a.runs,a.numRleValues);e=Sc(e,a.runs,a.numRleValues),i=om(e)}else i=om(e);break;case he.RLE:i=DP(e,t.runs,t.numRleValues);break;case he.NONE:i=bP(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?la(i,r,0n):i}function X0(e,t,r){let i;switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let a=t;i=um(Sc(e,a.runs,a.numRleValues))}else i=um(e);break;case he.RLE:i=Sc(e,t.runs,t.numRleValues);break;case he.NONE:i=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?la(i,r,0n):i}function oA(e,t,r){switch(t.logicalLevelTechnique1){case he.DELTA:if(t.logicalLevelTechnique2===he.RLE){let i=t;e=N0(e,i.runs,i.numRleValues)}return wP(e),e;case he.RLE:return hA(e,t,r);case he.NONE:return e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}function lA(e,t){if(t.logicalLevelTechnique1===he.DELTA&&t.logicalLevelTechnique2===he.NONE)return AP(e);if(t.logicalLevelTechnique1===he.RLE&&t.logicalLevelTechnique2===he.NONE){let r=t;return IP(e,r.runs,r.numRleValues)}if(t.logicalLevelTechnique1===he.NONE&&t.logicalLevelTechnique2===he.NONE){EP(e);let r=new Uint32Array(t.numValues+1);return r[0]=0,r.set(e,1),r}if(t.logicalLevelTechnique1===he.DELTA&&t.logicalLevelTechnique2===he.RLE){let r=t,i=CP(e,r.runs,r.numRleValues);return Rd(i),new Uint32Array(i)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}function Ul(e,t,r,i,a="int32"){let n=e.logicalLevelTechnique1;if(n===he.RLE)return e.runs===1?je.CONST:je.FLAT;if(n!==he.DELTA||e.logicalLevelTechnique2!==he.RLE)return e.numValues===1?je.CONST:je.FLAT;let s=t instanceof Ir?t.size():t,o=e;if(o.numRleValues!==s)return je.FLAT;if(o.runs===1)return je.SEQUENCE;if(o.runs!==2)return e.numValues===1?je.CONST:je.FLAT;let l=i.get();if(e.physicalLevelTechnique===xr.VARINT)return uA(r,i,a)?je.SEQUENCE:e.numValues===1?je.CONST:je.FLAT;let u=i.get(),h=new Int32Array(r.buffer,r.byteOffset+u,4);return i.set(l),h[2]===2&&h[3]===2?je.SEQUENCE:e.numValues===1?je.CONST:je.FLAT}function uA(e,t,r){let i=new $0(t.get());if(r==="int64"){let n=Fd(e,i,4);return n[2]===2n&&n[3]===2n}let a=Mt(e,i,4);return a[2]===2&&a[3]===2}function hA(e,t,r){return r?SP(e,t.runs,t.numRleValues):N0(e,t.runs,t.numRleValues)}var Y0=class extends Nl{getValueFromBuffer(e){return this.dataBuffer[e]}},K0=class extends B0{constructor(e,t,r,i,a){super(e,a?BigInt64Array.of(t):BigUint64Array.of(t),r,i)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function Od(e,t,r){return{x:cm(e,t)-r,y:cm(e>>1,t)-r}}function cm(e,t){let r=0;for(let i=0;i<t;i++)r|=(e&1<<2*i)>>i;return r}var Ct;(function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"})(Ct||(Ct={}));var cA;(function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"})(cA||(cA={}));var ua;(function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"})(ua||(ua={}));function dA(e){let t=Array(e.numGeometries),r=1,i=1,a=1,n=0,s=0,o=0,l=e.mortonSettings,u=e.topologyVector,h=u.geometryOffsets,c=u.partOffsets,d=u.ringOffsets,p=e.vertexOffsets,f=!p||p.length===0,m=e.containsPolygonGeometry(),g=e.vertexBuffer;for(let _=0;_<e.numGeometries;_++){let y=e.geometryType(_);switch(y){case Ct.POINT:{let v,x;if(f)v=g[s++],x=g[s++];else if(e.vertexBufferType===ua.MORTON){let w=g[p[o++]],b=Od(w,l.numBits,l.coordinateShift);v=b.x,x=b.y}else{let w=p[o++]*2;v=g[w],x=g[w+1]}t[n++]=[[new C(v,x)]],h&&a++,c&&r++,d&&i++}break;case Ct.MULTIPOINT:{let v=h[a]-h[a-1];a++;let x;if(f){x=Array(v);for(let w=0;w<v;w++){let b=g[s++],T=g[s++];x[w]=new C(b,T)}}else x=ki(e.vertexBufferType,g,p,o,v,!1,l),o+=v;t[n++]=x.map(w=>[w]),r+=v,i+=v}break;case Ct.LINESTRING:{let v;m?(v=d[i]-d[i-1],i++):v=c[r]-c[r-1],r++;let x;f?(x=va(g,s,v,!1),s+=v*2):(x=ki(e.vertexBufferType,g,p,o,v,!1,l),o+=v),t[n++]=[x],h&&a++}break;case Ct.POLYGON:{let v=c[r]-c[r-1];r++;let x=Array(v-1),w,b=d[i]-d[i-1];if(i++,f){w=va(g,s,b,!0),s+=b*2;for(let T=0;T<x.length;T++)b=d[i]-d[i-1],i++,x[T]=va(g,s,b,!0),s+=b*2}else{w=ki(e.vertexBufferType,g,p,o,b,!0,l),o+=b;for(let T=0;T<x.length;T++)b=d[i]-d[i-1],i++,x[T]=ki(e.vertexBufferType,g,p,o,b,!0,l),o+=b}t[n++]=[w].concat(x),h&&a++}break;case Ct.MULTILINESTRING:{let v=h[a]-h[a-1];a++;let x=Array(v);for(let w=0;w<v;w++){let b;if(m?(b=d[i]-d[i-1],i++):b=c[r]-c[r-1],r++,f)x[w]=va(g,s,b,!1),s+=b*2;else{let T=ki(e.vertexBufferType,g,p,o,b,!1,l);x[w]=T,o+=b}}t[n++]=x}break;case Ct.MULTIPOLYGON:{let v=h[a]-h[a-1];a++;let x=Array(v);for(let w=0;w<v;w++){let b=c[r]-c[r-1];r++;let T,P=Array(b-1),S=d[i]-d[i-1];i++,f?(T=va(g,s,S,!0),s+=S*2):(T=ki(e.vertexBufferType,g,p,o,S,!0,l),o+=S);for(let I=0;I<P.length;I++){let R=d[i]-d[i-1];i++,f?(P[I]=va(g,s,R,!0),s+=R*2):(P[I]=ki(e.vertexBufferType,g,p,o,R,!0,l),o+=R)}x[w]=[T].concat(P)}t[n++]=x.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return t}function ki(e,t,r,i,a,n,s){return e===ua.MORTON?fA(t,r,i,a,n,s):pA(t,r,i,a,n)}function va(e,t,r,i){let a=Array(i?r+1:r);for(let n=0;n<r*2;n+=2){let s=e[t+n],o=e[t+n+1];a[n/2]=new C(s,o)}return i&&(a[a.length-1]=a[0]),a}function pA(e,t,r,i,a){let n=Array(a?i+1:i);for(let s=0;s<i*2;s+=2){let o=t[r+s/2]*2,l=e[o],u=e[o+1];n[s/2]=new C(l,u)}return a&&(n[n.length-1]=n[0]),n}function fA(e,t,r,i,a,n){let s=Array(a?i+1:i);for(let o=0;o<i;o++){let l=e[t[r+o]],u=Od(l,n.numBits,n.coordinateShift);s[o]=new C(u.x,u.y)}return a&&(s[s.length-1]=s[0]),s}var J0=class{constructor(e,t,r,i,a){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=r,this._vertexBuffer=i,this._mortonSettings=a}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){let t=this.vertexOffsets?this.vertexOffsets[e]*2:e*2;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){let r=this.vertexOffsets[e],i=this.vertexBuffer[r],a=Od(i,this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[a.x,a.y]}let t=this.vertexOffsets?this.vertexOffsets[e]*2:e*2;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return dA(this)}get mortonSettings(){return this._mortonSettings}};function mA(e,t,r,i,a){return new Q0(e,t,ua.VEC_2,r,i,a)}function gA(e,t,r,i,a,n){return new Q0(e,t,ua.MORTON,r,i,a,n)}var Q0=class extends J0{constructor(e,t,r,i,a,n,s){super(r,i,a,n,s),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Ct.POLYGON||this._geometryType===Ct.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function e1(e,t,r,i){return new t1(ua.VEC_2,e,t,r,i)}function _A(e,t,r,i,a){return new t1(ua.MORTON,e,t,r,i,a)}var t1=class extends J0{constructor(e,t,r,i,a,n){super(e,r,i,a,n),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===Ct.POLYGON||this.geometryType(e)===Ct.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},r1=class{constructor(e,t,r,i){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=r,this._topologyVector=i}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw Error("Cannot convert GpuVector to coordinates without topology information");let e=new Uint32Array(this.numGeometries);for(let t=0;t<this.numGeometries;t++)e[t]=this.geometryType(t);return e1(e,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function dm(e,t,r,i,a,n){return new yA(e,t,r,i,a,n)}var yA=class extends r1{constructor(e,t,r,i,a,n){super(r,i,a,n),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function pm(e,t,r,i,a){return new xA(e,t,r,i,a)}var xA=class extends r1{constructor(e,t,r,i,a){super(t,r,i,a),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function vA(e,t,r,i,a){let n=He(e,r),s=Ul(n,i,e,r),o,l,u,h;if(s===je.CONST){let v=Ld(e,r,n),x,w,b,T;for(let P=0;P<t-1;P++){let S=He(e,r);switch(S.physicalStreamType){case ut.LENGTH:switch(S.logicalStreamType.lengthType){case gt.GEOMETRIES:x=yi(e,r,S);break;case gt.PARTS:w=yi(e,r,S);break;case gt.RINGS:b=yi(e,r,S);break;case gt.TRIANGLES:T=yi(e,r,S)}break;case ut.OFFSET:switch(S.logicalStreamType.offsetType){case ai.VERTEX:o=Dt(e,r,S);break;case ai.INDEX:h=Dt(e,r,S)}break;case ut.DATA:if(Ot.VERTEX===S.logicalStreamType.dictionaryType)l=ll(e,r,S,a);else{let I=S;u={numBits:I.numBits,coordinateShift:I.coordinateShift},l=Dt(e,r,S,a)}}}return h?x!==void 0||w!==void 0?dm(i,v,T,h,l,{geometryOffsets:x,partOffsets:w,ringOffsets:b}):dm(i,v,T,h,l):u===void 0?mA(i,v,{geometryOffsets:x,partOffsets:w,ringOffsets:b},o,l):gA(i,v,{geometryOffsets:x,partOffsets:w,ringOffsets:b},o,l,u)}let c=Dt(e,r,n),d,p,f,m;for(let v=0;v<t-1;v++){let x=He(e,r);switch(x.physicalStreamType){case ut.LENGTH:switch(x.logicalStreamType.lengthType){case gt.GEOMETRIES:d=Dt(e,r,x);break;case gt.PARTS:p=Dt(e,r,x);break;case gt.RINGS:f=Dt(e,r,x);break;case gt.TRIANGLES:m=yi(e,r,x)}break;case ut.OFFSET:switch(x.logicalStreamType.offsetType){case ai.VERTEX:o=Dt(e,r,x);break;case ai.INDEX:h=Dt(e,r,x)}break;case ut.DATA:if(Ot.VERTEX===x.logicalStreamType.dictionaryType)l=ll(e,r,x,a);else{let w=x;u={numBits:w.numBits,coordinateShift:w.coordinateShift},l=Dt(e,r,x,a)}}}let g,_,y;return d?(g=Vu(c,d,2),p&&f?(_=fm(c,g,p,!1),y=wA(c,g,_,f)):p&&(_=bA(c,g,p))):p&&f?(_=Vu(c,p,1),y=fm(c,_,f,!0)):p&&(_=Vu(c,p,0)),h&&!_?pm(c,m,h,l):h?pm(c,m,h,l,{geometryOffsets:g,partOffsets:_,ringOffsets:y}):u===void 0?e1(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},o,l):_A(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},o,l,u)}function Vu(e,t,r){let i=new Uint32Array(e.length+1),a=0;i[0]=a;let n=0;for(let s=0;s<e.length;s++)a=i[s+1]=a+(e[s]>r?t[n++]:1);return i}function fm(e,t,r,i){let a=new Uint32Array(t[t.length-1]+1),n=0;a[0]=n;let s=1,o=0;for(let l=0;l<e.length;l++){let u=e[l],h=t[l+1]-t[l];if(u===5||u===2||i&&(u===4||u===1))for(let c=0;c<h;c++)n=a[s++]=n+r[o++];else for(let c=0;c<h;c++)a[s++]=++n}return a}function bA(e,t,r){let i=new Uint32Array(t[t.length-1]+1),a=0;i[0]=a;let n=1,s=0;for(let o=0;o<e.length;o++){let l=e[o],u=t[o+1]-t[o];if(l===4||l===1)for(let h=0;h<u;h++)a=i[n++]=a+r[s++];else for(let h=0;h<u;h++)i[n++]=++a}return i}function wA(e,t,r,i){let a=new Uint32Array(r[r.length-1]+1),n=0;a[0]=n;let s=1,o=1,l=0;for(let u=0;u<e.length;u++){let h=e[u],c=t[u+1]-t[u];if(h!==0&&h!==3)for(let d=0;d<c;d++){let p=r[s]-r[s-1];s++;for(let f=0;f<p;f++)n=a[o++]=n+i[l++]}else for(let d=0;d<c;d++)a[o++]=++n,s++}return a}var TA=class extends oa{constructor(e,t,r){super(e,t.getBuffer(),r),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}},DA=class extends Nl{getValueFromBuffer(e){return this.dataBuffer[e]}},i1=class extends oa{constructor(e,t,r,i){super(e,i?BigInt64Array.of(t):BigUint64Array.of(t),r)}getValueFromBuffer(e){return this.dataBuffer[0]}},$d=class extends oa{constructor(e,t,r,i){super(e,r,i),this.offsetBuffer=t}},mm=class extends $d{constructor(e,t,r,i){super(e,t,r,i??t.length-1)}getValueFromBuffer(e){let t=this.offsetBuffer[e],r=this.offsetBuffer[e+1];return kd(this.dataBuffer,t,r)}},Oa=class extends $d{constructor(e,t,r,i,a){super(e,r,i,a??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e],r=this.offsetBuffer[t],i=this.offsetBuffer[t+1];return kd(this.dataBuffer,r,i)}};function SA(e,t){let r=0;for(let i=0;i<t.length;i++){let a=t[i];a===255?(r++,i++):r+=e[a]}return r}function EA(e,t,r){let i=new Uint32Array(t.length);for(let s=1;s<t.length;s++)i[s]=i[s-1]+t[s-1];let a=new Uint8Array(SA(t,r)),n=0;for(let s=0;s<r.length;s++){let o=r[s];if(o===255)s++,a[n++]=r[s];else{let l=t[o],u=i[o];for(;l-- >0;)a[n++]=e[u++]}}return a}var a1=class extends $d{constructor(e,t,r,i,a,n,s,o){super(e,r,i,s??t.length),this.indexBuffer=t,this.symbolOffsetBuffer=a,this.symbolTableBuffer=n,this.sharedDictionaryCache=o}getValueFromBuffer(e){var a;this.decodedDictionary??(this.decodedDictionary=(a=this.sharedDictionaryCache)==null?void 0:a.decodedDictionary,this.decodedDictionary??(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let t=this.indexBuffer[e],r=this.offsetBuffer[t],i=this.offsetBuffer[t+1];return kd(this.decodedDictionary,r,i)}decodeDictionary(){return this.symbolLengthBuffer??(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),EA(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),r=e[0];for(let i=1;i<e.length;i++){let a=e[i];t[i-1]=a-r,r=a}return t}};function n1(e,t,r,i,a){let n,s,o,l,u,h=a,c,d;for(let p=0;p<i;p++){let f=He(t,r);switch(f.physicalStreamType){case ut.PRESENT:{let m=new Ir(tn(t,f.numValues,f.byteLength,r),f.numValues);h=a??m;break}case ut.OFFSET:s=Dt(t,r,f,void 0,h);break;case ut.LENGTH:{let m=yi(t,r,f);gt.DICTIONARY===f.logicalStreamType.lengthType?n=m:gt.SYMBOL===f.logicalStreamType.lengthType?l=m:c=m;break}case ut.DATA:{let m=t.subarray(r.get(),r.get()+f.byteLength);r.add(f.byteLength);let g=f.logicalStreamType.dictionaryType;Ot.FSST===g?u=m:Ot.SINGLE===g||Ot.SHARED===g?o=m:Ot.NONE===g&&(d=m);break}}}return PA(e,u,s,n,o,l,h)??AA(e,o,s,n,h)??CA(e,c,d,s,h)}function PA(e,t,r,i,a,n,s){if(t){if(!r||!i||!a||!n)throw Error(`Incomplete FSST dictionary string column "${e}"`);return new a1(e,r,i,a,n,t,s)}}function AA(e,t,r,i,a){if(t){if(!r||!i)throw Error(`Incomplete dictionary string column "${e}"`);return a?new Oa(e,r,i,t,a):new Oa(e,r,i,t)}}function CA(e,t,r,i,a){if(t&&r){if(i)return a?new Oa(e,i,t,r,a):new Oa(e,i,t,r);if(a&&a.size()!==t.length-1){let n=new Uint32Array(a.size()),s=0;for(let o=0;o<a.size();o++)a.get(o)?n[o]=s++:n[o]=0;return new Oa(e,n,t,r,a)}return a?new mm(e,t,r,a):new mm(e,t,r)}}function IA(e,t,r,i){let a,n,s,o,l=!1;for(;!l;){let p=He(e,t);switch(p.physicalStreamType){case ut.LENGTH:gt.DICTIONARY===p.logicalStreamType.lengthType?a=yi(e,t,p):s=yi(e,t,p);break;case ut.DATA:Ot.SINGLE===p.logicalStreamType.dictionaryType||Ot.SHARED===p.logicalStreamType.dictionaryType?(n=e.subarray(t.get(),t.get()+p.byteLength),l=!0):o=e.subarray(t.get(),t.get()+p.byteLength),t.add(p.byteLength)}}if(r.type!=="complexType")throw Error(`Shared dictionary column ${r.name} must be a complex (struct) column.`);if(!a||!n)throw Error(`Incomplete shared dictionary for column "${r.name}"`);let u=r.complexType.children,h=[],c=o?{}:void 0,d=0;for(let p of u){let f=Mt(e,t,1)[0];if(f===0)continue;let m=p.name?`${r.name}${p.name}`:r.name;if(p.type!=="scalarField"||p.scalarField.physicalType!==Te.STRING)throw Error("Currently only scalar string fields are implemented for a struct.");if(f>1&&!p.nullable||f===1&&p.nullable)throw Error(`The number of streams for the child field ${p.name} does not match its nullability. nullibilty: ${p.nullable}, numStreams: ${f}`);let g;if(p.nullable){let y=He(e,t);g=new Ir(tn(e,y.numValues,y.byteLength,t),y.numValues)}let _=Dt(e,t,He(e,t),void 0,g);if(o){if(!s)throw Error(`Incomplete shared FSST dictionary for column "${m}"`);h[d++]=new a1(m,_,a,n,s,o,g,c)}else h[d++]=new Oa(m,_,a,n,g)}return h}var gm=class extends oa{constructor(e,t,r){super(e,new Uint8Array,r??t.length),this.values=t}getValueFromBuffer(e){return this.values[e]}},ni;(function(e){e[e.STRING=1]="STRING",e[e.INT32=2]="INT32",e[e.UINT32=4]="UINT32",e[e.INT64=8]="INT64",e[e.UINT64=16]="UINT64",e[e.FLOAT=32]="FLOAT",e[e.DOUBLE=64]="DOUBLE",e[e.PRESENCE=128]="PRESENCE"})(ni||(ni={}));var Ni;(function(e){e[e.FALSE=0]="FALSE",e[e.TRUE=1]="TRUE",e[e.START_MAP=2]="START_MAP",e[e.START_LIST=3]="START_LIST",e[e.COUNT=4]="COUNT"})(Ni||(Ni={}));function MA(e,t,r,i){let a=zA(r);if(i===0)return a.map(h=>new gm(h,[]));let n=FA(e,t,i),s=(n.presentStream?n.presentCount:n.lengthStream.length)/a.length,o=[],l=0,u=0;for(let h=0;h<a.length;h++){let c=OA(n,h,s,l,u);o.push(new gm(a[h],c.value,c.nullabilityBuffer)),l=c.countsEnd,u=c.valuesEnd}return o}function zA(e){let t=e.type==="complexType"?e.complexType.children:void 0;return!t||t.length===0?[e.name]:t.map(r=>e.name+(r.name??""))}function FA(e,t,r){let i=e[t.get()];t.add(1);let a=Dt(e,t,He(e,t)),n=r-1,s=[];i&ni.STRING&&(n-=RA(e,t,s)),n-=kA(e,t,i,s),n-=LA(e,t,i,s);let o,l=0;if(i&ni.PRESENCE){let h=BA(e,t);o=h.value,l=h.count,n--}let u=new Uint32Array;if(n>0&&(u=Dt(e,t,He(e,t)),n--),n!==0)throw Error(`Unexpected number of remaining streams while decoding map column: ${n}`);return{lengthStream:a,dictionary:s,presentStream:o,presentCount:l,flattenedValues:u}}function RA(e,t,r){let i=e[t.get()];t.add(1);let a=n1("",e,t,i);if(a)for(let n=0;n<a.size;n++)r.push(a.getValue(n));return i}function kA(e,t,r,i){let a=0;return r&ni.INT32?(za(i,ll(e,t,He(e,t))),a++):r&ni.INT64&&(za(i,W0(e,t,He(e,t))),a++),r&ni.UINT32?(za(i,Dt(e,t,He(e,t))),a++):r&ni.UINT64&&(za(i,Bd(e,t,He(e,t))),a++),a}function LA(e,t,r,i){let a=0;return r&ni.FLOAT&&(za(i,U0(e,t,He(e,t).numValues)),a++),r&ni.DOUBLE&&(za(i,G0(e,t,He(e,t).numValues)),a++),a}function BA(e,t){let r=He(e,t);if(r.physicalStreamType!==ut.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${r.physicalStreamType}`);let i=r.numValues,a=t.get(),n=new Ir(tn(e,i,r.byteLength,t),i);return t.set(a+r.byteLength),{value:n,count:i}}function OA(e,t,r,i,a){let{lengthStream:n,flattenedValues:s,presentStream:o,dictionary:l}=e,u=t*r,h=r,c;if(o){c=new Ir(new Uint8Array(Math.ceil(r/8)),r),h=0;for(let y=0;y<r;y++)o.get(u+y)&&(c.set(y,!0),h++)}let d=i+h;if(d>n.length)throw Error("Merged map counts underflow while decoding child streams");let p=Array(r),f=i,m=a;for(let y=0;y<r;y++){if(o&&!o.get(u+y)){p[y]=null;continue}let v=m+n[f++];if(v>s.length)throw Error("Map value stream underflow while decoding feature payload");let x=$A(s,m,v,l);p[y]=x.value,m=x.nextIndex}let g=0;for(let y=i;y<d;y++)g+=n[y];let _=a+g;if(m!==_)throw Error("Unused flattened map values remain after decode");return{value:p,nullabilityBuffer:c,countsEnd:d,valuesEnd:_}}function $A(e,t,r,i){return r-t===1||e[t]===Ni.START_LIST?jd(e,t,r,i):s1(e,t,r,i)}function s1(e,t,r,i){let a=Object.create(null),n=t;for(;n<r;){let s=o1(e[n++],i);if(typeof s!="string")throw Error(`Map key dictionary index does not resolve to a string: ${s}`);let o=jd(e,n,r,i);a[s]=o.value,n=o.nextIndex}return{value:a,nextIndex:n}}function jd(e,t,r,i){if(t>=r)throw Error("Unexpected end of map value stream");let a=e[t];if(a===Ni.FALSE)return{value:!1,nextIndex:t+1};if(a===Ni.TRUE)return{value:!0,nextIndex:t+1};if(a===Ni.START_MAP){let n=_m(e,t,r);return{value:s1(e,t+2,n,i).value,nextIndex:n}}if(a===Ni.START_LIST){let n=_m(e,t,r),s=[],o=t+2;for(;o<n;){let l=jd(e,o,n,i);s.push(l.value),o=l.nextIndex}return{value:s,nextIndex:n}}return{value:o1(a,i),nextIndex:t+1}}function _m(e,t,r){if(t+1>=r)throw Error("Missing length for nested map/list payload");let i=e[t+1];if(i<2)throw Error(`Invalid nested payload length: ${i}`);let a=t+i;if(a>r)throw Error("Nested payload exceeds containing payload bounds");return a}function o1(e,t){let r=e-Ni.COUNT;if(r<0||r>=t.length)throw Error(`Scalar dictionary index out of range: ${e}`);return t[r]}function za(e,t){for(let r of t)e.push(r)}function jA(e,t,r,i,a,n){var s;return r.type==="scalarType"?VA(i,e,t,a,r.scalarType,r):((s=r.complexType)==null?void 0:s.physicalType)===Ti.MAP?MA(e,t,r,i):i===0?null:IA(e,t,r)}function VA(e,t,r,i,a,n){let s;if(e===0)return null;if(n.nullable){let l=He(t,r),u=l.numValues,h=r.get(),c=tn(t,u,l.byteLength,r);r.set(h+l.byteLength),s=new Ir(c,l.numValues)}let o=s??i;switch(a.physicalType){case Te.UINT_32:case Te.INT_32:return ZA(t,r,n,a,o);case Te.STRING:{let l=n.nullable?e-1:e;return n1(n.name,t,r,l,s)??null}case Te.BOOLEAN:return NA(t,r,n,i,o);case Te.UINT_64:case Te.INT_64:return qA(t,r,n,o,a);case Te.FLOAT:return UA(t,r,n,o);case Te.DOUBLE:return GA(t,r,n,o);default:throw Error(`The specified data type for the field is currently not supported: ${a}`)}}function NA(e,t,r,i,a){let n=He(e,t),s=n.numValues,o=t.get(),l=bs(a)?a:void 0,u=tn(e,s,n.byteLength,t,l);t.set(o+n.byteLength);let h=new Ir(u,s);return new TA(r.name,h,a)}function UA(e,t,r,i){let a=He(e,t),n=bs(i)?i:void 0,s=U0(e,t,a.numValues,n);return new DA(r.name,s,i)}function GA(e,t,r,i){let a=He(e,t),n=bs(i)?i:void 0,s=G0(e,t,a.numValues,n);return new Ad(r.name,s,i)}function qA(e,t,r,i,a){let n=He(e,t),s=Ul(n,i,e,t,"int64"),o=a.physicalType===Te.INT_64;if(s===je.FLAT){let u=bs(i)?i:void 0,h=o?W0(e,t,n,u):Bd(e,t,n,u);return new Y0(r.name,h,i)}if(s===je.SEQUENCE){let u=Z0(e,t,n);return new K0(r.name,u[0],u[1],n.numRleValues,o)}let l=o?iA(e,t,n):H0(e,t,n);return new i1(r.name,l,i,o)}function ZA(e,t,r,i,a){let n=He(e,t),s=Ul(n,a,e,t),o=i.physicalType===Te.INT_32;if(s===je.FLAT){let u=bs(a)?a:void 0,h=o?ll(e,t,n,void 0,u):Dt(e,t,n,void 0,u);return new Pd(r.name,h,a)}if(s===je.SEQUENCE){let u=q0(e,t,n);return new Cd(r.name,u[0],u[1],n.numRleValues,o)}let l=o?eA(e,t,n):Ld(e,t,n);return new Id(r.name,l,a,o)}function bs(e){return e instanceof Ir}const ft={ID:0,ID_NULLABLE:1,ID_LONG:2,GEOMETRY:4,SCALAR_BASE:10,STRUCT:30,MAP:31};function l1(e){switch(e){case ft.ID:case ft.ID|ft.ID_NULLABLE:case ft.ID|ft.ID_LONG:case ft.ID|ft.ID_LONG|ft.ID_NULLABLE:return{nullable:(e&ft.ID_NULLABLE)!==0,columnScope:Rn.FEATURE,type:"scalarType",scalarType:{longID:(e&ft.ID_LONG)!==0,type:"logicalType",logicalType:O0.ID}};case ft.GEOMETRY:return{nullable:!1,columnScope:Rn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ti.GEOMETRY,children:[]}};case ft.STRUCT:return{nullable:!1,columnScope:Rn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ti.STRUCT,children:[]}};case ft.MAP:return{nullable:!0,columnScope:Rn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ti.MAP,children:[]}};default:return KA(e)}}function WA(e){return e>=ft.SCALAR_BASE}function u1(e){return e===ft.STRUCT||e===ft.MAP}function HA(e){if(e.type==="scalarType"){let t=e.scalarType;if(t.type==="physicalType")switch(t.physicalType){case Te.BOOLEAN:case Te.INT_8:case Te.UINT_8:case Te.INT_32:case Te.UINT_32:case Te.INT_64:case Te.UINT_64:case Te.FLOAT:case Te.DOUBLE:return!1;case Te.STRING:return!0;default:return!1}if(t.type==="logicalType")return!1}else if(e.type==="complexType"){let t=e.complexType;if(t.type==="physicalType")switch(t.physicalType){case Ti.GEOMETRY:case Ti.STRUCT:case Ti.MAP:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function XA(e){var t;return e.type==="scalarType"&&((t=e.scalarType)==null?void 0:t.type)==="logicalType"&&e.scalarType.logicalType===O0.ID}function YA(e){var t;return e.type==="complexType"&&((t=e.complexType)==null?void 0:t.type)==="physicalType"&&e.complexType.physicalType===Ti.GEOMETRY}function KA(e){let t;switch(e){case 10:case 11:t=Te.BOOLEAN;break;case 12:case 13:t=Te.INT_8;break;case 14:case 15:t=Te.UINT_8;break;case 16:case 17:t=Te.INT_32;break;case 18:case 19:t=Te.UINT_32;break;case 20:case 21:t=Te.INT_64;break;case 22:case 23:t=Te.UINT_64;break;case 24:case 25:t=Te.FLOAT;break;case 26:case 27:t=Te.DOUBLE;break;case 28:case 29:t=Te.STRING;break;default:return null}return{nullable:!!(e&1),columnScope:Rn.FEATURE,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:t}}}const JA=new TextDecoder,ym="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function Vd(e,t){let r=Mt(e,t,1)[0];if(r===0)return"";let i=t.get(),a=i+r,n=e.subarray(i,a);return t.add(r),JA.decode(n)}function QA(e){let t=e.name,r=e.nullable;return e.type==="scalarType"?{type:"scalarField",scalarField:e.scalarType,name:t,nullable:r}:{type:"complexField",complexField:e.complexType,name:t,nullable:r}}function h1(e,t){let r=Mt(e,t,1)[0]>>>0,i=r>=ft.SCALAR_BASE?l1(r):null;if(!i)throw Error(`Unsupported field type code ${r}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let a={...i,name:Vd(e,t)};if(a.type==="complexType"&&u1(r)){let n=a.complexType,s=Mt(e,t,1)[0]>>>0;n.children=Array(s);for(let o=0;o<s;o++)n.children[o]=h1(e,t)}return QA(a)}function eC(e,t){let r=Mt(e,t,1)[0]>>>0,i=l1(r);if(!i)throw Error(`Unsupported column type code ${r}. Supported: ${ym}`);let a;if(WA(r))a=Vd(e,t);else if(r<ft.GEOMETRY)a="id";else if(r===ft.GEOMETRY)a="geometry";else throw Error(`Unsupported column type code ${r}. Supported: ${ym}`);let n={...i,name:a};if(n.type==="complexType"&&u1(r)){let s=Mt(e,t,1)[0]>>>0,o=n.complexType;o.children=Array(s);for(let l=0;l<s;l++)o.children[l]=h1(e,t)}return n}function tC(e,t){let r={};r.featureTables=[];let i={};if(i.name=Vd(e,t),i.name.length===0)throw Error("Missing layer name");let a=Mt(e,t,1)[0]>>>0,n=Mt(e,t,1)[0]>>>0;i.columns=Array(n);for(let s=0;s<n;s++)i.columns[s]=eC(e,t);return r.featureTables.push(i),[r,a]}function rC(e,t,r=!0){let i=new $0(0),a=[];for(;i.get()<e.length;){let n=Mt(e,i,1)[0]>>>0,s=i.get()+n;if(s>e.length)throw Error(`Block overruns tile: ${s} > ${e.length}`);let o=Mt(e,i,1)[0]>>>0;if(o!==1&&o!==2){i.set(s);continue}let[l,u]=tC(e,i),h=l.featureTables[0],c=null,d=null,p=[],f=0;for(let g of h.columns){let _=g.name;if(XA(g)){let y=null;if(g.nullable){let x=He(e,i),w=i.get(),b=tn(e,x.numValues,x.byteLength,i);i.set(w+x.byteLength),y=new Ir(b,x.numValues)}let v=He(e,i);f=y?y.size():v.decompressedCount,c=iC(e,g,i,_,v,y??f,r)}else if(YA(g)){let y=Mt(e,i,1)[0];if(f===0){let v=i.get();f=He(e,i).decompressedCount,i.set(v)}d=vA(e,y,i,f,t)}else{let y=HA(g)?Mt(e,i,1)[0]:1;if(y===0)continue;let v=jA(e,i,g,y,f);if(v)if(Array.isArray(v))for(let x of v)p.push(x);else p.push(v)}}let m=new EE(h.name,d,c,p,u);a.push(m),i.set(s)}return a}function iC(e,t,r,i,a,n,s=!1){var h;let o=(h=t.scalarType)!=null&&h.longID?Te.UINT_64:Te.UINT_32,l=typeof n=="number"?void 0:n,u=Ul(a,n,e,r,o===Te.UINT_64?"int64":"int32");if(o===Te.UINT_32)switch(u){case je.FLAT:return new Pd(i,Dt(e,r,a,void 0,l),n);case je.SEQUENCE:{let c=q0(e,r,a);return new Cd(i,c[0],c[1],a.numRleValues,!1)}case je.CONST:return new Id(i,Ld(e,r,a),n,!1)}switch(u){case je.FLAT:return s?new Ad(i,tA(e,r,a,l),n):new Y0(i,Bd(e,r,a,l),n);case je.SEQUENCE:{let c=Z0(e,r,a);return new K0(i,c[0],c[1],a.numRleValues,!1)}case je.CONST:return new i1(i,H0(e,r,a),n,!1)}throw Error("Vector type not supported for id column.")}var aC=class{constructor(e,t){var r;switch(this._featureData=e,this.properties=this._featureData.properties||{},(r=this._featureData.geometry)==null?void 0:r.type){case Ct.POINT:case Ct.MULTIPOINT:this.type=1;break;case Ct.LINESTRING:case Ct.MULTILINESTRING:this.type=2;break;case Ct.POLYGON:case Ct.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){let e=[];for(let t of this._featureData.geometry.coordinates){let r=[];for(let i of t)r.push(new C(i.x,i.y));e.push(r)}return e}},nC=class{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new aC(this.features[e],this.extent)}},sC=class{constructor(e){this.layers={};let t=rC(new Uint8Array(e));this.layers=t.reduce((r,i)=>({...r,[i.name]:new nC(i)}),{})}},oC=class{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Ah(k,16,0),this.grid3D=new Ah(k,16,0),this.featureIndexArray=new Iy,this.promoteId=t}insert(e,t,r,i,a,n){let s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,i,a);let o=n?this.grid3D:this.grid;for(let l of t){let u=[1/0,1/0,-1/0,-1/0];for(let h of l)u[0]=Math.min(u[0],h.x),u[1]=Math.min(u[1],h.y),u[2]=Math.max(u[2],h.x),u[3]=Math.max(u[3],h.y);u[0]<8192&&u[1]<8192&&u[2]>=0&&u[3]>=0&&o.insert(s,u[0],u[1],u[2],u[3])}}loadVTLayers(){if(!this.vtLayers){switch(this.encoding){case"mlt":this.vtLayers=new sC(this.rawTileData).layers;break;default:this.vtLayers=new RT(new _0(this.rawTileData)).layers}this.sourceLayerCoder=new SE(this.vtLayers?Object.keys(this.vtLayers).sort():[Co])}return this.vtLayers}query(e,t,r,i){this.loadVTLayers();let a=e.params,n=k/e.tileSize/e.scale,s=Yn(a.filter,"queryRenderedFeatures filter",a.globalState),o=e.queryGeometry,l=e.queryPadding*n,u=Pr.fromPoints(o),h=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),c=Pr.fromPoints(e.cameraQueryGeometry).expandBy(l),d=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,(m,g,_,y)=>fw(e.cameraQueryGeometry,m-l,g-l,_+l,y+l));for(let m of d)h.push(m);h.sort(uC);let p={},f;for(let m of h){if(m===f)continue;f=m;let g=this.featureIndexArray.get(m),_=null;this.loadMatchingFeature(p,g.bucketIndex,g.sourceLayerIndex,g.featureIndex,s,a.layers,a.availableImages,t,r,i,(y,v,x)=>(_||(_=na(y)),v.queryIntersectsFeature({queryGeometry:o,feature:y,featureState:x,geometry:_,zoom:this.z,transform:e.transform,pixelsToTileUnits:n,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return p}loadMatchingFeature(e,t,r,i,a,n,s,o,l,u,h){let c=this.bucketLayerIDs[t];if(n&&!c.some(m=>n.has(m)))return;let d=this.sourceLayerCoder.decode(r),p=this.vtLayers[d].feature(i);if(a.needGeometry){let m=sa(p,!0);if(!a.filter(new ze(this.tileID.overscaledZ),m,this.tileID.canonical))return}else if(!a.filter(new ze(this.tileID.overscaledZ),p))return;let f=this.getId(p,d);for(let m of c){if(n&&!n.has(m))continue;let g=o[m];if(!g)continue;let _={};f&&u&&(_=u.getState(g.sourceLayer||"_geojsonTileLayer",f));let y=W({},l[m]);y.paint=xm(y.paint,g.paint,p,_,s),y.layout=xm(y.layout,g.layout,p,_,s);let v=!h||h(p,g,_);if(!v)continue;let x=new L0(p,this.z,this.x,this.y,f);x.layer=y;let w=e[m];w===void 0&&(w=e[m]=[]),w.push({featureIndex:i,feature:x,intersectionZ:v})}}lookupSymbolFeatures(e,t,r,i,a,n,s,o){let l={};this.loadVTLayers();let u=Yn(a.filterSpec,"queryRenderedFeatures symbol filter",a.globalState);for(let h of e)this.loadMatchingFeature(l,r,i,h,u,n,s,o,t);return l}hasLayer(e){for(let t of this.bucketLayerIDs)for(let r of t)if(e===r)return!0;return!1}getId(e,t){var i;let r=e.id;if(this.promoteId){let a=typeof this.promoteId=="string"?this.promoteId:this.promoteId[t];r=e.properties[a],typeof r=="boolean"&&(r=Number(r)),r===void 0&&((i=e.properties)!=null&&i.cluster)&&this.promoteId&&(r=Number(e.properties.cluster_id))}return r}};G("FeatureIndex",oC,{omit:["rawTileData","sourceLayerCoder"]});function lC(e){return typeof e=="object"&&!!e&&"evaluate"in e}function xm(e,t,r,i,a){return Gc(e,(n,s)=>{let o=t instanceof Fl?t.get(s):null;return lC(o)?o.evaluate(r,i,void 0,a):o})}function uC(e,t){return t-e}var hC=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(let e in this.data)for(let t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,r){let i=e.wrapped().key;this.data[i]===void 0&&(this.data[i]=[]);let a={value:t,timeout:void 0};if(r!==void 0&&(a.timeout=setTimeout(()=>{this.remove(e,a)},r)),this.data[i].push(a),this.order.push(i),this.order.length>this.max){let n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){let t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;let r=e.wrapped().key,i=t===void 0?0:this.data[r].indexOf(t),a=this.data[r][i];return this.data[r].splice(i,1),a.timeout&&clearTimeout(a.timeout),this.data[r].length===0&&delete this.data[r],this.onRemove(a.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(e){let t=[];for(let r in this.data)for(let i of this.data[r])e(i.value)||t.push(i);for(let r of t)this.remove(r.value.tileID,r)}};/**
* MapLibre GL JS
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.11.2/LICENSE.txt
*/var cC="6.11.2";function c1(){var e=new _t(4);return _t!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function dC(e,t){var r=t[0],i=t[1],a=t[2],n=t[3],s=r*n-a*i;return s?(s=1/s,e[0]=n*s,e[1]=-i*s,e[2]=-a*s,e[3]=r*s,e):null}function pC(e){return e[0]*e[3]-e[2]*e[1]}function fC(e,t,r){var i=t[0],a=t[1],n=t[2],s=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=i*l+n*o,e[1]=a*l+s*o,e[2]=i*-o+n*l,e[3]=a*-o+s*l,e}let Nu,vm,Uu;const Xt={frame(e,t,r,i){let a=i||window,n=a.requestAnimationFrame(o=>{s(),t(o)}),{unsubscribe:s}=Oo(e.signal,"abort",()=>{s(),a.cancelAnimationFrame(n),r(new hs(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((r,i)=>{this.frame(e,r,i,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t;if(jc()&&!Lg())t=new OffscreenCanvas(e.width,e.height).getContext("2d",{willReadFrequently:!0});else{let r=window.document.createElement("canvas");r.width=e.width,r.height=e.height,t=r.getContext("2d",{willReadFrequently:!0})}if(!t)throw Error("failed to create canvas 2d context");return t.drawImage(e,0,0,e.width,e.height),t},resolveURL(e){return Nu||(Nu=document.createElement("a")),Nu.href=e,Nu.href},get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return Uu===void 0?matchMedia?(vm??(vm=matchMedia("(prefers-reduced-motion: reduce)")),vm.matches):!1:Uu},set prefersReducedMotion(e){Uu=e}},mC=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function Fe(){return mC.getCurrentTime()}const gC=new Set("a.abbr.b.bdi.bdo.br.cite.code.del.div.em.i.img.ins.kbd.li.mark.ol.p.q.s.samp.small.span.strong.sub.sup.time.u.ul.var.wbr".split(".")),_C=new Set(["alt","class","datetime","dir","height","href","hreflang","lang","referrerpolicy","rel","role","src","target","title","translate","type","width"]),yC=new Set(["href","src"]),xC=new Set(["http:","https:","mailto:"]);let bm;function Gu(){return bm??(bm={getAttribute:Element.prototype.getAttribute,getAttributeNames:Element.prototype.getAttributeNames,querySelectorAll:Element.prototype.querySelectorAll,remove:Element.prototype.remove,removeAttribute:Element.prototype.removeAttribute,localName:Object.getOwnPropertyDescriptor(Element.prototype,"localName").get,namespaceURI:Object.getOwnPropertyDescriptor(Element.prototype,"namespaceURI").get}),bm}var t,Le,Je=(Le=class{static create(t,r,i){let a=window.document.createElement(t);return r!==void 0&&(a.className=r),i&&i.appendChild(a),a}static createNS(t,r){return window.document.createElementNS(t,r)}static disableDrag(){Le.docStyle&&Le.selectProp&&(Le.userSelect=Le.docStyle[Le.selectProp],Le.docStyle[Le.selectProp]="none")}static enableDrag(){Le.docStyle&&Le.selectProp&&(Le.docStyle[Le.selectProp]=Le.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",Le.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",Le.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",Le.suppressClickInternal,!0)},0)}static getScale(t){let r=t.getBoundingClientRect();return{x:r.width/t.offsetWidth||1,y:r.height/t.offsetHeight||1,boundingClientRect:r}}static getPoint(t,r,i){let a=r.boundingClientRect;return new C((i.clientX-a.left)/r.x-t.clientLeft,(i.clientY-a.top)/r.y-t.clientTop)}static mousePos(t,r){let i=Le.getScale(t);return Le.getPoint(t,i,r)}static touchPos(t,r){let i=[],a=Le.getScale(t);for(let n of r)i.push(Le.getPoint(t,a,n));return i}static sanitize(t){let r=new DOMParser().parseFromString(t,"text/html").body,{querySelectorAll:i,remove:a}=Gu();for(let s of Array.from(i.call(r,"*")))Le.isAllowedElement(s)?Le.removeDisallowedAttributes(s):a.call(s);let n=document.createDocumentFragment();return n.append(...r.childNodes),n}static isAllowedElement(t){let{namespaceURI:r,localName:i}=Gu();return r.call(t)==="http://www.w3.org/1999/xhtml"&&gC.has(i.call(t))}static removeDisallowedAttributes(t){let{getAttributeNames:r,getAttribute:i,removeAttribute:a}=Gu();for(let n of r.call(t))Le.isAllowedAttribute(n,i.call(t,n))||a.call(t,n)}static isAllowedAttribute(t,r){if(!_C.has(t)&&!t.startsWith("aria-"))return!1;if(!yC.has(t))return!0;try{return xC.has(new URL(r,"https://maplibre.invalid/").protocol)}catch{return!1}}},Le.docStyle=typeof window<"u"&&((t=window.document)==null?void 0:t.documentElement.style),Le.selectProp=!Le.docStyle||"userSelect"in Le.docStyle?"userSelect":"webkitUserSelect",Le);let Gr;(function(e){let t,r,i,a;e.resetRequestQueue=()=>{t=[],r=0,i=0,a={}},e.addThrottleControl=c=>{let d=i++;return a[d]=c,d},e.removeThrottleControl=c=>{delete a[c],u()};let n=()=>{for(let c of Object.keys(a))if(a[c]())return!0;return!1};async function s(c,d,p,f,m=!0,g){let _=await c.transformRequest(d,p);return qc(f.signal),Gr.getImage(_,f,m,g)}e.transformAndGetImage=s,e.getImage=(c,d,p=!0,f)=>new Promise((m,g)=>{c.headers||(c.headers={}),c.headers.accept="image/webp,*/*",W(c,{type:"image"});let _={abortController:d,requestParameters:c,supportImageRefresh:p,imageBitmapOptions:f,state:"queued",onError:y=>{g(y)},onSuccess:y=>{m(y)}};t.push(_),u()});let o=(c,d)=>typeof createImageBitmap=="function"?vv(c,d):bv(c),l=async c=>{c.state="running";let{requestParameters:d,supportImageRefresh:p,imageBitmapOptions:f,onError:m,onSuccess:g,abortController:_}=c,y=p===!1&&!f&&!Na(self)&&!Zg(d.url)&&(!d.headers||Object.keys(d.headers).reduce((x,w)=>x&&w==="accept",!0));r++;let v=y?h(d,_):gl(d,_);try{let x=await v;delete c.abortController,c.state="completed",x.data instanceof HTMLImageElement||Gi(x.data)?g(x):!x.data||x.data.byteLength===0?g({data:null,cacheControl:x.cacheControl,expires:x.expires}):g({data:await o(x.data,f),cacheControl:x.cacheControl,expires:x.expires})}catch(x){delete c.abortController,m(zt(x))}finally{r--,u()}},u=()=>{let c=n()?Ei.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:Ei.MAX_PARALLEL_IMAGE_REQUESTS;for(let d=r;d<c&&t.length>0;d++){let p=t.shift();if(p.abortController.signal.aborted){d--;continue}l(p)}},h=(c,d)=>new Promise((p,f)=>{let m=new Image,g=c.url,_=c.credentials;_&&_==="include"?m.crossOrigin="use-credentials":(_&&_==="same-origin"||!Hg(g))&&(m.crossOrigin="anonymous"),d.signal.addEventListener("abort",()=>{m.src="",f(new hs(d.signal.reason))}),m.fetchPriority="high",m.onload=()=>{m.onerror=m.onload=null,p({data:m})},m.onerror=()=>{m.onerror=m.onload=null,!d.signal.aborted&&f(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},m.src=g})})(Gr||(Gr={})),Gr.resetRequestQueue();var vC=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}},bt=class extends ia{},K=class extends bt{},wm=class extends bt{constructor(e={}){super("style.load",e)}},Dr=class extends bt{constructor(e,t={}){super(e,t),this.dataType="style"}},Ne=class extends bt{constructor(e,t={}){super(e,t),this.dataType="source"}},ir=class extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(e,r);let a=Je.mousePos(t.getCanvas(),r),n=t.unproject(a);super(e,W({point:a,lngLat:n,originalEvent:r},i)),this._defaultPrevented=!1,this.target=t}},so=class extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r){let i=e==="touchend"?r.changedTouches:r.touches,a=Je.touchPos(t.getCanvasContainer(),i),n=a.map(l=>t.unproject(l)),s=a.reduce((l,u,h,c)=>l.add(u.div(c.length)),new C(0,0)),o=t.unproject(s);super(e,{points:a,point:s,lngLats:n,lngLat:o,originalEvent:r}),this._defaultPrevented=!1}},bC=class extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},Tm=class extends bt{},wC=class extends bt{constructor(e={}){super("terrain",e)}},TC=class extends bt{constructor(e={}){super("projectiontransition",e)}},qu=class extends bt{},DC=class extends bt{constructor(e={}){super("styleimagemissing",e)}};function SC(e,t){let r={};for(let i in e)i!=="ref"&&(r[i]=e[i]);return Fv.forEach(i=>{i in t&&(r[i]=t[i])}),r}function Dm(e){e=e.slice();let t=Object.create(null);for(let r=0;r<e.length;r++)t[e[r].id]=e[r];for(let r=0;r<e.length;r++)"ref"in e[r]&&(e[r]=SC(e[r],t[e[r].ref]));return e}function Ce(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Ce(e[r],t[r]))return!1;return!0}if(typeof e=="object"&&e&&t!==null){if(typeof t!="object"||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(!Ce(e[r],t[r]))return!1;return!0}return e===t}function tr(e,t){e.push(t)}function d1(e,t,r){tr(r,{command:"addSource",args:[e,t[e]]})}function p1(e,t,r){tr(t,{command:"removeSource",args:[e]}),r[e]=!0}function EC(e,t,r,i){p1(e,r,i),d1(e,t,r)}function PC(e,t,r){let i;for(i in e[r])if(Object.prototype.hasOwnProperty.call(e[r],i)&&i!=="data"&&!Ce(e[r][i],t[r][i]))return!1;for(i in t[r])if(Object.prototype.hasOwnProperty.call(t[r],i)&&i!=="data"&&!Ce(e[r][i],t[r][i]))return!1;return!0}function AC(e,t,r,i){e||(e={}),t||(t={});let a;for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&(Object.prototype.hasOwnProperty.call(t,a)||p1(a,r,i));for(a in t)Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)?Ce(e[a],t[a])||(e[a].type==="geojson"&&t[a].type==="geojson"&&PC(e,t,a)?tr(r,{command:"setGeoJSONSourceData",args:[a,t[a].data]}):EC(a,t,r,i)):d1(a,t,r))}function Sm(e,t,r,i,a){tr(t,{command:a,args:[r,i,e[i]]})}function oo(e,t,r,i,a){e||(e={}),t||(t={});for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Ce(e[n],t[n])||Sm(t,r,i,n,a));for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&!Object.prototype.hasOwnProperty.call(e,n)&&(Ce(e[n],t[n])||Sm(t,r,i,n,a))}function Em(e){return e.id}function Pm(e,t){return e[t.id]=t,e}function CC(e,t,r){e||(e=[]),t||(t=[]);let i=e.map(Em),a=t.map(Em),n=e.reduce(Pm,{}),s=t.reduce(Pm,{}),o=i.slice(),l=Object.create(null),u,h,c,d,p;for(let f=0,m=0;f<i.length;f++)u=i[f],Object.prototype.hasOwnProperty.call(s,u)?m++:(tr(r,{command:"removeLayer",args:[u]}),o.splice(o.indexOf(u,m),1));for(let f=0,m=0;f<a.length;f++)u=a[a.length-1-f],o[o.length-1-f]!==u&&(Object.prototype.hasOwnProperty.call(n,u)?(tr(r,{command:"removeLayer",args:[u]}),o.splice(o.lastIndexOf(u,o.length-m),1)):m++,d=o[o.length-f],tr(r,{command:"addLayer",args:[s[u],d]}),o.splice(o.length-f,0,u),l[u]=!0);for(let f=0;f<a.length;f++)if(u=a[f],h=n[u],c=s[u],!(l[u]||Ce(h,c))){if(!Ce(h.source,c.source)||!Ce(h["source-layer"],c["source-layer"])||!Ce(h.type,c.type)){tr(r,{command:"removeLayer",args:[u]}),d=o[o.lastIndexOf(u)+1],tr(r,{command:"addLayer",args:[c,d]});continue}for(p in oo(h.layout,c.layout,r,u,"setLayoutProperty"),oo(h.paint,c.paint,r,u,"setPaintProperty"),Ce(h.filter,c.filter)||tr(r,{command:"setFilter",args:[u,c.filter]}),(!Ce(h.minzoom,c.minzoom)||!Ce(h.maxzoom,c.maxzoom))&&tr(r,{command:"setLayerZoomRange",args:[u,c.minzoom,c.maxzoom]}),h)Object.prototype.hasOwnProperty.call(h,p)&&p!=="layout"&&p!=="paint"&&p!=="filter"&&p!=="metadata"&&p!=="minzoom"&&p!=="maxzoom"&&(p.indexOf("paint.")===0?oo(h[p],c[p],r,u,"setPaintProperty"):Ce(h[p],c[p])||tr(r,{command:"setLayerProperty",args:[u,p,c[p]]}));for(p in c)Object.prototype.hasOwnProperty.call(c,p)&&!Object.prototype.hasOwnProperty.call(h,p)&&p!=="layout"&&p!=="paint"&&p!=="filter"&&p!=="metadata"&&p!=="minzoom"&&p!=="maxzoom"&&(p.indexOf("paint.")===0?oo(h[p],c[p],r,u,"setPaintProperty"):Ce(h[p],c[p])||tr(r,{command:"setLayerProperty",args:[u,p,c[p]]}))}}function IC(e,t){if(!e)return[{command:"setStyle",args:[t]}];let r=[];try{if(!Ce(e.version,t.version))return[{command:"setStyle",args:[t]}];Ce(e.center,t.center)||r.push({command:"setCenter",args:[t.center]}),Ce(e.state,t.state)||r.push({command:"setGlobalState",args:[t.state]}),Ce(e.centerAltitude,t.centerAltitude)||r.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Ce(e.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),Ce(e.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),Ce(e.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),Ce(e.roll,t.roll)||r.push({command:"setRoll",args:[t.roll]}),Ce(e.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),Ce(e.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),Ce(e["font-faces"],t["font-faces"])||r.push({command:"setFontFaces",args:[t["font-faces"]]}),Ce(e.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),Ce(e.light,t.light)||r.push({command:"setLight",args:[t.light]});let i=!Ce(e.terrain,t.terrain);i&&!t.terrain&&r.push({command:"setTerrain",args:[void 0]}),Ce(e.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),Ce(e.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});let a={},n=[];AC(e.sources,t.sources,n,a);let s=[];e.layers&&e.layers.forEach(o=>{"source"in o&&a[o.source]?r.push({command:"removeLayer",args:[o.id]}):s.push(o)}),r=r.concat(n),CC(s,t.layers,r),i&&t.terrain&&r.push({command:"setTerrain",args:[t.terrain]})}catch(i){console.warn("Unable to compute style diff:",i),r=[{command:"setStyle",args:[t]}]}return r}function MC(){let e={},t=M.$version;for(let r in M.$root){let i=M.$root[r];if(i.required){let a=null;a=r==="version"?t:i.type==="array"?[]:{},a!=null&&(e[r]=a)}}return e}function Io(e){let t=[];if(typeof e=="string")t.push({id:"default",url:e});else if(e&&e.length>0){let r=[];for(let{id:i,url:a}of e){let n=`${i}${a}`;r.includes(n)||(r.push(n),t.push({id:i,url:a}))}}return t}function Am(e,t,r){try{let i=new URL(e);return i.pathname+=`${t}${r}`,i.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function zC(e,t,r,i){let a=Io(e),n=r>1?"@2x":"",s={},o={};for(let{id:l,url:u}of a){let h=await t.transformRequest(Am(u,n,".json"),"SpriteJSON");s[l]=_l(h,i);let c=await t.transformRequest(Am(u,n,".png"),"SpriteImage");o[l]=Gr.getImage(c,i)}return await Promise.all([...Object.values(s),...Object.values(o)]),FC(s,o)}async function FC(e,t){let r={};for(let i in e){r[i]={};let a=(await t[i]).data;if(!a)throw Error(`Could not load sprite image for ${i}: the response is empty`);let n=Xt.getImageCanvasContext(a),s=(await e[i]).data;for(let o in s){let{width:l,height:u,x:h,y:c,sdf:d,pixelRatio:p,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y}=s[o],v={width:l,height:u,x:h,y:c,context:n};r[i][o]={data:null,pixelRatio:p,sdf:d,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y,spriteData:v}}}return r}var RC=class extends Rt{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let e of Object.keys(this.images))this.removeImage(e);this._spriteImagesIds={}}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:t,promiseResolve:r}of this.requestors)r(this._getImagesForIds(t));this.requestors=[]}}getImage(e){let t=this.images[e];if(t&&!t.data&&t.spriteData){let r=t.spriteData;t.data=new $e({width:r.width,height:r.height},r.context.getImageData(r.x,r.y,r.width,r.height).data),t.spriteData=null}return t}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t,this._imagesIds=null,t.isWebGLImage&&this.updateImage(e,t,!1))}_validate(e,t){let r=!0,i=t.data||t.spriteData;return this._validateStretch(t.stretchX,i==null?void 0:i.width)||(this.fire(new X(Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(t.stretchY,i==null?void 0:i.height)||(this.fire(new X(Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(t.content,t)||(this.fire(new X(Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let r=0;for(let i of e){if(i[0]<r||i[1]<i[0]||t<i[1])return!1;r=i[1]}return!0}_validateContent(e,t){if(!e)return!0;if(e.length!==4)return!1;let r=t.spriteData,i=(r==null?void 0:r.width)||t.data.width,a=(r==null?void 0:r.height)||t.data.height;return e[0]<0||i<e[0]||e[1]<0||a<e[1]||e[2]<0||i<e[2]||e[3]<0||a<e[3]||e[2]<e[0]?!1:e[3]>=e[1]}updateImage(e,t,r=!0){let i=this.images[e];if(r){let a=i.data||i.spriteData;if(a.width!==t.data.width||a.height!==t.data.height)throw Error(`size mismatch between old image (${a.width}x${a.height}) and new image (${t.data.width}x${t.data.height}).`)}t.version=(i.version??0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){var r;let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,(r=t.userImage)!=null&&r.onRemove&&t.userImage.onRemove())}listImages(){return this._imagesIds??(this._imagesIds=Object.keys(this.images)),this._imagesIds}_getSpriteImageId(e,t){return e==="default"?t:`${e}:${t}`}setSpriteImages(e,t){let r=this._spriteImagesIds[e]??[],i=[];for(let s in t){let o=this._getSpriteImageId(e,s);i.push(o),o in this.images?this.updateImage(o,t[s],!1):this.addImage(o,t[s])}let a=new Set(i),n=r.filter(s=>!a.has(s));for(let s of n)this.removeImage(s);return this._spriteImagesIds[e]=i,{loaded:i,removed:n}}removeSpriteImages(e){let t=this._spriteImagesIds[e]??[];for(let r of t)this.removeImage(r);return delete this._spriteImagesIds[e],t}removeAllSpriteImages(){let e=Object.values(this._spriteImagesIds).flat();for(let t of e)this.removeImage(t);return this._spriteImagesIds={},e}setMissingImageResolver(e){this.missingImageResolver=e}getImages(e){return new Promise((t,r)=>{let i=!0;if(!this.isLoaded())for(let a of e)this.images[a]||(i=!1);this.isLoaded()||i?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}async _getImagesForIds(e){var a;let t=new Set(e.filter(n=>!this.getImage(n))),r=this.missingImageResolver;r&&await Promise.allSettled(Array.from(t,n=>r(n)));let i={};for(let n of e){let s=this.getImage(n);s&&(t.delete(n),i[n]={data:s.data.clone(),pixelRatio:s.pixelRatio,sdf:s.sdf,version:s.version,stretchX:s.stretchX,stretchY:s.stretchY,content:s.content,textFitWidth:s.textFitWidth,textFitHeight:s.textFitHeight,hasRenderCallback:!!((a=s.userImage)!=null&&a.render),isWebGLImage:s.isWebGLImage})}for(let n of t)this.fire(new DC({id:n})),_e(`Image "${n}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return i}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let r=this.getImage(t);r||_e(`Image with ID: "${t}" was not found`),_S(r)&&this.updateImage(t,r)}}cloneImages(){let e={};for(let t in this.images){let r=this.images[t];e[t]={...r,data:r.data?r.data.clone():null}}return e}},kC=class{constructor(e){this._imageManager=e,this._entries={},this._image=new $e({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&(this._texture=(this._texture.destroy(),null)),this._entries={},this._image=new $e({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:e,height:t}=this._image;return{width:e,height:t}}getPattern(e){let t=this._imageManager.getImage(e);if(!t)return null;let r=this._entries[e];if((r==null?void 0:r.image)!==t){let i={w:t.data.width+2,h:t.data.height+2,x:0,y:0};this._entries[e]={bin:i,position:new Dd(i,t),image:t}}else if(r.position.version!==t.version)r.position.version=t.version;else return r.position;return this._update(),this._entries[e].position}bind(e){let t=e.gl;this._texture?this._dirty&&(this._dirty=(this._texture.update(this._image),!1)):(this._texture=new dt(e,this._image,t.RGBA),this._dirty=!1),this._texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_update(){for(let a in this._entries)this._imageManager.getImage(a)||delete this._entries[a];let e=[];for(let a in this._entries)e.push(this._entries[a].bin);let{w:t,h:r}=y0(e),i=this._image;i.resize({width:t||1,height:r||1});for(let a in this._entries){let{bin:n}=this._entries[a],s=n.x+1,o=n.y+1,l=this._entries[a].image.data,u=l.width,h=l.height;$e.copy(l,i,{x:0,y:0},{x:s,y:o},{width:u,height:h}),$e.copy(l,i,{x:0,y:h-1},{x:s,y:o-1},{width:u,height:1}),$e.copy(l,i,{x:0,y:0},{x:s,y:o+h},{width:u,height:1}),$e.copy(l,i,{x:u-1,y:0},{x:s-1,y:o},{width:1,height:h}),$e.copy(l,i,{x:0,y:0},{x:s+u,y:o},{width:1,height:h})}this._dirty=!0}};const Ec=1114111,LC={start:0,end:Ec};let BC=0;function OC(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,a,n]=t;return a.length+n.length>6?null:Cm(parseInt(`${a}${"0".repeat(n.length)}`,16),parseInt(`${a}${"f".repeat(n.length)}`,16))}let r=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!r)return null;let i=parseInt(r[1],16);return Cm(i,r[2]===void 0?i:parseInt(r[2],16))}function Cm(e,t){return e>t||e>Ec?null:{start:e,end:Math.min(t,Ec)}}function $C(e,t){return e.ranges.some(({start:r,end:i})=>t>=r&&t<=i)}var jC=class{constructor(e){this.requestManager=e,this._faces={},this._registered=new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,r]of Object.entries(e??{})){let i=Array.isArray(r)?r:[r];this._faces[t]=i.map(a=>this._declareFontFace(t,a)).filter(a=>a!==null)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t){for(let r of e.split(","))for(let i of this._faces[r.trim()]??[])if($C(i,t)&&(i.loaded??(i.loaded=this._loadFontFace(i)),await i.loaded))return i.family;return null}_declareFontFace(e,t){let r=typeof t=="string"?{url:t}:t;if(typeof(r==null?void 0:r.url)!="string")return _e(`Ignoring the font face declared for "${e}": it has no URL.`),null;let i=`maplibre-gl-font-face-${BC++}`,a=r["unicode-range"];if(!(a!=null&&a.length))return{url:r.url,ranges:[LC],family:i};let n=[];for(let s of a){let o=OC(s);if(!o){_e(`Ignoring the unicode range "${s}" of the font face at ${r.url}: it is not a valid range.`);continue}n.push(o)}return n.length?{url:r.url,ranges:n,family:i}:null}async _loadFontFace(e){if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return _e(`Ignoring the font face at ${e.url}: this environment has no CSS Font Loading API.`),!1;let t;try{return t=new FontFace(e.family,await this._downloadFontFile(e.url)),Object.values(this._faces).some(r=>r.includes(e))?(document.fonts.add(t),this._registered.add(t),await t.load(),!0):!1}catch(r){return t&&this._unregister(t),_e(`Ignoring the font face at ${e.url}: ${zt(r).message}`),!1}}async _downloadFontFile(e){let t=await this.requestManager.transformRequest(e,"Glyphs"),r=await Wg(t,new AbortController);if(!(r!=null&&r.data))throw Error(`the response was empty for the font file at ${e}`);return r.data}_unregister(e){var t;(t=document.fonts)==null||t.delete(e),this._registered.delete(e)}_unregisterAll(){var e;for(let t of this._registered)(e=document.fonts)==null||e.delete(t);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}};const Pc=1e20,Nd=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**.45454545454545453;Nd[e]=t*Math.abs(t)}Nd[255]=-1e20;var VC=class{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:i=.25,fontFamily:a="sans-serif",fontWeight:n="normal",fontStyle:s="normal",lang:o=null}={}){this.buffer=t,this.radius=r,this.cutoff=i,this.lang=o;let l=this.size=e+t*4,u=this._createCanvas(l),h=this.ctx=u.getContext("2d",{willReadFrequently:!0});h.font=`${s} ${n} ${e}px ${a}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,e);let t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:a,actualBoundingBoxRight:n}=this.ctx.measureText(e),s=Math.ceil(r),o=Math.floor(-a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n)-o)),u=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(i))),h=l+2*this.buffer,c=u+2*this.buffer,d=Math.max(h*c,0),p=new Uint8ClampedArray(d),f={data:p,width:h,height:c,glyphWidth:l,glyphHeight:u,glyphTop:s,glyphLeft:o,glyphAdvance:t};if(l===0||u===0)return f;let{ctx:m,buffer:g,gridInner:_,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,l,u),m.fillText(e,g-o,g+s);let v=m.getImageData(g,g,l,u);y.fill(Pc,0,d),_.fill(0,0,d);let x=3;for(let P=0;P<u;P++){let S=(P+g)*h+g;for(let I=0;I<l;I++,x+=4,S++){let R=v.data[x];if(R===0)continue;let F=Nd[R];y[S]=Math.max(0,F),_[S]=Math.max(0,-F)}}Im(y,0,0,h,c,h,this.f,this.v,this.z);let w=Math.min(g,1);Im(_,g-w,g-w,l+2*w,u+2*w,h,this.f,this.v,this.z);let b=255/this.radius,T=255*(1-this.cutoff);for(let P=0;P<d;P++){let S=Math.sqrt(y[P])-Math.sqrt(_[P]);p[P]=Math.round(T-b*S)}return f}};function Im(e,t,r,i,a,n,s,o,l){for(let u=t;u<t+i;u++)Mm(e,r*n+u,n,a,s,o,l);for(let u=r;u<r+a;u++)Mm(e,u*n+t,1,i,s,o,l)}function Mm(e,t,r,i,a,n,s){n[0]=0,s[0]=-1e20,s[1]=Pc,a[0]=e[t];for(let o=1,l=0,u=0;o<i;o++){a[o]=e[t+o*r];let h=o*o;do{let c=n[l];u=(a[o]-a[c]+h-c*c)/(o-c)/2}while(u<=s[l]&&--l>-1);l++,n[l]=o,s[l]=u,s[l+1]=Pc}for(let o=0,l=0;o<i;o++){for(;s[l+1]<o;)l++;let u=n[l],h=o-u;e[t+o*r]=a[u]+h*h}}const NC=M.layout_symbol["text-font"].default.join(","),UC=(e,t)=>{let r=new VC(e);return r.buffer=t,r};var GC=class{constructor(e,t,r,i=UC){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=r,this.fontFaceManager=new jC(e),this.createRasterizer=i}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){var a;let t=[];for(let n in e)for(let s in e[n])for(let o of e[n][s])t.push(this._getAndCacheGlyphsPromise(n,o,s));let r=await Promise.all(t),i={};for(let{stack:n,id:s,variant:o,glyph:l}of r)i[n]||(i[n]={}),(a=i[n])[o]||(a[o]={}),i[n][o][s]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics};return i}async _getAndCacheGlyphsPromise(e,t,r){var l,u;(l=this.entries)[e]??(l[e]={glyphs:{default:{}},requests:{},ranges:{}});let i=this.entries[e],a=(u=i.glyphs)[r]||(u[r]={}),n=a[t];if(n!==void 0)return{stack:e,id:t,variant:r,glyph:n};if(r!=="default")return a[t]=null,{stack:e,id:t,variant:r,glyph:null};let s=t.codePointAt(0),o=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,s):null;return o?(n=a[t]=await this._drawGlyph(i,e,t,o),{stack:e,id:t,variant:r,glyph:n}):!this.url||rl(t)||this._charUsesLocalIdeographFontFamily(s)?(n=a[t]=await this._drawGlyph(i,e,t),{stack:e,id:t,variant:r,glyph:n}):{...await this._downloadAndCacheRangePromise(e,t),variant:r}}async _downloadAndCacheRangePromise(e,t){var n;let r=t.codePointAt(0),i=this.entries[e],a=Math.floor(r/256);if(i.ranges[a])return{stack:e,id:t,glyph:null};(n=i.requests)[a]||(n[a]=this._loadGlyphRange(e,a));try{let s=await i.requests[a];for(let o in s)i.glyphs.default[String.fromCodePoint(+o)]=s[+o];return i.ranges[a]=!0,{stack:e,id:t,glyph:s[r]||null}}catch(s){let o=i.glyphs.default[t]=await this._drawGlyph(i,e,t);return this._warnOnMissingGlyphRange(o,a,r,zt(s)),{stack:e,id:t,glyph:o}}}async _loadGlyphRange(e,t){let r=t*256,i=r+255,a=await this.requestManager.transformRequest(this.url.replace("{fontstack}",e).replace("{range}",`${r}-${i}`),"Glyphs"),n=await Wg(a,new AbortController);if(!(n!=null&&n.data))throw Error(`Could not load glyph range. range: ${t}, ${r}-${i}`);let s={};for(let o of gS(n.data))s[o.id]=o;return s}_warnOnMissingGlyphRange(e,t,r,i){let a=t*256,n=a+255,s=r.toString(16).padStart(4,"0").toUpperCase();_e(`Unable to load glyph range ${t}, ${a}-${n}. Rendering codepoint U+${s} locally instead. ${i}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&vD(e)}async _drawGlyph(e,t,r,i){let a=(await this._getTinySDF(e,t,r,i)).draw(r),n=new RegExp("^\\p{gc=Cf}+$","u").test(r);return{id:r.codePointAt(0),bitmap:new yd({width:a.width||60,height:a.height||60},a.data),metrics:{width:n?0:a.glyphWidth/2||24,height:a.glyphHeight/2||24,left:a.glyphLeft/2+.5||0,top:a.glyphTop/2-27.5||-8,advance:n?0:a.glyphAdvance/2||24,isDoubleResolution:!0}}}_getTinySDF(e,t,r,i){var l,u;let a=rl(r);if(i){let h=a?"clusterTinySDFs":"fontFaceTinySDFs";return e[h]??(e[h]={}),(l=e[h])[i]||(l[i]=this._createTinySDF(i,!1,a?3:1)),e[h][i]}let n=t===NC&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(r.codePointAt(0)),s=n?this.localIdeographFontFamily:t;if(a)return e.clusterTinySDFs??(e.clusterTinySDFs={}),(u=e.clusterTinySDFs)[s]||(u[s]=this._createTinySDF(s,!0,3)),e.clusterTinySDFs[s];let o=n?"ideographTinySDF":"tinySDF";return e[o]||(e[o]=this._createTinySDF(s)),e[o]}async _createTinySDF(e,t=!0,r=1){var o;let i=e?e.split(","):[];i.push("sans-serif");let a=i.map(l=>/[-\w]+/.test(l)?l:`'${CSS.escape(l)}'`).join(","),n=t?this._fontWeight(i[0]):void 0,s=t?this._fontStyle(i[0]):"normal";if(typeof document<"u"&&((o=document.fonts)!=null&&o.load))try{await document.fonts.load(`${s} ${n||"normal"} 48px ${a}`)}catch(l){_e(`Failed to load font "${a}": ${zt(l).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(r-1)/4)),radius:16,cutoff:.25,fontFamily:a,fontWeight:n,fontStyle:s,lang:this.lang},6)}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){let t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950},r;for(let[i,a]of Object.entries(t))RegExp(`\\b${i}\\b`,"i").test(e)&&(r=`${a}`);return r}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.fontFaceTinySDFs={},t.glyphs={default:{}},t.requests={},t.ranges={}}this.entries={},this.fontFaceManager.destroy()}};let qC;const ZC=()=>qC||(qC=new wt({anchor:new N(M.light.anchor,"anchor"),position:new N(M.light.position,"position"),color:new N(M.light.color,"color"),intensity:new N(M.light.intensity,"intensity")}));var WC=class extends Rt{constructor(e,t){super(),this._transitionable=new zl(ZC(),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return _v(this.properties.get("position"))}setLight(e,t={}){this._validate(Zt.light,e,t)||this._transitionable.setValues(e)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(e,t,r){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,r)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,r){return _s(this,e,{value:t},r)}};let HC;const XC=()=>HC||(HC=new wt({"sky-color":new N(M.sky["sky-color"],"sky-color"),"horizon-color":new N(M.sky["horizon-color"],"horizon-color"),"fog-color":new N(M.sky["fog-color"],"fog-color"),"fog-ground-blend":new N(M.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new N(M.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new N(M.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new N(M.sky["atmosphere-blend"],"atmosphere-blend")}));var YC=class extends Rt{constructor(e,t){super(),this._transitionable=new zl(XC(),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new ze(0))}setSky(e,t={}){return!this._validate(Zt.sky,e,t)&&(e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0}),this._transitionable.setValues(e),!0)}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(e,t,r){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,r)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,r={}){return _s(this,e,{value:t},r)}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}},KC=class{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){var i;let r=e.join(",")+String(t);return(i=this.dashEntry)[r]||(i[r]=this.addDash(e,t)),this.dashEntry[r]}getDashRanges(e,t,r){let i=e.length%2==1,a=[],n=i?-e[e.length-1]*r:0,s=e[0]*r,o=!0;a.push({left:n,right:s,isDash:o,zeroLength:e[0]===0});let l=e[0];for(let u=1;u<e.length;u++){o=!o;let h=e[u];n=l*r,l+=h,s=l*r,a.push({left:n,right:s,isDash:o,zeroLength:h===0})}return a}addRoundDash(e,t,r){let i=t/2;for(let a=-r;a<=r;a++){let n=this.nextRow+r+a,s=this.width*n,o=0,l=e[o];for(let u=0;u<this.width;u++){u/l.right>1&&(l=e[++o]);let h=Math.abs(u-l.left),c=Math.abs(u-l.right),d=Math.min(h,c),p,f=a/r*(i+1);if(l.isDash){let m=i-Math.abs(f);p=Math.sqrt(d*d+m*m)}else p=i-Math.sqrt(d*d+f*f);this.data[s+u]=Math.max(0,Math.min(255,p+128))}}}addRegularDash(e){for(let s=e.length-1;s>=0;--s){let o=e[s],l=e[s+1];o.zeroLength?e.splice(s,1):(l==null?void 0:l.isDash)===o.isDash&&(l.left=o.left,e.splice(s,1))}let t=e[0],r=e[e.length-1];t.isDash===r.isDash&&(t.left=r.left-this.width,r.right=t.right+this.width);let i=this.width*this.nextRow,a=0,n=e[a];for(let s=0;s<this.width;s++){s/n.right>1&&(n=e[++a]);let o=Math.abs(s-n.left),l=Math.abs(s-n.right),u=Math.min(o,l),h=n.isDash?u:-u;this.data[i+s]=Math.max(0,Math.min(255,h+128))}}addDash(e,t){let r=t?7:0,i=2*r+1;if(this.nextRow+i>this.height)return _e("LineAtlas out of space"),null;let a=0;for(let s of e)a+=s;if(a!==0){let s=this.width/a,o=this.getDashRanges(e,this.width,s);t?this.addRoundDash(o,s,r):this.addRegularDash(o)}let n={y:this.nextRow+r,height:2*r,width:a};return this.nextRow+=i,this.dirty=!0,n}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}};function JC(e){if(!e)return!1;let t=globalThis.location;if(!t)return!1;try{return new URL(e,t.href).origin!==t.origin}catch{return!1}}function QC(){let e=import.meta.url;if(!/^https?:/.test(e))return"";let t=e.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs";return new URL(`./${t}`,e).href}function Zu(e,t){if(t)try{return new Worker(e,{type:"module"})}catch(r){console.warn("Module worker not supported, falling back to classic worker",r)}return new Worker(e)}async function eI(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);let r=await t.text(),i=new Blob([r],{type:"text/javascript"});return URL.createObjectURL(i)}function tI(e){let t=new Blob([`import ${JSON.stringify(new URL(e,import.meta.url).href)}`],{type:"text/javascript"});return URL.createObjectURL(t)}async function rI(){let e=Ei.WORKER_URL||QC(),t=!(e!=null&&e.endsWith(".cjs"));if(!JC(e))return Zu(e,t);if(t){let i=tI(e);try{return Zu(i,t)}finally{URL.revokeObjectURL(i)}}let r=await eI(e);try{return Zu(r,t)}finally{URL.revokeObjectURL(r)}}const iI="maplibre_preloaded_worker_pool";var f1=class m1{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let r=[];for(;r.length<m1.workerCount;)r.push(rI());this.workersPromise=Promise.all(r)}return(await this.workersPromise).slice()}release(t){if(delete this.active[t],this.numActive()===0&&this.workersPromise){let r=this.workersPromise;this.workersPromise=null,r.then(i=>{for(let a of i)a.terminate()})}}isPreloaded(){return!!this.active[iI]}numActive(){return Object.keys(this.active).length}};const aI=Math.floor(Xt.hardwareConcurrency/2);f1.workerCount=xv(globalThis)?Math.max(Math.min(aI,3),1):1;let zm;function g1(){return zm||(zm=new f1),zm}var _1=class extends Rt{constructor(e,t){super(),this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t,this.removed=!1,this.workerErrorSubscriptions=[],this.actorsPromise=this.initActors(t)}async initActors(e){let t=await this.workerPool.acquire(e);if(this.removed)return[];if(this.actors=t.map((r,i)=>{this.workerErrorSubscriptions.push(Oo(r,"error",()=>{this.fire(new X(Error("Worker failed to load. Check that the worker URL is correct.")))},!1));let a=new bE(r,e);return a.name=`Worker ${i}`,a}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(e,t){let r=await this.actorsPromise;return Promise.all(r.map(i=>i.sendAsync({type:e,data:t})))}async getActor(){let e=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%e.length,e[this.currentActor]}async waitForInitComplete(){this.actors.length===0&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.removed=!0;for(let t of this.actors)t.remove();for(let t of this.workerErrorSubscriptions)t.unsubscribe();this.actors=[],this.workerErrorSubscriptions=[],this.setEventedParent(null),e&&this.workerPool.release(this.id)}async registerMessageHandler(e,t){let r=await this.actorsPromise;for(let i of r)i.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let r of t)r.unregisterMessageHandler(e)}};let lo;function nI(){return lo||(lo=new _1(g1(),mh),lo.registerMessageHandler("GR",(e,t,r)=>gl(t,r))),lo}function sI(e,t){let r=Ci();return ot(r,r,[1,1,0]),Et(r,r,[e.width*.5,e.height*.5,1]),e.calculatePosMatrix?Da(r,r,e.calculatePosMatrix(t.toUnwrapped())):r}function oI(e,t,r){if(e)for(let i of e){let a=t[i];if((a==null?void 0:a.source)===r&&a.type==="fill-extrusion")return!0}else for(let i in t){let a=t[i];if(a.source===r&&a.type==="fill-extrusion")return!0}return!1}function lI(e,t,r,i,a,n,s){let o=oI((a==null?void 0:a.layers)??null,t,e.id),l=n.maxPitchScaleFactor(),u=e.tilesIn(i,l,o);u.sort(y1);let h=[];for(let c of u)h.push({wrappedTileID:c.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(t,r,e.getState(),c.queryGeometry,c.cameraQueryGeometry,c.scale,a,n,l,sI(n,c.tileID),s?(d,p)=>s(c.tileID,d,p):void 0)});return dI(cI(h),e)}function uI(e,t,r,i,a,n,s){let o={},l=n.queryRenderedSymbols(i),u=[];for(let h of Object.keys(l).map(Number))u.push(s[h]);u.sort(y1);for(let h of u){let c=h.featureIndex.lookupSymbolFeatures(l[h.bucketInstanceId],t,h.bucketIndex,h.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState},a.layers,a.availableImages,e);for(let d in c){o[d]||(o[d]=[]);let p=c[d];p.sort((f,m)=>{let g=h.featureSortOrder;if(g){let _=g.indexOf(f.featureIndex);return g.indexOf(m.featureIndex)-_}return m.featureIndex-f.featureIndex});for(let f of p)o[d].push(f)}}return pI(o,e,r)}function hI(e,t){let r=e.getRenderableIds().map(n=>e.getTileByID(n)),i=[],a={};for(let n of r){let s=n.tileID.canonical.key;a[s]||(a[s]=!0,n.querySourceFeatures(i,t))}return i}function y1(e,t){let r=e.tileID,i=t.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}function cI(e){let t={},r={};for(let{queryResults:i,wrappedTileID:a}of e){r[a]||(r[a]={});let n=r[a];for(let s in i){let o=i[s];n[s]||(n[s]={});let l=n[s];t[s]||(t[s]=[]);for(let u of o)l[u.featureIndex]||(l[u.featureIndex]=!0,t[s].push(u))}}return t}function dI(e,t){for(let r in e)for(let i of e[r])x1(i,t);return e}function pI(e,t,r){for(let i in e)for(let a of e[i]){let n=r[t[i].source];x1(a,n)}return e}function x1(e,t){let r=e.feature,i=t.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=i}async function v1(e,t,r,i){let a=e;if(e.url?a=(await _l(await t.transformRequest(e.url,"Source"),r)).data:await Xt.frameAsync(r,i),!a)return null;let n=us(W(a,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(n.vectorLayerIds=a.vector_layers.map(s=>s.id)),n}var ci=class Qr{constructor(t,r){t&&(r?this.setSouthWest(t).setNorthEast(r):Array.isArray(t)&&(t.length===4?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 J?new J(t.lng,t.lat):J.convert(t),this}setSouthWest(t){return this._sw=t instanceof J?new J(t.lng,t.lat):J.convert(t),this}extend(t){let r=this._sw,i=this._ne,a,n;if(t instanceof J)a=t,n=t;else if(t instanceof Qr){if(a=t._sw,n=t._ne,!a||!n)return this}else{if(Array.isArray(t)){if(t.length===4||t.every(Array.isArray)){let s=t;return this.extend(Qr.convert(s))}{let s=t;return this.extend(J.convert(s))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(J.convert(t)):this}return!r&&!i?(this._sw=new J(a.lng,a.lat),this._ne=new J(n.lng,n.lat)):(r.lng=Math.min(a.lng,r.lng),r.lat=Math.min(a.lat,r.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)),this}getCenter(){return new J((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 J(this.getWest(),this.getNorth())}getSouthEast(){return new J(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:r,lat:i}=J.convert(t),a=this._sw.lat<=i&&i<=this._ne.lat,n=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=r&&r>=this._ne.lng),a&&n}intersects(t){if(t=Qr.convert(t),!(t.getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let r=Math.abs(this.getEast()-this.getWest()),i=Math.abs(t.getEast()-t.getWest());if(r>=360||i>=360)return!0;let a=mr(this.getWest(),-180,180),n=mr(this.getEast(),-180,180),s=mr(t.getWest(),-180,180),o=mr(t.getEast(),-180,180),l=a>n,u=s>o;return l&&u?!0:l?o>=a||s<=n:u?n>=s||a<=o:s<=n&&o>=a}static convert(t){return t instanceof Qr||!t?t:new Qr(t)}static fromLngLat(t,r=0){let i=360*r/40075017,a=i/Math.cos(Math.PI/180*t.lat);return new Qr(new J(t.lng-a,t.lat-i),new J(t.lng+a,t.lat+i))}adjustAntiMeridian(){let t=new J(this._sw.lng,this._sw.lat),r=new J(this._ne.lng,this._ne.lat);return t.lng>r.lng?new Qr(t,new J(r.lng+360,r.lat)):new Qr(t,r)}},b1=class{constructor(e,t,r){this.bounds=ci.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=r||24}validateBounds(e){return!Array.isArray(e)||e.length!==4?[-180,-90,180,90]:[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]}contains(e){let t=2**e.z,r={minX:Math.floor(Ya(this.bounds.getWest())*t),minY:Math.floor(Ka(this.bounds.getNorth())*t),maxX:Math.ceil(Ya(this.bounds.getEast())*t),maxY:Math.ceil(Ka(this.bounds.getSouth())*t)};return e.x>=r.minX&&e.x<r.maxX&&e.y>=r.minY&&e.y<r.maxY}},fI=class extends Rt{constructor(e,t,r,i){if(super(),this.id=e,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,W(this,us(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=W({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,this.tileSize!==512)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(i)}async load(e=!1){this._loaded=!1,this.fire(new Ne("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await v1(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(W(this,t),t.bounds&&(this.tileBounds=new b1(t.bounds,this.minzoom,this.maxzoom)),this.fire(new Ne("data",{sourceDataType:"metadata"})),this.fire(new Ne("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,Si(t)||this.fire(new X(zt(t)))}}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest=(this._tileJSONRequest.abort(),null))}serialize(){return W({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:await this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(e),etag:e.etag};if(r.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete(),e.aborted)return;let i="RT";if(!e.actor||e.state==="expired")e.actor=this.dispatcher.getReadyActor(),i="LT";else if(e.state==="loading")return new Promise((a,n)=>{e.reloadPromise={resolve:a,reject:n}});e.abortController=new AbortController;try{let a=await e.actor.sendAsync({type:i,data:r},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,a);let n={};return a!=null&&a.etagUnmodified&&(n.unmodified=!0),n}catch(a){if(delete e.abortController,e.aborted||Si(a))return;if(a&&a.status!==404)throw a;this._afterTileLoadWorkerResponse(e,null)}}async _getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let t=e.tileID.scaledTo(this.maxzoom).canonical,r=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:await this.map._requestManager.transformRequest(r,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t!=null&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=t==null?void 0:t.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){let r=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(r.resolve).catch(r.reject)}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&await e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}})}async unloadTile(e){e.unloadVectorData(),e.actor&&await e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},w1=class extends Rt{constructor(e,t,r,i){super(),this.id=e,this.dispatcher=r,this.setEventedParent(i),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=W({type:"raster"},t),W(this,us(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new Ne("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await v1(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(W(this,t),t.bounds&&(this.tileBounds=new b1(t.bounds,this.minzoom,this.maxzoom)),this.fire(new Ne("data",{sourceDataType:"metadata"})),this.fire(new Ne("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,Si(t)||this.fire(new X(zt(t)))}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest=(this._tileJSONRequest.abort(),null))}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest=(this._tileJSONRequest.abort(),null)),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return W({},this._options)}setPremultiplyAlpha(e){return this._premultiplyAlpha===e||this.setSourceProperty(()=>{this._premultiplyAlpha=e}),this}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this._premultiplyAlpha,i=r?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let a=await Gr.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,i);if(delete e.abortController,e.aborted){e.state="unloaded";return}if(a){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let n=this.map.painter.context,s=n.gl,o=a.data??new $e({width:1,height:1},new Uint8Array(4));e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0,premultiply:r}):(e.texture=new dt(n,o,s.RGBA,{useMipmap:!0,premultiply:r}),e.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController)}async unloadTile(e){e.texture&&this.map.painter.saveTileTexture(e.texture)}hasTransition(){return!1}},mI=class extends w1{constructor(e,t,r,i){super(e,t,r,i),this.type="raster-dem",this.maxzoom=22,this._options=W({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox",this.redFactor=t.redFactor,this.greenFactor=t.greenFactor,this.blueFactor=t.blueFactor,this.baseShift=t.baseShift}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let r=await Gr.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete e.abortController,e.aborted){e.state="unloaded";return}if(r){if(this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires}),!r.data){e.state="loaded";return}let i=r.data,a=Gi(i)&&jc()?i:await this.readImageNow(i),n={type:this.type,uid:e.uid,source:this.id,rawImageData:a,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&e.state!=="expired"&&e.state!=="reloading")return;await this.dispatcher.waitForInitComplete(),(!e.actor||e.state==="expired")&&(e.actor=this.dispatcher.getReadyActor()),e.dem=await e.actor.sendAsync({type:"LDT",data:n}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0,e.state="loaded"}}catch(r){if(delete e.abortController,e.aborted)e.state="unloaded";else if(r)throw e.state="errored",r}}async readImageNow(e){if(typeof VideoFrame<"u"&&Lg()){let t=e.width+4,r=e.height+4;try{return new $e({width:t,height:r},await Tv(e,-2,-2,t,r))}catch{}}return Xt.getImageData(e,2)}_getNeighboringTiles(e){let t=e.canonical,r=2**t.z,i=(t.x-1+r)%r,a=t.x===0?e.wrap-1:e.wrap,n=(t.x+1+r)%r,s=t.x+1===r?e.wrap+1:e.wrap,o={};return o[new St(e.overscaledZ,a,t.z,i,t.y).key]={backfilled:!1},o[new St(e.overscaledZ,s,t.z,n,t.y).key]={backfilled:!1},t.y>0&&(o[new St(e.overscaledZ,a,t.z,i,t.y-1).key]={backfilled:!1},o[new St(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},o[new St(e.overscaledZ,s,t.z,n,t.y-1).key]={backfilled:!1}),t.y+1<r&&(o[new St(e.overscaledZ,a,t.z,i,t.y+1).key]={backfilled:!1},o[new St(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},o[new St(e.overscaledZ,s,t.z,n,t.y+1).key]={backfilled:!1}),o}async unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&await e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}})}};function ul(e,t){return t?e.properties[t]:e.id}function gI(e,t){let r=new Map;if(e==null||e.type==null)return r;if(e.type==="Feature"){let i=ul(e,t);return i==null?void 0:(r.set(i,e),r)}if(e.type==="FeatureCollection"){let i=new Set;for(let a of e.features){let n=ul(a,t);if(n==null||i.has(n))return;i.add(n),r.set(n,a)}return r}}function _I(e,t,r){var a,n;let i=[];if(t.removeAll)e.clear();else if(t.remove)for(let s of t.remove){let o=e.get(s);o&&(i.push(o.geometry),e.delete(s))}if(t.add)for(let s of t.add){let o=ul(s,r);if(o==null)continue;let l=e.get(o);l&&i.push(l.geometry),i.push(s.geometry),e.set(o,s)}if(t.update)for(let s of t.update){let o=e.get(s.id);if(!o)continue;let l=!!s.newGeometry,u=s.removeAllProperties||((a=s.removeProperties)==null?void 0:a.length)>0||((n=s.addOrUpdateProperties)==null?void 0:n.length)>0;if(!l&&!u)continue;i.push(o.geometry);let h={...o};if(e.set(s.id,h),l&&(i.push(s.newGeometry),h.geometry=s.newGeometry),u){if(h.properties=s.removeAllProperties?{}:{...h.properties||{}},s.removeProperties)for(let c of s.removeProperties)delete h.properties[c];if(s.addOrUpdateProperties)for(let{key:c,value:d}of s.addOrUpdateProperties)h.properties[c]=d}}return i}function yI(e,t,r){if(!e)return t||{};if(!t)return e||{};let i=Fm(e,r),a=Fm(t,r);xI(i,a);let n={};if((i.removeAll||a.removeAll)&&(n.removeAll=!0),n.remove=new Set([...i.remove,...a.remove]),n.add=new Map([...i.add,...a.add]),n.update=new Map([...i.update,...a.update]),n.remove.size&&n.add.size)for(let s of n.add.keys())n.remove.delete(s);return bI(n)}function xI(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let r of t.remove)e.add.delete(r),e.update.delete(r);for(let[r,i]of t.update){let a=e.update.get(r);a&&(t.update.set(r,vI(a,i)),e.update.delete(r))}}function vI(e,t){let r={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties&&e.addOrUpdateProperties){let i=new Set(t.removeProperties);e.addOrUpdateProperties=e.addOrUpdateProperties.filter(a=>!i.has(a.key))}return(e.removeAllProperties||t.removeAllProperties)&&(r.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(r.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(r.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(r.newGeometry=t.newGeometry||e.newGeometry),r}function Fm(e,t){var i,a;if(!e)return{};let r={};return r.removeAll=e.removeAll,r.remove=new Set(e.remove||[]),r.add=new Map((i=e.add)==null?void 0:i.map(n=>[ul(n,t),n])),r.update=new Map((a=e.update)==null?void 0:a.map(n=>[n.id,n])),r}function bI(e){let t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}function T1(e){return!e||e.length===0?[]:typeof e[0]=="number"?[e]:e.flatMap(t=>T1(t))}function Mo(e){return e.type==="GeometryCollection"?e.geometries.flatMap(t=>Mo(t)):T1(e.coordinates)}function Rm(e){let t=new ci,r;switch(e.type){case"FeatureCollection":r=e.features.flatMap(i=>Mo(i.geometry));break;case"Feature":r=Mo(e.geometry);break;default:r=Mo(e)}if(r.length===0)return t;for(let i of r){let[a,n]=i;t.extend([a,n])}return t}function wI({x:e,y:t,z:r},i=0){let a=cc((e-i)/2**r),n=os((t+1+i)/2**r),s=cc((e+1+i)/2**r),o=os((t-i)/2**r);return new ci([a,n],[s,o])}var TI=class extends Rt{constructor(e,t,r,i){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:t.data},this.actorPromise=r.getActor(),this.setEventedParent(i),this._data=typeof t.data=="string"?{url:t.data}:{geojson:t.data},this._options=W({},t),this._collectResourceTiming=t.collectResourceTiming,t.maxzoom!==void 0&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId,t.clusterMaxZoom!==void 0&&this.maxzoom<=t.clusterMaxZoom&&_e(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=W({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(t.buffer===void 0?128:t.buffer),tolerance:this._pixelsToTileUnits(t.tolerance===void 0?.375:t.tolerance),extent:k,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1,promoteId:this._promoteIdKey,cluster:t.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(t.clusterMaxZoom),minPoints:Math.max(2,t.clusterMinPoints||2),extent:k,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}get _promoteIdKey(){return typeof this.promoteId=="string"?this.promoteId:void 0}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(k/this.tileSize)}_tileUnitsToPixels(e){return e/(k/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||_e(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}async load(){await this._updateWorkerData()}onAdd(e){this.map=e,this.load()}setData(e){return this._data=typeof e=="string"?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e},this._updateWorkerData()}updateData(e){return this._pendingWorkerUpdate.diff=yI(this._pendingWorkerUpdate.diff,e,this._promoteIdKey),this._updateWorkerData()}async getData(){return this._data.url&&await this.once("data"),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return Rm(await this.getData())}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,e.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}getClusterOptions(){let{cluster:e,clusterOptions:t}=this.workerOptions.geojsonVtOptions;return{cluster:e,clusterMaxZoom:t.maxZoom,clusterRadius:this._tileUnitsToPixels(t.radius)}}async getClusterExpansionZoom(e){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterChildren(e){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterLeaves(e,t,r){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:r}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate()){_e(`No pending worker updates for GeoJSONSource ${this.id}.`);return}let{data:e,diff:t,updateCluster:r}=this._pendingWorkerUpdate,i=this._getLoadGeoJSONParameters(e,t,r);e===void 0?t?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(i),await this._updatePromise}async _getLoadGeoJSONParameters(e,t,r){let i=W({type:this.type,source:this.id},this.workerOptions);if(typeof e=="string")return i.request=await this.map._requestManager.transformRequest(Xt.resolveURL(e),"Source"),i.request.collectResourceTiming=this._collectResourceTiming,i;if(e!==void 0)return i.data=e,i;if(t)return i.dataDiff=t,i;if(r)return i.updateCluster=!0,i}async _dispatchWorkerUpdate(e){this._isUpdatingWorker=!0,this.fire(new Ne("dataloading"));try{let t=await e,r=await(await this.actorPromise).sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||r.abandoned){this.fire(new Ne("dataabort"));return}r.data&&(this._data={geojson:r.data});let i=this._applyDiffToSource(t.dataDiff),a=this._getShouldReloadTileOptions(i),n={};this._applyResourceTiming(n,r),this.fire(new Ne("data",{...n,sourceDataType:"metadata"})),this.fire(new Ne("data",{...n,sourceDataType:"content",shouldReloadTileOptions:a}))}catch(t){if(this._isUpdatingWorker=!1,this._removed){this.fire(new Ne("dataabort"));return}this.fire(new X(zt(t)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(e,t){var a;if(!this._collectResourceTiming)return;let r=(a=t.resourceTiming)==null?void 0:a[this.id];if(!r)return;let i=r.slice(0);i!=null&&i.length&&W(e,{resourceTiming:i})}_applyDiffToSource(e){if(!e)return;let t=this._promoteIdKey;if(!this._data.url&&!this._data.updateable){let i=gI(this._data.geojson,t);if(!i)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:i}}if(!this._data.updateable)return;let r=_I(this._data.updateable,e,t);if(!(e.removeAll||this._options.cluster))return r}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(t=>Rm(t))}}shouldReloadTile(e,{affectedBounds:t}){if(e.state==="loading")return!0;if(e.state==="unloaded")return!1;let{buffer:r,extent:i}=this.workerOptions.geojsonVtOptions,a=wI(e.tileID.canonical,r/i);for(let n of t)if(a.intersects(n))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(e){let t=e.actor?"RT":"LT";e.actor=await this.actorPromise;let r={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;try{let i=await(await this.actorPromise).sendAsync({type:t,data:r},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(i,this.map.painter,t==="RT")}catch(i){if(delete e.abortController,e.aborted||Si(i))return;throw i}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}async unloadTile(e){e.unloadVectorData(),await(await this.actorPromise).sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then(e=>e.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return W({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}};const $a=[0,0,1],DI=(e,t)=>({u_tl_parent:new ce(e,t.u_tl_parent),u_scale_parent:new U(e,t.u_scale_parent),u_buffer_scale:new U(e,t.u_buffer_scale),u_image_warp:new jt(e,t.u_image_warp),u_fade_t:new U(e,t.u_fade_t),u_opacity:new U(e,t.u_opacity),u_image0:new H(e,t.u_image0),u_image1:new H(e,t.u_image1),u_brightness_low:new U(e,t.u_brightness_low),u_brightness_high:new U(e,t.u_brightness_high),u_saturation_factor:new U(e,t.u_saturation_factor),u_contrast_factor:new U(e,t.u_contrast_factor),u_spin_weights:new jt(e,t.u_spin_weights),u_coords_top:new rs(e,t.u_coords_top),u_coords_bottom:new rs(e,t.u_coords_bottom)}),SI=(e,t,r,i,a,n)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp:n,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:AI(i.paint.get("raster-saturation")),u_contrast_factor:PI(i.paint.get("raster-contrast")),u_spin_weights:EI(i.paint.get("raster-hue-rotate")),u_coords_top:[a[0].x,a[0].y,a[1].x,a[1].y],u_coords_bottom:[a[3].x,a[3].y,a[2].x,a[2].y]});function EI(e){e*=Math.PI/180;let t=Math.sin(e),r=Math.cos(e);return[(2*r+1)/3,(-Math.sqrt(3)*t-r+1)/3,(Math.sqrt(3)*t-r+1)/3]}function PI(e){return e>0?1/(1-e):1+e}function AI(e){return e>0?1-1/(1.001-e):-e}var ws=class{constructor(e,t,r){this.vertexBuffer=e,this.indexBuffer=t,this.segments=r}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const Ui=Ye([{name:"a_pos",type:"Int16",components:2}]),uo=k/128;function D1(e,t){let r=CI(t,"16bit"),i=bi.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),a=Yr.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new ws(e.createVertexBuffer(i,Ui.members),e.createIndexBuffer(a),Ze.simpleSegment(0,0,i.length,a.length))}function CI(e,t){let r=e.granularity===void 0?1:Math.max(e.granularity,1),i=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),n=i+1,s=a+1,o=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=r+ +!!e.generateBorders,h=r+(e.generateBorders||e.extendToSouthPole?1:0),c=n*s,d=i*a*6,p=n*s>65536;if(p&&t==="16bit")throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let f=p||t==="32bit",m=new Int16Array(c*2),g=0;for(let v=l;v<=h;v++)for(let x=o;x<=u;x++){let w=x/r*k;x===-1&&(w=-uo),x===r+1&&(w=k+uo);let b=v/r*k;v===-1&&(b=e.extendToNorthPole?$n:-uo),v===r+1&&(b=e.extendToSouthPole?jn:k+uo),m[g++]=w,m[g++]=b}let _=f?new Uint32Array(d):new Uint16Array(d),y=0;for(let v=0;v<a;v++)for(let x=0;x<i;x++){let w=x+v*n,b=x+1+v*n,T=x+(v+1)*n,P=x+1+(v+1)*n;_[y++]=w,_[y++]=T,_[y++]=b,_[y++]=b,_[y++]=T,_[y++]=P}return{vertices:m.buffer.slice(0),indices:_.buffer.slice(0),uses32bitIndices:f}}var Ts=class extends Rt{constructor(e,t,r,i){super(),this.imageWarp=$a,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,this.id=e,this.dispatcher=r,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=t}async load(e){if(this.options.url===void 0){this._loaded=!0,this._finishLoading();return}this._loaded=!1,this.fire(new Ne("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await Gr.transformAndGetImage(this.map._requestManager,this.url,"Image",this._abortController);this._abortController=null,this._loaded=!0,t!=null&&t.data?(this._setImage(t.data),e&&(this.coordinates=e),this._finishLoading()):this.fire(new X(Error(`Could not load image ${this.url}: the response is empty`)))}catch(t){if(Si(t))return;this._abortController=null,this._loaded=!0,this.fire(new X(zt(t)))}}loaded(){return this._loaded}updateImage(e){return this._abortController&&(this._abortController=(this._abortController.abort(),null)),"image"in e?(this._loaded=!0,this._setImage(e.image),e.coordinates&&(this.coordinates=e.coordinates),this._finishLoading(),this):e.url?(this.options.url=e.url,this.load(e.coordinates),this):this}_setImage(e){this.image=e,this._imageDirty=!0}getMesh(e,t){return!this._subdividedQuad||t?null:(this._subdividedMesh??(this._subdividedMesh=D1(e,{granularity:16})),this._subdividedMesh)}_disposeTexture(){var e;(e=this.texture)==null||e.destroy(),this.texture=null}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Ne("data",{sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){var e;this._abortController&&(this._abortController=(this._abortController.abort(),null)),this._disposeTexture(),(e=this._subdividedMesh)==null||e.destroy(),this._subdividedMesh=null,this.image=null,this.tiles={}}setWarp(e){return this._warp===e?this:(this._warp=e,this.tileCoords&&this.setCoordinates(this.coordinates),this)}getWarp(){return this._warp}setCoordinates(e){this.coordinates=e;let t=e.map(Ie.fromLngLat);return this.tileID=II(t),this.terrainTileRanges=this._getOverlappingTileRanges(t),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=t.map(r=>this.tileID.getTilePoint(r)._round()),this.imageWarp=zI(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!S1(this.tileCoords),this.flippedWindingOrder=MI(this.tileCoords),this.fire(new Ne("data",{sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,t=e.gl;this.texture?this._imageDirty&&(this.texture.update(this.image),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)):(this.texture=new dt(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let r=!1;for(let i in this.tiles){let a=this.tiles[i];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,r=!0)}r&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(e){var t;(t=this.tileID)!=null&&t.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}serialize(){let e={type:"image",coordinates:this.coordinates};return this.options.url!==void 0&&(e.url=this.options.url),e}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:t,minY:r,maxX:i,maxY:a}=Pr.fromPoints(e),n={};for(let s=0;s<=25;s++){let o=2**s,l=Math.floor(t*o),u=Math.floor(r*o),h=Math.floor(i*o),c=Math.floor(a*o),d=(l%o+o)%o,p=h%o,f=Math.floor(l/o),m=Math.floor(h/o);n[s]={minWrap:f,maxWrap:m,minTileXWrapped:d,maxTileXWrapped:p,minTileY:u,maxTileY:c}}return n}};function II(e){let t=Pr.fromPoints(e),r=t.width(),i=t.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(r,i))/Math.LN2)),n=2**a;return new Vl(a,Math.floor((t.minX+t.maxX)/2*n),Math.floor((t.minY+t.maxY)/2*n))}function MI(e){let t=e[1].x-e[0].x,r=e[1].y-e[0].y,i=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-r*i<0}function zI(e,t){if(t==="flat"||S1(e))return $a;let[r,i,a,n]=e,s=r.x-i.x+a.x-n.x,o=r.y-i.y+a.y-n.y,l=[i.x-a.x,i.y-a.y,n.x-a.x,n.y-a.y],[u,h,c,d]=l,p=pC(l),f=(s*d-c*o)/p,m=(u*o-s*h)/p,g=[1,1+f,1+f+m,1+m],_=Math.max(...g)/Math.min(...g),y=t==="perspective"?0:FI(_);return!(_>=1&&_<=512)||y>=1?$a:[f,m,y]}function FI(e){let t=(1-4/e)/.9921875;return Math.max(0,t)}function S1(e){let[t,r,i,a]=e;return t.x+i.x===r.x+a.x&&t.y+i.y===r.y+a.y}var RI=class extends Ts{constructor(e,t,r,i){super(e,t,r,i),this._onPlayingHandler=()=>{var a;(a=this.map)==null||a.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=t}async load(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push((await this.map._requestManager.transformRequest(t,"Source")).url);try{let t=await zv(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new X(zt(t)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new X(new O(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new dt(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let r=!1;for(let i in this.tiles){let a=this.tiles[i];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,r=!0)}r&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},kI=class extends Ts{constructor(e,t,r,i){super(e,t,r,i),t.coordinates?(!Array.isArray(t.coordinates)||t.coordinates.length!==4||t.coordinates.some(a=>!Array.isArray(a)||a.length!==2||a.some(n=>typeof n!="number")))&&this.fire(new X(new O(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new X(new O(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new X(new O(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas!="string"&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new X(new O(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new X(new O(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=t.animate===void 0||t.animate}async load(){if(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 X(Error("Canvas dimensions cannot be less than or equal to zero.")));return}this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this._playing=(this.prepare(),!1))},this._finishLoading()}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this._playing=!1,super.onRemove()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let t=this.map.painter.context,r=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new dt(t,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let i=!1;for(let a in this.tiles){let n=this.tiles[a];n.state!=="loaded"&&(n.state="loaded",n.texture=this.texture,i=!0)}i&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}};const LI={},BI=(e,t,r,i)=>{let a=new(OI(t.type))(e,t,r,i);if(a.id!==e)throw Error(`Expected Source id to be ${e} instead of ${a.id}`);return a},OI=e=>{switch(e){case"geojson":return TI;case"image":return Ts;case"raster":return w1;case"raster-dem":return mI;case"vector":return fI;case"video":return RI;case"canvas":return kI}return LI[e]};function $I(e,t){let r={};if(!t)return r;for(let i of e){let a=i.layerIds.map(n=>t.getLayer(n)).filter(Boolean);if(a.length!==0){i.layers=a,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map(n=>a.filter(s=>s.id===n)[0]));for(let n of a)r[n.id]=i}}return r}const Ac="RTLPluginLoaded";var jI=class extends Rt{constructor(...e){super(...e),this.status="unavailable",this.url=null,this.dispatcher=nI()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(t=>{throw this.status="error",t})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}async setRTLTextPlugin(e,t=!1){if(this.url)throw Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Xt.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if(this.status==="unavailable")if(t)this.status="deferred",this._syncState(this.status);else return this._requestImport();else if(this.status==="requested")return this._requestImport()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new ia(Ac))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}};let km=null;function Cc(){return km||(km=new jI),km}var E1=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=Vg(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadingDirection!==0||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:r,fadeEndTime:i}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=r,this.fadeEndTime=i}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=Fe(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(e){return this.rttObjects[e]}acquireRTT(e,t,r){return this.rttObjects[t]=e.acquireRTT(r)}releaseRTT(e){if(this.rttObjects.length!==0){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}loadVectorData(e,t,r){if((e==null?void 0:e.etagUnmodified)===!0){this.state="loaded";return}if(this.hasData()&&this.unloadVectorData(),this.state="loaded",!e){this.collisionBoxArray=new vy;return}e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=$I(e.buckets,t==null?void 0:t.style),this.hasSymbolBuckets=!1;for(let i in this.buckets){let a=this.buckets[i];if(a instanceof sl)if(this.hasSymbolBuckets=!0,r)a.justReloaded=!0;else break}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let i in this.buckets){let a=this.buckets[i];if(a instanceof sl&&a.hasRTLText){this.hasRTLText=!0,Cc().lazyLoad();break}}this.queryPadding=0;for(let i in this.buckets){let a=this.buckets[i];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(i).queryRadius(a))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(let r in this.buckets){let i=this.buckets[r];i.uploadPending()&&i.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new dt(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasImage=(this.glyphAtlasTexture=new dt(e,this.glyphAtlasImage,t.ALPHA),null))}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,r,i,a,n,s,o,l,u,h){var c;return(c=this.latestFeatureIndex)!=null&&c.rawTileData?this.latestFeatureIndex.query({queryGeometry:i,cameraQueryGeometry:a,scale:n,tileSize:this.tileSize,pixelPosMatrix:u,transform:o,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,r):{}}querySourceFeatures(e,t){let r=this.latestFeatureIndex;if(!(r!=null&&r.rawTileData))return;let i=r.loadVTLayers(),a=t!=null&&t.sourceLayer?t.sourceLayer:"",n=i._geojsonTileLayer||i[a];if(!n)return;let s=Yn(t==null?void 0:t.filter,`querySourceFeatures[${a}].filter`,t==null?void 0:t.globalState),{z:o,x:l,y:u}=this.tileID.canonical,h={z:o,x:l,y:u};for(let c=0;c<n.length;c++){let d=n.feature(c);if(s.needGeometry){let m=sa(d,!0);if(!s.filter(new ze(this.tileID.overscaledZ),m,this.tileID.canonical))continue}else if(!s.filter(new ze(this.tileID.overscaledZ),d))continue;let p=r.getId(d,a),f=new L0(d,o,l,u,p);f.tile=h,e.push(f)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let t=this.expirationTime;if(e.cacheControl){let r=yv(e.cacheControl);r["max-age"]&&(this.expirationTime=Date.now()+r["max-age"]*1e3)}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let r=Date.now(),i=!1;if(this.expirationTime>r)i=!1;else if(!t)i=!0;else if(this.expirationTime<t)i=!0;else{let a=this.expirationTime-t;a?this.expirationTime=r+Math.max(a,3e4):i=!0}i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),2**31-1)}setFeatureState(e,t,r){var a,n,s;if(!((a=this.latestFeatureIndex)!=null&&a.rawTileData)||Object.keys(e).length===0||this.featureStateRevision===r)return;this.featureStateRevision=r;let i=this.latestFeatureIndex.loadVTLayers();for(let o in this.buckets){if(!t.style.hasLayer(o))continue;let l=this.buckets[o],u=l.layers[0].sourceLayer||"_geojsonTileLayer",h=i[u],c=e[u];if(!h||!c||c.length===0)continue;l.update(c,h,((n=this.imageAtlas)==null?void 0:n.patternPositions)||{},this.dashPositions||{});let d=(s=t==null?void 0:t.style)==null?void 0:s.getLayer(o);d&&(this.queryPadding=Math.max(this.queryPadding,d.queryRadius(l)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Fe()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=Fe()+e}setDependencies(e,t){let r={};for(let i of t)r[i]=!0;this.dependencies[e]=r}hasDependency(e,t){for(let r of e){let i=this.dependencies[r];if(i){for(let a of t)if(i[a])return!0}}return!1}};function Lm(e){let t=[];for(let r in e)t.push({id:r,state:e[r]});return t}var VI=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,r){var a,n,s,o,l;let i=String(t);if((a=this.stateChanges)[e]||(a[e]={}),(n=this.stateChanges[e])[i]||(n[i]={}),W(this.stateChanges[e][i],r),this.deletedStates[e]===null){this.deletedStates[e]={};for(let u in this.state[e])if(u===i){this.deletedStates[e][i]={};for(let h in this.state[e][u])r[h]===void 0&&(this.deletedStates[e][i][h]=null)}else this.deletedStates[e][u]=null}else if(((s=this.deletedStates[e])==null?void 0:s[i])===null){this.deletedStates[e][i]={};for(let u in this.state[e][i])r[u]===void 0&&(this.deletedStates[e][i][u]=null)}else for(let u in r)((l=(o=this.deletedStates[e])==null?void 0:o[i])==null?void 0:l[u])===null&&delete this.deletedStates[e][i][u]}removeFeatureState(e,t,r){var a,n,s;if(this.deletedStates[e]===null)return;let i=String(t);if((a=this.deletedStates)[e]||(a[e]={}),r&&t!==void 0)this.deletedStates[e][i]!==null&&((n=this.deletedStates[e])[i]||(n[i]={}),this.deletedStates[e][i][r]=null);else if(t!==void 0)if((s=this.stateChanges[e])!=null&&s[i])for(r in this.deletedStates[e][i]={},this.stateChanges[e][i])this.deletedStates[e][i][r]=null;else this.deletedStates[e][i]=null;else this.deletedStates[e]=null}getState(e,t){let r=String(t),i=this.state[e]||{},a=this.stateChanges[e]||{},n=W({},i[r],a[r]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let s=this.deletedStates[e][t];if(s===null)return{};for(let o in s)delete n[o]}return n}initializeTileState(e,t){let r={};for(let i in this.state)r[i]=Lm(this.state[i]);e.setFeatureState(r,t,this.revision)}coalesceChanges(e,t){var a,n,s;let r={};for(let o in this.stateChanges){(a=this.state)[o]||(a[o]={}),r[o]||(r[o]={});for(let l in this.stateChanges[o])(n=this.state[o])[l]||(n[l]={}),W(this.state[o][l],this.stateChanges[o][l]),r[o][l]=this.state[o][l]}for(let o in this.deletedStates)if((s=this.state)[o]||(s[o]={}),r[o]||(r[o]={}),this.deletedStates[o]===null)for(let l in this.state[o])this.state[o][l]={},r[o][l]={};else for(let l in this.deletedStates[o]){if(this.deletedStates[o][l]===null)this.state[o][l]={};else for(let u of Object.keys(this.deletedStates[o][l]))delete this.state[o][l][u];r[o][l]=this.state[o][l]}if(this.stateChanges={},this.deletedStates={},Object.keys(r).length===0)return;this.revision++;let i={};for(let o in r)i[o]=Lm(r[o]);e.setFeatureState(i,t,this.revision)}},Ud=class P1{constructor(t,r){this.min=t,this.max=r,this.center=Ve([],fr([],this.min,this.max),.5)}quadrant(t){let r=[t%2==0,t<2],i=ch(this.min),a=ch(this.max);for(let n=0;n<r.length;n++)i[n]=r[n]?this.min[n]:this.center[n],a[n]=r[n]?this.center[n]:this.max[n];return a[2]=this.max[2],new P1(i,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]}intersectsFrustum(t){let r=!0;for(let i of t.planes){let a=this.intersectsPlane(i);if(a===0)return 0;a===1&&(r=!1)}return r?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let r=t[3],i=t[3];for(let a=0;a<3;a++)t[a]>0?(r+=t[a]*this.min[a],i+=t[a]*this.max[a]):(i+=t[a]*this.min[a],r+=t[a]*this.max[a]);return r>=0?2:i<0?0:1}},Gd=class A1{constructor(t,r,i){this.points=t,this.planes=r,this.aabb=i}static fromInvProjectionMatrix(t,r=1,i=0,a,n){let s=[[-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]],o=n?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],l=2**i,u=s.map(p=>NI(p,t,r,l));a&&UI(u,o[0],a,n);let h=o.map(p=>{let f=li([],u[p[0]],u[p[1]]),m=li([],u[p[2]],u[p[1]]),g=Bt([],Ht([],f,m)),_=-lt(g,u[p[1]]);return g.concat(_)}),c=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let p of u)for(let f=0;f<3;f++)c[f]=Math.min(c[f],p[f]),d[f]=Math.max(d[f],p[f]);return new A1(u,h,new Ud(c,d))}};function NI(e,t,r,i){let a=Pt([],e,t),n=1/a[3]/r*i;return rv(a,a,[n,n,1/a[3],n])}function UI(e,t,r,i){let a=i?4:0,n=i?0:4,s=0,o=[],l=[];for(let c=0;c<4;c++){let d=li([],e[c+n],e[c+a]),p=Sr(d);Ve(d,d,1/p),o.push(p),l.push(d)}for(let c=0;c<4;c++){let d=uv(e[c+a],l[c],r);s=d!==null&&d>=0?Math.max(s,d):Math.max(s,o[c])}let u=GI(e,t),h=qI(r,u);if(h!==null){let c=h/lt(l[0],u);s=Math.min(s,c)}for(let c=0;c<4;c++){let d=Math.min(s,o[c]);e[c+n]=[e[c+a][0]+l[c][0]*d,e[c+a][1]+l[c][1]*d,e[c+a][2]+l[c][2]*d,1]}}function GI(e,t){let r=li([],e[t[0]],e[t[1]]),i=li([],e[t[2]],e[t[1]]),a=[0,0,0,0];return Bt(a,Ht([],r,i)),a[3]=-lt(a,e[t[0]]),a}function qI(e,t){let r=Bo(e),i=ev([],e,1/r),a=li([],t,Ve([],i,lt(t,i))),n=Bo(a);if(n>0){let s=Math.sqrt(1-i[3]*i[3]),o=Ve([],i,-i[3]),l=fr([],o,Ve([],a,s/n));return ph(t,l)}return null}function ZI(e,t,r){let i=t.intersectsFrustum(e);if(!r||i===0)return i;let a=t.intersectsPlane(r);return a===0?0:i===2&&a===2?2:1}function Bm(e,t,r){let i=0,a=(r-t)/10;for(let n=0;n<10;n++){let s=t+(n+.5)/10*(r-t);i+=a*Math.cos(s)**+e}return i}function Ic(e,t){return function(r,i,a,n,s){let o=2*((e-1)/It(Math.cos(Ge(Hi-s))/Math.cos(Ge(Hi)))-1),l=Math.acos(a/n),u=2*Bm(o-1,0,Ge(s/2)),h=Math.min(Ge(Hi),l+Ge(s/2)),c=Math.min(h,l-Ge(s/2)),d=Bm(o-1,c,h),p=Math.atan(i/a),f=Math.hypot(i,a),m=r;return m+=It(n/f/Math.max(.5,Math.cos(Ge(s/2)))),m+=o*It(Math.cos(p))/2,m-=It(Math.max(1,d/u/t))/2,m}}const WI=Ic(9.314,3);function qd(e,t){let r=(t.roundZoom?Math.round:Math.floor)(e.zoom+It(e.tileSize/t.tileSize));return Math.max(0,r)}function HI(e,t){let r=Hi-e.pitch-e.fov/2,i=ne((15-r)/15,0,1),a=Math.max(500,t??0);return e.elevation+i*a}function XI(e,t,r){let i=e.planes[1],a=e.points.map(l=>{let u=i[0]*l[0]+i[1]*l[1]+i[2]*l[2]+i[3];if(Math.abs(u)>1e-6)return l;let h=[l[0]-r[0],l[1]-r[1],l[2]-r[2]],c=i[0]*h[0]+i[1]*h[1]+i[2]*h[2];if(c>=-1e-9)return l;let d=t/-c;return[l[0]+h[0]*d,l[1]+h[1]*d,l[2]+h[2]*d,l[3]]}),n=e.planes.map((l,u)=>u===1?[l[0],l[1],l[2],l[3]+t]:l),s=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let l of a)for(let u=0;u<3;u++)s[u]=Math.min(s[u],l[u]),o[u]=Math.max(o[u],l[u]);return new Gd(a,n,new Ud(s,o))}function YI(e,t,r,i){let a=Math.hypot(t[0],t[1],t[2]);if(a===0)return{frustum:e,plane:t};let n=1+i/Lt,s=ne(-t[3]/a,-1,1),o=Math.cos(Math.acos(s)+Math.acos(1/n));return{frustum:XI(e,Math.sqrt(n*n-1),r),plane:[t[0],t[1],t[2],-o*a]}}function an(e,t){let r=e.getCameraFrustum(),i=e.getClippingPlane();i&&t.maxContentElevation>0&&({frustum:r,plane:i}=YI(r,i,e.cameraPosition,t.maxContentElevation));let a=BT(e),n=Ie.fromLngLat(e.center,e.elevation),s=HI(e,t.maxContentElevation),o=e.getCoveringTilesDetailsProvider(),l=o.allowVariableZoom(e,t),u=qd(e,t),h=t.minzoom||0,c=t.maxzoom===void 0?e.maxZoom:t.maxzoom,d=Math.min(Math.max(0,u),c),p=2**d,f=[p*a.x,p*a.y,0],m=[p*n.x,p*n.y,0],g=Math.hypot(n.x-a.x,n.y-a.y),_=Math.abs(n.z-a.z),y=Math.hypot(g,_),v=b=>({zoom:0,x:0,y:0,wrap:b,fullyVisible:!1}),x=[],w=[];if(e.renderWorldCopies&&o.allowWorldCopies())for(let b=1;b<=3;b++)x.push(v(-b)),x.push(v(b));for(x.push(v(0));x.length>0;){let b=x.pop(),T=b.x,P=b.y,S=b.fullyVisible,I={x:T,y:P,z:b.zoom},R=o.getTileBoundingVolume(I,b.wrap,s,t);if(!S){let E=ZI(r,R,i);if(E===0)continue;S=E===2}let F=o.distanceToTile2d(a.x,a.y,I,R),D=u;l&&(D=(t.calculateTileZoom||WI)(e.zoom+It(e.tileSize/t.tileSize),F,_,y,e.fov)),D=(t.roundZoom?Math.round:Math.floor)(D),D=Math.max(0,D);let A=Math.min(D,c);if(b.wrap=o.getWrap(n,I,b.wrap),b.zoom>=A){if(b.zoom<h)continue;let E=d-b.zoom,z=f[0]-.5-(T<<E),L=f[1]-.5-(P<<E),B=t.reparseOverscaled?Math.max(b.zoom,D):b.zoom;w.push({tileID:new St(b.zoom===c?B:b.zoom,b.wrap,b.zoom,T,P),distanceSq:lv([m[0]-.5-T,m[1]-.5-P]),tileDistanceToCamera:Math.sqrt(z*z+L*L)});continue}for(let E=0;E<4;E++){let z=(T<<1)+E%2,L=(P<<1)+(E>>1),B=b.zoom+1;x.push({zoom:B,x:z,y:L,wrap:b.wrap,fullyVisible:S})}}return w.sort((b,T)=>b.distanceSq-T.distanceSq).map(b=>b.tileID)}function Om(e){return e==="raster"||e==="image"||e==="video"}function KI(e,t,r,i,a,n,s){let o=Fe(),l=cv(t);for(let u of t){let h=e.getTileById(u.key);(h.fadingDirection===0||h.fadeOpacity===0)&&h.resetFadeLogic(),!JI(e,h,r,o,i,a,s)&&(QI(e,h,r,o,n,s)||eM(h,l,o,s)||h.resetFadeLogic())}}function JI(e,t,r,i,a,n,s){if(!t.hasData())return!1;let{tileID:o,fadingRole:l,fadingDirection:u,fadingParentID:h}=t;if(l===0&&u===1&&h)return r[h.key]=h,!0;let c=Math.max(o.overscaledZ-a,n);for(let d=o.overscaledZ-1;d>=c;d--){let p=o.scaledTo(d),f=e.getLoadedTile(p);if(f)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:f.tileID,fadeEndTime:i+s}),f.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:i+s}),r[p.key]=p,!0}return!1}function QI(e,t,r,i,a,n){if(!t.hasData())return!1;let s=t.tileID.children(a),o=$m(e,t,s,r,i,a,n);if(o)return!0;for(let l of s)$m(e,t,l.children(a),r,i,a,n)&&(o=!0);return o}function $m(e,t,r,i,a,n,s){if(r[0].overscaledZ>=n)return!1;let o=!1;for(let l of r){let u=e.getLoadedTile(l);if(!u)continue;let{fadingRole:h,fadingDirection:c,fadingParentID:d}=u;(h!==0||c!==0||!d)&&(u.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:t.tileID,fadeEndTime:a+s}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+s})),i[l.key]=l,o=!0}return o}function eM(e,t,r,i){let a=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(a)){let n=r+i;return e.setSelfFadeLogic(n),!0}return!1}function tM(e,t){if(t<=0)return!1;let r=Fe();for(let i of e.getAllTiles())if(i.fadeEndTime>=r)return!0;return!1}function rM(e,t){var i,a,n;let r=t.getRenderableIds();for(let s of r){if(!((i=e.neighboringTiles)!=null&&i[s]))continue;let o=t.getTileById(s);e.neighboringTiles[s].backfilled||jm(e,o),!((n=(a=o.neighboringTiles)==null?void 0:a[e.tileID.key])!=null&&n.backfilled)&&jm(o,e)}}function jm(e,t){var s;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x,i=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,n=t.tileID.key;(r!==0||i!==0)&&(Math.abs(i)>1||(Math.abs(r)>1&&(Math.abs(r+a)===1?r+=a:Math.abs(r-a)===1&&(r-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),(s=e.neighboringTiles)!=null&&s[n]&&(e.neighboringTiles[n].backfilled=!0))))}var Vm=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let r in this._tiles){let i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),t[i.tileID.key]=i}this._tiles=t}setFeatureState(e,t,r){for(let i in this._tiles)this._tiles[i].setFeatureState(e,t,r)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(t=>t.tileID).sort(nm).map(t=>t.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){let t=this.getTileById(e.key);return t!=null&&t.hasData()?t:null}isIdRenderable(e,t=!1){var r;return(r=this.getTileById(e))==null?void 0:r.isRenderable(t)}getRenderableIds(e=0,t){let r=[];for(let i of this.getAllIds())this.isIdRenderable(i,t)&&r.push(this.getTileById(i));return t?r.sort((i,a)=>{let n=i.tileID,s=a.tileID,o=new C(n.canonical.x,n.canonical.y)._rotate(-e),l=new C(s.canonical.x,s.canonical.y)._rotate(-e);return n.overscaledZ-s.overscaledZ||l.y-o.y||l.x-o.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(nm).map(i=>i.key)}},oi,Mc=(oi=class extends Rt{constructor(t,r,i){super(),this._maxContentElevationSeen=0,this.id=t,this.dispatcher=i,this.on("data",a=>{this._dataHandler(a)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=BI(t,r,i,this),this._inViewTiles=new Vm,this._outOfViewCache=new hC(0,a=>this._unloadTile(a)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new VI,this._didEmitContent=!1,this._updated=!1}onAdd(t){var r;this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,(r=this._source)!=null&&r.onAdd&&this._source.onAdd(t)}onRemove(t){var r;for(let i of this._inViewTiles.getAllTiles())i.unloadVectorData();this.clearTiles(),(r=this._source)!=null&&r.onRemove&&this._source.onRemove(t),this._inViewTiles=new Vm}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if((this.used!==void 0||this.usedForTerrain!==void 0)&&!this.used&&!this.usedForTerrain)return!0;if(!this._updated)return!1;for(let t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}getSource(){return this._source}getState(){return this._state}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,this.terrain)}async _loadTile(t,r,i,a){try{let n=await this._source.loadTile(t);this._tileLoaded(t,r,i,a,n)}catch(n){t.state="errored",n.status===404?this.update(this.transform,this.terrain):this._source.fire(new X(zt(n),{tile:t}))}}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new Ne("dataabort",{tile:t,coord:t.tileID}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let r of this._inViewTiles.getAllTiles())r.upload(t),r.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var r;return this._inViewTiles.getRenderableIds((r=this.transform)==null?void 0:r.bearingInRadians,t)}hasRenderableParent(t){let r=t.overscaledZ-1;if(r>=this._source.minzoom){let i=this.getLoadedTile(t.scaledTo(r));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(t,r=void 0){if(this._paused){this._shouldReloadOnResume=!0;return}this._outOfViewCache.reset();for(let i of this._inViewTiles.getAllIds()){let a=this._inViewTiles.getTileById(i);(!r||this._source.shouldReloadTile(a,r))&&(t?this._reloadTile(i,a.state==="errored"?"loading":"expired"):a.state!=="errored"&&this._reloadTile(i,"reloading"))}}async _reloadTile(t,r){let i=this._inViewTiles.getTileById(t);if(!i)return;let a=i.hasData();i.state!=="loading"&&(i.state=r),await this._loadTile(i,t,r,a)}_tileLoaded(t,r,i,a,n){a||(t.timeAdded=Fe(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration)),i==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(r,t),!(n!=null&&n.unmodified)&&(this.getSource().type==="raster-dem"&&t.dem&&rM(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new Ne("data",{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,r){let i=this._getLoadedDescendents(r),a=new Set;for(let n of r){let s=i[n.key];if(!(s!=null&&s.length)){a.add(n);continue}let o=n.overscaledZ+oi.maxOverzooming,l=s.filter(c=>c.tileID.overscaledZ<=o);if(!l.length){a.add(n);continue}let u=Math.min(...l.map(c=>c.tileID.overscaledZ)),h=l.filter(c=>c.tileID.overscaledZ===u).map(c=>c.tileID);for(let c of h)t[c.key]=c;this._areDescendentsComplete(h,u,n.overscaledZ)||a.add(n)}return a}_getLoadedDescendents(t){var i;let r={};for(let a of this._inViewTiles.getAllTiles().filter(n=>n.hasData()))for(let n of t)a.tileID.isChildOf(n)&&(r[i=n.key]||(r[i]=[]),r[n.key].push(a));return r}_areDescendentsComplete(t,r,i){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===r:4**(r-i)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let r=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),i=this._maxTileCacheZoomLevels===null?Ei.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,a=Math.floor(r*i),n=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,a):a;this._outOfViewCache.setMaxSize(n)}handleWrapJump(t){let r=(t-(this._prevLng===void 0?t:this._prevLng))/360,i=Math.round(r);this._prevLng=t,i&&(this._inViewTiles.handleWrapJump(i),this._resetTileReloadTimers())}_updateMaxContentElevation(){var a,n;let t=this._maxContentElevationSeen,r=(n=(a=this.map)==null?void 0:a.style)==null?void 0:n._layers;if(!r)return t;let i=this._inViewTiles.getAllTiles();for(let s in r){let o=r[s];if(o.type!=="symbol"||o.source!==this.id||o.isHidden(this.transform.zoom))continue;let l=o;if(!l.layout)continue;let u=l.layout.get("symbol-height-offset");if(t=Math.max(t,u.constantOr(0)),!u.isConstant())for(let h of i){let c=h.getBucket(o);c&&c.maxHeightOffset>t&&(t=c.maxHeightOffset)}}return this._maxContentElevationSeen=t,t}update(t,r){if(!this._sourceLoaded||this._paused)return;this.transform=t,this.terrain=r,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng);let i;!this.used&&!this.usedForTerrain?i=[]:this._source.tileID?i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(l=>new St(l.canonical.z,l.wrap,l.canonical.z,l.canonical.x,l.canonical.y)):(i=an(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type==="vector"&&this.map._zoomLevelsToOverscale!==void 0?Math.max(this._source.maxzoom,t.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:r,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(i=i.filter(l=>this._source.hasTile(l)))),this.usedForTerrain&&(i=this._addTerrainIdealTiles(i));let a=i.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}));let n=qd(t,this._source),s=this._updateRetainedTiles(i,n),o=Om(this._source.type);o&&this._rasterFadeDuration>0&&!r&&KI(this._inViewTiles,i,s,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),o?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(t){for(let r of this._inViewTiles.getAllIds())t[r]||this._removeTile(r)}_cleanUpVectorTiles(t){for(let r of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(r);if(t[r]){i.clearSymbolFadeHold();continue}if(!i.hasSymbolBuckets){this._removeTile(r);continue}i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(r):i.setSymbolHoldDuration(this.map._fadeDuration)}}_addTerrainIdealTiles(t){let r=[];for(let i of t)if(i.canonical.z>this._source.minzoom){let a=i.scaledTo(i.canonical.z-1);r.push(a);let n=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));r.push(n)}return t.concat(r)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,r){var l;let i=new Set;for(let u of t)this._addTile(u).hasData()||i.add(u);let a=t.reduce((u,h)=>(u[h.key]=h,u),{}),n=this._retainLoadedChildren(a,i),s={},o=Math.max(r-oi.maxUnderzooming,this._source.minzoom);for(let u of n){let h=this._inViewTiles.getTileById(u.key),c=h==null?void 0:h.wasRequested();for(let d=u.overscaledZ-1;d>=o;--d){let p=u.scaledTo(d);if(s[p.key])break;if(s[p.key]=!0,h=this.getTile(p),!h&&c&&(h=this._addTile(p)),h){let f=h.hasData();if((f||!((l=this.map)!=null&&l.cancelPendingTileRequestsWhileZooming)||c)&&(a[p.key]=p),c=h.wasRequested(),f)break}}}return a}_addTile(t){let r=this._inViewTiles.getTileById(t.key);if(r)return r;r=this._outOfViewCache.getAndRemove(t),r&&(r.resetFadeLogic(),this._setTileReloadTimer(t.key,r),r.tileID=t,this._state.initializeTileState(r,this.map?this.map.painter:null));let i=r;return r||(r=new E1(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(r,t.key,r.state,!1)),r.uses++,this._inViewTiles.setTile(t.key,r),i||this._source.fire(new Ne("dataloading",{tile:r,coord:r.tileID})),r}_setTileReloadTimer(t,r){this._clearTileReloadTimer(t);let i=r.getExpiryTimeout();if(i){let a=()=>{this._reloadTile(t,"expired"),delete this._timers[t]};this._timers[t]=setTimeout(a,i)}}_clearTileReloadTimer(t){let r=this._timers[t];r&&(clearTimeout(r),delete this._timers[t])}_resetTileReloadTimers(){for(let t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(let t of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,r)}}refreshTiles(t){for(let r of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(r);(this._inViewTiles.isIdRenderable(r)||i.state=="errored")&&t.some(a=>a.equals(i.tileID.canonical))&&this._reloadTile(r,"expired")}}_removeTile(t){let r=this._inViewTiles.getTileById(t);r&&(r.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),!(r.uses>0)&&(r.hasData()&&r.state!=="reloading"?this._outOfViewCache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}_dataHandler(t){if(t.dataType==="source"){if(t.sourceDataType==="metadata"){this._sourceLoaded=!0;return}t.sourceDataType==="content"&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}resetMaxContentElevation(){this._maxContentElevationSeen=0}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1,this.resetMaxContentElevation();for(let t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,r,i){let a=[],n=this.transform;if(!n)return a;let s=n.getCoveringTilesDetailsProvider().allowWorldCopies(),o=i?n.getCameraQueryGeometry(t):t,l=p=>n.screenPointToMercatorCoordinate(p,this.terrain),u=this.transformBbox(t,l,!s),h=this.transformBbox(o,l,!s),c=this.getIds(),d=Pr.fromPoints(h);for(let p of c){let f=this._inViewTiles.getTileById(p);if(f.holdingForSymbolFade())continue;let m=s?[f.tileID]:[f.tileID.unwrapTo(-1),f.tileID.unwrapTo(0)],g=2**(n.zoom-f.tileID.overscaledZ),_=r*f.queryPadding*k/f.tileSize/g;for(let y of m){let v=d.map(x=>y.getTilePoint(new Ie(x.x,x.y)));if(v.expandBy(_),v.intersects(IT)){let x=u.map(b=>y.getTilePoint(b)),w=h.map(b=>y.getTilePoint(b));a.push({tile:f,tileID:s?y:y.unwrapTo(0),queryGeometry:x,cameraQueryGeometry:w,scale:g})}}}return a}transformBbox(t,r,i){let a=t.map(r);if(i){let n=Pr.fromPoints(t);n.shrinkBy(Math.min(n.width(),n.height())*.001);let s=n.map(r);Pr.fromPoints(a).covers(s)||(a=a.map(o=>o.x>.5?new Ie(o.x-1,o.y,o.z):o))}return a}getVisibleCoordinates(t){let r=this.getRenderableIds(t).map(i=>this._inViewTiles.getTileById(i).tileID);return this.transform&&this.transform.populateCache(r),r}hasTransition(){return this._source.hasTransition()?!0:Om(this._source.type)&&tM(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,r,i){t||(t=Co),this._state.updateState(t,r,i)}removeFeatureState(t,r,i){t||(t=Co),this._state.removeFeatureState(t,r,i)}getFeatureState(t,r){return t||(t=Co),this._state.getState(t,r)}setDependencies(t,r,i){let a=this._inViewTiles.getTileById(t);a&&a.setDependencies(r,i)}reloadTilesForDependencies(t,r){for(let i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(t,r)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter(i=>!i.hasDependency(t,r))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}},oi.maxUnderzooming=10,oi.maxOverzooming=3,oi),iM=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let r=1;r<this.points.length;r++)this._distances[r]=this._distances[r-1]+this.points[r].dist(this.points[r-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,this.length*.5),this.paddedLength=this.length-this.padding*2}lerp(e){if(this.points.length===1)return this.points[0];e=ne(e,0,1);let t=1,r=this._distances[t],i=e*this.paddedLength+this.padding;for(;r<i&&t<this._distances.length;)r=this._distances[++t];let a=t-1,n=this._distances[a],s=r-n,o=s>0?(i-n)/s:0;return this.points[a].mult(1-o).add(this.points[t].mult(o))}};function zo(e,t,r,i,a){return a?e?e(t,r)+i:i===0?void 0:i:i}function ho(e,t){let r=!0;return e==="always"||(e==="never"||t==="never")&&(r=!1),r}var Nm=class{constructor(e,t,r){let i=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(t/r);for(let n=0;n<this.xCellCount*this.yCellCount;n++)i.push([]),a.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,r,i,a){this._forEachCell(t,r,i,a,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(a)}insertCircle(e,t,r,i){this._forEachCell(t-i,r-i,t+i,r+i,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(r),this.circles.push(i)}_insertBoxCell(e,t,r,i,a,n){this.boxCells[a].push(n)}_insertCircleCell(e,t,r,i,a,n){this.circleCells[a].push(n)}_query(e,t,r,i,a,n,s){if(r<0||e>this.width||i<0||t>this.height)return[];let o=[];if(e<=0&&t<=0&&this.width<=r&&this.height<=i){if(a)return[{key:null,x1:e,y1:t,x2:r,y2:i}];for(let l=0;l<this.boxKeys.length;l++)o.push({key:this.boxKeys[l],x1:this.bboxes[l*4],y1:this.bboxes[l*4+1],x2:this.bboxes[l*4+2],y2:this.bboxes[l*4+3]});for(let l=0;l<this.circleKeys.length;l++){let u=this.circles[l*3],h=this.circles[l*3+1],c=this.circles[l*3+2];o.push({key:this.circleKeys[l],x1:u-c,y1:h-c,x2:u+c,y2:h+c})}}else{let l={hitTest:a,overlapMode:n,seenUids:{box:{},circle:{}}};this._forEachCell(e,t,r,i,this._queryCell,o,l,s)}return o}query(e,t,r,i){return this._query(e,t,r,i,!1,null)}hitTest(e,t,r,i,a,n){return this._query(e,t,r,i,!0,a,n).length>0}hitTestCircle(e,t,r,i,a){let n=e-r,s=e+r,o=t-r,l=t+r;if(s<0||n>this.width||l<0||o>this.height)return!1;let u=[],h={hitTest:!0,overlapMode:i,circle:{x:e,y:t,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(n,o,s,l,this._queryCellCircle,u,h,a),u.length>0}_queryCell(e,t,r,i,a,n,s,o){let{seenUids:l,hitTest:u,overlapMode:h}=s,c=this.boxCells[a],d=1e-6;if(c!==null){let f=this.bboxes;for(let m of c)if(!l.box[m]){l.box[m]=!0;let g=m*4,_=this.boxKeys[m];if(e<=f[g+2]+d&&t<=f[g+3]+d&&r>=f[g+0]-d&&i>=f[g+1]-d&&(!o||o(_))&&(!u||!ho(h,_.overlapMode))&&(n.push({key:_,x1:f[g],y1:f[g+1],x2:f[g+2],y2:f[g+3]}),u))return!0}}let p=this.circleCells[a];if(p!==null){let f=this.circles;for(let m of p)if(!l.circle[m]){l.circle[m]=!0;let g=m*3,_=this.circleKeys[m];if(this._circleAndRectCollide(f[g],f[g+1],f[g+2],e,t,r,i)&&(!o||o(_))&&(!u||!ho(h,_.overlapMode))){let y=f[g],v=f[g+1],x=f[g+2];if(n.push({key:_,x1:y-x,y1:v-x,x2:y+x,y2:v+x}),u)return!0}}}return!1}_queryCellCircle(e,t,r,i,a,n,s,o){let{circle:l,seenUids:u,overlapMode:h}=s,c=this.boxCells[a];if(c!==null){let p=this.bboxes;for(let f of c)if(!u.box[f]){u.box[f]=!0;let m=f*4,g=this.boxKeys[f];if(this._circleAndRectCollide(l.x,l.y,l.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!o||o(g))&&!ho(h,g.overlapMode))return n.push(!0),!0}}let d=this.circleCells[a];if(d!==null){let p=this.circles;for(let f of d)if(!u.circle[f]){u.circle[f]=!0;let m=f*3,g=this.circleKeys[f];if(this._circlesCollide(p[m],p[m+1],p[m+2],l.x,l.y,l.radius)&&(!o||o(g))&&!ho(h,g.overlapMode))return n.push(!0),!0}}}_forEachCell(e,t,r,i,a,n,s,o){let l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),h=this._convertToXCellCoord(r),c=this._convertToYCellCoord(i);for(let d=l;d<=h;d++)for(let p=u;p<=c;p++){let f=this.xCellCount*p+d;if(a.call(this,e,t,r,i,f,n,s,o))return}}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,r,i,a,n){let s=i-e,o=a-t,l=r+n;return l*l>s*s+o*o}_circleAndRectCollide(e,t,r,i,a,n,s){let o=(n-i)/2,l=Math.abs(e-(i+o));if(l>o+r)return!1;let u=(s-a)/2,h=Math.abs(t-(a+u));if(h>u+r)return!1;if(l<=o||h<=u)return!0;let c=l-o,d=h-u;return c*c+d*d<=r*r}};function aM(e,t){let r=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),i=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),a=t[0]*r,n=t[4]*r,s=t[8]*i,o=t[1]*r,l=t[5]*r,u=t[9]*i,h=t[2]*r,c=t[6]*r,d=t[10]*i;e[0]=a,e[1]=n,e[2]=s,e[4]=o,e[5]=l,e[6]=u,e[8]=h,e[9]=c,e[10]=d;let p=t[12],f=t[13],m=t[14];return e[12]=-a*p-o*f-h*m,e[13]=-n*p-l*f-c*m,e[14]=-s*p-u*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}function nM(e,t){return e[0]=1/t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1/t[5],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=0,e[11]=1/t[14],e[12]=0,e[13]=0,e[14]=-1,e[15]=t[10]/t[14],e}function sM(e,t){let r=1/(t[0]*t[5]-t[1]*t[4]);return e[0]=t[5]*r,e[1]=-t[1]*r,e[2]=0,e[3]=0,e[4]=-t[4]*r,e[5]=t[0]*r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15],e}const oM=Ci();function Zd(e,t,r){let i=Ci();if(!e){let{vecSouth:a,vecEast:n}=Wd(t),s=c1();s[0]=n[0],s[1]=n[1],s[2]=a[0],s[3]=a[1],dC(s,s),i[0]=s[0],i[1]=s[1],i[4]=s[2],i[5]=s[3]}return Et(i,i,[1/r,1/r,1]),i}function lM(e,t,r,i){if(e){let a=Ci();if(!t){let{vecSouth:n,vecEast:s}=Wd(r);a[0]=s[0],a[1]=s[1],a[4]=n[0],a[5]=n[1]}return Et(a,a,[i,i,1]),a}return r.pixelsToClipSpaceMatrix}function Wd(e){let t=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),i=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),n=Math.sin(e.bearingInRadians),s=dh();s[0]=-a*i*r-n*t,s[1]=-n*i*r+a*t;let o=$p(s);o<1e-9?jp(s):Op(s,s,1/o);let l=dh();l[0]=a*i*t-n*r,l[1]=n*i*t+a*r;let u=$p(l);return u<1e-9?jp(l):Op(l,l,1/u),{vecEast:l,vecSouth:s}}function ta(e,t,r){return zo(e.getElevation,t,r,e.heightOffset??0,e.heightAnchorGround??!0)}function Hd(e,t,r,i){let a;i==null?(a=[e,t,0,1],Xd(a,a,r)):(a=[e,t,i,1],Pt(a,a,r));let n=a[3];return{point:new C(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function C1(e,t){return .5+e/t*.5}function uM(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function hM(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=r?e.textSizeData:e.iconSizeData,f=jl(p,t.transform.zoom),m=[256/t.width*2+1,256/t.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let _=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=t.transform.width/t.transform.height,x=!1;for(let w=0;w<y.length;w++){let b=y.get(w);if(b.hidden||b.writingMode===2&&!x){ja(b.numGlyphs,g);continue}x=!1;let T=new C(b.anchorX,b.anchorY),P={getElevation:d,pitchedLabelPlaneMatrix:i,lineVertexArray:_,pitchWithMap:n,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:T,unwrappedTileID:l,width:u,height:h,translation:c},S=z1(b.anchorX,b.anchorY,P);if(!uM(S.point,m)){ja(b.numGlyphs,g);continue}let I=S.signedDistanceFromCamera,R=C1(t.transform.cameraToCenterDistance,I),F=Sd(p,f,b),D=n?F*t.transform.getPitchedTextCorrection(b.anchorX,b.anchorY,l)/R:F*R,A=Gm({projectionContext:P,pitchedLabelPlaneMatrixInverse:a,symbol:b,fontSize:D,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:v,rotateToLine:o});x=A.useVertical,(A.notEnoughRoom||x||A.needsFlipping&&Gm({projectionContext:P,pitchedLabelPlaneMatrixInverse:a,symbol:b,fontSize:D,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:v,rotateToLine:o}).notEnoughRoom)&&ja(b.numGlyphs,g)}r?e.text.dynamicLayoutVertexBuffer.updateData(g):e.icon.dynamicLayoutVertexBuffer.updateData(g)}function I1(e,t,r,i,a,n,s,o){let l=n.glyphStartIndex+n.numGlyphs,u=n.lineStartIndex,h=n.lineStartIndex+n.lineLength,c=t.getoffsetX(n.glyphStartIndex),d=t.getoffsetX(l-1),p=hl(e*c,r,i,a,n.segment,u,h,o,s);if(!p)return null;let f=hl(e*d,r,i,a,n.segment,u,h,o,s);return!f||o.projectionCache.anyProjectionOccluded?null:{first:p,last:f}}function Um(e,t,r,i){return e===1&&Math.abs(r.y-t.y)>Math.abs(r.x-t.x)*i?{useVertical:!0}:(e===2?t.y<r.y:t.x>r.x)?{needsFlipping:!0}:null}function Gm(e){let{projectionContext:t,pitchedLabelPlaneMatrixInverse:r,symbol:i,fontSize:a,flip:n,keepUpright:s,glyphOffsetArray:o,dynamicLayoutVertexArray:l,aspectRatio:u,rotateToLine:h}=e,c=a/24,d=i.lineOffsetX*c,p=i.lineOffsetY*c,f;if(i.numGlyphs>1){let m=i.glyphStartIndex+i.numGlyphs,g=i.lineStartIndex,_=i.lineStartIndex+i.lineLength,y=I1(c,o,d,p,n,i,h,t);if(!y)return{notEnoughRoom:!0};let v=co(y.first.point.x,y.first.point.y,t,r),x=co(y.last.point.x,y.last.point.y,t,r);if(s&&!n){let w=Um(i.writingMode,v,x,u);if(w)return w}f=[y.first];for(let w=i.glyphStartIndex+1;w<m-1;w++){let b=hl(c*o.getoffsetX(w),d,p,n,i.segment,g,_,t,h);if(!b)return{notEnoughRoom:!0};f.push(b)}f.push(y.last)}else{if(s&&!n){let g=ra(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,_=i.lineStartIndex+i.segment+1,y=new C(t.lineVertexArray.getx(_),t.lineVertexArray.gety(_)),v=ra(y.x,y.y,t),x=v.signedDistanceFromCamera>0?v.point:M1(t.tileAnchorPoint,y,g,1,t),w=co(g.x,g.y,t,r),b=co(x.x,x.y,t,r),T=Um(i.writingMode,w,b,u);if(T)return T}let m=hl(c*o.getoffsetX(i.glyphStartIndex),d,p,n,i.segment,i.lineStartIndex,i.lineStartIndex+i.lineLength,t,h);if(!m||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};f=[m]}for(let m of f)nl(l,m.point,m.angle);return{}}function M1(e,t,r,i,a){let n=e.add(e.sub(t)._unit()),s=ra(n.x,n.y,a).point,o=r.sub(s);return r.add(o._mult(i/o.mag()))}function zc(e,t,r){let i=t.projectionCache;if(i.projections[e])return i.projections[e];let a=new C(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),n=ra(a.x,a.y,t);if(n.signedDistanceFromCamera>0)return i.projections[e]=n.point,i.anyProjectionOccluded||(i.anyProjectionOccluded=n.isOccluded),n.point;let s=e-r.direction,o=r.distanceFromAnchor===0?t.tileAnchorPoint:new C(t.lineVertexArray.getx(s),t.lineVertexArray.gety(s)),l=r.absOffsetX-r.distanceFromAnchor+1;return M1(o,a,r.previousVertex,l,t)}function ra(e,t,r){let i=e+r.translation[0],a=t+r.translation[1],n;return r.pitchWithMap?(n=Hd(i,a,r.pitchedLabelPlaneMatrix,ta(r,i,a)),n.isOccluded=!1):(n=r.transform.projectTileCoordinates(i,a,r.unwrappedTileID,ta(r,i,a)),n.point.x=(n.point.x*.5+.5)*r.width,n.point.y=(-n.point.y*.5+.5)*r.height),n}function co(e,t,r,i){if(r.pitchWithMap){let a=[e,t,0,1];Pt(a,a,i);let n=a[0]/a[3],s=a[1]/a[3];return r.transform.projectTileCoordinates(n,s,r.unwrappedTileID,ta(r,n,s)).point}return{x:e/r.width*2-1,y:1-t/r.height*2}}function z1(e,t,r){return r.transform.projectTileCoordinates(e,t,r.unwrappedTileID,ta(r,e,t))}function Fc(e,t,r){return e._unit()._perp()._mult(t*r)}function cM(e,t,r,i,a,n,s,o,l){if(o.projectionCache.offsets[e])return o.projectionCache.offsets[e];let u=r.add(t);if(e+l.direction<i||e+l.direction>=a)return o.projectionCache.offsets[e]=u,u;let h=zc(e+l.direction,o,l),c=Fc(h.sub(r),s,l.direction),d=r.add(c),p=h.add(c);return o.projectionCache.offsets[e]=gv(n,u,d,p)||u,o.projectionCache.offsets[e]}function hl(e,t,r,i,a,n,s,o,l){let u=i?e-t:e+t,h=u>0?1:-1,c=0;i&&(h*=-1,c=Math.PI),h<0&&(c+=Math.PI);let d=h>0?n+a:n+a+1,p;o.projectionCache.cachedAnchorPoint?p=o.projectionCache.cachedAnchorPoint:(p=ra(o.tileAnchorPoint.x,o.tileAnchorPoint.y,o).point,o.projectionCache.cachedAnchorPoint=p);let f=p,m=p,g,_,y=0,v=0,x=Math.abs(u),w=[],b;for(;y+v<=x;){if(d+=h,d<n||d>=s)return null;y+=v,m=f,_=g;let I={absOffsetX:x,direction:h,distanceFromAnchor:y,previousVertex:m};if(f=zc(d,o,I),r===0)w.push(m),b=f.sub(m);else{let R,F=f.sub(m);R=F.mag()===0?Fc(zc(d+h,o,I).sub(f),r,h):Fc(F,r,h),_||(_=m.add(R)),g=cM(d,R,f,n,s,_,r,o,I),w.push(_),b=g.sub(_)}v=b.mag()}let T=(x-y)/v,P=b._mult(T)._add(_||m),S=c+Math.atan2(f.y-m.y,f.x-m.x);return w.push(P),{point:P,angle:l?S:0,path:w}}const dM=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ja(e,t){for(let r=0;r<e;r++){let i=t.length;t.resize(i+4),t.float32.set(dM,i*3)}}function Xd(e,t,r){let i=t[0],a=t[1];return e[0]=r[0]*i+r[4]*a+r[12],e[1]=r[1]*i+r[5]*a+r[13],e[3]=r[3]*i+r[7]*a+r[15],e}function pM(e,t){let r=oM;return sM(r,t.pitchedLabelPlaneMatrix),e.map(i=>{let a=Hd(i.x,i.y,r,ta(t,i.x,i.y)),n=t.transform.projectTileCoordinates(a.point.x,a.point.y,t.unwrappedTileID,ta(t,a.point.x,a.point.y));return n.point.x=(n.point.x*.5+.5)*t.width,n.point.y=(-n.point.y*.5+.5)*t.height,n})}function fM(e){let t=0,r=0,i=0,a=0;for(let n=0;n<e.length;n++)e[n].isOccluded?(i=n+1,a=0):(a++,a>r&&(r=a,t=i));return e.slice(t,t+r)}var mM=class{constructor(e,t=new Nm(e.width+200,e.height+200,25),r=new Nm(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=r,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,r,i,a,n,s,o,l,u,h,c,d=0,p=!0){let f=e.anchorPointX+o[0],m=e.anchorPointY+o[1],g=this.projectAndGetPerspectiveRatio(f,m,a,zo(u,f,m,d,p),c),_=r*g.perspectiveRatio,y;if(!n&&!s){let S=g.x+(h?h.x*_:0),I=g.y+(h?h.y*_:0);y={allPointsOccluded:!1,box:[S+e.x1*_,I+e.y1*_,S+e.x2*_,I+e.y2*_]}}else y=this._projectCollisionBox(e,_,i,a,n,s,o,g,u,h,c,d,p);let[v,x,w,b]=y.box,T=n?y.allPointsOccluded:g.isOccluded,P=T;return P||(P=g.perspectiveRatio<this.perspectiveRatioCutoff),P||(P=!this.isInsideGrid(v,x,w,b)),P||t!=="always"&&this.grid.hitTest(v,x,w,b,t,l)?{box:[v,x,w,b],placeable:!1,offscreen:!1,occluded:T}:{box:[v,x,w,b],placeable:!0,offscreen:this.isOffscreen(v,x,w,b),occluded:T}}placeCollisionCircles(e,t,r,i,a,n,s,o,l,u,h,c,d,p){let f=[],m=new C(t.anchorX,t.anchorY),g=this.getPerspectiveRatio(m.x,m.y,n,p==null?void 0:p(m.x,m.y)),_=(l?a*this.transform.getPitchedTextCorrection(t.anchorX,t.anchorY,n)/g:a*g)/24,y={projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},v=t.lineOffsetX*_,x=t.lineOffsetY*_,w={getElevation:p,pitchedLabelPlaneMatrix:s,lineVertexArray:r,pitchWithMap:l,projectionCache:y,transform:this.transform,tileAnchorPoint:m,unwrappedTileID:n,width:this.transform.width,height:this.transform.height,translation:d},b=I1(_,i,v,x,!1,t,!1,w),T=!1,P=!1,S=!0;if(b){let I=h*.5*g+c,R=new C(-100,-100),F=new C(this.screenRightBoundary,this.screenBottomBoundary),D=new iM,A=b.first,E=b.last,z=[];for(let V=A.path.length-1;V>=1;V--)z.push(A.path[V]);for(let V=1;V<E.path.length;V++)z.push(E.path[V]);let L=I*2.5;if(l){let V=this.projectPathToScreenSpace(z,w);z=V.some(Q=>Q.signedDistanceFromCamera<=0)?[]:V.map(Q=>Q.point)}let B=[];if(z.length>0){let V=z[0].clone(),Q=z[0].clone();for(let le=1;le<z.length;le++)V.x=Math.min(V.x,z[le].x),V.y=Math.min(V.y,z[le].y),Q.x=Math.max(Q.x,z[le].x),Q.y=Math.max(Q.y,z[le].y);B=V.x>=R.x&&Q.x<=F.x&&V.y>=R.y&&Q.y<=F.y?[z]:Q.x<R.x||V.x>F.x||Q.y<R.y||V.y>F.y?[]:I0([z],R.x,R.y,F.x,F.y)}for(let V of B){D.reset(V,I*.25);let Q=0;Q=D.length<=.5*I?1:Math.ceil(D.paddedLength/L)+1;for(let le=0;le<Q;le++){let De=le/Math.max(Q-1,1),pe=D.lerp(De),Be=pe.x+100,xe=pe.y+100;f.push(Be,xe,I,0);let Ue=Be-I,Ee=xe-I,pt=Be+I,yt=xe+I;if(S&&(S=this.isOffscreen(Ue,Ee,pt,yt)),P||(P=this.isInsideGrid(Ue,Ee,pt,yt)),e!=="always"&&this.grid.hitTestCircle(Be,xe,I,e,u)&&(T=!0,!o))return{circles:[],offscreen:!1,collisionDetected:T}}}}return{circles:!o&&T||!P||g<this.perspectiveRatioCutoff?[]:f,offscreen:S,collisionDetected:T}}projectPathToScreenSpace(e,t){return fM(pM(e,t))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let t=[],r=new Pr;for(let h of e){let c=new C(h.x+100,h.y+100);r.extend(c),t.push(c)}let{minX:i,minY:a,maxX:n,maxY:s}=r,o=this.grid.query(i,a,n,s).concat(this.ignoredGrid.query(i,a,n,s)),l={},u={};for(let h of o){let c=h.key;if(l[c.bucketInstanceId]===void 0&&(l[c.bucketInstanceId]={}),l[c.bucketInstanceId][c.featureIndex])continue;let d=[new C(h.x1,h.y1),new C(h.x2,h.y1),new C(h.x2,h.y2),new C(h.x1,h.y2)];Ly(t,d)&&(l[c.bucketInstanceId][c.featureIndex]=!0,u[c.bucketInstanceId]===void 0&&(u[c.bucketInstanceId]=[]),u[c.bucketInstanceId].push(c.featureIndex))}return u}insertCollisionBox(e,t,r,i,a,n){let s=r?this.ignoredGrid:this.grid,o={bucketInstanceId:i,featureIndex:a,collisionGroupID:n,overlapMode:t};s.insert(o,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,r,i,a,n){let s=r?this.ignoredGrid:this.grid,o={bucketInstanceId:i,featureIndex:a,collisionGroupID:n,overlapMode:t};for(let l=0;l<e.length;l+=4)s.insertCircle(o,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,t,r,i,a){if(a){let n;i==null?(n=[e,t,0,1],Xd(n,n,a)):(n=[e,t,i,1],Pt(n,n,a));let s=n[3];return{x:(n[0]/s+1)/2*this.transform.width+100,y:(-n[1]/s+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/s),isOccluded:!1,signedDistanceFromCamera:s}}{let n=this.transform.projectTileCoordinates(e,t,r,i);return{x:(n.point.x+1)/2*this.transform.width+100,y:(-n.point.y+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/n.signedDistanceFromCamera),isOccluded:n.isOccluded,signedDistanceFromCamera:n.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,r,i){let a=this.transform.projectTileCoordinates(e,t,r,i);return .5+.5*(this.transform.cameraToCenterDistance/a.signedDistanceFromCamera)}isOffscreen(e,t,r,i){return r<100||e>=this.screenRightBoundary||i<100||t>this.screenBottomBoundary}isInsideGrid(e,t,r,i){return r>=0&&e<this.gridRightBoundary&&i>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=Ar([]);return ot(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,r,i,a,n,s,o,l,u,h,c=0,d=!0){let p=1,f=0,m=0,g=1,_=e.anchorPointX+s[0],y=e.anchorPointY+s[1];if(n&&!a){let E=this.projectAndGetPerspectiveRatio(_+1,y,i,zo(l,_+1,y,c,d),h),z=E.x-o.x,L=E.y-o.y,B=Math.atan(L/z)+(z<0?Math.PI:0),V=Math.sin(B),Q=Math.cos(B);p=Q,f=V,m=-V,g=Q}else if(!n&&a){let E=Wd(this.transform);p=E.vecEast[0],f=E.vecEast[1],m=E.vecSouth[0],g=E.vecSouth[1]}let v=o.x,x=o.y,w=t;if(a&&(v=_,x=y,w=2**-(this.transform.zoom-r.overscaledZ),w*=this.transform.getPitchedTextCorrection(_,y,i),!u)){let E=o.signedDistanceFromCamera/this.transform.cameraToCenterDistance,z=ne(.5+.5*E,0,4);w*=z}u&&(v+=p*u.x*w+m*u.y*w,x+=f*u.x*w+g*u.y*w);let b=e.x1*w,T=e.x2*w,P=(b+T)/2,S=e.y1*w,I=e.y2*w,R=(S+I)/2,F=[{offsetX:b,offsetY:S},{offsetX:P,offsetY:S},{offsetX:T,offsetY:S},{offsetX:T,offsetY:R},{offsetX:T,offsetY:I},{offsetX:P,offsetY:I},{offsetX:b,offsetY:I},{offsetX:b,offsetY:R}],D=[];for(let{offsetX:E,offsetY:z}of F)D.push(new C(v+p*E+m*z,x+f*E+g*z));let A=!1;if(a){let E=D.map(z=>this.projectAndGetPerspectiveRatio(z.x,z.y,i,zo(l,z.x,z.y,c,d),h));A=E.some(z=>!z.isOccluded),D=E.map(z=>new C(z.x,z.y))}else A=!0;return{box:hv(D),allPointsOccluded:!A}}},qm=class{constructor(e,t,r,i){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):i&&r?1:0,this.placed=r}isHidden(){return this.opacity===0&&!this.placed}},wn=class{constructor(e,t,r,i,a){this.text=new qm(e?e.text:null,t,r,a),this.icon=new qm(e?e.icon:null,t,i,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Zm=class{constructor(e,t,r){this.text=e,this.icon=t,this.skipFade=r}},gM=class{constructor(e,t,r,i,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=r,this.bucketIndex=i,this.tileID=a}},_M=class{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:r=>r.collisionGroupID===t}}return this.collisionGroups[e]}};function Wm(e,t,r,i,a){let{horizontalAlign:n,verticalAlign:s}=$l(e),o=-(n-.5)*t,l=-(s-.5)*r;return new C(o+i[0]*a,l+i[1]*a)}var yM=class{constructor(e,t,r,i,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new mM(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new _M(i),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;if(t)return(r,i)=>t.getElevation(e,r,i)}getBucketParts(e,t,r,i){let a=r.getBucket(t),n=r.latestFeatureIndex;if(!a||!n||t.id!==a.layerIds[0])return;let s=r.collisionBoxArray,o=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-r.tileID.overscaledZ),h=r.tileSize/k,c=r.tileID.toUnwrapped(),d=o.get("text-rotation-alignment")==="map",p=nr(r,1,this.transform.zoom),f=Di(this.collisionIndex.transform,r,l.get("text-translate"),l.get("text-translate-anchor")),m=Di(this.collisionIndex.transform,r,l.get("icon-translate"),l.get("icon-translate-anchor")),g=Zd(d,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new gM(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,r.tileID);let _={bucket:a,layout:o,translationText:f,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:g,scale:u,textPixelRatio:h,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:jl(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(let y of a.sortKeyRanges){let{sortKey:v,symbolInstanceStart:x,symbolInstanceEnd:w}=y;e.push({sortKey:v,symbolInstanceStart:x,symbolInstanceEnd:w,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:_})}attemptAnchorPlacement(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y,v,x,w){var I,R,F;let b=_c[e.textAnchor],T=[e.textOffset0,e.textOffset1],P=Wm(b,r,i,T,a),S=this.collisionIndex.placeCollisionBox(t,c,o,l,u,s,n,m,h.predicate,y,P,v,x,w);if((!_||this.collisionIndex.placeCollisionBox(_,c,o,l,u,s,n,g,h.predicate,y,P,v,x,w).placeable)&&S.placeable){let D;if((I=this.prevPlacement)!=null&&I.variableOffsets[d.crossTileID]&&((F=(R=this.prevPlacement)==null?void 0:R.placements[d.crossTileID])!=null&&F.text)&&(D=this.prevPlacement.variableOffsets[d.crossTileID].anchor),d.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:T,width:r,height:i,anchor:b,textBoxScale:a,prevAnchor:D},this.markUsedJustification(p,b,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:P,placedGlyphBoxes:S}}}placeLayerBucketPart(e,t,r){let{bucket:i,layout:a,translationText:n,translationIcon:s,unwrappedTileID:o,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:h,collisionBoxArray:c,partiallyEvaluatedTextSize:d,collisionGroup:p}=e.parameters,f=a.get("text-optional"),m=a.get("icon-optional"),g=al(a,"text-overlap","text-allow-overlap"),_=g==="always",y=al(a,"icon-overlap","icon-allow-overlap"),v=y==="always",x=a.get("text-rotation-alignment")==="map",w=a.get("text-pitch-alignment")==="map",b=a.get("icon-text-fit")!=="none",T=a.get("symbol-z-order")==="viewport-y",P=a.get("symbol-height-anchor")==="ground",S=_&&(v||!i.hasIconData()||m),I=v&&(_||!i.hasTextData()||f);!i.collisionArrays&&c&&i.deserializeCollisionBoxes(c);let R=this.retainedQueryData[i.bucketInstanceId].tileID,F=this._getTerrainElevationFunc(R),D=this.transform.getFastPathSimpleProjectionMatrix(R),A=(E,z,L)=>{var ge,re;if(t[E.crossTileID])return;if(h){this.placements[E.crossTileID]=new Zm(!1,!1,!1);return}let B=E.heightOffset,V=!1,Q=!1,le=!0,De=null,pe={box:null,placeable:!1,offscreen:null,occluded:!1},Be={placeable:!1},xe=null,Ue=null,Ee=null,pt=0,yt=0,Nt=0;z.textFeatureIndex?pt=z.textFeatureIndex:E.useRuntimeCollisionCircles&&(pt=E.featureIndex),z.verticalTextFeatureIndex&&(yt=z.verticalTextFeatureIndex);let Ut=z.textBox;if(Ut){let $=q=>{let be=1;if(i.allowVerticalPlacement&&!q&&this.prevPlacement){let we=this.prevPlacement.placedOrientations[E.crossTileID];we&&(this.placedOrientations[E.crossTileID]=we,be=we,this.markUsedOrientation(i,be,E))}return be},ye=(q,be)=>{if(i.allowVerticalPlacement&&E.numVerticalGlyphVertices>0&&z.verticalTextBox){for(let we of i.writingModes)if(we===2?(pe=be(),Be=pe):pe=q(),pe==null?void 0:pe.placeable)break}else pe=q()},ee=E.textAnchorOffsetStartIndex,ie=E.textAnchorOffsetEndIndex;if(ie===ee){let q=(be,we)=>{let ae=this.collisionIndex.placeCollisionBox(be,g,u,R,o,w,x,n,p.predicate,F,void 0,D,B,P);return ae!=null&&ae.placeable&&(this.markUsedOrientation(i,we,E),this.placedOrientations[E.crossTileID]=we),ae};ye(()=>q(Ut,1),()=>{let be=z.verticalTextBox;return i.allowVerticalPlacement&&E.numVerticalGlyphVertices>0&&be?q(be,2):{box:null,offscreen:null}}),$(pe==null?void 0:pe.placeable)}else{let q=_c[(re=(ge=this.prevPlacement)==null?void 0:ge.variableOffsets[E.crossTileID])==null?void 0:re.anchor],be=(ae,et,Mi)=>{let Kr=ae.x2-ae.x1,zr=ae.y2-ae.y1,Fr=E.textBoxScale,Oe=b&&y==="never"?et:null,ke=null,or=g==="never"?1:2,br="never";q&&or++;for(let ha=0;ha<or;ha++){for(let st=ee;st<ie;st++){let ht=i.textAnchorOffsets.get(st);if(q&&ht.textAnchor!==q)continue;let ca=this.attemptAnchorPlacement(ht,ae,Kr,zr,Fr,x,w,u,R,o,p,br,E,i,Mi,n,s,Oe,F,D,B,P);if(ca&&(ke=ca.placedGlyphBoxes,ke==null?void 0:ke.placeable))return V=!0,De=ca.shift,ke}q?q=null:br=g}return r&&!ke&&(ke={box:this.collisionIndex.placeCollisionBox(Ut,"always",u,R,o,w,x,n,p.predicate,F,void 0,D,B,P).box,offscreen:!1,placeable:!1,occluded:!1}),ke};ye(()=>be(Ut,z.iconBox,1),()=>{let ae=z.verticalTextBox,et=pe==null?void 0:pe.placeable;return i.allowVerticalPlacement&&!et&&E.numVerticalGlyphVertices>0&&ae?be(ae,z.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),pe&&(V=pe.placeable,le=pe.offscreen);let we=$(pe==null?void 0:pe.placeable);if(!V&&this.prevPlacement){let ae=this.prevPlacement.variableOffsets[E.crossTileID];ae&&(this.variableOffsets[E.crossTileID]=ae,this.markUsedJustification(i,ae.anchor,E,we))}}}if(xe=pe,V=xe==null?void 0:xe.placeable,le=xe==null?void 0:xe.offscreen,E.useRuntimeCollisionCircles&&E.centerJustifiedTextSymbolIndex>=0){let $=i.text.placedSymbolArray.get(E.centerJustifiedTextSymbolIndex),ye=Sd(i.textSizeData,d,$),ee=a.get("text-padding"),ie=E.collisionCircleDiameter;Ue=this.collisionIndex.placeCollisionCircles(g,$,i.lineVertexArray,i.glyphOffsetArray,ye,o,l,r,w,p.predicate,ie,ee,n,F),Ue.circles.length&&Ue.collisionDetected&&!r&&_e("Collisions detected, but collision boxes are not shown"),V=_||Ue.circles.length>0&&!Ue.collisionDetected,le&&(le=Ue.offscreen)}if(z.iconFeatureIndex&&(Nt=z.iconFeatureIndex),z.iconBox){let $=ye=>this.collisionIndex.placeCollisionBox(ye,y,u,R,o,w,x,s,p.predicate,F,b&&De?De:void 0,D,B,P);Be&&Be.placeable&&z.verticalIconBox?(Ee=$(z.verticalIconBox),Q=Ee.placeable):(Ee=$(z.iconBox),Q=Ee.placeable),le&&(le=Ee.offscreen)}let Tt=f||E.numHorizontalGlyphVertices===0&&E.numVerticalGlyphVertices===0,nt=m||E.numIconVertices===0;!Tt&&!nt?Q=V=Q&&V:nt?Tt||Q&&(Q=V):V=Q&&V;let Yt=V&&xe.placeable,vr=Q&&Ee.placeable;if(Yt&&(Be&&Be.placeable&&yt?this.collisionIndex.insertCollisionBox(xe.box,g,a.get("text-ignore-placement"),i.bucketInstanceId,yt,p.ID):this.collisionIndex.insertCollisionBox(xe.box,g,a.get("text-ignore-placement"),i.bucketInstanceId,pt,p.ID)),vr&&this.collisionIndex.insertCollisionBox(Ee.box,y,a.get("icon-ignore-placement"),i.bucketInstanceId,Nt,p.ID),Ue&&V&&this.collisionIndex.insertCollisionCircles(Ue.circles,g,a.get("text-ignore-placement"),i.bucketInstanceId,pt,p.ID),r&&this.storeCollisionData(i.bucketInstanceId,L,z,xe,Ee,Ue),E.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");if(i.bucketInstanceId===0)throw Error("bucket.bucketInstanceId can't be 0");let sr=(V||S)&&!(xe!=null&&xe.occluded),Z=(Q||I)&&!(Ee!=null&&Ee.occluded);this.placements[E.crossTileID]=new Zm(sr,Z,le||i.justReloaded),t[E.crossTileID]=!0};if(T){if(e.symbolInstanceStart!==0)throw Error("bucket.bucketInstanceId should be 0");let E=i.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let z=E.length-1;z>=0;--z){let L=E[z];A(i.symbolInstances.get(L),i.collisionArrays[L],L)}}else for(let E=e.symbolInstanceStart;E<e.symbolInstanceEnd;E++)A(i.symbolInstances.get(E),i.collisionArrays[E],E);i.justReloaded=!1}storeCollisionData(e,t,r,i,a,n){if(r.textBox||r.iconBox){let s;this.collisionBoxArrays.has(e)?s=this.collisionBoxArrays.get(e):(s=new Map,this.collisionBoxArrays.set(e,s));let o;s.has(t)?o=s.get(t):(o={text:null,icon:null},s.set(t,o)),r.textBox&&(o.text=i.box),r.iconBox&&(o.icon=a.box)}if(n){let s=this.collisionCircleArrays[e];s===void 0&&(s=this.collisionCircleArrays[e]=[]);for(let o=0;o<n.circles.length;o+=4)s.push(n.circles[o+0]-100),s.push(n.circles[o+1]-100),s.push(n.circles[o+2]),s.push(+!!n.collisionDetected)}}markUsedJustification(e,t,r,i){let a={left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex},n;n=i===2?r.verticalPlacedTextSymbolIndex:a[yc(t)];let s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(let o of s)o>=0&&(n>=0&&o!==n?e.text.placedSymbolArray.get(o).crossTileID=0:e.text.placedSymbolArray.get(o).crossTileID=r.crossTileID)}markUsedOrientation(e,t,r){let i=t===1||t===3?t:0,a=t===2?t:0,n=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(let s of n)e.text.placedSymbolArray.get(s).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,r=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let i=t?t.symbolFadeChange(e):1,a=t?t.opacities:{},n=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(let o in this.placements){let l=this.placements[o],u=a[o];u?(this.opacities[o]=new wn(u,i,l.text,l.icon),r||(r=l.text!==u.text.placed),r||(r=l.icon!==u.icon.placed)):(this.opacities[o]=new wn(null,i,l.text,l.icon,l.skipFade),r||(r=l.text||l.icon))}for(let o in a){let l=a[o];if(!this.opacities[o]){let u=new wn(l,i,!1,!1);u.isHidden()||(this.opacities[o]=u,r||(r=l.text.placed),r||(r=l.icon.placed))}}for(let o in n)!this.variableOffsets[o]&&this.opacities[o]&&!this.opacities[o].isHidden()&&(this.variableOffsets[o]=n[o]);for(let o in s)!this.placedOrientations[o]&&this.opacities[o]&&!this.opacities[o].isHidden()&&(this.placedOrientations[o]=s[o]);if(t&&t.lastPlacementChangeTime===void 0)throw Error("Last placement time for previous placement is not defined");r?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let r={};for(let i of t){let a=i.getBucket(e);a&&i.latestFeatureIndex&&e.id===a.layerIds[0]&&this.updateBucketOpacities(a,i.tileID,r,i.collisionBoxArray)}}updateBucketOpacities(e,t,r,i){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],n=a.layout,s=new wn(null,0,!1,!1,!0),o=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),u=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h=n.get("text-rotation-alignment")==="map",c=n.get("text-pitch-alignment")==="map",d=n.get("icon-text-fit")!=="none",p=new wn(null,0,o&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(o||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);let f=(g,_,y)=>{for(let v=0;v<_/4;v++)g.opacityVertexArray.emplaceBack(y);g.hasVisibleVertices||(g.hasVisibleVertices=y!==Tn)},m=this.collisionBoxArrays.get(e.bucketInstanceId);for(let g=0;g<e.symbolInstances.length;g++){let _=e.symbolInstances.get(g),{numHorizontalGlyphVertices:y,numVerticalGlyphVertices:v,crossTileID:x}=_,w=r[x],b=this.opacities[x];w?b=s:b||(b=p,this.opacities[x]=b),r[x]=!0;let T=y>0||v>0,P=_.numIconVertices>0,S=this.placedOrientations[_.crossTileID],I=S===2,R=S===1||S===3;if(T){let D=Xm(b.text),A=I?Tn:D;f(e.text,y,A);let E=R?Tn:D;f(e.text,v,E);let z=b.text.isHidden(),L=[_.rightJustifiedTextSymbolIndex,_.centerJustifiedTextSymbolIndex,_.leftJustifiedTextSymbolIndex];for(let Q of L)Q>=0&&(e.text.placedSymbolArray.get(Q).hidden=z||I?1:0);_.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(_.verticalPlacedTextSymbolIndex).hidden=z||R?1:0);let B=this.variableOffsets[_.crossTileID];B&&this.markUsedJustification(e,B.anchor,_,S);let V=this.placedOrientations[_.crossTileID];V&&(this.markUsedJustification(e,"left",_,V),this.markUsedOrientation(e,V,_))}if(P){let D=Xm(b.icon),A=!(d&&_.verticalPlacedIconSymbolIndex&&I);if(_.placedIconSymbolIndex>=0){let E=A?D:Tn;f(e.icon,_.numIconVertices,E),e.icon.placedSymbolArray.get(_.placedIconSymbolIndex).hidden=b.icon.isHidden()}if(_.verticalPlacedIconSymbolIndex>=0){let E=A?Tn:D;f(e.icon,_.numVerticalIconVertices,E),e.icon.placedSymbolArray.get(_.verticalPlacedIconSymbolIndex).hidden=b.icon.isHidden()}}let F=m!=null&&m.has(g)?m.get(g):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let D=e.collisionArrays[g];if(D){let A=new C(0,0);if(D.textBox||D.verticalTextBox){let E=!0;if(u){let z=this.variableOffsets[x];z?(A=Wm(z.anchor,z.width,z.height,z.textOffset,z.textBoxScale),h&&A._rotate(c?-this.transform.bearingInRadians:this.transform.bearingInRadians)):E=!1}if(D.textBox||D.verticalTextBox){let z;D.textBox&&(z=I),D.verticalTextBox&&(z=R),Hm(e.textCollisionBox.collisionVertexArray,b.text.placed,!E||z,F.text,A.x,A.y)}}if(D.iconBox||D.verticalIconBox){let E=!(R||!D.verticalIconBox),z;D.iconBox&&(z=E),D.verticalIconBox&&(z=!E),Hm(e.iconCollisionBox.collisionVertexArray,b.icon.placed,z,F.icon,d?A.x:0,d?A.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){let r=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*r>e}setStale(){this.stale=!0}};function Hm(e,t,r,i,a,n){(!i||i.length===0)&&(i=[0,0,0,0]);let s=i[0]-100,o=i[1]-100,l=i[2]-100,u=i[3]-100;e.emplaceBack(+!!t,+!!r,a||0,n||0,s,o),e.emplaceBack(+!!t,+!!r,a||0,n||0,l,o),e.emplaceBack(+!!t,+!!r,a||0,n||0,l,u),e.emplaceBack(+!!t,+!!r,a||0,n||0,s,u)}const xM=2**25,vM=2**24,bM=2**17,wM=2**16;function Xm(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return 4294967295;let t=+!!e.placed,r=Math.floor(e.opacity*127);return r*xM+t*vM+r*bM+t*wM+r*512+t*256+r*2+t}const Tn=0;var TM=class{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,r,i,a){let n=this._bucketParts;for(;this._currentTileIndex<e.length;){let s=e[this._currentTileIndex];if(t.getBucketParts(n,i,s,this._sortAcrossTiles),this._currentTileIndex++,a())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((s,o)=>s.sortKey-o.sortKey));this._currentPartIndex<n.length;){let s=n[this._currentPartIndex];if(t.placeLayerBucketPart(s,this._seenCrossTileIDs,r),this._currentPartIndex++,a())return!0}return!1}},DM=class{constructor(e,t,r,i,a,n,s,o){this.placement=new yM(e,t,n,s,o),this._currentPlacementIndex=r.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(e,t,r){let i=Fe(),a=()=>!this._forceFullPlacement&&Fe()-i>2;for(;this._currentPlacementIndex>=0;){let n=t[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if(k0(n)&&n.layout&&(!n.minzoom||n.minzoom<=s)&&(!n.maxzoom||n.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new TM(n)),this._inProgressLayer.continuePlacement(r[n.source],this.placement,this._showCollisionBoxes,n,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}};const Ym=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Xe=new Uint32Array(96);var SM=class F1{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[r,i]=new Uint8Array(t,0,2);if(r!==219)throw Error("Data does not appear to be in a KDBush format.");let a=i>>4;if(a!==1)throw Error(`Got v${a} data when expected v1.`);let n=Ym[i&15];if(!n)throw Error("Unrecognized array type.");let[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new F1(o,s,n,void 0,t)}constructor(t,r=64,i=Float64Array,a=ArrayBuffer,n){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let s=Ym.indexOf(this.ArrayType),o=t*2*this.ArrayType.BYTES_PER_ELEMENT,l=t*this.IndexArrayType.BYTES_PER_ELEMENT,u=(8-l%8)%8;if(s<0)throw Error(`Unexpected typed array class: ${i}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new i(n,8+l+u,t*2),this._pos=t*2,this._finished=!0;else{let h=this.data=new a(8+o+l+u);this.ids=new this.IndexArrayType(h,8,t),this.coords=new i(h,8+l+u,t*2),this._pos=0,this._finished=!1,new Uint8Array(h,0,2).set([219,16+s]),new Uint16Array(h,2,1)[0]=r,new Uint32Array(h,4,1)[0]=t}}add(t,r){let i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=r,i}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return Rc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,r,i,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:s,nodeSize:o}=this;Xe[0]=0,Xe[1]=n.length-1,Xe[2]=0;let l=3,u=[];for(;l>0;){let h=Xe[--l],c=Xe[--l],d=Xe[--l];if(c-d<=o){for(let g=d;g<=c;g++){let _=s[2*g],y=s[2*g+1];_>=t&&_<=i&&y>=r&&y<=a&&u.push(n[g])}continue}let p=d+c>>1,f=s[2*p],m=s[2*p+1];f>=t&&f<=i&&m>=r&&m<=a&&u.push(n[p]),(h===0?t<=f:r<=m)&&(Xe[l++]=d,Xe[l++]=p-1,Xe[l++]=1-h),(h===0?i>=f:a>=m)&&(Xe[l++]=p+1,Xe[l++]=c,Xe[l++]=1-h)}return u}within(t,r,i){let a=[];return this.withinInto(t,r,i,a),a}withinInto(t,r,i,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:s,nodeSize:o}=this;Xe[0]=0,Xe[1]=n.length-1,Xe[2]=0;let l=3,u=0,h=i*i;for(;l>0;){let c=Xe[--l],d=Xe[--l],p=Xe[--l];if(d-p<=o){for(let _=p;_<=d;_++)Km(s[2*_],s[2*_+1],t,r)<=h&&(a[u++]=n[_]);continue}let f=p+d>>1,m=s[2*f],g=s[2*f+1];Km(m,g,t,r)<=h&&(a[u++]=n[f]),(c===0?t-i<=m:r-i<=g)&&(Xe[l++]=p,Xe[l++]=f-1,Xe[l++]=1-c),(c===0?t+i>=m:r+i>=g)&&(Xe[l++]=f+1,Xe[l++]=d,Xe[l++]=1-c)}return u}};function Rc(e,t,r,i,a,n){if(a-i<=r)return;let s=i+a>>1;R1(e,t,s,i,a,n),Rc(e,t,r,i,s-1,1-n),Rc(e,t,r,s+1,a,1-n)}function R1(e,t,r,i,a,n){for(;a>i;){if(a-i>600){let u=a-i+1,h=r-i+1,c=Math.log(u),d=.5*Math.exp(2*c/3),p=.5*Math.sqrt(c*d*(u-d)/u)*(h-u/2<0?-1:1);R1(e,t,r,Math.max(i,Math.floor(r-h*d/u+p)),Math.min(a,Math.floor(r+(u-h)*d/u+p)),n)}let s=t[2*r+n],o=i,l=a;for(Dn(e,t,i,r),t[2*a+n]>s&&Dn(e,t,i,a);o<l;){for(Dn(e,t,o,l),o++,l--;t[2*o+n]<s;)o++;for(;t[2*l+n]>s;)l--}t[2*i+n]===s?Dn(e,t,i,l):(l++,Dn(e,t,l,a)),l<=r&&(i=l+1),r<=l&&(a=l-1)}}function Dn(e,t,r,i){Wu(e,r,i),Wu(t,2*r,2*i),Wu(t,2*r+1,2*i+1)}function Wu(e,t,r){let i=e[t];e[t]=e[r],e[r]=i}function Km(e,t,r,i){let a=e-r,n=t-i;return a*a+n*n}const Sn=512/k/2;var EM=class{constructor(e,t,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};let i=new Map;for(let a=0;a<t.length;a++){let n=t.get(a),s=n.key,o=i.get(s);o?o.push(n):i.set(s,[n])}for(let[a,n]of i){let s={positions:n.map(o=>({x:Math.floor(o.anchorX*Sn),y:Math.floor(o.anchorY*Sn)})),crossTileIDs:n.map(o=>o.crossTileID)};if(s.positions.length>128){let o=new SM(s.positions.length,16,Uint16Array);for(let{x:l,y:u}of s.positions)o.add(l,u);o.finish(),delete s.positions,s.index=o}this._symbolsByKey[a]=s}}getScaledCoordinates(e,t){let{x:r,y:i,z:a}=this.tileID.canonical,{x:n,y:s,z:o}=t.canonical,l=o-a,u=Sn/2**l,h=(n*k+e.anchorX)*u,c=(s*k+e.anchorY)*u,d=r*k*Sn,p=i*k*Sn;return{x:Math.floor(h-d),y:Math.floor(c-p)}}findMatches(e,t,r){let i=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let a=0;a<e.length;a++){let n=e.get(a);if(n.crossTileID)continue;let s=this._symbolsByKey[n.key];if(!s)continue;let o=this.getScaledCoordinates(n,t);s.index?this.findMatchesForIndexedEntry(s,n,o,i,r):s.positions&&this.findMatchesForNonIndexedEntry(s,n,o,i,r)}}findMatchesForIndexedEntry(e,t,r,i,a){let n=e.index.range(r.x-i,r.y-i,r.x+i,r.y+i),s=1/0;for(let o of n)o<s&&!a[e.crossTileIDs[o]]&&(s=o);if(s!==1/0){let o=e.crossTileIDs[s];a[o]=!0,t.crossTileID=o}}findMatchesForNonIndexedEntry(e,t,r,i,a){for(let n=0;n<e.positions.length;n++){let s=e.positions[n],o=e.crossTileIDs[n];if(Math.abs(s.x-r.x)<=i&&Math.abs(s.y-r.y)<=i&&!a[o]){a[o]=!0,t.crossTileID=o;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},PM=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},AM=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let r in this.indexes){let i=this.indexes[r],a={};for(let n in i){let s=i[n];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+t),a[s.tileID.key]=s}this.indexes[r]=a}this.lng=e}addBucket(e,t,r){var a,n,s;if((a=this.indexes[e.overscaledZ])!=null&&a[e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let o=0;o<t.symbolInstances.length;o++){let l=t.symbolInstances.get(o);l.crossTileID=0}(n=this.usedCrossTileIDs)[s=e.overscaledZ]||(n[s]={});let i=this.usedCrossTileIDs[e.overscaledZ];for(let o in this.indexes){let l=this.indexes[o];if(Number(o)>e.overscaledZ)for(let u in l){let h=l[u];h.tileID.isChildOf(e)&&h.findMatches(t.symbolInstances,e,i)}else{let u=l[e.scaledTo(Number(o)).key];u&&u.findMatches(t.symbolInstances,e,i)}}for(let o=0;o<t.symbolInstances.length;o++){let l=t.symbolInstances.get(o);l.crossTileID||(l.crossTileID=r.generate(),i[l.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new EM(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let r of t.getCrossTileIDsLists())for(let i of r)delete this.usedCrossTileIDs[e][i]}removeStaleBuckets(e){let t=!1;for(let r in this.indexes){let i=this.indexes[r];for(let a in i)e[i[a].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,i[a]),delete i[a],t=!0)}return t}},k1=class{constructor(){this.layerIndexes={},this.crossTileIDs=new PM,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,r){let i=this.layerIndexes[e.id];i===void 0&&(i=this.layerIndexes[e.id]=new AM);let a=!1,n={};i.handleWrapJump(r);for(let s of t){let o=s.getBucket(e);e.id===(o==null?void 0:o.layerIds[0])&&(o.bucketInstanceId||(o.bucketInstanceId=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId)),i.addBucket(s.tileID,o,this.crossTileIDs)&&(a=!0),n[o.bucketInstanceId]=!0)}return i.removeStaleBuckets(n)&&(a=!0),a}pruneUnusedLayers(e){let t={};for(let r of e)t[r]=!0;for(let r in this.layerIndexes)t[r]||delete this.layerIndexes[r]}},CM=`#ifdef GL_ES
precision mediump float;
#else
#if !defined(lowp)
#define lowp
#endif
#if !defined(mediump)
#define mediump
#endif
#if !defined(highp)
#define highp
#endif
#endif
out highp vec4 fragColor;layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};`,IM=`#ifdef GL_ES
precision highp float;
#else
#if !defined(lowp)
#define lowp
#endif
#if !defined(mediump)
#define mediump
#endif
#if !defined(highp)
#define highp
#endif
#endif
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const uint packedOpacity) {return vec2(float(packedOpacity >> 1u)/127.0,float(packedOpacity & 1u));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c
);}
#ifdef TERRAIN3D
uniform sampler2D u_terrain;uniform highp sampler2D u_depth;layout(std140) uniform TerrainUBO {highp mat4 u_terrain_matrix;highp vec4 u_terrain_unpack;highp float u_terrain_dim;highp float u_terrain_exaggeration;};
#endif
const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
#ifdef TERRAIN3D
highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
#else
return 1.0;
#endif
}float calculate_visibility(vec4 pos) {
#ifdef TERRAIN3D
vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
#else
return 1.0;
#endif
}float ele(ivec2 pos) {
#ifdef TERRAIN3D
vec4 rgb=(texelFetch(u_terrain,pos,0)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
#else
return 0.0;
#endif
}float get_elevation(vec2 pos) {
#ifdef TERRAIN3D
#ifdef GLOBE
if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
#endif
vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.5;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
#else
return 0.0;
#endif
}const float PI=3.141592653589793;
#define PROJECTION_UBO
layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};`,MM=`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,zM="layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}",FM=`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,RM="uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}",kM=`in vec3 v_data;flat in float v_visibility;
#pragma maplibre: define highp vec4 color
#pragma maplibre: define mediump float radius
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define highp vec4 stroke_color
#pragma maplibre: define mediump float stroke_width
#pragma maplibre: define lowp float stroke_opacity
void main() {
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize mediump float radius
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize highp vec4 stroke_color
#pragma maplibre: initialize mediump float stroke_width
#pragma maplibre: initialize lowp float stroke_opacity
vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,LM=`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;flat out float v_visibility;
#pragma maplibre: define highp vec4 color
#pragma maplibre: define mediump float radius
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define highp vec4 stroke_color
#pragma maplibre: define mediump float stroke_width
#pragma maplibre: define lowp float stroke_opacity
void main(void) {
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize mediump float radius
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize highp vec4 stroke_color
#pragma maplibre: initialize mediump float stroke_width
#pragma maplibre: initialize lowp float stroke_opacity
ivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {
#ifdef GLOBE
vec3 center_vector=projectToSphere(circle_center);
#endif
float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {
#ifdef GLOBE
vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
#else
vec4 projected_center=projectTileWithElevation(circle_center,ele);
#endif
corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}
#ifdef GLOBE
vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
#else
gl_Position=projectTileWithElevation(corner_position,ele);
#endif
} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`,Jm="void main() {fragColor=vec4(1.0);}";const Nr={prelude:ve(CM,IM),projectionMercator:ve(`
void clipAntimeridian() {}`,"float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:ve("in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}",`#define GLOBE_RADIUS 6371008.8
#ifndef PROJECTION_UBO
uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;
#endif
out highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy
);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:ve(MM,zM),backgroundPattern:ve(FM,RM),circle:ve(kM,LM),clippingMask:ve(Jm,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:ve(`uniform highp float u_intensity;in vec2 v_extrude;
#pragma maplibre: define highp float weight
#define GAUSS_COEF 0.3989422804014327
void main() {
#pragma maplibre: initialize highp float weight
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in ivec2 a_pos;out vec2 v_extrude;
#pragma maplibre: define highp float weight
#pragma maplibre: define mediump float radius
const highp float ZERO=1.0/255.0/16.0;
#define GAUSS_COEF 0.3989422804014327
void main(void) {
#pragma maplibre: initialize highp float weight
#pragma maplibre: initialize mediump float radius
ivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=vec2(pos_raw >> 3);
#ifdef GLOBE
vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);
#else
gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
#endif
}`),heatmapTexture:ve(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(0.0);
#endif
}`,"uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:ve("flat in float v_placed;flat in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;flat out float v_placed;flat out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ve("flat in float v_radius;in vec2 v_extrude;flat in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;flat out float v_radius;out vec2 v_extrude;flat out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:ve(`#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {vec4 data=texelFetch(u_elevation_stops,ivec2(stop,0),0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else
{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,"uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=2.0/u_dimension;float scale=(u_dimension.x-4.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:ve("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","layout(location=0) in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:ve(Jm,`layout(location=0) in vec2 a_pos;void main() {
#ifdef GLOBE
gl_Position=projectTileFor3D(a_pos,0.0);
#else
gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
#endif
}`),fill:ve(`#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp float opacity
void main() {
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize lowp float opacity
fragColor=color*opacity;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp float opacity
void main() {
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize lowp float opacity
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:ve(`in vec2 v_pos;
#ifdef GLOBE
in float v_depth;
#endif
#pragma maplibre: define highp vec4 outline_color
#pragma maplibre: define lowp float opacity
void main() {
#pragma maplibre: initialize highp vec4 outline_color
#pragma maplibre: initialize lowp float opacity
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
#ifdef GLOBE
if (v_depth > 1.0) {discard;}
#endif
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;
#ifdef GLOBE
out float v_depth;
#endif
#pragma maplibre: define highp vec4 outline_color
#pragma maplibre: define lowp float opacity
void main() {
#pragma maplibre: initialize highp vec4 outline_color
#pragma maplibre: initialize lowp float opacity
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;
#ifdef GLOBE
v_depth=gl_Position.z/gl_Position.w;
#endif
}`),fillOutlinePattern:ve(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;uniform bool u_sdf_pattern;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;
#ifdef GLOBE
in float v_depth;
#endif
#pragma maplibre: define lowp float opacity
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp vec4 pattern_from
#pragma maplibre: define lowp vec4 pattern_to
void main() {
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize mediump vec4 pattern_from
#pragma maplibre: initialize mediump vec4 pattern_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*alpha*opacity;} else {fragColor=mix(color1,color2,u_fade)*alpha*opacity;}
#ifdef GLOBE
if (v_depth > 1.0) {discard;}
#endif
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;
#ifdef GLOBE
out float v_depth;
#endif
#pragma maplibre: define lowp float opacity
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp vec4 pattern_from
#pragma maplibre: define lowp vec4 pattern_to
#pragma maplibre: define lowp float pixel_ratio_from
#pragma maplibre: define lowp float pixel_ratio_to
void main() {
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize mediump vec4 pattern_from
#pragma maplibre: initialize mediump vec4 pattern_to
#pragma maplibre: initialize lowp float pixel_ratio_from
#pragma maplibre: initialize lowp float pixel_ratio_to
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;
#ifdef GLOBE
v_depth=gl_Position.z/gl_Position.w;
#endif
}`),fillPattern:ve(`#ifdef GL_ES
precision highp float;
#endif
uniform vec2 u_texsize;uniform float u_fade;uniform bool u_sdf_pattern;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
#pragma maplibre: define lowp float opacity
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp vec4 pattern_from
#pragma maplibre: define lowp vec4 pattern_to
void main() {
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize mediump vec4 pattern_from
#pragma maplibre: initialize mediump vec4 pattern_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*opacity;} else {fragColor=mix(color1,color2,u_fade)*opacity;}
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;
#pragma maplibre: define lowp float opacity
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp vec4 pattern_from
#pragma maplibre: define lowp vec4 pattern_to
#pragma maplibre: define lowp float pixel_ratio_from
#pragma maplibre: define lowp float pixel_ratio_to
void main() {
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize mediump vec4 pattern_from
#pragma maplibre: initialize mediump vec4 pattern_to
#pragma maplibre: initialize lowp float pixel_ratio_from
#pragma maplibre: initialize lowp float pixel_ratio_to
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:ve(`in vec4 v_color;void main() {fragColor=v_color;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;
#ifdef TERRAIN3D
layout(location=2) in vec2 a_centroid;
#endif
out vec4 v_color;
#pragma maplibre: define highp float base
#pragma maplibre: define highp float height
#pragma maplibre: define highp vec4 color
void main() {
#pragma maplibre: initialize highp float base
#pragma maplibre: initialize highp float height
#pragma maplibre: initialize highp vec4 color
vec3 normal=vec3(a_normal_ed.xyz);float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);
#ifdef TERRAIN3D
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
#else
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
#endif
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
#ifdef GLOBE
vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
#else
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
#endif
float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
#ifdef GLOBE
mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
#endif
directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:ve(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;
#pragma maplibre: define lowp float base
#pragma maplibre: define lowp float height
#pragma maplibre: define lowp vec4 pattern_from
#pragma maplibre: define lowp vec4 pattern_to
#pragma maplibre: define lowp float pixel_ratio_from
#pragma maplibre: define lowp float pixel_ratio_to
void main() {
#pragma maplibre: initialize lowp float base
#pragma maplibre: initialize lowp float height
#pragma maplibre: initialize mediump vec4 pattern_from
#pragma maplibre: initialize mediump vec4 pattern_to
#pragma maplibre: initialize lowp float pixel_ratio_from
#pragma maplibre: initialize lowp float pixel_ratio_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;
#ifdef TERRAIN3D
layout(location=2) in vec2 a_centroid;
#endif
#ifdef GLOBE
out vec3 v_sphere_pos;
#endif
out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
#pragma maplibre: define lowp float base
#pragma maplibre: define lowp float height
#pragma maplibre: define lowp vec4 pattern_from
#pragma maplibre: define lowp vec4 pattern_to
#pragma maplibre: define lowp float pixel_ratio_from
#pragma maplibre: define lowp float pixel_ratio_to
void main() {
#pragma maplibre: initialize lowp float base
#pragma maplibre: initialize lowp float height
#pragma maplibre: initialize mediump vec4 pattern_from
#pragma maplibre: initialize mediump vec4 pattern_to
#pragma maplibre: initialize lowp float pixel_ratio_from
#pragma maplibre: initialize lowp float pixel_ratio_to
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=vec3(a_normal_ed.xyz);float edgedistance=float(a_normal_ed.w);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);
#ifdef TERRAIN3D
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
#else
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
#endif
base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
#ifdef GLOBE
vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
#else
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
#endif
vec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384
? a_pos
: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:ve(`#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-4.0;float a=getElevation(pos+ivec2(-1,-1));float b=getElevation(pos+ivec2(0,-1));float c=getElevation(pos+ivec2(1,-1));float d=getElevation(pos+ivec2(-1,0));float e=getElevation(pos);float f=getElevation(pos+ivec2(1,0));float g=getElevation(pos+ivec2(-1,1));float h=getElevation(pos+ivec2(0,1));float i=getElevation(pos+ivec2(1,1));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+128.0/255.0,deriv.y/8.0+128.0/255.0,1.0,1.0),0.0,1.0);
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ve(`uniform sampler2D u_image;in highp vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];
#define PI 3.141592653589793
#define STANDARD 0
#define COMBINED 1
#define IGOR 2
#define MULTIDIRECTIONAL 3
#define BASIC 4
float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else
{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else
{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {highp vec2 size=vec2(textureSize(u_image,0));highp vec2 texturePos=(v_pos*(size-2.0)+1.0)/size;vec4 pixel=texture(u_image,texturePos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=(pixel.rg-128.0/255.0)*8.0/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,"uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:ve(`flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
#ifdef GLOBE
in float v_depth;
#endif
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
void main() {
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);
#ifdef GLOBE
if (v_depth > 1.0) {discard;}
#endif
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
#ifdef GLOBE
out float v_depth;
#endif
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define mediump float gapwidth
#pragma maplibre: define lowp float offset
#pragma maplibre: define mediump float width
void main() {
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize mediump float gapwidth
#pragma maplibre: initialize lowp float offset
#pragma maplibre: initialize mediump float width
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
#ifdef GLOBE
v_depth=gl_Position.z/gl_Position.w;
#endif
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
v_width2=vec2(outset,inset);}`),lineGradient:ve(`uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
#ifdef GLOBE
in float v_depth;
#endif
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
void main() {
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
#ifdef GLOBE
if (v_depth > 1.0) {discard;}
#endif
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
#ifdef GLOBE
out float v_depth;
#endif
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define mediump float gapwidth
#pragma maplibre: define lowp float offset
#pragma maplibre: define mediump float width
void main() {
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize mediump float gapwidth
#pragma maplibre: initialize lowp float offset
#pragma maplibre: initialize mediump float width
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
#ifdef GLOBE
v_depth=gl_Position.z/gl_Position.w;
#endif
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
v_width2=vec2(outset,inset);}`),linePattern:ve(`#ifdef GL_ES
precision highp float;
#endif
uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;
#ifdef GLOBE
in float v_depth;
#endif
#pragma maplibre: define lowp vec4 pattern_from
#pragma maplibre: define lowp vec4 pattern_to
#pragma maplibre: define lowp float pixel_ratio_from
#pragma maplibre: define lowp float pixel_ratio_to
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
void main() {
#pragma maplibre: initialize mediump vec4 pattern_from
#pragma maplibre: initialize mediump vec4 pattern_to
#pragma maplibre: initialize lowp float pixel_ratio_from
#pragma maplibre: initialize lowp float pixel_ratio_to
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
clipAntimeridian();vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;
#ifdef GLOBE
if (v_depth > 1.0) {discard;}
#endif
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
#define LINE_DISTANCE_SCALE 2.0
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;
#ifdef GLOBE
out float v_depth;
#endif
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define lowp float offset
#pragma maplibre: define mediump float gapwidth
#pragma maplibre: define mediump float width
#pragma maplibre: define lowp float floorwidth
#pragma maplibre: define lowp vec4 pattern_from
#pragma maplibre: define lowp vec4 pattern_to
#pragma maplibre: define lowp float pixel_ratio_from
#pragma maplibre: define lowp float pixel_ratio_to
void main() {
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize lowp float offset
#pragma maplibre: initialize mediump float gapwidth
#pragma maplibre: initialize mediump float width
#pragma maplibre: initialize lowp float floorwidth
#pragma maplibre: initialize mediump vec4 pattern_from
#pragma maplibre: initialize mediump vec4 pattern_to
#pragma maplibre: initialize lowp float pixel_ratio_from
#pragma maplibre: initialize lowp float pixel_ratio_to
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
#ifdef GLOBE
v_depth=gl_Position.z/gl_Position.w;
#endif
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:ve(`uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
#ifdef GLOBE
in float v_depth;
#endif
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define mediump float width
#pragma maplibre: define lowp float floorwidth
#pragma maplibre: define mediump vec4 dasharray_from
#pragma maplibre: define mediump vec4 dasharray_to
void main() {
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize mediump float width
#pragma maplibre: initialize lowp float floorwidth
#pragma maplibre: initialize mediump vec4 dasharray_from
#pragma maplibre: initialize mediump vec4 dasharray_to
clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);
#ifdef GLOBE
if (v_depth > 1.0) {discard;}
#endif
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
#define LINE_DISTANCE_SCALE 2.0
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
#ifdef GLOBE
out float v_depth;
#endif
#pragma maplibre: define highp vec4 color
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define mediump float gapwidth
#pragma maplibre: define lowp float offset
#pragma maplibre: define mediump float width
#pragma maplibre: define lowp float floorwidth
#pragma maplibre: define mediump vec4 dasharray_from
#pragma maplibre: define mediump vec4 dasharray_to
void main() {
#pragma maplibre: initialize highp vec4 color
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize mediump float gapwidth
#pragma maplibre: initialize lowp float offset
#pragma maplibre: initialize mediump float width
#pragma maplibre: initialize lowp float floorwidth
#pragma maplibre: initialize mediump vec4 dasharray_from
#pragma maplibre: initialize mediump vec4 dasharray_to
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
#ifdef GLOBE
v_depth=gl_Position.z/gl_Position.w;
#endif
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),lineGradientSDF:ve(`uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;
#ifdef GLOBE
in float v_depth;
#endif
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define mediump float width
#pragma maplibre: define lowp float floorwidth
#pragma maplibre: define mediump vec4 dasharray_from
#pragma maplibre: define mediump vec4 dasharray_to
void main() {
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize mediump float width
#pragma maplibre: initialize lowp float floorwidth
#pragma maplibre: initialize mediump vec4 dasharray_from
#pragma maplibre: initialize mediump vec4 dasharray_to
clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);
#ifdef GLOBE
if (v_depth > 1.0) {discard;}
#endif
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
#define LINE_DISTANCE_SCALE 2.0
layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;
#ifdef GLOBE
out float v_depth;
#endif
#pragma maplibre: define lowp float blur
#pragma maplibre: define lowp float opacity
#pragma maplibre: define mediump float gapwidth
#pragma maplibre: define lowp float offset
#pragma maplibre: define mediump float width
#pragma maplibre: define lowp float floorwidth
#pragma maplibre: define mediump vec4 dasharray_from
#pragma maplibre: define mediump vec4 dasharray_to
void main() {
#pragma maplibre: initialize lowp float blur
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize mediump float gapwidth
#pragma maplibre: initialize lowp float offset
#pragma maplibre: initialize mediump float width
#pragma maplibre: initialize lowp float floorwidth
#pragma maplibre: initialize mediump vec4 dasharray_from
#pragma maplibre: initialize mediump vec4 dasharray_to
if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
#ifdef GLOBE
v_depth=gl_Position.z/gl_Position.w;
#endif
#ifdef TERRAIN3D
v_gamma_scale=1.0;
#else
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#endif
float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),layerOpacity:ve(`uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(0.0);
#endif
}`,"layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:ve(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec3 u_image_warp;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 topLeft=u_coords_top.xy;vec2 topRight=u_coords_top.zw;vec2 bottomLeft=u_coords_bottom.xy;vec2 bottomRight=u_coords_bottom.zw;vec2 bilinearPos=mix(mix(topLeft,topRight,fractionalPos.x),mix(bottomLeft,bottomRight,fractionalPos.x),fractionalPos.y);float denominator=dot(u_image_warp.xy,fractionalPos)+1.0;vec2 acrossTop=topRight-topLeft+u_image_warp.x*topRight;vec2 downLeft=bottomLeft-topLeft+u_image_warp.y*bottomLeft;vec2 projectivePos=(acrossTop*fractionalPos.x+downLeft*fractionalPos.y+topLeft)/denominator;vec2 position=mix(projectivePos,bilinearPos,u_image_warp.z);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5;
#ifdef GLOBE
if (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}
#endif
float perspectiveRatio=mix(1.0/denominator,1.0,u_image_warp.z);v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}`),symbolIcon:ve(`uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform bool u_rotate_symbol;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_tex;flat out float v_total_opacity;
#pragma maplibre: define lowp float opacity
void main() {
#pragma maplibre: initialize lowp float opacity
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
#ifdef GLOBE
if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
#endif
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}`),symbolSDF:ve(`#define SDF_PX 8.0
uniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;
#pragma maplibre: define highp vec4 fill_color
#pragma maplibre: define highp vec4 halo_color
#pragma maplibre: define lowp float halo_width
#pragma maplibre: define lowp float halo_blur
void main() {
#pragma maplibre: initialize highp vec4 fill_color
#pragma maplibre: initialize highp vec4 halo_color
#pragma maplibre: initialize lowp float halo_width
#pragma maplibre: initialize lowp float halo_blur
float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_data0;out vec3 v_data1;
#pragma maplibre: define highp vec4 fill_color
#pragma maplibre: define highp vec4 halo_color
#pragma maplibre: define lowp float opacity
#pragma maplibre: define lowp float halo_width
#pragma maplibre: define lowp float halo_blur
void main() {
#pragma maplibre: initialize highp vec4 fill_color
#pragma maplibre: initialize highp vec4 halo_color
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize lowp float halo_width
#pragma maplibre: initialize lowp float halo_blur
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
#ifdef GLOBE
if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
#endif
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}`),symbolTextAndIcon:ve(`#define SDF_PX 8.0
#define SDF 1.0
#define ICON 0.0
uniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;
#pragma maplibre: define highp vec4 fill_color
#pragma maplibre: define highp vec4 halo_color
#pragma maplibre: define lowp float halo_width
#pragma maplibre: define lowp float halo_blur
void main() {
#pragma maplibre: initialize highp vec4 fill_color
#pragma maplibre: initialize highp vec4 halo_color
#pragma maplibre: initialize lowp float halo_width
#pragma maplibre: initialize lowp float halo_blur
float total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;layout(location=4) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;
#pragma maplibre: define highp vec4 fill_color
#pragma maplibre: define highp vec4 halo_color
#pragma maplibre: define lowp float opacity
#pragma maplibre: define lowp float halo_width
#pragma maplibre: define lowp float halo_blur
void main() {
#pragma maplibre: initialize highp vec4 fill_color
#pragma maplibre: initialize highp vec4 halo_color
#pragma maplibre: initialize lowp float opacity
#pragma maplibre: initialize lowp float halo_width
#pragma maplibre: initialize lowp float halo_blur
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
#ifdef GLOBE
if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
#endif
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}`),terrain:ve("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","layout(location=0) in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:ve("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),atmosphere:ve(`#ifdef GL_ES
precision highp float;
#endif
in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758
);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,"layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:ve("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;in vec3 v_view_direction;const float ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS=100000.0/6371000.0;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;float opacity=1.0;if (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,((angle_to_globe_center-horizon_angle)*u_camera_to_center_distance+1.0)*u_device_pixel_ratio,u_sky_blend);float closest_approach=max(dot(ray,u_globe_position),0.0);float lowest_altitude=sqrt(max(globe_distance*globe_distance-closest_approach*closest_approach,0.0))-u_globe_radius;float atmosphere_height=u_globe_radius*ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS;float inside_atmosphere=1.0-smoothstep(atmosphere_height,10.0*atmosphere_height,globe_distance-u_globe_radius);float through_atmosphere=1.0-smoothstep(0.0,atmosphere_height,lowest_altitude);opacity=inside_atmosphere*through_atmosphere*(1.0-u_atmosphere_blend);}if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor*=mix(1.0,opacity,u_sky_blend);}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}")};function ve(e,t){let r=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,i=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=n?n.concat(a):a,o=i?i.length:0,l={};return e=e.replace(r,(u,h,c,d,p)=>(l[p]=!0,h==="define"?`
#ifndef HAS_UNIFORM_u_${p}
in ${c} ${d} ${p};
#else
uniform ${c} ${d} u_${p};
#endif
`:`
#ifdef HAS_UNIFORM_u_${p}
${c} ${d} ${p} = u_${p};
#endif
`)),t=t.replace(r,(u,h,c,d,p)=>{let f=d==="float"?"vec2":"vec4",m=p.match(/color/)?"color":f;return l[p]?h==="define"?`
#ifndef HAS_UNIFORM_u_${p}
uniform lowp float u_${p}_t;
layout(location = ${o++}) in ${c} ${f} a_${p};
out ${c} ${d} ${p};
#else
uniform ${c} ${d} u_${p};
#endif
`:m==="vec4"?`
#ifndef HAS_UNIFORM_u_${p}
${p} = a_${p};
#else
${c} ${d} ${p} = u_${p};
#endif
`:`
#ifndef HAS_UNIFORM_u_${p}
${p} = unpack_mix_${m}(a_${p}, u_${p}_t);
#else
${c} ${d} ${p} = u_${p};
#endif
`:h==="define"?`
#ifndef HAS_UNIFORM_u_${p}
uniform lowp float u_${p}_t;
layout(location = ${o++}) in ${c} ${f} a_${p};
#else
uniform ${c} ${d} u_${p};
#endif
`:m==="vec4"?`
#ifndef HAS_UNIFORM_u_${p}
${c} ${d} ${p} = a_${p};
#else
${c} ${d} ${p} = u_${p};
#endif
`:`
#ifndef HAS_UNIFORM_u_${p}
${c} ${d} ${p} = unpack_mix_${m}(a_${p}, u_${p}_t);
#else
${c} ${d} ${p} = u_${p};
#endif
`}),{fragmentSource:e,vertexSource:t,staticAttributes:i,staticUniforms:s}}const L1="#define PROJECTION_MERCATOR",B1="mercator";var kc=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return B1}get shaderDefine(){return L1}get shaderPreludeCode(){return Nr.projectionMercator}get vertexShaderPreludeCode(){return Nr.projectionMercator.vertexSource}get subdivisionGranularity(){return vd.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,r,i,a){if(this._cachedMesh)return this._cachedMesh;let n=new bi;n.emplaceBack(0,0),n.emplaceBack(k,0),n.emplaceBack(0,k),n.emplaceBack(k,k);let s=e.createVertexBuffer(n,Ui.members),o=Ze.simpleSegment(0,0,4,2),l=new Yr;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new ws(s,u,o),this._cachedMesh}recalculate(){}hasTransition(){return!1}},Qm=class O1{constructor(t=0,r=0,i=0,a=0){if(isNaN(t)||t<0||isNaN(r)||r<0||isNaN(i)||i<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=r,this.left=i,this.right=a}interpolate(t,r,i){return r.top!=null&&t.top!=null&&(this.top=We.number(t.top,r.top,i)),r.bottom!=null&&t.bottom!=null&&(this.bottom=We.number(t.bottom,r.bottom,i)),r.left!=null&&t.left!=null&&(this.left=We.number(t.left,r.left,i)),r.right!=null&&t.right!=null&&(this.right=We.number(t.right,r.right,i)),this}getCenter(t,r){let i=ne((this.left+t-this.right)/2,0,t),a=ne((this.top+r-this.bottom)/2,0,r);return new C(i,a)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new O1(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function cl(e,t){if(!e.renderWorldCopies||e.lngRange)return;let r=t.lng-e.center.lng;t.lng+=r>180?-360:r<-180?360:0}function eg(e){return Math.max(0,Math.floor(e))}var Yd=class{constructor(e,t){this.applyConstrain=(r,i)=>this._constrainOverride===null?this._callbacks.defaultConstrain(r,i):this._constrainOverride(r,i),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=(t==null?void 0:t.renderWorldCopies)===void 0||!!(t!=null&&t.renderWorldCopies),this._minZoom=(t==null?void 0:t.minZoom)||0,this._maxZoom=(t==null?void 0:t.maxZoom)||22,this._minPitch=(t==null?void 0:t.minPitch)===void 0||(t==null?void 0:t.minPitch)===null?0:t==null?void 0:t.minPitch,this._maxPitch=(t==null?void 0:t.maxPitch)===void 0||(t==null?void 0:t.maxPitch)===null?60:t==null?void 0:t.maxPitch,this._constrainOverride=(t==null?void 0:t.constrainOverride)??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new J(0,0),this._elevation=0,this._zoom=0,this._tileZoom=eg(this._zoom),this._scale=$t(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Qm,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,t){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=eg(this._zoom),this._scale=$t(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Qm(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=e.autoCalculateNearFarZ,t&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){if(this._minZoom===e)return;this._minZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get maxZoom(){return this._maxZoom}setMaxZoom(e){if(this._maxZoom===e)return;this._maxZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get minPitch(){return this._minPitch}setMinPitch(e){if(this._minPitch===e)return;this._minPitch=e;let t=this._unmodified;this.setPitch(Math.max(this.pitch,e)),this._unmodified=t}get maxPitch(){return this._maxPitch}setMaxPitch(e){if(this._maxPitch===e)return;this._maxPitch=e;let t=this._unmodified;this.setPitch(Math.min(this.pitch,e)),this._unmodified=t}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){e===void 0&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new C(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let t=mr(e,-180,180)*Math.PI/180;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=c1(),fC(this._rotationMatrix,this._rotationMatrix,-this._bearingInRadians))}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let t=ne(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==t&&(this._unmodified=!1,this._pitchInRadians=t,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return jr(this._fovInRadians)}setFov(e){e=ne(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=Ge(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let t=this.applyConstrain(this._center,e).zoom;this._zoom!==t&&(this._unmodified=!1,this._zoom=t,this._tileZoom=Math.max(0,Math.floor(t)),this._scale=$t(t),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){(e.lat!==this._center.lat||e.lng!==this._center.lng)&&(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,r){this._unmodified=!1,this._edgeInsets.interpolate(e,t,r),this.constrainInternal(),this._calcMatrices()}resize(e,t,r=!0){this._width=e,this._height=t,r&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){var e,t;return((e=this._latRange)==null?void 0:e.length)!==2||((t=this._lngRange)==null?void 0:t.length)!==2?null:new ci([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-qr,qr])}getCameraQueryGeometry(e,t){if(t.length===1)return[t[0],e];{let{minX:r,minY:i,maxX:a,maxY:n}=Pr.fromPoints(t).extend(e);return[new C(r,i),new C(a,i),new C(a,n),new C(r,n),new C(r,i)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:r}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(r),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._pixelPerMeter=Wi(1,this.center.lat)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=Ar(new Float64Array(16));Et(e,e,[this._width/2,-this._height/2,1]),ot(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=Ar(new Float64Array(16)),Et(e,e,[1,-1,1]),ot(e,e,[-1,-1,0]),Et(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e;let t=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(t)*this._height,this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,r,i){let a=r===void 0?this.bearing:r,n=i=i===void 0?this.pitch:i,{distanceToCenter:s,clampedElevation:o}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,n),{x:l,y:u}=dc(n,a),h=Ie.fromLngLat(e,t),c=i0(1,h.y),d,p,f=0;do{if(f+=1,f>10)break;p=s/c;let m=l*p,g=u*p;d=new Ie(h.x+m,h.y+g),c=1/d.meterInMercatorCoordinateUnits()}while(Math.abs(s-p*c)>1e-12);return{center:d.toLngLat(),elevation:o,zoom:It(this.height/2/Math.tan(this.fovInRadians/2)/p/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=1/this.worldSize,r=Wi(1,this.center.lat)*this.worldSize,i=Ie.fromLngLat(this.center,this.elevation),a=i.x/t,n=i.y/t,s=i.z/t,o=this.pitch,l=this.bearing,{x:u,y:h,z:c}=dc(o,l),d=this.cameraToCenterDistance,p=a+d*-u,f=n+d*-h,m=s+d*c,{distanceToCenter:g,clampedElevation:_}=this._distanceToCenterFromAltElevationPitch(m/r,e,o),y=g*r,v=p+u*y,x=f+h*y,w=new Ie(v*t,x*t,0).toLngLat(),b=Wi(1,w.lat),T=It(this.height/2/Math.tan(this.fovInRadians/2)/g/b/this.tileSize);this._elevation=_,this._center=w,this.setZoom(T)}_distanceToCenterFromAltElevationPitch(e,t,r){let i=-Math.cos(Ge(r)),a=e-t,n,s=t;return i*a>=0||Math.abs(i)<Math.cos(Ge(89.25))?(n=1e4,s=e+n*i):n=-a/i,{distanceToCenter:n,clampedElevation:s}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new C(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let t=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/t,e.canonical.y/t,1/t/k,1/t/k]}},BM=class{distanceToTile2d(e,t,r,i){let a=i,n=a.distanceX([e,t]),s=a.distanceY([e,t]);return Math.hypot(n,s)}getWrap(e,t,r){return r}getTileBoundingVolume(e,t,r,i){let a=Math.min(0,r),n=Math.max(0,r);if(i!=null&&i.terrain){let o=new St(e.z,t,e.z,e.x,e.y),l=i.terrain.getMinMaxElevation(o);a=l.minElevation??a,n=l.maxElevation??n}let s=1<<e.z;return new Ud([t+e.x/s,e.y/s,a],[t+(e.x+1)/s,(e.y+1)/s,n])}allowVariableZoom(e,t){let r=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,i=ne(78.5-r/2,0,60);return!!t.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}};const OM=Ye([{name:"a_pos3d",type:"Int16",components:3}]);var $M=class extends Rt{constructor(e){super(),this._lastTilesetChange=Fe(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(e,t){this.tileManager.update(e,t),this._renderableTilesKeys=[];let r={},i=!1;for(let a of an(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t}))r[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=new Float32Array(16),Br(a.terrainRttPosMatrix32f,0,k,k,0,0,1),this._tiles[a.key]=new E1(a,this.tileSize),this._lastTilesetChange=Fe(),i=!0);for(let a in this._tiles)r[a]||(this._tiles[a].releaseRTT(this.tileManager.map.painter),delete this._tiles[a],i=!0);return i}releaseRTT(e){for(let t in this._tiles){let r=this._tiles[t];(r.tileID.equals(e)||r.tileID.isChildOf(e)||e.isChildOf(r.tileID))&&r.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let e in this._tiles)this._tiles[e].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let t={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID,a=e.clone(),n=$i();if(i.canonical.equals(e.canonical))Br(n,0,k,k,0,0,1);else if(i.canonical.isChildOf(e.canonical)){let s=i.canonical.z-e.canonical.z,o=i.canonical.x-(i.canonical.x>>s<<s),l=i.canonical.y-(i.canonical.y>>s<<s),u=k>>s;Br(n,0,u,u,0,0,1),ot(n,n,[-o*u,-l*u,0])}else if(e.canonical.isChildOf(i.canonical)){let s=e.canonical.z-i.canonical.z,o=e.canonical.x-(e.canonical.x>>s<<s),l=e.canonical.y-(e.canonical.y>>s<<s),u=k>>s;Br(n,0,k,k,0,0,1),ot(n,n,[o*u,l*u,0]),Et(n,n,[1/2**s,1/2**s,0])}else continue;a.terrainRttPosMatrix32f=new Float32Array(n),t[r]=a}return t}_getTerrainCoordsForTileRanges(e,t){let r={};for(let i of this._renderableTilesKeys){let a=this._tiles[i].tileID;if(!this._isWithinTileRanges(a,t))continue;let n=e.clone(),s=$i();if(a.canonical.z===e.canonical.z){let o=e.canonical.x-a.canonical.x+e.wrap*(1<<e.canonical.z),l=e.canonical.y-a.canonical.y;Br(s,0,k,k,0,0,1),ot(s,s,[o*k,l*k,0])}else if(a.canonical.z>e.canonical.z){let o=a.canonical.z-e.canonical.z,l=a.canonical.x-(a.canonical.x>>o<<o)+e.wrap*(1<<a.canonical.z),u=a.canonical.y-(a.canonical.y>>o<<o),h=e.canonical.x-(a.canonical.x>>o),c=e.canonical.y-(a.canonical.y>>o),d=k>>o;Br(s,0,d,d,0,0,1),ot(s,s,[-l*d+h*k,-u*d+c*k,0])}else{let o=e.canonical.z-a.canonical.z,l=e.canonical.x-(e.canonical.x>>o<<o)+e.wrap*(1<<e.canonical.z),u=e.canonical.y-(e.canonical.y>>o<<o),h=(e.canonical.x>>o)-a.canonical.x,c=(e.canonical.y>>o)-a.canonical.y,d=k<<o;Br(s,0,d,d,0,0,1),ot(s,s,[l*k+h*d,u*k+c*d,0])}n.terrainRttPosMatrix32f=new Float32Array(s),r[i]=n}return r}getSourceTile(e,t){var n,s;let r=this.tileManager._source,i=e.overscaledZ-this.deltaZoom;if(i>r.maxzoom&&(i=r.maxzoom),i<r.minzoom)return;(n=this._sourceTileCache)[s=e.key]||(n[s]=e.scaledTo(i).key);let a=this.findTileInCaches(this._sourceTileCache[e.key]);if(!(a!=null&&a.dem)&&t)for(;i>=r.minzoom&&!(a!=null&&a.dem);)a=this.findTileInCaches(e.scaledTo(i--).key);return a}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Fe()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let r=t[e.canonical.z];return!!r&&(e.wrap>r.minWrap||e.wrap<r.maxWrap||e.canonical.x>=r.minTileXWrapped&&e.canonical.x<=r.maxTileXWrapped&&e.canonical.y>=r.minTileY&&e.canonical.y<=r.maxTileY)}};const tg=k*(1-1e-12),rg=-.5;var jM=class{constructor(e,t,r,i="auto"){this._meshCache={},this.painter=e,this.tileManager=new $M(t),this.options=r,this.exaggeration=typeof r.exaggeration=="number"?r.exaggeration:1,this._terrainSkirtLength=i,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this._elevationSamplerCache=new Map}destroy(){this._fbo&&(this._fbo=(this._fbo.destroy(),null)),this._fboDepthTexture&&(this._fboDepthTexture=(this._fboDepthTexture.destroy(),null)),this._emptyDemTexture&&(this._emptyDemTexture=(this._emptyDemTexture.destroy(),null)),this._emptyDepthTexture&&(this._emptyDepthTexture=(this._emptyDepthTexture.destroy(),null));for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,r,i=k){let a=e.normalizeCoordinates(t,r,i);if(!a)return 0;let n=this.getElevationSampler(a.tileID);return n?n(a.x,a.y,i):0}getElevationForLngLatZoom(e,t){if(!im(t,e.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(r,i%k,a%k,k)}getElevationForLngLat(e,t){let r=this.getCoverageIndex();if(r){let n=Ie.fromLngLat(e),s=Kd(r,this.exaggeration,n.x,n.y);if(s.demLoaded)return s.elevation}let i=an(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),a=0;for(let n of i)n.canonical.z>a&&(a=Math.min(n.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,a)}getElevation(e,t,r,i=k){return this.getDEMElevation(e,t,r,i)*this.exaggeration}resetElevationCache(){this._elevationSamplerCache.clear(),this._coverageIndex=void 0}getCoverageIndex(){return this._coverageIndex===void 0&&(this._coverageIndex=this._buildCoverageIndex()),this._coverageIndex}_buildCoverageIndex(){let e=[],t=new Map,r=0,i=0;for(let a of this.tileManager.getRenderableTiles()){if(!a)continue;let{canonical:n,wrap:s}=a.tileID;e.includes(n.z)||e.push(n.z);let o=this.getElevationSampler(a.tileID);t.set(`${s}/${n.z}/${n.x}/${n.y}`,o);let{minElevation:l,maxElevation:u}=this.getMinMaxElevation(a.tileID);r=Math.min(r,l??0),i=Math.max(i,u??0)}return t.size===0?null:(e.sort((a,n)=>n-a),{zooms:e,samplerPerTile:t,minElevation:r-10,maxElevation:i+10})}getElevationSampler(e){let t=e.key,r=this._elevationSamplerCache.get(t);if(r)return r;let i=this.tileManager.getSourceTile(e,!0),a=i==null?void 0:i.dem;if(!i||!a)return null;let n=this._getDEMTileMatrix(e,i),s=n[0]*a.dim,o=n[5]*a.dim,l=n[12]*a.dim+rg,u=n[13]*a.dim+rg,h=(c,d,p)=>{let f=p===8192?1:k/p;return a.sampleBilinear(c*f*s+l,d*f*o+u)};return this._elevationSamplerCache.set(t,h),h}_getDEMTileMatrix(e,t){let r=`${t.tileID.key}/${e.key}`,i=this._demMatrixCache.get(r);if(i)return i;let a=e.canonical.z-t.tileID.canonical.z,n=e.canonical.x-(e.canonical.x>>a<<a),s=e.canonical.y-(e.canonical.y>>a<<a),o=Vx(new Float64Array(16),[1/(k<<a),1/(k<<a),0]);return ot(o,o,[n*k,s*k,0]),this._demMatrixCache.set(r,o),o}getTerrainData(e){var i,a;if(!this._emptyDemTexture){let n=this.painter.context,s=new $e({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new dt(n,s,n.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new dt(n,new $e({width:1,height:1}),n.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=Ar([])}let t=this.tileManager.getSourceTile(e,!0);if(t!=null&&t.dem&&(!t.demTexture||t.needsTerrainPrepare)){let n=this.painter.context;t.demTexture||(t.demTexture=this.painter.getTileTexture(t.dem.stride)),t.demTexture?t.demTexture.update(t.dem.getPixels(),{premultiply:!1}):t.demTexture=new dt(n,t.dem.getPixels(),n.gl.RGBA,{premultiply:!1}),t.demTexture.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),t.needsTerrainPrepare=!1}let r=t?this._getDEMTileMatrix(e,t):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:((i=t==null?void 0:t.dem)==null?void 0:i.dim)||1,u_terrain_matrix:r,u_terrain_unpack:((a=t==null?void 0:t.dem)==null?void 0:a.getUnpackVector())||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:((t==null?void 0:t.demTexture)||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:t}}getFramebuffer(){let e=this.painter,t=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==t||this._fbo.height!==r)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new dt(e.context,{width:t,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(t,r,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,t,r))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}getTerrainMesh(e){var d;let t=((d=this.painter.style.projection)==null?void 0:d.transitionState)>0,r=t&&e.canonical.y===0,i=t&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${r?"n":""}_${i?"s":""}`;if(this._meshCache[a])return this._meshCache[a];let n=this.painter.context,s=new V2,o=new Yr,l=this.meshSize,u=k/l,h=l*l;for(let p=0;p<=l;p++)for(let f=0;f<=l;f++)s.emplaceBack(f*u,p*u,0);for(let p=0;p<h;p+=l+1)for(let f=0;f<l;f++)o.emplaceBack(f+p,l+f+p+1,l+f+p+2),o.emplaceBack(f+p,l+f+p+2,f+p+1);this._terrainSkirtLength!=="none"&&this._buildSkirts(s,o,l,u,r,i);let c=new ws(n.createVertexBuffer(s,OM.members),n.createIndexBuffer(o),Ze.simpleSegment(0,0,s.length,o.length));return this._meshCache[a]=c,c}getSkirtLength(e){return 2*Math.PI*Lt/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){if(!im(t,e.wrap()))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getMinMaxElevation(r).minElevation??0}getMinMaxElevation(e){let t=this.tileManager.getSourceTile(e,!0),r={minElevation:null,maxElevation:null};return t!=null&&t.dem&&(r.minElevation=t.dem.min*this.exaggeration,r.maxElevation=t.dem.max*this.exaggeration),r}_getOverscaledTileIDFromLngLatZoom(e,t){let r=Ie.fromLngLat(e.wrap()),i=(1<<t)*k,a=r.x*i,n=r.y*i,s=Math.floor(a/k),o=Math.floor(n/k);return{tileID:new St(t,0,t,s,o),mercatorX:a,mercatorY:n}}_buildSkirts(e,t,r,i,a,n){let s=e.length,o=s+(r+1),l=(r+1)*r,u=a?$n:0,h=+!a,c=n?jn:k,d=+!n;for(let m=0;m<=r;m++)e.emplaceBack(m*i,u,h);for(let m=0;m<=r;m++)e.emplaceBack(m*i,c,d);for(let m=0;m<r;m++)t.emplaceBack(l+m,o+m,o+m+1),t.emplaceBack(l+m,o+m+1,l+m+1),t.emplaceBack(0+m,s+m+1,s+m),t.emplaceBack(0+m,0+m+1,s+m+1);let p=e.length,f=p+(r+1)*2;for(let m of[0,1])for(let g=0;g<=r;g++)for(let _ of[0,1])e.emplaceBack(m*k,g*i,_);for(let m=0;m<r*2;m+=2)t.emplaceBack(p+m,p+m+1,p+m+3),t.emplaceBack(p+m,p+m+3,p+m+2),t.emplaceBack(f+m,f+m+3,f+m+1),t.emplaceBack(f+m,f+m+2,f+m+3)}};const ig={covered:!1,demLoaded:!1,elevation:0};function Kd(e,t,r,i){if(i<0||i>=1)return ig;let a=Math.floor(r),n=r-a;for(let s of e.zooms){let o=1<<s,l=n*o,u=i*o,h=Math.floor(l),c=Math.floor(u),d=`${a}/${s}/${h}/${c}`;if(!e.samplerPerTile.has(d))continue;let p=e.samplerPerTile.get(d);return p?{covered:!0,demLoaded:!0,elevation:p(Math.min((l-h)*k,tg),Math.min((u-c)*k,tg),k)*t}:{covered:!0,demLoaded:!1,elevation:0}}return ig}function $1(e,t){return e.covered&&t<=e.elevation+1e-6}function j1(e,t,r,i,a){for(let n=0;n<40&&i-r>a;n++){let s=(r+i)/2;t(e,s)?i=s:r=s}return{lo:r,hi:i}}var dl=class V1{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,r,i){this._helper.interpolatePadding(t,r,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,r,i=!0){this._helper.resize(t,r,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,r){this._helper.overrideNearFarZ(t,r)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t,r){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(i,a)=>{a=ne(+a,this.minZoom,this.maxZoom);let n={center:new J(i.lng,i.lat),zoom:a},s=this._helper._lngRange;!this._helper._renderWorldCopies&&s===null&&(s=[-179.9999999999,180-1e-10]);let o=this.tileSize*$t(n.zoom),l=0,u=o,h=0,c=o,d=0,p=0,{x:f,y:m}=this.size;if(this._helper._latRange){let w=this._helper._latRange;l=Ka(w[1])*o,u=Ka(w[0])*o,u-l<m&&(d=m/(u-l))}s&&(h=mr(Ya(s[0])*o,0,o),c=mr(Ya(s[1])*o,0,o),c<h&&(c+=o),c-h<f&&(p=f/(c-h)));let{x:g,y:_}=Vr(o,i),y,v,x=Math.max(p||0,d||0);if(x){let w=new C(p?(c+h)/2:g,d?(u+l)/2:_);return n.center=ls(o,w).wrap(),n.zoom+=It(x),n}if(this._helper._latRange){let w=m/2;_-w<l&&(v=l+w),_+w>u&&(v=u-w)}if(s){let w=(h+c)/2,b=g;this._helper._renderWorldCopies&&(b=mr(g,w-o/2,w+o/2));let T=f/2;b-T<h&&(y=h+T),b+T>c&&(y=c-T)}if(y!==void 0||v!==void 0){let w=new C(y??g,v??_);n.center=ls(o,w).wrap()}return n},this.applyConstrain=(i,a)=>this._helper.applyConstrain(i,a),this._helper=r??new Yd({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,a)=>this.defaultConstrain(i,a)},t),this._coveringTilesDetailsProvider=new BM}clone(){let t=new V1;return t.apply(this,!1),t}apply(t,r){this._helper.apply(t,r)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){let r=[new ol(0,t)];if(this._helper._renderWorldCopies){let i=this.screenPointToMercatorCoordinate(new C(0,0)),a=this.screenPointToMercatorCoordinate(new C(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new C(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new C(0,this._helper._height)),o=Math.floor(Math.min(i.x,a.x,n.x,s.x)),l=Math.floor(Math.max(i.x,a.x,n.x,s.x));for(let u=o-1;u<=l+1;u++)u!==0&&r.push(new ol(u,t))}return r}getCameraFrustum(){return Gd.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){let r=this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLat(r,this):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(t,r,i=this.elevation){let a=i-this.elevation,n=this.screenPointToMercatorCoordinateAtZ(r,a),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),o=Ie.fromLngLat(t),l=new Ie(o.x-(n.x-s.x),o.y-(n.y-s.y));this.setCenter(l==null?void 0:l.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,r){return r?this.coordinatePoint(Ie.fromLngLat(t),r.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(Ie.fromLngLat(t))}screenPointToLocation(t,r){var i;return(i=this.screenPointToMercatorCoordinate(t,r))==null?void 0:i.toLngLat()}screenPointToLocationAtElevation(t,r){var i;return(i=this.screenPointToMercatorCoordinateAtZ(t,r-this.elevation))==null?void 0:i.toLngLat()}screenPointToMercatorCoordinate(t,r){if(r){let i=this.screenTerrainPointToMercatorCoordinate(t,r);if(i!=null)return i}return this.screenPointToMercatorCoordinateAtZ(t)}screenTerrainPointToMercatorCoordinate(t,r){let i=r.getCoverageIndex();if(!i)return null;let{near:a,far:n}=this.getRaySegmentFromPixel(t),s=this.worldSize,o=n[0]-a[0],l=n[1]-a[1],u=n[2]-a[2],h={index:i,exaggeration:r.exaggeration,near:a,dx:o,dy:l,dz:u,worldSize:s},c=0,d=1;if(u===0){if(a[2]>i.maxElevation||a[2]<i.minElevation)return null}else{let _=(i.maxElevation-a[2])/u,y=(i.minElevation-a[2])/u;if(c=Math.max(c,Math.min(_,y)),d=Math.min(d,Math.max(_,y)),c>d)return null}let p=Math.hypot(o,l),f=ne(Math.ceil(p*(d-c)/4),1,512),m=0,g=!po(h,0);for(let _=0;_<=f;_++){let y=c+(d-c)*_/f;if(!g)g=!po(h,y);else if(po(h,y)){let{lo:v,hi:x}=j1(h,po,m,y,.001/p),w=Fo(h,v),b=Fo(h,x),T=a[2]+v*u-w.elevation,P=a[2]+x*u-b.elevation,S=w.covered&&T>P?ne(v+T*(x-v)/(T-P),v,x):x;return new Ie((a[0]+S*o)/s,(a[1]+S*l)/s,Fo(h,S).elevation)}m=y}return null}getRaySegmentFromPixel(t){let r=[t.x,t.y,0,1],i=[t.x,t.y,1,1];Pt(r,r,this._pixelMatrixInverse),Pt(i,i,this._pixelMatrixInverse);let a=r[3],n=i[3],s=this.elevation;return{near:[r[0]/a,r[1]/a,r[2]/a+s],far:[i[0]/n,i[1]/n,i[2]/n+s]}}screenPointToMercatorCoordinateAtZ(t,r){let i=r||0,{near:a,far:n}=this.getRaySegmentFromPixel(t),s=a[2]===n[2]?0:(i+this.elevation-a[2])/(n[2]-a[2]);return new Ie(We.number(a[0],n[0],s)/this.worldSize,We.number(a[1],n[1],s)/this.worldSize,i)}coordinatePoint(t,r=0,i=this._pixelMatrix){let a=this._coordinateClipPoint(t,r,i),n=a[3];return n>0?new C(a[0]/n,a[1]/n):this._offScreenPointBehindCamera(a[0],a[1],n)}_coordinateClipPoint(t,r,i){let a=[t.x*this.worldSize,t.y*this.worldSize,r,1];return Pt(a,a,i)}_offScreenPointBehindCamera(t,r,i){let a=this.width/2,n=this.height/2,s=t-a*i,o=r-n*i;s===0&&o===0&&(o=1);let l=a+this.width,u=n+this.height,h=Math.min(s===0?1/0:l/Math.abs(s),o===0?1/0:u/Math.abs(o));return new C(a+s*h,n+o*h)}getBounds(){let t=Math.max(0,this._helper._height/2-Nn(this));return new ci().extend(this.screenPointToLocation(new C(0,t))).extend(this.screenPointToLocation(new C(this._helper._width,t))).extend(this.screenPointToLocation(new C(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new C(0,this._helper._height)))}isPointOnMapSurface(t,r){return r?this.screenTerrainPointToMercatorCoordinate(t,r)!=null:t.y>this.centerPoint.y-Nn(this)}calculatePosMatrix(t,r=!1,i=!1){let a=t.key??Ba(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),n=r?this._alignedPosMatrixCache:this._posMatrixCache;if(n.has(a)){let l=n.get(a);return i?l.f32:l.f64}let s=ku(t,this.worldSize);Da(s,r?this._alignedProjMatrix:this._viewProjMatrix,s);let o={f64:s,f32:new Float32Array(s)};return n.set(a,o),i?o.f32:o.f64}calculateFogMatrix(t){let r=t.key,i=this._fogMatrixCacheF32;if(i.has(r))return i.get(r);let a=ku(t,this.worldSize);return Da(a,this._fogMatrix,a),i.set(r,new Float32Array(a)),i.get(r)}calculateCenterFromCameraLngLatAlt(t,r,i,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,r,i,a)}calculateCameraOptionsFromTo(t,r,i,a){let n=Ie.fromLngLat(t,r),s=Ie.fromLngLat(i,a),o=s.x-n.x,l=s.y-n.y,u=s.z-n.z,h=Math.hypot(o,l,u);if(h===0)throw Error("Can't calculate camera options with same From and To");let c=Math.hypot(o,l),d=It(this.cameraToCenterDistance/h/this.tileSize),p=jr(Math.atan2(o,-l)),f=jr(Math.acos(c/h));return f=u<0?90-f:90+f,{center:s.toLngLat(),elevation:a,zoom:d,pitch:f,bearing:p}}_calculateNearFarZ(t,r,i){let a=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),n=t-a*this._helper._pixelPerMeter/Math.cos(r),s=a<0?n:t,o=Math.PI/2+this.pitchInRadians,l=Ge(this.fov)*(Math.abs(Math.cos(Ge(this.roll)))*this.height+Math.abs(Math.sin(Ge(this.roll)))*this.width)/this.height*(.5+i.y/this.height),u=Math.sin(l)*s/Math.sin(ne(Math.PI-o-l,.01,Math.PI-.01)),h=Nn(this),c=Math.atan(h/this._helper.cameraToCenterDistance),d=Ge(90-Hi),p=c>d?2*c*(.5+i.y/(h*2)):d,f=Math.sin(p)*s/Math.sin(ne(Math.PI-o-p,.01,Math.PI-.01)),m=Math.min(u,f);this._helper._farZ=(Math.cos(Math.PI/2-r)*m+s)*1.01,this._helper._nearZ=this._helper._height/50}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let r=this.centerOffset,i=Vr(this.worldSize,this.center),a=i.x,n=i.y,s=Ge(Math.min(this.pitch,Hi)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(s));t&&this._calculateNearFarZ(o,s,r);let l;l=new Float64Array(16),hh(l,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),nM(this._invProjMatrix,l),l[8]=-r.x*2/this._helper._width,l[9]=r.y*2/this._helper._height,this._projectionMatrix=uh(l),Et(l,l,[1,-1,1]),ot(l,l,[0,0,-this._helper.cameraToCenterDistance]),xi(l,l,-this.rollInRadians),Va(l,l,this.pitchInRadians),xi(l,l,-this.bearingInRadians),ot(l,l,[-a,-n,0]),this._mercatorMatrix=Et([],l,[this.worldSize,this.worldSize,this.worldSize]),Et(l,l,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=Da(new Float64Array(16),this.clipSpaceToPixelsMatrix,l),ot(l,l,[0,0,-this.elevation]),this._viewProjMatrix=l,this._invViewProjMatrix=ko([],l);let u=[0,0,-1,1];Pt(u,u,this._invViewProjMatrix),this._cameraPosition=[u[0]/u[3],u[1]/u[3],u[2]/u[3]],this._fogMatrix=new Float64Array(16),hh(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=-r.x*2/this.width,this._fogMatrix[9]=r.y*2/this.height,Et(this._fogMatrix,this._fogMatrix,[1,-1,1]),ot(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),xi(this._fogMatrix,this._fogMatrix,-this.rollInRadians),Va(this._fogMatrix,this._fogMatrix,this.pitchInRadians),xi(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),ot(this._fogMatrix,this._fogMatrix,[-a,-n,0]),Et(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),ot(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=Da(new Float64Array(16),this.clipSpaceToPixelsMatrix,l);let h=this._helper._width%2/2,c=this._helper._height%2/2,d=Math.cos(this.bearingInRadians),p=Math.sin(-this.bearingInRadians),f=a-Math.round(a)+d*h+p*c,m=n-Math.round(n)+d*c+p*h,g=new Float64Array(l);if(ot(g,g,[f>.5?f-1:f,m>.5?m-1:m,0]),this._alignedProjMatrix=g,l=ko(new Float64Array(16),this._pixelMatrix),!l)throw Error("failed to invert matrix");this._pixelMatrixInverse=l,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new C(0,0)),r=[t.x*this.worldSize,t.y*this.worldSize,0,1];return Pt(r,r,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this.cameraToCenterDistance/this.pixelsPerMeter+this.elevation}getCameraLngLat(){let t=Wi(1,this.center.lat)*this.worldSize,r=this._helper.cameraToCenterDistance/t;return s0(this.center,this.elevation,this.pitch,this.bearing,r).toLngLat()}getProjectionData(t){let{overscaledTileID:r,aligned:i,applyTerrainMatrix:a}=t,n=this._helper.getMercatorTileCoordinates(r),s=r?this.calculatePosMatrix(r,i,!0):null,o;return o=r!=null&&r.terrainRttPosMatrix32f&&a?r.terrainRttPosMatrix32f:s||jg(),{mainMatrix:o,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:o,clipAntimeridian:!1}}isLocationOccluded(t,r,i){if(!(r!=null&&r.getCoverageIndex()))return!1;let a=Ie.fromLngLat(t);i??(i=r.getElevationForLngLat(t,this));let n=this._coordinateClipPoint(a,i,this._pixelMatrix3D),s=n[3];if(s<=0||n[2]>s)return!0;let o=new C(n[0]/s,n[1]/s),l=this.screenTerrainPointToMercatorCoordinate(o,r);if(l==null)return!1;let u=this.getRaySegmentFromPixel(o),h=ag(u,a.x*this.worldSize,a.y*this.worldSize,i);return ag(u,l.x*this.worldSize,l.y*this.worldSize,l.z)<h*.99}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,r,i){return 1}transformLightDirection(t){return ch(t)}getRayDirectionFromPixel(t){throw Error("Not implemented.")}projectTileCoordinates(t,r,i,a){let n=this.calculatePosMatrix(i),s;a==null?(s=[t,r,0,1],Xd(s,s,n)):(s=[t,r,a,1],Pt(s,s,n));let o=s[3];return{point:new C(s[0]/o,s[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}populateCache(t){for(let r of t)this.calculatePosMatrix(r)}getProjectionDataForCustomLayer(t=!0){let r=new St(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:r,applyGlobeMatrix:t}),a=ku(r,this.worldSize);Da(a,this._viewProjMatrix,a);let n=[k,k,this.worldSize/this._helper.pixelsPerMeter],s=$i();return Et(s,a,n),{...i,tileMercatorCoords:[0,0,1,1],fallbackMatrix:s,mainMatrix:s}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function Fo(e,t){return Kd(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize)}function po(e,t){return $1(Fo(e,t),e.near[2]+t*e.dz)}function ag({near:e,far:t},r,i,a){let n=t[0]-e[0],s=t[1]-e[1],o=t[2]-e[2];return((r-e[0])*n+(i-e[1])*s+(a-e[2])*o)/(n*n+s*s+o*o)}function N1(){_e("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function U1(e){if(e.useSlerp)if(e.k<1){let t=Np(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=Np(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),i=new Float64Array(4);bo(i,t,r,e.k);let a=Dv(i);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(We.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(We.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(We.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function G1(e,t,r,i,a){let n=a.padding,s=Vr(a.worldSize,r.getNorthWest()),o=Vr(a.worldSize,r.getNorthEast()),l=Vr(a.worldSize,r.getSouthEast()),u=Vr(a.worldSize,r.getSouthWest()),h=Ge(-i),c=s.rotate(h),d=o.rotate(h),p=l.rotate(h),f=u.rotate(h),m=new C(Math.max(c.x,d.x,f.x,p.x),Math.max(c.y,d.y,f.y,p.y)),g=new C(Math.min(c.x,d.x,f.x,p.x),Math.min(c.y,d.y,f.y,p.y)),_=m.sub(g),y=a.width-(n.left+n.right+t.left+t.right),v=a.height-(n.top+n.bottom+t.top+t.bottom),x=y/_.x,w=v/_.y;if(w<0||x<0){N1();return}let b=Math.min(It(a.scale*Math.min(x,w)),e.maxZoom),T=C.convert(e.offset),P=(t.left-t.right)/2,S=(t.top-t.bottom)/2,I=new C(P,S).rotate(Ge(i)),R=T.add(I).mult(a.scale/$t(b));return{center:ls(a.worldSize,s.add(l).div(2).sub(R)),zoom:b,bearing:i}}var pl=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let r=e.mag(),i=Math.abs(Nn(t));return{easingOffset:e.mult(Math.min(i*.75/r,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,r){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(r,e.around,e.aroundElevation)}cameraForBoxAndBearing(e,t,r,i,a){return G1(e,t,r,i,a)}handleJumpToCenterZoom(e,t){let r=t.zoom===void 0?e.zoom:+t.zoom;e.zoom!==r&&e.setZoom(+t.zoom),t.center!==void 0&&e.setCenter(J.convert(t.center))}handleEaseTo(e,t){let r=e.zoom,i=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:t.roll===void 0?e.roll:t.roll,pitch:t.pitch===void 0?e.pitch:t.pitch,bearing:t.bearing===void 0?e.bearing:t.bearing},s=t.zoom!==void 0,o=!e.isPaddingEqual(t.padding),l=!1,u=s?+t.zoom:e.zoom,h=e.centerPoint.add(t.offsetAsPoint),c=e.screenPointToLocation(h),{center:d,zoom:p}=e.applyConstrain(J.convert(t.center||c),u??r);cl(e,d);let f=Vr(e.worldSize,c),m=Vr(e.worldSize,d).sub(f),g=$t(p-r);l=p!==r;let _=v=>{if(l&&e.setZoom(We.number(r,p,v)),Ug(a,n)||U1({startEulerAngles:a,endEulerAngles:n,tr:e,k:v,useSlerp:a.roll!=n.roll}),o&&(e.interpolatePadding(i,t.padding,v),h=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let x=$t(e.zoom-r),w=(p>r?Math.min(2,g):Math.max(.5,g))**(1-v),b=ls(e.worldSize,f.add(m.mult(v*w)).mult(x));e.setLocationAtPoint(e.renderWorldCopies?b.wrap():b,h)}},y=this._transformAtAnimationEnd(e,p,n,t.padding);return t.around?y.setLocationAtPoint(t.around,t.aroundPoint):y.setLocationAtPoint(d,y.centerPoint.add(t.offsetAsPoint)),{easeFunc:_,isZooming:l,elevationCenter:y.center}}handleFlyTo(e,t){let r=t.zoom!==void 0,i=e.zoom,a=e.applyConstrain(J.convert(t.center||t.locationAtOffset),r?+t.zoom:i),n=a.center,s=a.zoom;cl(e,n);let o=e.worldSize,l=Vr(o,t.locationAtOffset),u=Vr(o,n).sub(l),h=u.mag(),c=$t(s-i),d=t.minZoom===void 0?e.minZoom:+t.minZoom,p=Math.max(d,e.minZoom),f=Math.min(p,i,s),m=e.applyConstrain(n,f).zoom,g=$t(m-i),_=(v,x,w,b)=>{e.setZoom(v===1?s:i+It(x));let T=v===1?n:ls(o,l.add(u.mult(w)));e.setLocationAtPoint(e.renderWorldCopies?T.wrap():T,b)},y=this._transformAtAnimationEnd(e,s,{roll:t.roll,pitch:t.pitch,bearing:t.bearing},t.padding);return y.setLocationAtPoint(n,y.centerPoint.add(t.offsetAsPoint)),{easeFunc:_,scaleOfZoom:c,targetCenter:y.center,scaleOfMinZoom:g,pixelPathLength:h}}_transformAtAnimationEnd(e,t,r,i){let a=e.clone();return a.setZoom(t),a.setRoll(r.roll),a.setPitch(r.pitch),a.setBearing(r.bearing),a.setPadding(i),a}};let VM;const NM=()=>VM||(VM=new wt({type:new N(M.projection.type,"type")})),Hu=new vd({fill:new ii(128,2),line:new ii(512,0),tile:new ii(128,32),stencil:new ii(128,1),circle:3});var q1=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Nr.projectionGlobe}get vertexShaderPreludeCode(){return Nr.projectionMercator.vertexSource}get subdivisionGranularity(){return Hu}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,r,i,a){let n=(a==="stencil"?Hu.stencil:Hu.tile).getGranularityForZoomLevel(t.z),s=t.y===0&&i,o=t.y===(1<<t.z)-1&&i;return this._getMesh(e,{granularity:n,generateBorders:r,extendToNorthPole:s,extendToSouthPole:o})}_getMesh(e,t){let r=this._getMeshKey(t);if(r in this._tileMeshCache)return this._tileMeshCache[r];let i=D1(e,t);return this._tileMeshCache[r]=i,i}recalculate(e){}hasTransition(){return!1}},ng=class extends Rt{constructor(e,t){super(),this._transitionable=new zl(NM(),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new ze(0)),this._mercatorProjection=new kc,this._verticalPerspectiveProjection=new q1}get transitionState(){let e=this.properties.get("type");if(typeof e=="string"&&e==="mercator")return 0;if(typeof e=="string"&&e==="vertical-perspective")return 1;if(e instanceof Ii){if(e.from===e.to)return e.from==="mercator"?0:1;if(e.from==="vertical-perspective"&&e.to==="mercator")return 1-e.transition;if(e.from==="mercator"&&e.to==="vertical-perspective")return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}getMeshFromTileID(e,t,r,i,a){return this.currentProjection.getMeshFromTileID(e,t,r,i,a)}setProjection(e){this._transitionable.setValue("type",(e==null?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}};function Z1(e){let t=Ja(e.worldSize,e.center.lat);return 2*Math.PI*t}function UM(e,t,r){let i=mt(t),a=mt(r),n=lt(i,a),s=Math.acos(n),o=Z1(e);return s/(2*Math.PI)*o}function GM(e,t){return[Ki(e*Math.PI*2+Math.PI,Math.PI*2),2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-Math.PI*.5]}function qM(e,t){let r=Math.cos(t),i=new Float64Array(3);return i[0]=Math.sin(e)*r,i[1]=Math.sin(t),i[2]=Math.cos(e)*r,i}function gi(e,t,r,i,a){let n=1/(1<<a),s=e/k*n+r*n,o=t/k*n+i*n,l=Ki(s*Math.PI*2+Math.PI,Math.PI*2),u=2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-Math.PI*.5,h=Math.cos(u),c=new Float64Array(3);return c[0]=Math.sin(l)*h,c[1]=Math.sin(u),c[2]=Math.cos(l)*h,c}function mt(e){return qM(e.lng*Math.PI/180,e.lat*Math.PI/180)}function Ja(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function W1(e){let t=Pt(Oi(),[0,0,0,1],e.modelViewProjectionMatrix);return Pt(t,t,e.inverseProjectionMatrix),[t[0]/t[3],t[1]/t[3],t[2]/t[3]]}function Un(e){let t=Math.asin(e[1])/Math.PI*180,r=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(r>1e-6){let i=e[0]/r,a=e[2]/r,n=Math.acos(a),s=(i>0?n:-n)/Math.PI*180;return new J(mr(s,-180,180),t)}return new J(0,t)}function ZM(e,t){return Nc(Oi(),-e.lng,-e.lat,t)}function WM(e){let t=e[0],r=e[1],i=e[2],a=e[3];return{lng:-Math.atan2(2*(a*t+r*i),1-2*(t*t+r*r))*180/Math.PI,lat:-Math.asin(ne(2*(a*r-i*t),-1,1))*180/Math.PI,bearing:Math.atan2(2*(a*i+t*r),1-2*(r*r+i*i))*180/Math.PI}}const Xu=Math.PI*.98;function sg(e,t){let r=e.cameraPosition,i=Sr(r);if(i<=1)return e.screenPointToLocation(t);let a=Pe();Bt(a,r);let n=e.getRayDirectionFromPixel(t),s=-lt(n,a),o=Pe();Lo(o,n,a,s);let l=Sr(o);if(l<1e-9)return e.screenPointToLocation(t);let u=Math.atan2(l,s),h=Math.asin(1/i)*.9;if(u<h)return e.screenPointToLocation(t);let c=i*Math.sin(h),d=Math.asin(ne(c,-1,1))-h,p=i*Math.cos(h)/Math.sqrt(Math.max(1-c*c,1e-12))-1,f=Xu-d,m=u-h,g=d+p*m*f/(f+p*m),_=Pe();Ve(_,o,1/l);let y=Pe();return Ve(y,a,Math.cos(ne(g,0,Xu))),Lo(y,y,_,Math.sin(ne(g,0,Xu))),Bt(y,y),Un(y)}function HM(e,t,r,i,a=!0){let n=sg(e,r),s=t;if(i)s=sg(e,r.sub(i));else if(!e.isPointOnMapSurface(r))return;let o=mt(n),l=mt(s),u=ZM(e.center,e.bearing),h=Ht(Pe(),l,o),c=Math.sqrt(lt(h,h)),d=Math.acos(ne(lt(l,o),-1,1))/2,p=Math.sin(d),f=c?kp(h[1]/c*p,-h[0]/c*p,h[2]/c*p,Math.cos(d)):kp(0,0,0,1),{lng:m,lat:g,bearing:_}=WM(av(Oi(),u,f)),y=e.center.lat,v=e.zoom,x=ne(g,-90,90),w=a?XM(e,r,i,m):m;e.setCenter(new J(mr(w,-180,180),x)),a||e.setBearing(_),e.setZoom(v+xt(y,e.center.lat))}function XM(e,t,r,i){let a=e.center.lng,n=e.center.lat,s=n>=0?90:-90,o=e.locationToScreenPoint(new J(0,s)),l=t.x-o.x,u=t.y-o.y,h=l*l+u*u,c=ne(1-(qr-Math.abs(n))/12,0,1),d=c*c*(3-2*c),p=Ki(i-a+180,360)-180,f=0;if(d>0&&r){let m=(l*r.y-u*r.x)/Math.max(h,400);f=(s>0?1:-1)*m*180/Math.PI}return a+(1-d)*p+d*f}function YM(e){let t=Pe();return t[0]=e[0]*-e[3],t[1]=e[1]*-e[3],t[2]=e[2]*-e[3],{center:t,radius:Math.sqrt(1-e[3]*e[3])}}function KM(e,t,r){let i=Pe();li(i,r,e);let a=Pe();return Lo(a,e,i,t/Bo(i)),a}function fl(e){return Math.cos(e*Math.PI/180)}function xt(e,t){let r=fl(e),i=fl(t);return It(i/r)}function JM(e,t){return 360/Z1({worldSize:e,center:{lat:t}})}function QM(e,t){let r=e.rotate(t.bearingInRadians),i=t.zoom+xt(t.center.lat,0),a=Fa(1/fl(t.center.lat),1/fl(Math.min(Math.abs(t.center.lat),60)),wo(i,7,3,0,1)),n=JM(t.worldSize,t.center.lat);return new J(t.center.lng-r.x*n*a,ne(t.center.lat+r.y*n,-qr,qr))}function Yu(e){let t=.5*e,r=Math.sin(t),i=Math.cos(t);return Math.log(r+i)-Math.log(i-r)}function og(e,t,r,i){let a=e.lat+r*i;if(Math.abs(r)>1){let n=e.lat+r,s=(Math.sign(n)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,o=Math.abs(e.lat+r)*Math.PI/180,l=Yu(s+i*(o-s)),u=Yu(s),h=Yu(o),c=(l-u)/(h-u),d=e.lng+t*c;return new J(d,a)}{let n=e.lng+t*i;return new J(n,a)}}function fo(e,t,r=1){let i=lt(e,t),a=r*r,n=Pe(),s=Pe();Ve(s,t,i),li(n,e,s);let o=a-lt(n,n);if(o<0)return null;let l=lt(e,e)-a,u=-i+(i<0?1:-1)*Math.sqrt(o),h=l/u,c=u,d=Math.max(h,c);return d<0?null:{tMin:Math.min(h,c),tMax:d}}function H1(e,t){let r=t*.01569612305760477,i=ne((e-r)/(9*r),0,1);return i*i*(3-2*i)}var e3=class{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,r,i){let a=`${e.z}_${e.x}_${e.y}_${i!=null&&i.terrain?"t":""}_${Math.round(r)}`,n=this._cache.get(a);if(n)return n;let s=this._cachePrevious.get(a);if(s)return this._cache.set(a,s),s;let o=this._boundingVolumeFactory(e,t,r,i);return this._cache.set(a,o),this._hadAnyChanges=!0,o}},Ku=class Lc{constructor(t,r,i,a){this.min=i,this.max=a,this.points=t,this.planes=r}static fromAabb(t,r){let i=[];for(let a=0;a<8;a++)i.push([(a>>0&1)==1?r[0]:t[0],(a>>1&1)==1?r[1]:t[1],(a>>2&1)==1?r[2]:t[2]]);return new Lc(i,[[-1,0,0,r[0]],[1,0,0,-t[0]],[0,-1,0,r[1]],[0,1,0,-t[1]],[0,0,-1,r[2]],[0,0,1,-t[2]]],t,r)}static fromCenterSizeAngles(t,r,i){let a=Nc([],i[0],i[1],i[2]),n=vu([],[r[0],0,0],a),s=vu([],[0,r[1],0],a),o=vu([],[0,0,r[2]],a),l=[...t],u=[...t];for(let c=0;c<8;c++)for(let d=0;d<3;d++){let p=t[d]+n[d]*((c>>0&1)==1?1:-1)+s[d]*((c>>1&1)==1?1:-1)+o[d]*((c>>2&1)==1?1:-1);l[d]=Math.min(l[d],p),u[d]=Math.max(u[d],p)}let h=[];for(let c=0;c<8;c++){let d=[...t];fr(d,d,Ve([],n,(c>>0&1)==1?1:-1)),fr(d,d,Ve([],s,(c>>1&1)==1?1:-1)),fr(d,d,Ve([],o,(c>>2&1)==1?1:-1)),h.push(d)}return new Lc(h,[[...n,-lt(n,h[0])],[...s,-lt(s,h[0])],[...o,-lt(o,h[0])],[-n[0],-n[1],-n[2],-lt(n,h[7])],[-s[0],-s[1],-s[2],-lt(s,h[7])],[-o[0],-o[1],-o[2],-lt(o,h[7])]],l,u)}intersectsFrustum(t){let r=!0,i=this.points.length,a=this.planes.length,n=t.planes.length,s=t.points.length;for(let o=0;o<n;o++){let l=t.planes[o],u=0;for(let h=0;h<i;h++){let c=this.points[h];l[0]*c[0]+l[1]*c[1]+l[2]*c[2]+l[3]>=0&&u++}if(u===0)return 0;u<i&&(r=!1)}if(r)return 2;for(let o=0;o<a;o++){let l=this.planes[o],u=0;for(let h=0;h<s;h++){let c=t.points[h];l[0]*c[0]+l[1]*c[1]+l[2]*c[2]+l[3]>=0&&u++}if(u===0)return 0}return 1}intersectsPlane(t){let r=this.points.length,i=0;for(let a=0;a<r;a++){let n=this.points[a];t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]>=0&&i++}return i===r?2:i===0?0:1}};function Ro(e,t,r){let i=e-t;return i<0?-i:Math.max(0,i-r)}function Ju(e,t,r,i,a){let n=e-r,s;return s=n<0?Math.min(-n,1+n-a):n>a?Math.min(Math.max(n-a,0),1-n):0,Math.max(s,Ro(t,i,a))}var t3=class{constructor(){this._boundingVolumeCache=new e3(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,r,i){let a=1<<r.z,n=1/a,s=r.x/a,o=r.y/a,l=.5,u=2;return u=Math.min(u,Ju(e,t,s,o,n)),u=Math.min(u,Ju(e,t,s+l,-o-n,n)),u=Math.min(u,Ju(e,t,s+l,2-o-n,n)),u}getWrap(e,t,r){let i=1<<t.z,a=1/i,n=t.x/i,s=Ro(e.x,n,a),o=Ro(e.x,n-1,a),l=Ro(e.x,n+1,a),u=Math.min(s,o,l);return u===l?1:u===o?-1:0}allowVariableZoom(e,t){return qd(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,r,i){return this._boundingVolumeCache.getTileBoundingVolume(e,t,r,i)}_computeTileBoundingVolume(e,t,r,i){let a=Math.min(0,r),n=Math.max(0,r);if(i!=null&&i.terrain){let s=new St(e.z,t,e.z,e.x,e.y),o=i.terrain.getMinMaxElevation(s);a=o.minElevation??a,n=Math.max(o.maxElevation??n,n)}if(a/=Lt,n/=Lt,a+=1,n+=1,e.z<=0)return Ku.fromAabb([-n,-n,-n],[n,n,n]);if(e.z===1)return Ku.fromAabb([e.x===0?-n:0,e.y===0?0:-n,-n],[e.x===0?0:n,e.y===0?n:0,n]);{let s=[gi(0,0,e.x,e.y,e.z),gi(k,0,e.x,e.y,e.z),gi(k,k,e.x,e.y,e.z),gi(0,k,e.x,e.y,e.z)],o=[];for(let P of s)o.push(Ve([],P,n));if(n!==a)for(let P of s)o.push(Ve([],P,a));e.y===0&&o.push([0,1,0]),e.y===(1<<e.z)-1&&o.push([0,-1,0]);let l=[1,1,1],u=[-1,-1,-1];for(let P of o)for(let S=0;S<3;S++)l[S]=Math.min(l[S],P[S]),u[S]=Math.max(u[S],P[S]);let h=gi(k/2,k/2,e.x,e.y,e.z),c=Ht([],[0,1,0],h);Bt(c,c);let d=Ht([],h,c);Bt(d,d);let p=Ht([],s[2],s[1]);Bt(p,p);let f=Ht([],s[0],s[3]);Bt(f,f),o.push(Ve([],h,n)),e.y>=(1<<e.z)/2&&o.push(Ve([],gi(k/2,0,e.x,e.y,e.z),n)),e.y<(1<<e.z)/2&&o.push(Ve([],gi(k/2,k,e.x,e.y,e.z),n));let m=lg(h,o),g=lg(d,o),_=[-h[0],-h[1],-h[2],m.max],y=[h[0],h[1],h[2],-m.min],v=[-d[0],-d[1],-d[2],g.max],x=[d[0],d[1],d[2],-g.min],w=[...p,0],b=[...f,0],T=[];return e.y===0?T.push(lr(b,w,_),lr(b,w,y)):T.push(lr(v,w,_),lr(v,w,y),lr(v,b,_),lr(v,b,y)),e.y===(1<<e.z)-1?T.push(lr(b,w,_),lr(b,w,y)):T.push(lr(x,w,_),lr(x,w,y),lr(x,b,_),lr(x,b,y)),new Ku(T,[_,y,v,x,w,b],l,u)}}};function lg(e,t){let r=1/0,i=-1/0;for(let a of t){let n=lt(e,a);r=Math.min(r,n),i=Math.max(i,n)}return{min:r,max:i}}const ug=1e-12;var X1=class Y1{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,r,i){this._helper.interpolatePadding(t,r,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,r){this._helper.resize(t,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,r){this._helper.overrideNearFarZ(t,r)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t,r){this._cachedClippingPlane=Oi(),this._projectionMatrix=Ns(),this._globeViewProjMatrix32f=jg(),this._globeViewProjMatrixF64=Ns(),this._globeViewProjMatrixF64Inverted=Ns(),this._globeProjMatrixInverted=Ns(),this._cameraPosition=Pe(),this.defaultConstrain=(i,a)=>{let n=ne(i.lat,-qr,qr),s=ne(+a,this.minZoom+xt(0,n),this.maxZoom);return{center:new J(i.lng,n),zoom:s}},this.applyConstrain=(i,a)=>this._helper.applyConstrain(i,a),this._helper=r??new Yd({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,a)=>this.defaultConstrain(i,a)},t),this._coveringTilesDetailsProvider=new t3}clone(){let t=new Y1;return t.apply(this,!1),t}apply(t,r){this._helper.apply(t,r)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=Pe();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){let{overscaledTileID:r,applyGlobeMatrix:i}=t,a=this._helper.getMercatorTileCoordinates(r);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:a,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!i,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:(r==null?void 0:r.canonical.z)===0}}_computeClippingPlane(t){let r=this.pitchInRadians,i=this.cameraToCenterDistance/t,a=Math.sin(r)*i,n=Math.cos(r)*i+1,s=1/Math.sqrt(a*a+n*n)*1,o=-a,l=n,u=Math.sqrt(o*o+l*l);o/=u,l/=u;let h=[0,o,l];bu(h,h,[0,0,0],-this.bearingInRadians),mn(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),ya(h,h,[0,0,0],this.center.lng*Math.PI/180);let c=1/Sr(h);return Ve(h,h,c),[...h,-s*c]}isLocationOccluded(t,r,i){let a=r==null?void 0:r.getCoverageIndex();i??(i=a?r.getElevationForLngLat(t,this):0);let n=cg(t,i);if(!this.isSurfacePointVisible(n))return!0;if(!a)return!1;let s=this._projectSurfacePointToScreen(n),o=this.cameraPosition,l=this.getRayDirectionFromPixel(s),u=dg(o,l,n);if(u<=0)return!0;let h=this.screenTerrainPointToMercatorCoordinate(s,r);return h!=null&&dg(o,l,cg(h.toLngLat(),h.z))<u*.99}transformLightDirection(t){let r=this._helper._center.lng*Math.PI/180,i=this._helper._center.lat*Math.PI/180,a=Math.cos(i),n=[Math.sin(r)*a,Math.sin(i),Math.cos(r)*a],s=[n[2],0,-n[0]],o=[0,0,0];Ht(o,s,n),Bt(s,s),Bt(o,o);let l=[s[0]*t[0]+o[0]*t[1]+n[0]*t[2],s[1]*t[0]+o[1]*t[1]+n[1]*t[2],s[2]*t[0]+o[2]*t[1]+n[2]*t[2]],u=[0,0,0];return Bt(u,l),u}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,r,i){let a=n0(t,r,i.canonical),n=GM(a.x,a.y);return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(t,r,i,a){let n=i.canonical,s=gi(t,r,n.x,n.y,n.z),o=1+(a??0)/Lt,l=s[0]*o,u=s[1]*o,h=s[2]*o,c=[l,u,h,1];Pt(c,c,this._globeViewProjMatrixF64);let d;if(o<=1){let p=this._cachedClippingPlane;d=p[0]*s[0]+p[1]*s[1]+p[2]*s[2]+p[3]<0}else d=this._isLineOfSightBlocked(l,u,h);return{point:new C(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:d}}_isLineOfSightBlocked(t,r,i){let a=this._cameraPosition,n=t-a[0],s=r-a[1],o=i-a[2],l=n*n+s*s+o*o;if(l===0)return!1;let u=ne(-(a[0]*n+a[1]*s+a[2]*o)/l,0,1),h=a[0]+u*n,c=a[1]+u*s,d=a[2]+u*o;return h*h+c*c+d*d<1}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let r=Ja(this.worldSize,this.center.lat),i=$i();t&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+r*2),hh(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let a=this.centerOffset;i[8]=-a.x*2/this._helper._width,i[9]=a.y*2/this._helper._height,this._projectionMatrix=uh(i),this._globeProjMatrixInverted=$i(),ko(this._globeProjMatrixInverted,i),ot(i,i,[0,0,-this.cameraToCenterDistance]),xi(i,i,this.rollInRadians),Va(i,i,-this.pitchInRadians),xi(i,i,this.bearingInRadians),ot(i,i,[0,0,-r]);let n=Pe();n[0]=r,n[1]=r,n[2]=r,Va(i,i,this.center.lat*Math.PI/180),Og(i,i,-this.center.lng*Math.PI/180),Et(i,i,n),this._globeViewProjMatrixF64=i,this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixF64Inverted=$i(),ko(this._globeViewProjMatrixF64Inverted,i);let s=Pe();this._cameraPosition=Pe(),this._cameraPosition[2]=this.cameraToCenterDistance/r,bu(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),mn(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),bu(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),fr(this._cameraPosition,this._cameraPosition,[0,0,1]),mn(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),ya(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(r);let o=uh(this._globeViewProjMatrixF64Inverted);Et(o,o,[1,1,-1]),this._cachedFrustum=Gd.fromInvProjectionMatrix(o,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){_e("calculateFogMatrix is not supported on globe projection.");let r=$i();return Ar(r),r}getVisibleUnwrappedCoordinates(t){return[new ol(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){if(t){_e("terrain is not fully supported on vertical perspective projection.");return}this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(Sr(this._cameraPosition)-1)*Lt}getCameraLngLat(){let t=Pe();return Bt(t,this._cameraPosition),Un(t)}populateCache(t){}getBounds(){let t=this.width*.5,r=this.height*.5,i=[new C(0,0),new C(t,0),new C(this.width,0),new C(this.width,r),new C(this.width,this.height),new C(t,this.height),new C(0,this.height),new C(0,r)],a=[];for(let c of i)a.push(this.unprojectScreenPoint(c));let n=0,s=0,o=0,l=0,u=this.center;for(let c of a){let d=er(u.lng,c.lng),p=er(u.lat,c.lat);d<s&&(s=d),d>n&&(n=d),p<l&&(l=p),p>o&&(o=p)}let h=[u.lng+s,u.lat+l,u.lng+n,u.lat+o];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new ci(h)}calculateCenterFromCameraLngLatAlt(t,r,i,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,r,i,a)}calculateCameraOptionsFromTo(t,r,i,a){let n=J.convert(i),s=mt(J.convert(t));Ve(s,s,1+r/Lt);let o=mt(n),l=Ve(Pe(),o,1+a/Lt),u=Vc(Pe(),s,o),h=Sr(u);if(h<ug||Zx(s,l)<ug)throw Error("Can't calculate camera options with same From and To");let c=Pe();ya(u,u,c,-Ge(n.lng)),mn(u,u,c,Ge(n.lat));let d=jr(Math.acos(ne(u[2]/h,-1,1))),p=Math.hypot(u[0],u[1])<h*1e-9?this.bearing:jr(Math.atan2(-u[0],-u[1]));return{center:n,elevation:a,zoom:It(this.cameraToCenterDistance/h/Ja(this.tileSize,n.lat)),pitch:d,bearing:p}}setLocationAtPoint(t,r,i){let a=mt(this.unprojectScreenPoint(r)),n=mt(t),s=Pe();Yx(s);let o=Pe();ya(o,a,s,-this.center.lng*Math.PI/180),mn(o,o,s,this.center.lat*Math.PI/180);let l=n[0]*n[0]+n[2]*n[2],u=o[0]*o[0];if(l<u)return;let h=Math.sqrt(l-u),c=-h,d=Us(n[0],n[2],o[0],h),p=Us(n[0],n[2],o[0],c),f=Pe();ya(f,n,s,-d);let m=Us(f[1],f[2],o[1],o[2]),g=Pe();ya(g,n,s,-p);let _=Us(g[1],g[2],o[1],o[2]),y=Math.PI*.5,v=m>=-y&&m<=y,x=_>=-y&&_<=y,w,b;if(v&&x){let I=this.center.lng*Math.PI/180,R=this.center.lat*Math.PI/180,F=Gs(d,I),D=Gs(m,R),A=Gs(p,I),E=Gs(_,R);F+D<A+E?(w=d,b=m):(w=p,b=_)}else if(v)w=d,b=m;else if(x)w=p,b=_;else return;let T=w/Math.PI*180,P=b/Math.PI*180,S=this.center.lat;this.setCenter(new J(T,ne(P,-90,90))),this.setZoom(this.zoom+xt(S,this.center.lat))}locationToScreenPoint(t,r){let i=mt(t);if(r){let a=r.getElevationForLngLatZoom(t,this._helper._tileZoom);Ve(i,i,1+a/Lt)}return this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(t){let r=Oi();return Pt(r,[...t,1],this._globeViewProjMatrixF64),r[0]/=r[3],r[1]/=r[3],new C((r[0]*.5+.5)*this.width,(-r[1]*.5+.5)*this.height)}screenPointToMercatorCoordinate(t,r){if(r){let i=this.screenTerrainPointToMercatorCoordinate(t,r);if(i)return i}return Ie.fromLngLat(this.unprojectScreenPoint(t))}screenTerrainPointToMercatorCoordinate(t,r){let i=r.getCoverageIndex();if(!i)return null;let a=this.cameraPosition,n=this.getRayDirectionFromPixel(t),s=fo(a,n,1+i.maxElevation/Lt);if(!s)return null;let o=fo(a,n,1+i.minElevation/Lt),l=Math.max(s.tMin,0),u=o?o.tMin:s.tMax;if(u<=l)return null;let h={index:i,exaggeration:r.exaggeration,origin:a,direction:n},c=0;for(let d=0;d<=256;d++){let p=l+(u-l)*d/256;if(hg(h,p)){let{hi:f}=j1(h,hg,c,p,1e-12),{sample:m,mercator:g}=K1(h,f);return new Ie(g.x,g.y,m.elevation)}c=p}return null}screenPointToLocation(t,r){var i;return(i=this.screenPointToMercatorCoordinate(t,r))==null?void 0:i.toLngLat()}screenPointToLocationAtElevation(t,r){return this.screenPointToLocation(t)}isPointOnMapSurface(t,r){let i=this._cameraPosition;return!!fo(i,this.getRayDirectionFromPixel(t))}getRayDirectionFromPixel(t){let r=Oi();r[0]=t.x/this.width*2-1,r[1]=(t.y/this.height*2-1)*-1,r[2]=1,r[3]=1,Pt(r,r,this._globeViewProjMatrixF64Inverted),r[0]/=r[3],r[1]/=r[3],r[2]/=r[3];let i=Pe();i[0]=r[0]-this._cameraPosition[0],i[1]=r[1]-this._cameraPosition[1],i[2]=r[2]-this._cameraPosition[2];let a=Pe();return Bt(a,i),a}isSurfacePointVisible(t){let r=this._cachedClippingPlane;return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let r=Oi();return Pt(r,[...t,1],this._globeViewProjMatrixF64),r[0]/=r[3],r[1]/=r[3],r[2]/=r[3],r[0]>-1&&r[0]<1&&r[1]>-1&&r[1]<1&&r[2]>-1&&r[2]<1}unprojectScreenPoint(t){let r=this._cameraPosition,i=this.getRayDirectionFromPixel(t),a=fo(r,i);if(a){let h=Pe();fr(h,r,[i[0]*a.tMin,i[1]*a.tMin,i[2]*a.tMin]);let c=Pe();return Bt(c,h),Un(c)}let n=this._cachedClippingPlane,s=n[0]*i[0]+n[1]*i[1]+n[2]*i[2],o=-ph(n,r)/s,l=Pe();if(o>0)fr(l,r,[i[0]*o,i[1]*o,i[2]*o]);else{let h=Pe();fr(h,r,[i[0]*2,i[1]*2,i[2]*2]);let c=ph(this._cachedClippingPlane,h);li(l,h,[this._cachedClippingPlane[0]*c,this._cachedClippingPlane[1]*c,this._cachedClippingPlane[2]*c])}let u=YM(n);return Un(KM(u.center,u.radius,l))}getProjectionDataForCustomLayer(t=!0){let r=this.getProjectionData({overscaledTileID:new St(0,0,0,0,0),applyGlobeMatrix:t});return r.tileMercatorCoords=[0,0,1,1],r}getFastPathSimpleProjectionMatrix(t){}};function K1(e,t){let r=Pe();Lo(r,e.origin,e.direction,t);let i=Sr(r),a=Pe();Ve(a,r,1/i);let n=Un(a),s=Ie.fromLngLat(n),o=new Ie(s.x,ne(s.y,0,.999999999)),l=Kd(e.index,e.exaggeration,o.x,o.y),u=Math.abs(n.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:u},radius:i,mercator:o}}function hg(e,t){let{sample:r,radius:i}=K1(e,t);return $1(r,(i-1)*Lt)}function cg(e,t){let r=mt(e);return Ve(r,r,1+t/Lt)}function dg(e,t,r){let i=Vc(Pe(),r,e);return lt(i,t)}var pg=class J1{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,r,i){this._helper.interpolatePadding(t,r,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,r,i=!0){this._helper.resize(t,r,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,r){this._helper.overrideNearFarZ(t,r)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t){this._globeness=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeness=1,this.defaultConstrain=(r,i)=>this.currentTransform.defaultConstrain(r,i),this.applyConstrain=(r,i)=>this._helper.applyConstrain(r,i),this._helper=new Yd({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(r,i)=>this.defaultConstrain(r,i)},t),this._globeness=1,this._mercatorTransform=new dl(void 0,this._helper),this._verticalPerspectiveTransform=new X1(void 0,this._helper)}clone(){let t=new J1;return t._globeness=this._globeness,t.apply(this,!1),t}apply(t,r){this._helper.apply(t,r)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){let r=this._mercatorTransform.getProjectionData(t),i=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:r.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:r.fallbackMatrix,clipAntimeridian:i.clipAntimeridian}}isLocationOccluded(t,r,i){return this.currentTransform.isLocationOccluded(t,r,i)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return Fa(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return Fa(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,r,i){let a=this._mercatorTransform.getPitchedTextCorrection(t,r,i),n=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,r,i);return Fa(a,n,this._globeness)}projectTileCoordinates(t,r,i,a){return this.currentTransform.projectTileCoordinates(t,r,i,a)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform._calcMatrices(),this._mercatorTransform._calcMatrices(this.autoCalculateNearFarZ&&!this.isGlobeRendering))}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this.currentTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,r,i,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,r,i,a)}calculateCameraOptionsFromTo(t,r,i,a){return this.currentTransform.calculateCameraOptionsFromTo(t,r,i,a)}setLocationAtPoint(t,r,i){this.currentTransform.setLocationAtPoint(t,r,i)}locationToScreenPoint(t,r){return this.currentTransform.locationToScreenPoint(t,r)}screenPointToMercatorCoordinate(t,r){return this.currentTransform.screenPointToMercatorCoordinate(t,r)}screenTerrainPointToMercatorCoordinate(t,r){return this.currentTransform.screenTerrainPointToMercatorCoordinate(t,r)}screenPointToLocation(t,r){return this.currentTransform.screenPointToLocation(t,r)}screenPointToLocationAtElevation(t,r){return this.currentTransform.screenPointToLocationAtElevation(t,r)}isPointOnMapSurface(t,r){return this.currentTransform.isPointOnMapSurface(t,r)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let r=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return r;let i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return i.fallbackMatrix=r.mainMatrix,i.projectionTransition=this._globeness,i}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},Q1=class ei{get useGlobeControls(){return!0}handlePanInertia(t,r){let i=QM(t,r);return Math.abs(i.lng-r.center.lng)>180&&(i.lng=r.center.lng+179.5*Math.sign(i.lng-r.center.lng)),{easingCenter:i,easingOffset:new C(0,0)}}handleMapControlsRollPitchBearingZoom(t,r){let i=t.around,a=r.screenPointToLocation(i);t.bearingDelta&&r.setBearing(r.bearing+t.bearingDelta),t.pitchDelta&&r.setPitch(r.pitch+t.pitchDelta),t.rollDelta&&r.setRoll(r.roll+t.rollDelta);let n=r.zoom;t.zoomDelta&&r.setZoom(r.zoom+t.zoomDelta);let s=r.zoom-n;if(s===0)return;let o=er(r.center.lng,a.lng),l=o/(Math.abs(o/180)+1),u=er(r.center.lat,a.lat),h=r.getRayDirectionFromPixel(i),c=r.cameraPosition,d=lt(c,h)*-1,p=Pe();fr(p,c,[h[0]*d,h[1]*d,h[2]*d]);let f=Sr(p),m=f-1,g=Math.exp(-Math.max(m-.3,0)*.5),_=wo(f,.95,.999,0,1),y=Ja(r.worldSize,r.center.lat)/Math.min(r.width,r.height),v=wo(y,.9,.5,1,.25),x=Math.min(g,Fa(1,v,_)),w=(1-$t(-s))*x,b=r.center.lat,T=r.zoom,P=new J(r.center.lng+l*w,ne(r.center.lat+u*w,-qr,qr));r.setLocationAtPoint(a,i);let S=r.center,I=wo(Math.abs(o),45,85,0,1),R=Math.max(I,_)**.25,F=er(S.lng,P.lng),D=er(S.lat,P.lat);r.setCenter(new J(S.lng+F*R,S.lat+D*R).wrap()),r.setZoom(T+xt(b,r.center.lat))}handleMapControlsPan(t,r,i){t.panDelta&&HM(r,i,r.isPointOnMapSurface(t.around)?t.around:r.centerPoint,t.panDelta)}cameraForBoxAndBearing(t,r,i,a,n){let s=G1(t,r,i,a,n);if(!s)return;let o=r.left/n.width*2-1,l=(n.width-r.right)/n.width*2-1,u=r.top/n.height*-2+1,h=(n.height-r.bottom)/n.height*-2+1,c=er(i.getWest(),i.getEast())<0,d=c?i.getEast():i.getWest(),p=c?i.getWest():i.getEast(),f=Math.max(i.getNorth(),i.getSouth()),m=Math.min(i.getNorth(),i.getSouth()),g=d+er(d,p)*.5,_=f+er(f,m)*.5,y=n.clone();y.setCenter(s.center),y.setBearing(s.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(s.zoom);let v=y.modelViewProjectionMatrix,x=[mt(i.getNorthWest()),mt(i.getNorthEast()),mt(i.getSouthWest()),mt(i.getSouthEast()),mt(new J(p,_)),mt(new J(d,_)),mt(new J(g,f)),mt(new J(g,m))],w=mt(s.center),b=1/0;for(let T of x)o<0&&(b=ei.getLesserNonNegativeNonNull(b,ei.solveVectorScale(T,w,v,"x",o))),l>0&&(b=ei.getLesserNonNegativeNonNull(b,ei.solveVectorScale(T,w,v,"x",l))),u>0&&(b=ei.getLesserNonNegativeNonNull(b,ei.solveVectorScale(T,w,v,"y",u))),h<0&&(b=ei.getLesserNonNegativeNonNull(b,ei.solveVectorScale(T,w,v,"y",h)));if(!Number.isFinite(b)||b===0){N1();return}return s.zoom=Math.min(y.zoom+It(b),t.maxZoom),s}handleJumpToCenterZoom(t,r){let i=t.center.lat,a=t.applyConstrain(r.center?J.convert(r.center):t.center,t.zoom).center;t.setCenter(a.wrap());let n=r.zoom===void 0?t.zoom+xt(i,a.lat):+r.zoom;t.zoom!==n&&t.setZoom(n)}handleEaseTo(t,r){let i=t.zoom,a=t.center,n=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:r.roll===void 0?t.roll:r.roll,pitch:r.pitch===void 0?t.pitch:r.pitch,bearing:r.bearing===void 0?t.bearing:r.bearing},l=r.zoom!==void 0,u=!t.isPaddingEqual(r.padding),h=!1,c=r.center?J.convert(r.center):a,d=t.applyConstrain(c,i).center;cl(t,d);let p=t.clone();p.setCenter(d),p.setZoom(l?+r.zoom:i+xt(a.lat,c.lat)),p.setBearing(r.bearing);let f=new C(ne(t.centerPoint.x+r.offsetAsPoint.x,0,t.width),ne(t.centerPoint.y+r.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(d,f);let m=(r.offset&&r.offsetAsPoint.mag())>0?p.center:d,g=l?+r.zoom:i+xt(a.lat,m.lat),_=i+xt(a.lat,0),y=g+xt(m.lat,0),v=er(a.lng,m.lng),x=er(a.lat,m.lat),w=$t(y-_);return h=g!==i,{easeFunc:b=>{if(Ug(s,o)||U1({startEulerAngles:s,endEulerAngles:o,tr:t,k:b,useSlerp:s.roll!=o.roll}),u&&t.interpolatePadding(n,r.padding,b),r.around)_e("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(r.around,r.aroundPoint);else{let T=b*(y>_?Math.min(2,w):Math.max(.5,w))**(1-b),P=og(a,v,x,T);t.setCenter(P.wrap())}if(h){let T=We.number(_,y,b)+xt(0,t.center.lat);t.setZoom(T)}},isZooming:h,elevationCenter:m}}handleFlyTo(t,r){let i=r.zoom!==void 0,a=t.center,n=t.zoom,s=t.padding,o=!t.isPaddingEqual(r.padding),l=t.applyConstrain(J.convert(r.center||r.locationAtOffset),n).center,u=i?+r.zoom:t.zoom+xt(t.center.lat,l.lat),h=t.clone();h.setCenter(l),h.setZoom(u),h.setBearing(r.bearing);let c=new C(ne(t.centerPoint.x+r.offsetAsPoint.x,0,t.width),ne(t.centerPoint.y+r.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(l,c);let d=h.center;cl(t,d);let p=UM(t,a,d),f=n+xt(a.lat,0),m=u+xt(d.lat,0),g=$t(m-f),_=typeof r.minZoom=="number"?+r.minZoom:t.minZoom,y=Math.max(_,t.minZoom)+xt(d.lat,0),v=Math.min(y,f,m)+xt(0,d.lat),x=t.applyConstrain(d,v).zoom+xt(d.lat,0),w=$t(x-f),b=er(a.lng,d.lng),T=er(a.lat,d.lat);return{easeFunc:(P,S,I,R)=>{let F=og(a,b,T,I);o&&t.interpolatePadding(s,r.padding,P);let D=P===1?d:F;t.setCenter(D.wrap());let A=f+It(S);t.setZoom(P===1?u:A+xt(0,D.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:w,pixelPathLength:p}}static solveVectorScale(t,r,i,a,n){let s=n,o=a==="x"?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],l=[i[3],i[7],i[11],i[15]],u=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],h=t[0]*l[0]+t[1]*l[1]+t[2]*l[2],c=r[0]*o[0]+r[1]*o[1]+r[2]*o[2],d=r[0]*l[0]+r[1]*l[1]+r[2]*l[2],p=(c+o[3]-s*d-s*l[3])/(c-u-s*d+s*h);return c+s*h===u+s*d||l[3]*(u-c)+o[3]*(d-h)+u*d===c*h?null:p}static getLesserNonNegativeNonNull(t,r){return r!==null&&r>=0&&r<t?r:t}},fg=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new pl,this._verticalPerspectiveCameraHelper=new Q1}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,r){this.currentHelper.handleMapControlsPan(e,t,r)}cameraForBoxAndBearing(e,t,r,i,a){return this.currentHelper.cameraForBoxAndBearing(e,t,r,i,a)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}};function r3(e,t,r){let i={constrainOverride:t};if(Array.isArray(e)){let a=new ng({type:e},r);return{projection:a,transform:new pg(i),cameraHelper:new fg(a)}}switch(e){case"mercator":return{projection:new kc,transform:new dl(i),cameraHelper:new pl};case"globe":{let a=new ng({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:a,transform:new pg(i),cameraHelper:new fg(a)}}case"vertical-perspective":return{projection:new q1,transform:new X1(i),cameraHelper:new Q1};default:return _e(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new kc,transform:new dl(i),cameraHelper:new pl}}}const i3=MC();var mg=class extends Rt{constructor(e,t={}){var i,a;super(),this._rtlPluginLoaded=()=>{for(let n in this.tileManagers){let s=this.tileManagers[n].getSource().type;(s==="vector"||s==="geojson")&&this.tileManagers[n].reload()}},this.map=e,this.dispatcher=new _1(g1(),e._getMapId()).setEventedParent(this),this.dispatcher.registerMessageHandler("GG",(n,s)=>this.getGlyphs(n,s)),this.dispatcher.registerMessageHandler("GI",(n,s)=>this.getImages(n,s)),this.dispatcher.registerMessageHandler("GDA",(n,s)=>this.getDashes(n,s)),this.imageManager=new RC,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new kC(this.imageManager);let r=((i=e._container)==null?void 0:i.lang)||typeof document<"u"&&((a=document.documentElement)==null?void 0:a.lang)||void 0;this.glyphManager=new GC(e._requestManager,t.localIdeographFontFamily,r),this.lineAtlas=new KC(256,512),this.crossTileSymbolIndex=new k1,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",Zc()),Cc().on(Ac,this._rtlPluginLoaded),this.on("data",n=>{if(n.dataType!=="source"||n.sourceDataType!=="metadata")return;let s=this.tileManagers[n.sourceId];if(!s)return;let o=s.getSource();if(o!=null&&o.vectorLayerIds)for(let l in this._layers){let u=this._layers[l];u.source===o.id&&this._validateLayer(u)}})}_setInitialValues(){var e;this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new Ch,this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,this.crossTileSymbolIndex=new(((e=this.crossTileSymbolIndex)==null?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,t){var i,a;this._checkLoaded();let r=t===null?((a=(i=this.stylesheet.state)==null?void 0:i[e])==null?void 0:a.default)??null:t;return this._setGlobalStateValues({[e]:r}),this}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t={};for(let r in e)t[r]=e[r].default;this._setGlobalStateValues(t)}_setGlobalStateValues(e){let t=[];for(let i in e)Or(e[i],this._globalState[i])||t.push(i);if(t.length===0)return;let r={...this._globalState};for(let i of t)this._globalState[i]=e[i];this._applyGlobalStateChanges(t,r)}_applyGlobalStateChanges(e,t){var n,s;let r=new Set,i={};for(let o of e)i[o]=this._globalState[o];for(let o in this._layers){let l=this._layers[o];l.retainPriorGlobalState(e,t);let u=l.getLayoutAffectingGlobalStateRefs(),h=l.getPaintAffectingGlobalStateRefs(),c=l.getVisibilityAffectingGlobalStateRefs();for(let d of e){if(u.has(d)&&r.add(l.source),h.has(d))for(let{name:p,value:f}of h.get(d))this._updatePaintProperty(l,p,f,{validate:!1});c!=null&&c.has(d)&&(l.recalculateVisibility(),this._updateLayer(l))}}let a={now:Fe(),transition:this.getTransition()};(n=this.light)==null||n.applyGlobalStateChange(e,t,a),(s=this.sky)==null||s.applyGlobalStateChange(e,t,a),this.dispatcher.broadcast("UGS",i);for(let o in this.tileManagers)r.has(o)&&(this._reloadSource(o),this._changed=!0)}async loadURL(e,t={},r){this.fire(new Dr("dataloading")),t.validate=typeof t.validate!="boolean"||t.validate,this._loadStyleRequest=new AbortController;let i=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(e,"Style");qc(i.signal);let n=await _l(a,i);this._loadStyleRequest===i&&(this._loadStyleRequest=null),this._load(n.data,t,r)}catch(a){this._loadStyleRequest===i&&(this._loadStyleRequest=null),a&&!i.signal.aborted&&this.fire(new X(zt(a)))}}loadJSON(e,t={},r){this.fire(new Dr("dataloading")),this._frameRequest=new AbortController,Xt.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,t.validate=t.validate!==!1,this._load(e,t,r)}).catch(()=>{})}loadEmpty(){this.fire(new Dr("dataloading")),this._load(i3,{validate:!1})}_load(e,t,r){var a;let i=t.transformStyle?t.transformStyle(r,e):e;if(!(t.validate&&cf(this,i))){i={...i},this._loaded=!0,this.stylesheet=i;for(let n in i.sources)this.addSource(n,i.sources[n],{validate:!1});i.sprite?this._loadSprite(i.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(i.glyphs),this.glyphManager.setFontFaces(i["font-faces"]),this._createLayers(),this.light=new WC(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(((a=this.stylesheet.projection)==null?void 0:a.type)||"mercator"),this.sky=new YC(this.stylesheet.sky,this._globalState),this.sky.setEventedParent(this),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new Dr("data")),this.fire(new wm)}}_createLayers(){var t;let e=Dm(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",e),this._order=e.map(r=>r.id),this._layers={},this._serializedLayers=null;for(let r of e){let i=$u(r,this._globalState);if(i.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=i,Mh(i)&&this.tileManagers[i.source]){let a=((t=r.paint)==null?void 0:t["raster-fade-duration"])??i.paint.get("raster-fade-duration");this.tileManagers[i.source].setRasterFadeDuration(a)}}}async _loadSprite(e,t=!1,r=void 0){this.imageManager.setLoaded(!1);let i=new AbortController;this._spriteRequest=i;let a;try{let n=await zC(e,this.map._requestManager,this.map.getPixelRatio(),i);if(!n)return;for(let s in n){let{loaded:o,removed:l}=this.imageManager.setSpriteImages(s,n[s]);this._markImagesChanged(l),t&&this._markImagesChanged(o)}}catch(n){a=n,i.signal.aborted||this.fire(new X(a))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new Dr("data")),r==null||r(a)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new Dr("data"))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let r=e.sourceLayer;if(!r)return;let i=t.getSource();(i.type==="geojson"||i.vectorLayerIds&&!i.vectorLayerIds.includes(r))&&this.fire(new X(Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,t=!1){let r=this._serializedAllLayers();if(!e||e.length===0)return Object.values(t?Wt(r):r);let i=[];for(let a of e)if(r[a]){let n=t?Wt(r[a]):r[a];i.push(n)}return i}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let r of t){let i=this._layers[r];i.type!=="custom"&&(e[r]=i.serialize())}return e}hasTransitions(){var e,t,r;if((e=this.light)!=null&&e.hasTransition()||(t=this.sky)!=null&&t.hasTransition()||(r=this.projection)!=null&&r.hasTransition())return!0;for(let i in this.tileManagers)if(this.tileManagers[i].hasTransition())return!0;for(let i in this._layers)if(this._layers[i].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading.")}update(e){if(!this._loaded)return;let t=this._changed;if(t){this._imagesListDirty&&(this._imagesListDirty=(this.dispatcher.broadcast("SI",this.imageManager.listImages()),!1));let a=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(a.length||n.length)&&this._updateWorkerLayers(a,n);for(let s in this._updatedSources){let o=this._updatedSources[s];if(o==="reload")this._reloadSource(s);else if(o==="clear")this._clearSource(s);else throw Error(`Invalid action ${o}`)}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let s in this._updatedPaintProps)this._layers[s].updateTransitions(e);this._resetUpdates()}let r={};for(let a in this.tileManagers){let n=this.tileManagers[a];r[a]=n.used,n.used=!1}let i=this.imageManager.listImages();for(let a of this._order){let n=this._layers[a];n.recalculate(e,i),!n.isHidden(e.zoom)&&n.source&&(this.tileManagers[n.source].used=!0)}for(let a in r){let n=this.tileManagers[a];!!r[a]!=!!n.used&&n.fire(new Ne("data",{sourceDataType:"visibility",sourceId:a}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,t&&this.fire(new Dr("data"))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){this._checkLoaded();let r=this.serialize();if(e=t.transformStyle?t.transformStyle(r,e):e,(t.validate??!0)&&cf(this,e))return!1;e=Wt(e),e.layers=Dm(e.layers);let i=IC(r,e),a=this._getOperationsToPerform(i);if(a.unimplemented.length>0)throw Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(a.operations.length===0)return!1;for(let n of a.operations)n();return this.stylesheet=e,this._serializedLayers=null,this.fire(new wm({style:this})),!0}_getOperationsToPerform(e){let t=[],r=[];for(let i of e)switch(i.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":{let[a,n]=i.args;t.push(()=>this.addLayer(a,n));break}case"removeLayer":{let[a]=i.args;t.push(()=>this.removeLayer(a));break}case"setPaintProperty":{let[a,n,s]=i.args;t.push(()=>this.setPaintProperty(a,n,s));break}case"setLayoutProperty":{let[a,n,s]=i.args;t.push(()=>this.setLayoutProperty(a,n,s));break}case"setFilter":{let[a,n]=i.args;t.push(()=>this.setFilter(a,n));break}case"addSource":{let[a,n]=i.args;t.push(()=>this.addSource(a,n));break}case"removeSource":{let[a]=i.args;t.push(()=>this.removeSource(a));break}case"setLayerZoomRange":{let[a,n,s]=i.args;t.push(()=>this.setLayerZoomRange(a,n,s));break}case"setLight":{let[a]=i.args;t.push(()=>this.setLight(a));break}case"setGeoJSONSourceData":{let[a,n]=i.args;t.push(()=>this.setGeoJSONSourceData(a,n));break}case"setGlyphs":{let[a]=i.args;t.push(()=>this.setGlyphs(a));break}case"setFontFaces":{let[a]=i.args;t.push(()=>this.setFontFaces(a));break}case"setSprite":{let[a]=i.args;t.push(()=>this.setSprite(a));break}case"setTerrain":{let[a]=i.args;t.push(()=>this.map.setTerrain(a));break}case"setSky":{let[a]=i.args;t.push(()=>this.setSky(a));break}case"setProjection":{let[a]=i.args;t.push(()=>this.setProjection(a));break}case"setGlobalState":{let[a]=i.args;t.push(()=>this.setGlobalState(a));break}case"setTransition":t.push(()=>{});break;default:r.push(i.command)}return{operations:t,unimplemented:r}}addImage(e,t){if(this.getImage(e)){this.fire(new X(Error(`An image named "${e}" already exists.`)));return}this.imageManager.addImage(e,t),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}setMissingImageResolver(e){this.imageManager.setMissingImageResolver(e)}removeImage(e){if(!this.getImage(e)){this.fire(new X(Error(`An image named "${e}" does not exist.`)));return}this.imageManager.removeImage(e),this._afterImageUpdated(e)}_markImagesChanged(e){for(let t of e)this._changedImages[t]=!0}_afterImageUpdated(e){this._changedImages[e]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new Dr("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,r={}){var a;if(this._checkLoaded(),this.tileManagers[e]!==void 0)throw Error(`Source "${e}" already exists.`);if(!t.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(py.has(t.type)&&this._validate(Zt.source,`sources.${e}`,t,null,r))return;(a=this.map)!=null&&a._collectResourceTiming&&(t.collectResourceTiming=!0);let i=this.tileManagers[e]=new Mc(e,t,this.dispatcher);i.style=this,i.setEventedParent(this,()=>({isSourceLoaded:i.loaded(),source:i.serialize(),sourceId:e})),i.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);for(let r in this._layers)if(this._layers[r].source===e)return this.fire(new X(Error(`Source "${e}" cannot be removed while layer "${r}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new Ne("data",{sourceDataType:"metadata",sourceId:e})),t.setEventedParent(null),t.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);let r=this.tileManagers[e].getSource();if(r.type!=="geojson")throw Error(`geojsonSource.type is ${r.type}, which is !== 'geojson`);r.setData(t),this._changed=!0}getSource(e){var t;return(t=this.tileManagers[e])==null?void 0:t.getSource()}addLayer(e,t,r={}){this._checkLoaded();let i=e.id;if(this.getLayer(i)){this.fire(new X(Error(`Layer "${i}" already exists on this map.`)));return}let a;if(e.type==="custom"){if(cd(this,gE(e)))return;a=$u(e,this._globalState)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(i,e.source),e=Wt(e),e=W(e,{source:i})),this._validate(Zt.layer,`layers.${i}`,e,{arrayIndex:-1},r))return;a=$u(e,this._globalState),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}let n=t?this._order.indexOf(t):this._order.length;if(t&&n===-1){this.fire(new X(Error(`Cannot add layer "${i}" before non-existing layer "${t}".`)));return}if(this._order.splice(n,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&a.type!=="custom"){let s=this._removedLayers[i];delete this._removedLayers[i],s.type===a.type?(this._updatedSources[a.source]="reload",this.tileManagers[a.source].pause()):this._updatedSources[a.source]="clear"}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e]){this.fire(new X(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));return}if(e===t)return;if(t&&!this._order.includes(t)){this.fire(new X(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));return}let r=this._order.indexOf(e);this._order.splice(r,1);let i=t?this._order.indexOf(t):this._order.length;this._order.splice(i,0,e),this._layerOrderChanged=!0}removeLayer(e){var i;this._checkLoaded();let t=this._layers[e];if(!t){this.fire(new X(Error(`Cannot remove non-existing layer "${e}".`)));return}t.setEventedParent(null);let r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.type==="symbol"&&t.source&&((i=this.tileManagers[t.source])==null||i.resetMaxContentElevation()),t.onRemove&&t.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,t,r){this._checkLoaded();let i=this.getLayer(e);if(!i){this.fire(new X(Error(`Cannot set the zoom range of non-existing layer "${e}".`)));return}(i.minzoom!==t||i.maxzoom!==r)&&(t!=null&&(i.minzoom=t),r!=null&&(i.maxzoom=r),this._updateLayer(i))}setFilter(e,t,r={}){this._checkLoaded();let i=this.getLayer(e);if(!i){this.fire(new X(Error(`Cannot filter non-existing layer "${e}".`)));return}if(!Or(i.filter,t)){if(t==null){i.setFilter(void 0),this._updateLayer(i);return}this._validate(Zt.filter,`layers.${i.id}.filter`,t,null,r)||(i.setFilter(Wt(t)),this._updateLayer(i))}}getFilter(e){return Wt(this.getLayer(e).filter)}setLayoutProperty(e,t,r,i={}){this._checkLoaded();let a=this.getLayer(e);if(!a){this.fire(new X(Error(`Cannot style non-existing layer "${e}".`)));return}Or(a.getLayoutProperty(t),r)||(a.setLayoutProperty(t,r,i),this._updateLayer(a))}getLayoutProperty(e,t){let r=this.getLayer(e);if(!r){this.fire(new X(Error(`Cannot get style of non-existing layer "${e}".`)));return}return r.getLayoutProperty(t)}setPaintProperty(e,t,r,i={}){this._checkLoaded();let a=this.getLayer(e);if(!a){this.fire(new X(Error(`Cannot style non-existing layer "${e}".`)));return}Or(a.getPaintProperty(t),r)||this._updatePaintProperty(a,t,r,i)}_updatePaintProperty(e,t,r,i={}){e.setPaintProperty(t,r,i)&&this._updateLayer(e),Mh(e)&&t==="raster-fade-duration"&&this.tileManagers[e.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[e.id]=!0,e.type==="symbol"&&this.triggerSymbolPlacement(),this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();let r=e.source,i=e.sourceLayer,a=this.tileManagers[r];if(a===void 0){this.fire(new X(Error(`The source '${r}' does not exist in the map's style.`)));return}let n=a.getSource().type;if(n==="geojson"&&i){this.fire(new X(Error("GeoJSON sources cannot have a sourceLayer parameter.")));return}if(n==="vector"&&!i){this.fire(new X(Error("The sourceLayer parameter must be provided for vector source types.")));return}if(e.id===void 0){this.fire(new X(Error("The feature id parameter must be provided.")));return}let s=["__proto__","constructor","prototype"];if(t&&Object.keys(t).some(o=>s.includes(o))){this.fire(new X(Error(`The feature state should not include one of the following keys: ${s}`)));return}a.setFeatureState(i,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let r=e.source,i=this.tileManagers[r];if(i===void 0){this.fire(new X(Error(`The source '${r}' does not exist in the map's style.`)));return}let a=i.getSource().type,n=a==="vector"?e.sourceLayer:void 0;if(a==="vector"&&!n){this.fire(new X(Error("The sourceLayer parameter must be provided for vector source types.")));return}if(t&&typeof e.id!="string"&&typeof e.id!="number"){this.fire(new X(Error("A feature id is required to remove its specific state property.")));return}i.removeFeatureState(n,e.id,t)}getFeatureState(e){this._checkLoaded();let t=e.source,r=e.sourceLayer,i=this.tileManagers[t];if(i===void 0){this.fire(new X(Error(`The source '${t}' does not exist in the map's style.`)));return}if(i.getSource().type==="vector"&&!r){this.fire(new X(Error("The sourceLayer parameter must be provided for vector source types.")));return}return e.id===void 0&&this.fire(new X(Error("The feature id parameter must be provided."))),i.getFeatureState(r,e.id)}getTransition(){var e;return W({duration:300,delay:0},(e=this.stylesheet)==null?void 0:e.transition)}serialize(){if(!this._loaded)return;let e=Gc(this.tileManagers,a=>a.serialize()),t=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return Ng({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,"font-faces":i["font-faces"],transition:i.transition,projection:i.projection,state:i.state,sources:e,layers:t,terrain:r},a=>a!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.tileManagers[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=n=>this._layers[n].type==="fill-extrusion",r={},i=[];for(let n=this._order.length-1;n>=0;n--){let s=this._order[n];if(t(s)){r[s]=n;for(let o of e){let l=o[s];if(l)for(let u of l)i.push(u)}}}i.sort((n,s)=>s.intersectionZ-n.intersectionZ);let a=[];for(let n=this._order.length-1;n>=0;n--){let s=this._order[n];if(t(s))for(let o=i.length-1;o>=0;o--){let l=i[o].feature;if(r[l.layer.id]<n)break;a.push(l),i.pop()}else for(let o of e){let l=o[s];if(l)for(let u of l)a.push(u.feature)}}return a}queryRenderedFeatures(e,t,r){t!=null&&t.filter&&this._validate(Zt.filter,"queryRenderedFeatures.filter",t.filter,null,t);let i={};if(t!=null&&t.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new X(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let l of t.layers){let u=this._layers[l];if(!u)return this.fire(new X(Error(`The layer '${l}' does not exist in the map's style and cannot be queried for features.`))),[];i[u.source]=!0}}let a=[];t.availableImages=this.imageManager.listImages();let n=this._serializedAllLayers(),s=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,o={...t,layers:s,globalState:this._globalState};for(let l in this.tileManagers)(!t.layers||i[l])&&a.push(lI(this.tileManagers[l],this._layers,n,e,o,r,this.map.terrain?(u,h,c)=>this.map.terrain.getElevation(u,h,c):void 0));return this.placement&&a.push(uI(this._layers,n,this.tileManagers,e,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t!=null&&t.filter&&this._validate(Zt.filter,"querySourceFeatures.filter",t.filter,null,t);let r=this.tileManagers[e];return r?hI(r,t?{...t,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let n in e)if(!Or(e[n],r[n])){i=!0;break}if(!i)return;let a={now:Fe(),transition:W({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,t),this.light.updateTransitions(a)}getProjection(){var e;return(e=this.stylesheet)==null?void 0:e.projection}setProjection(e){this._checkLoaded();let t=e??{type:"mercator"};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){var e;return(e=this.stylesheet)==null?void 0:e.sky}setSky(e,t={}){this._checkLoaded();let r=this.getSky(),i=!1;if(!e&&!r)return;if(e&&!r)i=!0;else if(!e&&r)i=!0;else for(let n in e)if(!Or(e[n],r[n])){i=!0;break}if(!i)return;let a={now:Fe(),transition:W({duration:300,delay:0},this.stylesheet.transition)};this.sky.setSky(e,t)&&(this.stylesheet.sky=e,this.sky.updateTransitions(a))}_setProjectionInternal(e){var r;let t=r3(e,(r=this.map._camera)==null?void 0:r.transform.constrainOverride,this._globalState);this.projection=t.projection,this.map.migrateProjection(t.transform,t.cameraHelper);for(let i in this.tileManagers)this.tileManagers[i].reload()}_validate(e,t,r,i,a={}){return a.validate!==!1&&_s(this,e,{key:t,style:this.serialize(),value:r,...i},a)}_remove(e=!0){this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._loadStyleRequest&&(this._loadStyleRequest=(this._loadStyleRequest.abort(),null)),this._spriteRequest&&(this._spriteRequest=(this._spriteRequest.abort(),null)),Cc().off(Ac,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let r=this.tileManagers[t];r.setEventedParent(null),r.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(let t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(e,t,r){var a;let i=this.pauseablePlacement;return!i||this._symbolPlacementTriggered||this._placedProjectionTransition!==((a=this.projection)==null?void 0:a.transitionState)||i._showCollisionBoxes!==t||i.placement.collisionGroups.crossSourceCollisions!==r||i.placement.transform.renderWorldCopies!==e.renderWorldCopies||!Gx(i.placement.transform.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,r,i,a=!1){var h,c;let n=!1,s=!1,o={};for(let d of this._order){let p=this._layers[d];if(p.type!=="symbol")continue;if(!o[p.source]){let m=this.tileManagers[p.source];o[p.source]=m.getRenderableIds(!0).map(g=>m.getTileByID(g)).sort((g,_)=>_.tileID.overscaledZ-g.tileID.overscaledZ||(g.tileID.isLessThan(_.tileID)?-1:1))}let f=this.crossTileSymbolIndex.addLayer(p,o[p.source],e.center.lng);n||(n=f)}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||(a=this._layerOrderChanged||r===0);let l=n||this._placementInputsChanged(e,t,i),u=((h=this.pauseablePlacement)==null?void 0:h.isDone())&&!this.placement.stillRecent(Fe(),e.zoom);if((a||!this.pauseablePlacement||u&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=(c=this.projection)==null?void 0:c.transitionState,this.pauseablePlacement=new DM(e,this.map.terrain,this._order,a,t,r,i,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,o),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Fe()),s=!0),n&&this.pauseablePlacement.placement.setStale()),s||n)for(let d of this._order){let p=this._layers[d];p.type==="symbol"&&this.placement.updateLayerOpacities(p,o[p.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Fe())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let r=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let i=this.tileManagers[t.source];return i&&i.setDependencies(t.tileID.key,t.type,t.icons),r}async getGlyphs(e,t){let r=await this.glyphManager.getGlyphs(t.stacks),i=this.tileManagers[t.source];return i&&i.setDependencies(t.tileID.key,t.type,[""]),r}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),!(e&&this._validate(Zt.glyphs,"glyphs",e,null,t))&&(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getFontFaces(){return this.stylesheet["font-faces"]||null}setFontFaces(e){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet["font-faces"]=e,this.glyphManager.setFontFaces(e)}async getDashes(e,t){let r={};for(let[i,a]of Object.entries(t.dashes))r[i]=this.lineAtlas.getDash(a.dasharray,a.round);return r}addSprite(e,t,r={},i){this._checkLoaded();let a=[{id:e,url:t}],n=[...Io(this.stylesheet.sprite),...a];this._validate(Zt.sprite,"sprite",n,null,r)||(this.stylesheet.sprite=n,this._loadSprite(a,!0,i))}removeSprite(e){this._checkLoaded();let t=Io(this.stylesheet.sprite);if(!t.find(i=>i.id===e)){this.fire(new X(Error(`Sprite "${e}" doesn't exists on this map.`)));return}let r=this.imageManager.removeSpriteImages(e);this._markImagesChanged(r),t.splice(t.findIndex(i=>i.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new Dr("data"))}getSprite(){return Io(this.stylesheet.sprite)}setSprite(e,t={},r){this._checkLoaded(),!(e&&this._validate(Zt.sprite,"sprite",e,null,t))&&(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._loadStyleRequest&&(this._loadStyleRequest=(this._loadStyleRequest.abort(),null)),this._spriteRequest&&(this._spriteRequest=(this._spriteRequest.abort(),null));for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.patternAtlas.destroy()),this.glyphManager&&this.glyphManager.destroy();for(let e in this._layers){let t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}};const a3=Ye([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var n3=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,r,i,a,n,s,o,l){this.context=e;let u=this.boundPaintVertexBuffers.length!==i.length;for(let h=0;!u&&h<i.length;h++)this.boundPaintVertexBuffers[h]!==i[h]&&(u=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==r||u||this.boundIndexBuffer!==a||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==o||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,r,i,a,n,s,o,l):e.bindVertexArray.set(this.vao)}freshBind(e,t,r,i,a,n,s,o){let l=e.numAttributes,u=this.context,h=u.gl;this.vao&&this.destroy(),this.vao=u.createVertexArray(),u.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=r,this.boundIndexBuffer=i,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=o,t.enableAttributes(h,e);for(let c of r)c.enableAttributes(h,e);n&&n.enableAttributes(h,e),s&&s.enableAttributes(h,e),o&&o.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,a);for(let c of r)c.bind(),c.setVertexAttribPointers(h,e,a);n&&(n.bind(),n.setVertexAttribPointers(h,e,a)),i&&i.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,e,a)),o&&(o.bind(),o.setVertexAttribPointers(h,e,a)),u.currentNumAttributes=l}destroy(){this.vao&&(this.vao=(this.context.deleteVertexArray(this.vao),null))}};const s3=(e,t)=>({u_depth:new H(e,t.u_depth),u_terrain:new H(e,t.u_terrain)}),o3=(e,t)=>({u_texture:new H(e,t.u_texture),u_ele_delta:new U(e,t.u_ele_delta),u_fog_matrix:new Cr(e,t.u_fog_matrix),u_fog_color:new Ai(e,t.u_fog_color),u_fog_ground_blend:new U(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new U(e,t.u_fog_ground_blend_opacity),u_horizon_color:new Ai(e,t.u_horizon_color),u_horizon_fog_blend:new U(e,t.u_horizon_fog_blend),u_is_globe_mode:new U(e,t.u_is_globe_mode)}),l3=(e,t)=>({u_ele_delta:new U(e,t.u_ele_delta)}),u3=(e,t,r,i,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:r?r.properties.get("fog-color"):se.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get("horizon-color"):se.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!a}),h3=e=>({u_ele_delta:e}),Gl={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2};function c3(e,t){for(let[r,i]of Object.entries(Gl)){let a=e.getUniformBlockIndex(t,r);a!==e.INVALID_INDEX&&e.uniformBlockBinding(t,a,i)}}const d3={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function Jd(e){let t={},r=0;for(let{name:i,type:a}of e){let[n,s]=d3[a];r=Math.ceil(r/s)*s,t[i]=r,r+=n}return{offsets:t,contentWords:r,sizeWords:Math.ceil(r/4)*4}}var Qd=class{constructor(e,t,r){this.context=e,this.binding=t,this.contentWords=r.contentWords;let i=e.gl;this.buffer=i.createBuffer(),i.bindBuffer(i.UNIFORM_BUFFER,this.buffer),i.bufferData(i.UNIFORM_BUFFER,r.sizeWords*4,i.DYNAMIC_DRAW),this.uploaded=new Float32Array(r.sizeWords),this.pending=new Float32Array(r.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1}upload(){let e=this.context.gl,t=!this.hasData;if(!t){let r=this.pendingWords,i=this.uploadedWords;for(let a=0;a<this.contentWords;a++)if(r[a]!==i[a]){t=!0;break}}if(!t){this.bind();return}e.bindBufferBase(e.UNIFORM_BUFFER,this.binding,this.buffer),this.context.boundUniformBuffers[this.binding]=this.buffer,e.bufferData(e.UNIFORM_BUFFER,this.pending,e.DYNAMIC_DRAW),this.uploaded.set(this.pending),this.hasData=!0}bind(){let e=this.context.boundUniformBuffers;if(e[this.binding]===this.buffer)return;let t=this.context.gl;t.bindBufferBase(t.UNIFORM_BUFFER,this.binding,this.buffer),e[this.binding]=this.buffer}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}};const ex=Jd([{name:"u_projection_matrix",type:"mat4"},{name:"u_projection_fallback_matrix",type:"mat4"},{name:"u_projection_tile_mercator_coords",type:"vec4"},{name:"u_projection_clipping_plane",type:"vec4"},{name:"u_projection_transition",type:"float"},{name:"u_projection_clip_antimeridian",type:"int"}]),ba=ex.offsets;function tx(e){return new Qd(e,Gl.ProjectionUBO,ex)}function gg(e,t){let r=e.pending;r.set(t.mainMatrix,ba.u_projection_matrix),r.set(t.fallbackMatrix,ba.u_projection_fallback_matrix),r.set(t.tileMercatorCoords,ba.u_projection_tile_mercator_coords),r.set(t.clippingPlane,ba.u_projection_clipping_plane),r[ba.u_projection_transition]=t.projectionTransition,e.pendingWords[ba.u_projection_clip_antimeridian]=+!!t.clipAntimeridian,e.upload()}function p3(e,t){if(!t){e.projectionUniformBuffer.bind();return}let r=t.uniformBufferKey;if(r===void 0){gg(e.projectionUniformBuffer,t);return}let i=e.keyedProjectionUniformBuffers.get(r);if(i){i.bind();return}let a=e.freeProjectionUniformBuffers.pop()??tx(e);e.keyedProjectionUniformBuffers.set(r,a),gg(a,t)}function f3(e){e.freeProjectionUniformBuffers.push(...e.keyedProjectionUniformBuffers.values()),e.keyedProjectionUniformBuffers.clear()}function m3(e){e.projectionUniformBuffer.destroy();for(let t of e.keyedProjectionUniformBuffers.values())t.destroy();for(let t of e.freeProjectionUniformBuffers)t.destroy()}const rx=Jd([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),mo=rx.offsets;function g3(e){return new Qd(e,Gl.TerrainUBO,rx)}function _3(e,t){let r=e.pending;r.set(t.u_terrain_matrix,mo.u_terrain_matrix),r.set(t.u_terrain_unpack,mo.u_terrain_unpack),r[mo.u_terrain_dim]=t.u_terrain_dim,r[mo.u_terrain_exaggeration]=t.u_terrain_exaggeration,e.upload()}function Qu(e){let t=[];for(let r of e){if(r===null)continue;let i=r.split(" ");t.push(i.pop())}return t}function y3(e,t){let r=new Set([e.INT,e.INT_VEC2,e.INT_VEC3,e.INT_VEC4,e.UNSIGNED_INT,e.UNSIGNED_INT_VEC2,e.UNSIGNED_INT_VEC3,e.UNSIGNED_INT_VEC4]),i=new Set,a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let n=0;n<a;n++){let s=e.getActiveAttrib(t,n);s&&r.has(s.type)&&i.add(s.name)}return i}var x3=class{constructor(e,t,r,i,a,n,s,o,l=[]){let u=e.gl;this.program=u.createProgram();let h=Qu(t.staticAttributes),c=r?r.getBinderAttributes():[],d=h.concat(c),p=Nr.prelude.staticUniforms?Qu(Nr.prelude.staticUniforms):[],f=t.staticUniforms?Qu(t.staticUniforms):[],m=r?r.getBinderUniforms():[],g=p.concat(f).concat(m),_=[];for(let S of g)_.includes(S)||_.push(S);let y=r?r.defines():[];y.unshift("#version 300 es"),a&&y.push("#define OVERDRAW_INSPECTOR;"),n&&y.push("#define TERRAIN3D;"),o&&y.push(o),l&&y.push(...l);let v=y.concat(Nr.prelude.fragmentSource,s.fragmentSource,t.fragmentSource).join(`
`),x=y.concat(Nr.prelude.vertexSource,s.vertexSource,t.vertexSource).join(`
`),w=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(w,v),u.compileShader(w),u.attachShader(this.program,w);let b=u.createShader(u.VERTEX_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(b,x),u.compileShader(b),u.attachShader(this.program,b),this.attributes={};let T={};if(this.numAttributes=d.length,u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS)){if(u.isContextLost()){this.failedToCreate=!0;return}throw u.getShaderParameter(w,u.COMPILE_STATUS)?u.getShaderParameter(b,u.COMPILE_STATUS)?Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${u.getShaderInfoLog(b)}`):Error(`Could not compile fragment shader: ${u.getShaderInfoLog(w)}`)}c3(u,this.program);let P=y3(u,this.program);for(let S of d){if(!S)continue;let I=u.getAttribLocation(this.program,S);I>=0&&(this.attributes[S]={location:I,isInteger:P.has(S)})}u.deleteShader(b),u.deleteShader(w);for(let S of _)if(S&&!T[S]){let I=u.getUniformLocation(this.program,S);I&&(T[S]=I)}this.fixedUniforms=i(e,T),this.terrainUniforms=s3(e,T),this.binderUniforms=r?r.getUniforms(e,T):[]}draw(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m,g,_,y){var w;let v=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.terrainUniformBuffer.bind(),e.frameUniformBuffer.bind(),e.setDepthMode(r),e.setStencilMode(i),e.setColorMode(a),e.setCullFace(n),o){e.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,o.depthTexture),e.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,o.texture);for(let b in this.terrainUniforms)this.terrainUniforms[b].set(o[b]);_3(e.terrainUniformBuffer,o)}if(p3(e,l),s)for(let b in this.fixedUniforms)this.fixedUniforms[b].set(s[b]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let x=0;switch(t){case v.LINES:x=2;break;case v.TRIANGLES:x=3;break;case v.LINE_STRIP:x=1}for(let b of d.get())b.vaos||(b.vaos={}),(w=b.vaos)[u]||(w[u]=new n3),b.vaos[u].bind(e,this,h,m?m.getPaintVertexBuffers():[],c,b.vertexOffset,g,_,y),v.drawElements(t,b.primitiveLength*x,v.UNSIGNED_SHORT,b.primitiveOffset*x*2)}};function ix(e,t,r){let i=1/nr(r,1,t.transform.tileZoom),a=2**r.tileID.overscaledZ,n=r.tileSize*2**t.transform.tileZoom/a,s=n*(r.tileID.canonical.x+r.tileID.wrap*a),o=n*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,o>>16],u_pixel_coord_lower:[s&65535,o&65535]}}function v3(e,t,r,i){let a=r.patternAtlas.getPattern(e.from.toString()),n=r.patternAtlas.getPattern(e.to.toString()),{width:s,height:o}=r.patternAtlas.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,h=u*(i.tileID.canonical.x+i.tileID.wrap*l),c=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[s,o],u_mix:t.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/nr(i,1,r.transform.tileZoom),u_pixel_coord_upper:[h>>16,c>>16],u_pixel_coord_lower:[h&65535,c&65535]}}const b3=(e,t)=>({u_lightpos:new jt(e,t.u_lightpos),u_lightpos_globe:new jt(e,t.u_lightpos_globe),u_lightintensity:new U(e,t.u_lightintensity),u_lightcolor:new jt(e,t.u_lightcolor),u_vertical_gradient:new U(e,t.u_vertical_gradient),u_opacity:new U(e,t.u_opacity),u_fill_translate:new ce(e,t.u_fill_translate)}),w3=(e,t)=>({u_lightpos:new jt(e,t.u_lightpos),u_lightpos_globe:new jt(e,t.u_lightpos_globe),u_lightintensity:new U(e,t.u_lightintensity),u_lightcolor:new jt(e,t.u_lightcolor),u_vertical_gradient:new U(e,t.u_vertical_gradient),u_height_factor:new U(e,t.u_height_factor),u_opacity:new U(e,t.u_opacity),u_fill_translate:new ce(e,t.u_fill_translate),u_image:new H(e,t.u_image),u_texsize:new ce(e,t.u_texsize),u_pixel_coord_upper:new ce(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new ce(e,t.u_pixel_coord_lower),u_scale:new jt(e,t.u_scale),u_fade:new U(e,t.u_fade)}),ax=(e,t,r,i)=>{let a=e.style.light,n=a.getCartesianPosition(),s=Bg();a.properties.get("anchor")==="viewport"&&Ox(s,e.transform.bearingInRadians),Xx(n,n,s);let o=e.transform.transformLightDirection(n),l=a.properties.get("color");return{u_lightpos:n,u_lightpos_globe:o,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+t,u_opacity:r,u_fill_translate:i}},T3=(e,t,r,i,a,n,s)=>W(ax(e,t,r,i),ix(n,e,s),{u_height_factor:-(2**a.overscaledZ)/s.tileSize/8}),D3=(e,t)=>({u_fill_translate:new ce(e,t.u_fill_translate)}),S3=(e,t)=>({u_image:new H(e,t.u_image),u_texsize:new ce(e,t.u_texsize),u_pixel_coord_upper:new ce(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new ce(e,t.u_pixel_coord_lower),u_scale:new jt(e,t.u_scale),u_fade:new U(e,t.u_fade),u_sdf_pattern:new H(e,t.u_sdf_pattern),u_fill_translate:new ce(e,t.u_fill_translate)}),E3=(e,t)=>({u_fill_translate:new ce(e,t.u_fill_translate)}),P3=(e,t)=>({u_image:new H(e,t.u_image),u_texsize:new ce(e,t.u_texsize),u_pixel_coord_upper:new ce(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new ce(e,t.u_pixel_coord_lower),u_scale:new jt(e,t.u_scale),u_fade:new U(e,t.u_fade),u_sdf_pattern:new H(e,t.u_sdf_pattern),u_fill_translate:new ce(e,t.u_fill_translate)}),nx=(e,t,r,i,a)=>W(ix(t,e,r),{u_fill_translate:i,u_sdf_pattern:+!!a}),A3=e=>({u_fill_translate:e}),C3=e=>({u_fill_translate:e}),I3=(e,t,r,i,a)=>nx(e,t,r,i,a),M3=(e,t)=>({u_scale_with_map:new H(e,t.u_scale_with_map),u_pitch_with_map:new H(e,t.u_pitch_with_map),u_extrude_scale:new ce(e,t.u_extrude_scale),u_globe_extrude_scale:new U(e,t.u_globe_extrude_scale),u_translate:new ce(e,t.u_translate)}),z3=(e,t,r,i,a)=>{let n=e.transform,s,o,l=0;if(r.paint.get("circle-pitch-alignment")==="map"){let u=nr(t,1,n.zoom);s=!0,o=[u,u],l=u/(k*2**t.tileID.overscaledZ)*2*Math.PI*a}else s=!1,o=n.pixelsToGLUnits;return{u_scale_with_map:+(r.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+s,u_extrude_scale:o,u_globe_extrude_scale:l,u_translate:i}},F3=(e,t)=>({u_color:new Ai(e,t.u_color),u_overlay:new H(e,t.u_overlay),u_overlay_scale:new U(e,t.u_overlay_scale)}),_g=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),R3=(e,t)=>({u_extrude_scale:new U(e,t.u_extrude_scale),u_intensity:new U(e,t.u_intensity),u_globe_extrude_scale:new U(e,t.u_globe_extrude_scale)}),k3=(e,t)=>({u_matrix:new Cr(e,t.u_matrix),u_image:new H(e,t.u_image),u_color_ramp:new H(e,t.u_color_ramp),u_opacity:new U(e,t.u_opacity)}),sx=(e,t,r,i)=>{let a=nr(e,1,t)/(k*2**e.tileID.overscaledZ)*2*Math.PI*i;return{u_extrude_scale:nr(e,1,t),u_intensity:r,u_globe_extrude_scale:a}},ox=(e,t,r,i)=>{let a=Ci();return Br(a,0,e.width,e.height,0,0,1),{u_matrix:a,u_image:r,u_color_ramp:i,u_opacity:t.paint.get("heatmap-opacity")}},L3=(e,t)=>({u_image:new H(e,t.u_image),u_latrange:new ce(e,t.u_latrange),u_exaggeration:new U(e,t.u_exaggeration),u_altitudes:new wf(e,t.u_altitudes),u_azimuths:new wf(e,t.u_azimuths),u_accent:new Ai(e,t.u_accent),u_method:new H(e,t.u_method),u_shadows:new bf(e,t.u_shadows),u_highlights:new bf(e,t.u_highlights)}),B3=(e,t)=>({u_matrix:new Cr(e,t.u_matrix),u_image:new H(e,t.u_image),u_dimension:new ce(e,t.u_dimension),u_zoom:new U(e,t.u_zoom),u_unpack:new rs(e,t.u_unpack)}),O3=(e,t,r)=>{let i=r.paint.get("hillshade-accent-color"),a;switch(r.paint.get("hillshade-method")){case"basic":a=4;break;case"combined":a=1;break;case"igor":a=2;break;case"multidirectional":a=3;break;default:a=0}let n=r.getIlluminationProperties();for(let s=0;s<n.directionRadians.length;s++)r.paint.get("hillshade-illumination-anchor")==="viewport"&&(n.directionRadians[s]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:j3(e,t.tileID),u_exaggeration:r.paint.get("hillshade-exaggeration"),u_altitudes:n.altitudeRadians,u_azimuths:n.directionRadians,u_accent:i,u_method:a,u_highlights:n.highlightColor,u_shadows:n.shadowColor}},$3=(e,t)=>{let r=t.stride,i=Ci();return Br(i,0,k,-k,0,0,1),ot(i,i,[0,-k,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:t.getUnpackVector()}};function j3(e,t){let r=2**t.canonical.z,i=t.canonical.y;return[new Ie(0,i/r).toLngLat().lat,new Ie(0,(i+1)/r).toLngLat().lat]}const V3=(e,t)=>({u_image:new H(e,t.u_image),u_unpack:new rs(e,t.u_unpack),u_dimension:new ce(e,t.u_dimension),u_elevation_stops:new H(e,t.u_elevation_stops),u_color_stops:new H(e,t.u_color_stops),u_color_ramp_size:new H(e,t.u_color_ramp_size),u_opacity:new U(e,t.u_opacity)}),N3=(e,t,r=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:r,u_opacity:e.paint.get("color-relief-opacity")}),U3=(e,t)=>({u_translation:new ce(e,t.u_translation),u_ratio:new U(e,t.u_ratio)}),G3=(e,t)=>({u_translation:new ce(e,t.u_translation),u_ratio:new U(e,t.u_ratio),u_image:new H(e,t.u_image),u_image_height:new U(e,t.u_image_height)}),q3=(e,t)=>({u_translation:new ce(e,t.u_translation),u_texsize:new ce(e,t.u_texsize),u_ratio:new U(e,t.u_ratio),u_image:new H(e,t.u_image),u_scale:new jt(e,t.u_scale),u_fade:new U(e,t.u_fade)}),Z3=(e,t)=>({u_translation:new ce(e,t.u_translation),u_ratio:new U(e,t.u_ratio),u_image:new H(e,t.u_image),u_mix:new U(e,t.u_mix),u_tileratio:new U(e,t.u_tileratio),u_crossfade_from:new U(e,t.u_crossfade_from),u_crossfade_to:new U(e,t.u_crossfade_to),u_lineatlas_width:new U(e,t.u_lineatlas_width),u_lineatlas_height:new U(e,t.u_lineatlas_height)}),W3=(e,t)=>({u_translation:new ce(e,t.u_translation),u_ratio:new U(e,t.u_ratio),u_image:new H(e,t.u_image),u_image_height:new U(e,t.u_image_height),u_tileratio:new U(e,t.u_tileratio),u_crossfade_from:new U(e,t.u_crossfade_from),u_crossfade_to:new U(e,t.u_crossfade_to),u_image_dash:new H(e,t.u_image_dash),u_mix:new U(e,t.u_mix),u_lineatlas_width:new U(e,t.u_lineatlas_width),u_lineatlas_height:new U(e,t.u_lineatlas_height)}),ql=(e,t,r,i)=>{let a=e.transform;return{u_translation:lx(e,t,r),u_ratio:i/nr(t,1,a.zoom)}},H3=(e,t,r,i,a)=>W(ql(e,t,r,i),{u_image:0,u_image_height:a}),X3=(e,t,r,i,a)=>{let n=e.transform,s=ep(t,n);return{u_translation:lx(e,t,r),u_texsize:t.imageAtlasTexture.size,u_ratio:i/nr(t,1,n.zoom),u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t}},Y3=(e,t,r,i,a)=>{let n=e.transform,s=ep(t,n);return W(ql(e,t,r,i),{u_tileratio:s,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image:0,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},K3=(e,t,r,i,a,n)=>{let s=e.transform,o=ep(t,s);return W(ql(e,t,r,i),{u_image:0,u_image_height:n,u_tileratio:o,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image_dash:1,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function ep(e,t){return 1/nr(e,1,t.tileZoom)}function lx(e,t,r){return Di(e.transform,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const J3=(e,t)=>({u_image:new H(e,t.u_image),u_opacity:new U(e,t.u_opacity)}),Q3=(e,t)=>({u_image:t,u_opacity:e}),e5=(e,t)=>({u_is_size_zoom_constant:new H(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new H(e,t.u_is_size_feature_constant),u_size_t:new U(e,t.u_size_t),u_size:new U(e,t.u_size),u_rotate_symbol:new H(e,t.u_rotate_symbol),u_label_plane_matrix:new Cr(e,t.u_label_plane_matrix),u_coord_matrix:new Cr(e,t.u_coord_matrix),u_is_text:new H(e,t.u_is_text),u_pitch_with_map:new H(e,t.u_pitch_with_map),u_is_along_line:new H(e,t.u_is_along_line),u_is_variable_anchor:new H(e,t.u_is_variable_anchor),u_texsize:new ce(e,t.u_texsize),u_texture:new H(e,t.u_texture),u_translation:new ce(e,t.u_translation),u_pitched_scale:new U(e,t.u_pitched_scale),u_is_offset:new H(e,t.u_is_offset),u_height_anchor_ground:new H(e,t.u_height_anchor_ground)}),t5=(e,t)=>({u_is_size_zoom_constant:new H(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new H(e,t.u_is_size_feature_constant),u_size_t:new U(e,t.u_size_t),u_size:new U(e,t.u_size),u_rotate_symbol:new H(e,t.u_rotate_symbol),u_label_plane_matrix:new Cr(e,t.u_label_plane_matrix),u_coord_matrix:new Cr(e,t.u_coord_matrix),u_is_text:new H(e,t.u_is_text),u_pitch_with_map:new H(e,t.u_pitch_with_map),u_is_along_line:new H(e,t.u_is_along_line),u_is_variable_anchor:new H(e,t.u_is_variable_anchor),u_texsize:new ce(e,t.u_texsize),u_texture:new H(e,t.u_texture),u_gamma_scale:new U(e,t.u_gamma_scale),u_is_halo:new H(e,t.u_is_halo),u_is_plain:new H(e,t.u_is_plain),u_translation:new ce(e,t.u_translation),u_pitched_scale:new U(e,t.u_pitched_scale),u_is_offset:new H(e,t.u_is_offset),u_height_anchor_ground:new H(e,t.u_height_anchor_ground)}),r5=(e,t)=>({u_is_size_zoom_constant:new H(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new H(e,t.u_is_size_feature_constant),u_size_t:new U(e,t.u_size_t),u_size:new U(e,t.u_size),u_rotate_symbol:new H(e,t.u_rotate_symbol),u_label_plane_matrix:new Cr(e,t.u_label_plane_matrix),u_coord_matrix:new Cr(e,t.u_coord_matrix),u_is_text:new H(e,t.u_is_text),u_pitch_with_map:new H(e,t.u_pitch_with_map),u_is_along_line:new H(e,t.u_is_along_line),u_is_variable_anchor:new H(e,t.u_is_variable_anchor),u_texsize:new ce(e,t.u_texsize),u_texsize_icon:new ce(e,t.u_texsize_icon),u_texture:new H(e,t.u_texture),u_texture_icon:new H(e,t.u_texture_icon),u_gamma_scale:new U(e,t.u_gamma_scale),u_is_halo:new H(e,t.u_is_halo),u_translation:new ce(e,t.u_translation),u_pitched_scale:new U(e,t.u_pitched_scale),u_is_offset:new H(e,t.u_is_offset),u_height_anchor_ground:new H(e,t.u_height_anchor_ground)}),ux=(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f)=>({u_is_size_zoom_constant:+(e==="constant"||e==="source"),u_is_size_feature_constant:+(e==="constant"||e==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_rotate_symbol:+r,u_label_plane_matrix:o,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+i,u_is_along_line:a,u_is_variable_anchor:n,u_texsize:c,u_texture:0,u_translation:u,u_pitched_scale:d,u_is_offset:p,u_height_anchor_ground:+f}),hx=(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f,m)=>{let g=s.transform;return W(ux(e,t,r,i,a,n,s,o,l,u,h,c,p,f,m),{u_gamma_scale:i?Math.cos(g.pitch*Math.PI/180)*g.cameraToCenterDistance:1,u_is_halo:+!!d,u_is_plain:1})},i5=(e,t,r,i,a,n,s,o,l,u,h,c,d,p,f)=>W(hx(e,t,r,i,a,n,s,o,l,u,!0,h,!0,d,p,f),{u_texsize_icon:c,u_texture_icon:1}),a5=(e,t)=>({u_opacity:new U(e,t.u_opacity),u_color:new Ai(e,t.u_color)}),n5=(e,t)=>({u_opacity:new U(e,t.u_opacity),u_image:new H(e,t.u_image),u_pattern_tl_a:new ce(e,t.u_pattern_tl_a),u_pattern_br_a:new ce(e,t.u_pattern_br_a),u_pattern_tl_b:new ce(e,t.u_pattern_tl_b),u_pattern_br_b:new ce(e,t.u_pattern_br_b),u_texsize:new ce(e,t.u_texsize),u_mix:new U(e,t.u_mix),u_pattern_size_a:new ce(e,t.u_pattern_size_a),u_pattern_size_b:new ce(e,t.u_pattern_size_b),u_scale_a:new U(e,t.u_scale_a),u_scale_b:new U(e,t.u_scale_b),u_pixel_coord_upper:new ce(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new ce(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new U(e,t.u_tile_units_to_pixels)}),s5=(e,t)=>({u_opacity:e,u_color:t}),o5=(e,t,r,i,a)=>W(v3(r,a,t,i),{u_opacity:e}),l5=(e,t)=>({u_sun_pos:new jt(e,t.u_sun_pos),u_atmosphere_blend:new U(e,t.u_atmosphere_blend),u_globe_position:new jt(e,t.u_globe_position),u_globe_radius:new U(e,t.u_globe_radius),u_inv_proj_matrix:new Cr(e,t.u_inv_proj_matrix)}),u5=(e,t,r,i,a)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:r,u_globe_radius:i,u_inv_proj_matrix:a}),h5=(e,t)=>({u_sky_color:new Ai(e,t.u_sky_color),u_horizon_color:new Ai(e,t.u_horizon_color),u_horizon:new ce(e,t.u_horizon),u_horizon_normal:new ce(e,t.u_horizon_normal),u_sky_horizon_blend:new U(e,t.u_sky_horizon_blend),u_sky_blend:new U(e,t.u_sky_blend),u_inv_proj_matrix:new Cr(e,t.u_inv_proj_matrix),u_globe_position:new jt(e,t.u_globe_position),u_globe_radius:new U(e,t.u_globe_radius),u_atmosphere_blend:new U(e,t.u_atmosphere_blend)}),c5=(e,t,r)=>{let i=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),n=Nn(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition,o=W1(t),l=Ja(t.worldSize,t.center.lat);return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-n*a)*r,(t.height/2+n*i)*r],u_horizon_normal:[-a,i],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*r,u_sky_blend:s,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:o,u_globe_radius:l,u_atmosphere_blend:e.properties.get("atmosphere-blend")*H1(Sr(o)-l,l)}},go=(e,t)=>({}),d5={fillExtrusion:b3,fillExtrusionPattern:w3,fill:D3,fillPattern:S3,fillOutline:E3,fillOutlinePattern:P3,circle:M3,collisionBox:go,collisionCircle:go,debug:F3,depth:go,clippingMask:go,heatmap:R3,heatmapTexture:k3,hillshade:L3,hillshadePrepare:B3,colorRelief:V3,line:U3,lineGradient:G3,linePattern:q3,lineSDF:Z3,lineGradientSDF:W3,layerOpacity:J3,raster:DI,symbolIcon:e5,symbolSDF:t5,symbolTextAndIcon:r5,background:a5,backgroundPattern:n5,terrain:o3,terrainDepth:l3,atmosphere:l5,sky:h5};var p5=class{constructor(e,t,r){this.context=e;let i=e.gl;this.buffer=i.createBuffer(),this.dynamicDraw=!!r,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}};const yg={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var f5=class{constructor(e,t,r,i){this.length=t.length,this.attributes=r,this.itemSize=t.bytesPerElement,this.dynamicDraw=i,this.context=e;let a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let r of this.attributes){let i=t.attributes[r.name];i!==void 0&&e.enableVertexAttribArray(i.location)}}setVertexAttribPointers(e,t,r){for(let i of this.attributes){let a=t.attributes[i.name];if(a!==void 0){let n=i.offset+this.itemSize*(r||0);a.isInteger?e.vertexAttribIPointer(a.location,i.components,e[yg[i.type]],this.itemSize,n):e.vertexAttribPointer(a.location,i.components,e[yg[i.type]],!1,this.itemSize,n)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Re=class{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}},m5=class extends Re{getDefault(){return se.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},g5=class extends Re{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},_5=class extends Re{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},y5=class extends Re{getDefault(){return[!0,!0,!0,!0]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},x5=class extends Re{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},v5=class extends Re{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},b5=class extends Re{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}},w5=class extends Re{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}},T5=class extends Re{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}},D5=class extends Re{getDefault(){return[0,1]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}},S5=class extends Re{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}},E5=class extends Re{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},P5=class extends Re{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}},A5=class extends Re{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}},C5=class extends Re{getDefault(){return se.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},I5=class extends Re{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},M5=class extends Re{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}},z5=class extends Re{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},F5=class extends Re{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},R5=class extends Re{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},k5=class extends Re{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},L5=class extends Re{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},B5=class extends Re{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}},O5=class extends Re{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},$5=class extends Re{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}},j5=class extends Re{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},V5=class extends Re{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},N5=class extends Re{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},U5=class extends Re{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}},G5=class extends Re{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}},q5=class extends Re{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}},tp=class extends Re{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},Z5=class extends tp{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}},W5=class extends tp{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},H5=class extends tp{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},X5=class{constructor(e,t,r,i,a){this.context=e,this.width=t,this.height=r;let n=e.gl,s=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new Z5(e,s),i)this.depthAttachment=a?new H5(e,s):new W5(e,s);else if(a)throw Error("Stencil cannot be set without depth")}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let r=this.depthAttachment.get();r&&e.deleteRenderbuffer(r)}e.deleteFramebuffer(this.framebuffer)}};const cx=Jd([{name:"u_units_to_pixels",type:"vec2"},{name:"u_world_size",type:"vec2"},{name:"u_camera_to_center_distance",type:"float"},{name:"u_symbol_fade_change",type:"float"},{name:"u_aspect_ratio",type:"float"},{name:"u_device_pixel_ratio",type:"float"},{name:"u_viewport_size",type:"vec2"},{name:"u_pixel_extrude_scale",type:"vec2"},{name:"u_pitch",type:"float"}]),Jt=cx.offsets;function Y5(e){return new Qd(e,Gl.FrameUBO,cx)}function K5(e,t){let r=e.pending,{transform:i}=t,a=t.context.gl;r[Jt.u_units_to_pixels]=1/i.pixelsToGLUnits[0],r[Jt.u_units_to_pixels+1]=1/i.pixelsToGLUnits[1],r[Jt.u_world_size]=a.drawingBufferWidth,r[Jt.u_world_size+1]=a.drawingBufferHeight,r[Jt.u_camera_to_center_distance]=i.cameraToCenterDistance,r[Jt.u_symbol_fade_change]=t.options.fadeDuration?t.symbolFadeChange:1,r[Jt.u_aspect_ratio]=i.width/i.height,r[Jt.u_device_pixel_ratio]=t.pixelRatio,r[Jt.u_viewport_size]=i.width,r[Jt.u_viewport_size+1]=i.height,r[Jt.u_pixel_extrude_scale]=1/i.width,r[Jt.u_pixel_extrude_scale+1]=1/i.height,r[Jt.u_pitch]=i.pitch/360*2*Math.PI,e.upload()}var tt=class{constructor(e,t,r){this.blendFunction=e,this.blendColor=t,this.mask=r}};tt.Replace=[1,0],tt.disabled=new tt(tt.Replace,se.transparent,[!1,!1,!1,!1]),tt.unblended=new tt(tt.Replace,se.transparent,[!0,!0,!0,!0]),tt.alphaBlended=new tt([1,771],se.transparent,[!0,!0,!0,!0]);var J5=class{constructor(e){this.gl=e,this.clearColor=new m5(this),this.clearDepth=new g5(this),this.clearStencil=new _5(this),this.colorMask=new y5(this),this.depthMask=new x5(this),this.stencilMask=new v5(this),this.stencilFunc=new b5(this),this.stencilOp=new w5(this),this.stencilTest=new T5(this),this.depthRange=new D5(this),this.depthTest=new S5(this),this.depthFunc=new E5(this),this.blend=new P5(this),this.blendFunc=new A5(this),this.blendColor=new C5(this),this.blendEquation=new I5(this),this.cullFace=new M5(this),this.cullFaceSide=new z5(this),this.frontFace=new F5(this),this.program=new R5(this),this.activeTexture=new k5(this),this.viewport=new L5(this),this.bindFramebuffer=new B5(this),this.bindRenderbuffer=new O5(this),this.bindTexture=new $5(this),this.bindVertexBuffer=new j5(this),this.bindElementBuffer=new V5(this),this.bindVertexArray=new N5(this),this.pixelStoreUnpack=new U5(this),this.pixelStoreUnpackPremultiplyAlpha=new G5(this),this.pixelStoreUnpackFlipY=new q5(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),e.getExtension("EXT_color_buffer_half_float"),e.getExtension("EXT_color_buffer_float"),this.boundUniformBuffers=[],this.projectionUniformBuffer=tx(this),this.keyedProjectionUniformBuffers=new Map,this.freeProjectionUniformBuffers=[],this.terrainUniformBuffer=g3(this),this.frameUniformBuffer=Y5(this)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0,this.boundUniformBuffers=[]}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(e,t){return new p5(this,e,t)}createVertexBuffer(e,t,r){return new f5(this,e,t,r)}createRenderbuffer(e,t,r){let i=this.gl,a=i.createRenderbuffer();return this.bindRenderbuffer.set(a),i.renderbufferStorage(i.RENDERBUFFER,e,t,r),this.bindRenderbuffer.set(null),a}createFramebuffer(e,t,r,i){return new X5(this,e,t,r,i)}clear({color:e,depth:t,stencil:r}){let i=this.gl,a=0;e&&(a|=i.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(a|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),r!==void 0&&(a|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),i.clear(a)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func===this.gl.ALWAYS&&!e.mask?this.depthTest.set(!1):(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range))}setStencilMode(e){e.test.func===this.gl.ALWAYS&&!e.mask?this.stencilTest.set(!1):(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask}))}setColorMode(e){Or(e.blendFunction,tt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){return this.gl.createVertexArray()}deleteVertexArray(e){this.gl.deleteVertexArray(e)}unbindVAO(){this.bindVertexArray.set(null)}},me=class{constructor(e,t,r){this.func=e,this.mask=t,this.range=r}};me.ReadOnly=!1,me.ReadWrite=!0,me.disabled=new me(519,me.ReadOnly,[0,1]);const eh=7680;var Ae=class{constructor(e,t,r,i,a,n){this.test=e,this.ref=t,this.mask=r,this.fail=i,this.depthFail=a,this.pass=n}};Ae.disabled=new Ae({func:519,mask:0},0,0,eh,eh,eh);const xg=1029,th=2305;var Se=class{constructor(e,t,r){this.enable=e,this.mode=t,this.frontFace=r}};Se.disabled=new Se(!1,xg,th),Se.backCCW=new Se(!0,xg,th),Se.frontCCW=new Se(!0,1028,th);function Q5(e,t,r){let i=(t==null?void 0:t.transitionState)??0;return{currentPass:"offscreen",currentLayer:0,opaquePassCutoff:1/0,depthRangeFor3D:[0,1],isRenderingToTexture:!1,transform:e,terrain:r,projectionTransition:i,isRenderingGlobe:i>0}}function Ft(e,t,r={}){let i=e.transform.getProjectionData({overscaledTileID:t,aligned:r.aligned,applyGlobeMatrix:!e.isRenderingToTexture,applyTerrainMatrix:r.applyTerrainMatrix??!0});return e.isRenderingToTexture||(i.uniformBufferKey=r.aligned?`${t.key}/aligned`:t.key),i}function Vt(e,t){var r;return e.isRenderingToTexture?null:((r=e.terrain)==null?void 0:r.getTerrainData(t))??null}let _o;function vg(e,t,r,i,a,n){let s=e.context,o=s.gl,l=e.useProgram("collisionBox"),u=[],h=0,c=0;for(let _ of i){let y=t.getTile(_).getBucket(r);if(!y)continue;let v=a?y.textCollisionBox:y.iconCollisionBox,x=y.collisionCircleArray;x.length>0&&(u.push({circleArray:x,circleOffset:c,coord:_}),h+=x.length/4,c=h),v&&l.draw(s,o.LINES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),Se.disabled,null,Vt(n,_),Ft(n,_),r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,e.transform.zoom,null,null,v.collisionVertexBuffer)}if(!a||!u.length)return;let d=e.useProgram("collisionCircle"),p=new K2;p.resize(h*4),p._trim();let f=0;for(let _ of u)for(let y=0;y<_.circleArray.length/4;y++){let v=y*4,x=_.circleArray[v+0],w=_.circleArray[v+1],b=_.circleArray[v+2],T=_.circleArray[v+3];p.emplace(f++,x,w,b,T,0),p.emplace(f++,x,w,b,T,1),p.emplace(f++,x,w,b,T,2),p.emplace(f++,x,w,b,T,3)}(!_o||_o.length<h*2)&&(_o=ez(h));let m=s.createIndexBuffer(_o,!0),g=s.createVertexBuffer(p,_D.members,!0);for(let _ of u)d.draw(s,o.TRIANGLES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),Se.disabled,null,Vt(n,_.coord),null,r.id,g,m,Ze.simpleSegment(0,_.circleOffset*2,_.circleArray.length,_.circleArray.length/2),null,e.transform.zoom,null,null,null);g.destroy(),m.destroy()}function ez(e){let t=e*2,r=new Q2;r.resize(t),r._trim();for(let i=0;i<t;i++){let a=i*6;r.uint16[a+0]=i*4+0,r.uint16[a+1]=i*4+1,r.uint16[a+2]=i*4+2,r.uint16[a+3]=i*4+2,r.uint16[a+4]=i*4+3,r.uint16[a+5]=i*4+0}return r}const tz=Ar(new Float32Array(16));function rz(e,t,r,i,a,n){if(n.currentPass!=="translucent")return;let s=Ae.disabled,o=e.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&az(i,e,r,t,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),a),r.paint.get("icon-opacity").constantOr(1)!==0&&bg(e,t,r,i,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment").constantOr("viewport"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),s,o,n),r.paint.get("text-opacity").constantOr(1)!==0&&bg(e,t,r,i,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),s,o,n),t.map.showCollisionBoxes&&(vg(e,t,r,i,!0,n),vg(e,t,r,i,!1,n))}function iz(e,t,r,i,a,n){let{horizontalAlign:s,verticalAlign:o}=$l(e),l=-(s-.5)*t,u=-(o-.5)*r;return new C((l/a+i[0])*n,(u/a+i[1])*n)}function az(e,t,r,i,a,n,s,o,l){var p;let u=t.transform,h=t.style.map.terrain,c=a==="map",d=n==="map";for(let f of e){let m=i.getTile(f),g=m.getBucket(r);if(!((p=g==null?void 0:g.text)!=null&&p.segments.get().length))continue;let _=g.textSizeData,y=jl(_,u.zoom),v=nr(m,1,t.transform.zoom),x=Zd(c,t.transform,v),w=r.layout.get("icon-text-fit")!=="none"&&g.hasIconData();if(y){let b=2**(u.zoom-m.tileID.overscaledZ),T=h?(P,S)=>h.getElevation(f,P,S):void 0;sz(g,c,d,l,u,x,b,y,w,Di(u,m,s,o),f.toUnwrapped(),T,r.layout.get("symbol-height-anchor")==="ground")}}}function nz(e,t,r,i,a,n){let s=t.tileAnchorPoint.add(new C(t.translation[0],t.translation[1]));if(t.pitchWithMap){let o=i.mult(n);r||(o=o.rotate(-a));let l=s.add(o);return Hd(l.x,l.y,t.pitchedLabelPlaneMatrix,ta(t,l.x,l.y)).point}if(r){let o=ra(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),l=Math.atan(o.y/o.x)+(o.x<0?Math.PI:0);return e.add(i.rotate(l))}return e.add(i)}function sz(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,g={};f.clear();for(let _=0;_<p.length;_++){let y=p.get(_),v=e.allowVerticalPlacement&&!y.placedOrientation,x=!y.hidden&&y.crossTileID&&!v?i[y.crossTileID]:null;if(!x)ja(y.numGlyphs,f);else{let w=new C(y.anchorX,y.anchorY),b={getElevation:c,heightOffset:y.heightOffset,heightAnchorGround:d,width:a.width,height:a.height,pitchedLabelPlaneMatrix:n,pitchWithMap:r,transform:a,tileAnchorPoint:w,translation:u,unwrappedTileID:h},T=r?z1(w.x,w.y,b):ra(w.x,w.y,b),P=C1(a.cameraToCenterDistance,T.signedDistanceFromCamera),S=Sd(e.textSizeData,o,y)*P/24;r&&(S*=e.tilePixelRatio/s);let{width:I,height:R,anchor:F,textOffset:D,textBoxScale:A}=x,E=iz(F,I,R,D,A,S),z=a.getPitchedTextCorrection(w.x+u[0],w.y+u[1],h),L=nz(T.point,b,t,E,-a.bearingInRadians,z),B=e.allowVerticalPlacement&&y.placedOrientation===2?Math.PI/2:0;for(let V=0;V<y.numGlyphs;V++)nl(f,L,B);l&&y.associatedIconIndex>=0&&(g[y.associatedIconIndex]={shiftedAnchor:L,angle:B})}}if(l){m.clear();let _=e.icon.placedSymbolArray;for(let y=0;y<_.length;y++){let v=_.get(y);if(v.hidden)ja(v.numGlyphs,m);else{let x=g[y];if(!x)ja(v.numGlyphs,m);else for(let w=0;w<v.numGlyphs;w++)nl(m,x.shiftedAnchor,x.angle)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function oz(e,t,r){return r.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function bg(e,t,r,i,a,n,s,o,l,u,h,c,d){let p=e.context,f=p.gl,m=e.transform,g=o==="map",_=l==="map",y=o!=="viewport"&&r.layout.get("symbol-placement")!=="point",v=g&&!_&&!y,x=!r.layout.get("symbol-sort-key").isConstant(),w=!1,b=e.getDepthModeForSublayer(0,me.ReadOnly),T=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),P=[],S=m.getCircleRadiusCorrection();for(let F of i){let D=t.getTile(F),A=D.getBucket(r);if(!A)continue;let E=a?A.text:A.icon;if(!(E!=null&&E.segments.get().length)||!E.hasVisibleVertices)continue;let z=E.programConfigurations.get(r.id),L=a||A.sdfIcons,B=a?A.textSizeData:A.iconSizeData,V=_||m.pitch!==0,Q=e.useProgram(oz(L,a,A),z),le=jl(B,m.zoom),De=Vt(d,F),pe,Be=[0,0],xe,Ue,Ee=null,pt;if(a){if(xe=D.glyphAtlasTexture,Ue=f.LINEAR,pe=D.glyphAtlasTexture.size,A.iconsInText){Be=D.imageAtlasTexture.size,Ee=D.imageAtlasTexture;let q=B.kind==="composite"||B.kind==="camera";pt=V||e.options.rotating||e.options.zooming||q?f.LINEAR:f.NEAREST}}else{let q=r.layout.get("icon-size").constantOr(0)!==1||A.iconsNeedLinear;xe=D.imageAtlasTexture,Ue=L||e.options.rotating||e.options.zooming||q||V?f.LINEAR:f.NEAREST,pe=D.imageAtlasTexture.size}let yt=nr(D,1,e.transform.zoom),Nt=Zd(g,e.transform,yt),Ut=lM(_,g,e.transform,yt),Tt=Di(m,D,n,s),nt=Ft(d,F),Yt=T&&A.hasTextData(),vr=r.layout.get("icon-text-fit")!=="none"&&Yt&&A.hasIconData(),sr=r._unevaluatedLayout.hasValue("icon-offset"),Z=r.layout.get("symbol-height-anchor")==="ground";if(y){let q=Ci();aM(q,Nt);let be=e.style.map.terrain?(we,ae)=>e.style.map.terrain.getElevation(F,we,ae):void 0;hM(A,e,a,Nt,q,_,u,r.layout.get("text-rotation-alignment")==="map",F.toUnwrapped(),m.width,m.height,Tt,be)}let ge=a&&T||vr,re=_?Nt:e.transform.clipSpaceToPixelsMatrix,$=y||ge?tz:re,ye=L&&r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1)!==0,ee;ee=L?A.iconsInText?i5(B.kind,le,v,_,y,ge,e,$,Ut,Tt,pe,Be,S,sr,Z):hx(B.kind,le,v,_,y,ge,e,$,Ut,Tt,a,pe,ye,S,sr,Z):ux(B.kind,le,v,_,y,ge,e,$,Ut,Tt,a,pe,S,sr,Z);let ie={program:Q,buffers:E,uniformValues:ee,projectionData:nt,atlasTexture:xe,atlasTextureIcon:Ee,atlasInterpolation:Ue,atlasInterpolationIcon:pt,isSDF:L,hasHalo:ye};if(x&&A.canOverlap){w=!0;let q=E.segments.get();for(let be of q)P.push({segments:new Ze([be]),sortKey:be.sortKey,state:ie,terrainData:De})}else P.push({segments:E.segments,sortKey:0,state:ie,terrainData:De})}w&&P.sort((F,D)=>F.sortKey-D.sortKey);let I=r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,R=r.layout.get("text-letter-spacing").constantOr(0)*24<0||I>1;for(let F of P){let D=F.state;p.activeTexture.set(f.TEXTURE0),D.atlasTexture.bind(D.atlasInterpolation,f.CLAMP_TO_EDGE),D.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),D.atlasTextureIcon&&D.atlasTextureIcon.bind(D.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let A=D.isSDF&&D.hasHalo;if(A){let E=D.uniformValues;E.u_is_halo=1,R&&(E.u_is_plain=0,wg(D.buffers,F.segments,r,e,D.program,b,h,c,E,D.projectionData,F.terrainData),E.u_is_halo=0,E.u_is_plain=1)}wg(D.buffers,F.segments,r,e,D.program,b,h,c,D.uniformValues,D.projectionData,F.terrainData),A&&!R&&(D.uniformValues.u_is_halo=0)}}function wg(e,t,r,i,a,n,s,o,l,u,h){let c=i.context,d=c.gl;a.draw(c,d.TRIANGLES,n,s,o,Se.backCCW,l,h,u,r.id,e.layoutVertexBuffer,e.indexBuffer,t,r.paint,i.transform.zoom,e.programConfigurations.get(r.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function lz(e,t,r,i,a){if(a.currentPass!=="translucent")return;let n=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),o=r.paint.get("circle-stroke-opacity"),l=!r.layout.get("circle-sort-key").isConstant();if(n.constantOr(1)===0&&(s.constantOr(1)===0||o.constantOr(1)===0))return;let u=e.context,h=u.gl,c=e.transform,d=e.getDepthModeForSublayer(0,me.ReadOnly),p=Ae.disabled,f=e.colorModeForRenderPass(),m=[],g=c.getCircleRadiusCorrection();for(let _ of i){let y=t.getTile(_),v=y.getBucket(r);if(!v)continue;let x=r.paint.get("circle-translate"),w=r.paint.get("circle-translate-anchor"),b=Di(c,y,x,w),T=v.programConfigurations.get(r.id),P=e.useProgram("circle",T),S=v.layoutVertexBuffer,I=v.indexBuffer,R=Vt(a,_),F={programConfiguration:T,program:P,layoutVertexBuffer:S,indexBuffer:I,uniformValues:z3(e,y,r,b,g),terrainData:R,projectionData:Ft(a,_)};if(l){let D=v.segments.get();for(let A of D)m.push({segments:new Ze([A]),sortKey:A.sortKey,state:F})}else m.push({segments:v.segments,sortKey:0,state:F})}l&&m.sort((_,y)=>_.sortKey-y.sortKey);for(let _ of m){let{programConfiguration:y,program:v,layoutVertexBuffer:x,indexBuffer:w,uniformValues:b,terrainData:T,projectionData:P}=_.state,S=_.segments;v.draw(u,h.TRIANGLES,d,p,f,Se.backCCW,b,T,P,r.id,x,w,S,r.paint,e.transform.zoom,y)}}function uz(e,t,r,i,a){if(r.paint.get("heatmap-opacity")===0)return;let n=e.context;if(e.style.map.terrain){for(let s of i){let o=t.getTile(s);t.hasRenderableParent(s)||(a.currentPass==="offscreen"?dz(e,o,r,s,a):a.currentPass==="translucent"&&pz(e,r,s,a))}n.viewport.set([0,0,e.width,e.height])}else a.currentPass==="offscreen"?hz(e,t,r,i,a):a.currentPass==="translucent"&&cz(e,r)}function hz(e,t,r,i,a){let n=e.context,s=n.gl,o=e.transform,l=Ae.disabled,u=new tt([s.ONE,s.ONE],se.transparent,[!0,!0,!0,!0]);fz(n,e,r),n.clear({color:se.transparent});for(let h of i){if(t.hasRenderableParent(h))continue;let c=t.getTile(h),d=c.getBucket(r);if(!d)continue;let p=d.programConfigurations.get(r.id),f=e.useProgram("heatmap",p),m=Ft(a,h,{applyTerrainMatrix:!1}),g=o.getCircleRadiusCorrection();f.draw(n,s.TRIANGLES,me.disabled,l,u,Se.backCCW,sx(c,o.zoom,r.paint.get("heatmap-intensity"),g),null,m,r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,o.zoom,p)}n.viewport.set([0,0,e.width,e.height])}function cz(e,t){let r=e.context,i=r.gl;r.setColorMode(e.colorModeForRenderPass());let a=t.heatmapFbos.get(Ko);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),px(r,t).bind(i.LINEAR,i.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(r,i.TRIANGLES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),Se.disabled,ox(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom))}function dz(e,t,r,i,a){let n=e.context,s=n.gl,o=Ae.disabled,l=new tt([s.ONE,s.ONE],se.transparent,[!0,!0,!0,!0]),u=t.getBucket(r);if(!u)return;let h=i.key,c=r.heatmapFbos.get(h);c||(c=dx(n,t.tileSize,t.tileSize),r.heatmapFbos.set(h,c)),n.bindFramebuffer.set(c.framebuffer),n.viewport.set([0,0,t.tileSize,t.tileSize]),n.clear({color:se.transparent});let d=u.programConfigurations.get(r.id),p=e.useProgram("heatmap",d,!a.isRenderingGlobe),f=Ft(a,t.tileID),m=Vt(a,i);p.draw(n,s.TRIANGLES,me.disabled,o,l,Se.disabled,sx(t,e.transform.zoom,r.paint.get("heatmap-intensity"),1),m,f,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,d)}function pz(e,t,r,i){let a=e.context,n=a.gl,s=e.transform;a.setColorMode(e.colorModeForRenderPass());let o=px(a,t),l=r.key,u=t.heatmapFbos.get(l);if(!u)return;a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,u.colorAttachment.get()),a.activeTexture.set(n.TEXTURE1),o.bind(n.LINEAR,n.CLAMP_TO_EDGE);let h=Ft(i,r,{applyTerrainMatrix:i.isRenderingGlobe});e.useProgram("heatmapTexture").draw(a,n.TRIANGLES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),Se.disabled,ox(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,s.zoom),u.destroy(),t.heatmapFbos.delete(l)}function fz(e,t,r){let i=e.gl;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let a=r.heatmapFbos.get(Ko);a?(i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=dx(e,t.width/4,t.height/4),r.heatmapFbos.set(Ko,a))}function dx(e,t,r){let i=e.gl,a=i.createTexture();i.bindTexture(i.TEXTURE_2D,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texStorage2D(i.TEXTURE_2D,1,i.RGBA16F,t,r);let n=e.createFramebuffer(t,r,!1,!1);return n.colorAttachment.set(a),n}function px(e,t){return t.colorRampTexture||(t.colorRampTexture=new dt(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function fx(e,t,r){let i=e.context,a=i.bindFramebuffer.get(),n=i.viewport.get(),[,,s,o]=n;return mz(e,s,o),i.viewport.set([0,0,s,o]),i.clear({color:se.transparent,depth:1,stencil:0}),e.currentStencilSource=void 0,e.renderTileClippingMasks(t,r),{compositeTarget:a,compositeViewport:n}}function mz(e,t,r){let i=e.context.gl;if(!e.layerOpacityFbo){let n=e.context.createFramebuffer(t,r,!0,!0),s=i.createTexture();i.bindTexture(i.TEXTURE_2D,s),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,r,0,i.RGBA,i.UNSIGNED_BYTE,null),n.colorAttachment.set(s),n.depthAttachment.set(e.context.createRenderbuffer(i.DEPTH_STENCIL,t,r)),e.layerOpacityFbo=n,e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}if(e.layerOpacityFbo.width===t&&e.layerOpacityFbo.height===r){e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}let a=e.layerOpacityFbo;i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,r,0,i.RGBA,i.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(a.depthAttachment.get()),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,t,r),e.context.bindRenderbuffer.set(null),a.width=t,a.height=r,e.context.bindFramebuffer.set(a.framebuffer)}function mx(e,t,r,i){let a=e.context,n=a.gl;a.bindFramebuffer.set(r.compositeTarget),a.viewport.set(r.compositeViewport),a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),e.useProgram("layerOpacity").draw(a,n.TRIANGLES,me.disabled,Ae.disabled,e.colorModeForRenderPass(),Se.disabled,Q3(t,0),null,null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom),e.currentStencilSource=void 0}function gx(e,t,r,i,a,n,s,o){let l=256;if(a.stepInterpolant){let u=t.getSource().maxzoom,h=s.canonical.z===u?Math.ceil(1<<e.transform.maxZoom-s.canonical.z):1,c=n.maxLineLength/k*1024*h;l=ne(mv(c),256,r.maxTextureSize)}return o.gradient=Gy({expression:a.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:o.gradient||void 0,clips:n.lineClipsArray}),o.texture?o.texture.update(o.gradient):o.texture=new dt(r,o.gradient,i.RGBA),o.version=a.gradientVersion,o.texture}function gz(e,t,r,i,a){e.activeTexture.set(t.TEXTURE0),r.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),i.updatePaintBuffers(a)}function _z(e,t,r,i,a,n){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(r.TEXTURE0),e.lineAtlas.bind(t)),i.updatePaintBuffers(n)}function yz(e,t,r,i,a,n,s){let o=n.gradients[a.id],l=o.texture;a.gradientVersion!==o.version&&(l=gx(e,t,r,i,a,n,s,o)),r.activeTexture.set(i.TEXTURE0),l.bind(a.stepInterpolant?i.NEAREST:i.LINEAR,i.CLAMP_TO_EDGE)}function xz(e,t,r,i,a,n,s,o,l){let u=n.gradients[a.id],h=u.texture;a.gradientVersion!==u.version&&(h=gx(e,t,r,i,a,n,s,u)),r.activeTexture.set(i.TEXTURE0),h.bind(a.stepInterpolant?i.NEAREST:i.LINEAR,i.CLAMP_TO_EDGE),r.activeTexture.set(i.TEXTURE1),e.lineAtlas.bind(r),o.updatePaintBuffers(l)}function vz(e,t,r,i,a){if(a.currentPass!=="translucent")return;let n=r.paint.get("line-opacity"),s=r.paint.get("line-width"),o=r.paint.get("line-layer-opacity");if(n.constantOr(1)!==0&&s.constantOr(1)!==0&&o!==0){if(o<1){let l=fx(e,r,i);Tg(e,t,r,i,a),mx(e,o,l,r);return}Tg(e,t,r,i,a)}}function Tg(e,t,r,i,a){let n=e.getDepthModeForSublayer(0,me.ReadOnly),s=e.colorModeForRenderPass(),o=r.paint.get("line-dasharray"),l=o.constantOr(1),u=r.paint.get("line-pattern"),h=u.constantOr(1),c=r.paint.get("line-gradient"),d=r.getCrossfadeParameters(),p;p=h?"linePattern":l&&c?"lineGradientSDF":l?"lineSDF":c?"lineGradient":"line";let f=e.context,m=f.gl,g=e.transform,_=!0;for(let y of i){let v=t.getTile(y);if(h&&!v.patternsLoaded())continue;let x=v.getBucket(r);if(!x)continue;let w=x.programConfigurations.get(r.id),b=e.context.program.get(),T=e.useProgram(p,w),P=_||T.program!==b,S=Vt(a,y),I=u.constantOr(null),R=o==null?void 0:o.constantOr(null);if(I&&v.imageAtlas){let z=v.imageAtlas,L=z.patternPositions[I.to.toString()],B=z.patternPositions[I.from.toString()];L&&B&&w.setConstantPatternPositions(L,B)}else if(R){let z=r.layout.get("line-cap").constantOr(null)==="round",L=e.lineAtlas.getDash(R.to,z),B=e.lineAtlas.getDash(R.from,z);w.setConstantDashPositions(L,B)}let F=Ft(a,y),D=g.getPixelScale(),A;h?(A=X3(e,v,r,D,d),gz(f,m,v,w,d)):l&&c?(A=K3(e,v,r,D,d,x.lineClipsArray.length),xz(e,t,f,m,r,x,y,w,d)):l?(A=Y3(e,v,r,D,d),_z(e,f,m,w,P,d)):c?(A=H3(e,v,r,D,x.lineClipsArray.length),yz(e,t,f,m,r,x,y)):A=ql(e,v,r,D);let E=e.stencilModeForClipping(y);T.draw(f,m.TRIANGLES,n,E,s,Se.disabled,A,S,F,r.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,r.paint,e.transform.zoom,w,x.layoutVertexBuffer2),_=!1}}function _x(e,t,r,i,a){if(!r||!(i!=null&&i.imageAtlas))return;let n=i.imageAtlas.patternPositions,s=n[r.to.toString()],o=n[r.from.toString()];if(!s&&o&&(s=o),!o&&s&&(o=s),!s||!o){let l=a.getPaintProperty(t);s=n[l],o=n[l]}s&&o&&e.setConstantPatternPositions(s,o)}function bz(e,t,r,i,a){let n=r.paint.get("fill-color"),s=r.paint.get("fill-opacity"),o=r.paint.get("fill-layer-opacity");if(s.constantOr(1)===0||o===0)return;if(o<1){if(a.currentPass!=="translucent")return;let h=fx(e,r,i);Dg(e,t,r,i,a),mx(e,o,h,r);return}let l=r.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&n.constantOr(se.transparent).a===1&&s.constantOr(0)===1;if(u&&a.currentPass==="opaque"){let h=e.colorModeForRenderPass();rp(e,t,r,i,e.getDepthModeForSublayer(1,me.ReadWrite),h,!1,a);return}if(u&&a.currentPass==="translucent"){yx(e,t,r,i,a);return}a.currentPass==="translucent"&&Dg(e,t,r,i,a)}function Dg(e,t,r,i,a){let n=e.colorModeForRenderPass();rp(e,t,r,i,e.getDepthModeForSublayer(1,me.ReadOnly),n,!1,a),yx(e,t,r,i,a)}function yx(e,t,r,i,a){if(!r.paint.get("fill-antialias"))return;let n=e.colorModeForRenderPass();rp(e,t,r,i,e.getDepthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,me.ReadOnly),n,!0,a)}function rp(e,t,r,i,a,n,s,o){let l=e.context.gl,u="fill-pattern",h=r.paint.get(u),c=h==null?void 0:h.constantOr(1),d=r.getCrossfadeParameters(),p,f,m,g,_,y=e.transform,v=r.paint.get("fill-translate"),x=r.paint.get("fill-translate-anchor");s?(f=c&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(f=c?"fillPattern":"fill",p=l.TRIANGLES);let w=h.constantOr(null);for(let b of i){let T=t.getTile(b);if(c&&!T.patternsLoaded())continue;let P=T.getBucket(r);if(!P)continue;let S=P.sdfPatterns[r.id]??!1,I=P.programConfigurations.get(r.id),R=e.useProgram(f,I),F=Vt(o,b);c&&(e.context.activeTexture.set(l.TEXTURE0),T.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),I.updatePaintBuffers(d)),_x(I,u,w,T,r);let D=Ft(o,b),A=Di(y,T,v,x);s?(g=P.indexBuffer2,_=P.segments2,m=f==="fillOutlinePattern"&&c?I3(e,d,T,A,S):C3(A)):(g=P.indexBuffer,_=P.segments,m=c?nx(e,d,T,A,S):A3(A));let E=e.stencilModeForClipping(b);R.draw(e.context,p,a,E,n,Se.backCCW,m,F,D,r.id,P.layoutVertexBuffer,g,_,r.paint,e.transform.zoom,I)}}function wz(e,t,r,i,a){let n=r.paint.get("fill-extrusion-opacity");if(n!==0&&a.currentPass==="translucent"){let s=new me(e.context.gl.LEQUAL,me.ReadWrite,a.depthRangeFor3D);if(n===1&&!r.paint.get("fill-extrusion-pattern").constantOr(1)){let o=e.colorModeForRenderPass();rh(e,t,r,i,s,Ae.disabled,o,a)}else rh(e,t,r,i,s,Ae.disabled,tt.disabled,a),rh(e,t,r,i,s,e.stencilModeFor3D(),e.colorModeForRenderPass(),a)}}function rh(e,t,r,i,a,n,s,o){let l=e.context,u=l.gl,h="fill-extrusion-pattern",c=r.paint.get(h),d=c.constantOr(1),p=r.getCrossfadeParameters(),f=r.paint.get("fill-extrusion-opacity"),m=c.constantOr(null),g=e.transform;for(let _ of i){let y=t.getTile(_),v=y.getBucket(r);if(!v)continue;let x=Vt(o,_),w=v.programConfigurations.get(r.id),b=e.useProgram(d?"fillExtrusionPattern":"fillExtrusion",w);d&&(e.context.activeTexture.set(u.TEXTURE0),y.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),w.updatePaintBuffers(p));let T=Ft(o,_);_x(w,h,m,y,r);let P=Di(g,y,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),S=r.paint.get("fill-extrusion-vertical-gradient"),I=d?T3(e,S,f,P,_,p,y):ax(e,S,f,P);b.draw(l,l.gl.TRIANGLES,a,n,s,Se.backCCW,I,x,T,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,w,e.style.map.terrain&&v.centroidVertexBuffer)}}function Tz(e,t,r,i,a){if(a.currentPass!=="offscreen"&&a.currentPass!=="translucent")return;let n=e.context,s=e.style.projection.useSubdivision,o=e.getDepthModeForSublayer(0,me.ReadOnly),l=e.colorModeForRenderPass();if(a.currentPass==="offscreen")Dz(e,t,i,r,o,Ae.disabled,l),n.viewport.set([0,0,e.width,e.height]);else if(a.currentPass==="translucent")if(s){let[u,h,c]=e.stencilConfigForOverlapTwoPass(i);ih(e,t,r,c,u,o,l,!1,a),ih(e,t,r,c,h,o,l,!0,a)}else{let[u,h]=e.getStencilConfigForOverlapAndUpdateStencilID(i);ih(e,t,r,h,u,o,l,!1,a)}}function ih(e,t,r,i,a,n,s,o,l){let u=e.style.projection,h=e.context,c=h.gl,d=[`#define NUM_ILLUMINATION_SOURCES ${r.paint.get("hillshade-highlight-color").values.length}`],p=e.useProgram("hillshade",null,!1,d),f=!e.options.moving;for(let m of i){let g=t.getTile(m),_=g.fbo;if(!_)continue;let y=u.getMeshFromTileID(h,m.canonical,o,!0,"raster"),v=Vt(l,m);h.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,_.colorAttachment.get());let x=Ft(l,m,{aligned:f});p.draw(h,c.TRIANGLES,n,a[m.overscaledZ],s,Se.backCCW,O3(e,g,r),v,x,r.id,y.vertexBuffer,y.indexBuffer,y.segments)}}function Dz(e,t,r,i,a,n,s){let o=e.context,l=o.gl,u=i.paint.get("resampling")==="nearest"?l.NEAREST:l.LINEAR;for(let h of r){let c=t.getTile(h),d=c.dem;if(!(d!=null&&d.data)||!c.needsHillshadePrepare)continue;let p=d.dim+2,f=d.stride,m=d.getPixels();if(o.activeTexture.set(l.TEXTURE1),o.pixelStoreUnpackPremultiplyAlpha.set(!1),c.demTexture||(c.demTexture=e.getTileTexture(f)),c.demTexture){let _=c.demTexture;_.update(m,{premultiply:!1}),_.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else c.demTexture=new dt(o,m,l.RGBA,{premultiply:!1}),c.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);o.activeTexture.set(l.TEXTURE0);let g=c.fbo;if(!g){let _=new dt(o,{width:p,height:p,data:null},l.RGBA);_.bind(u,l.CLAMP_TO_EDGE),g=c.fbo=o.createFramebuffer(p,p,!0,!1),g.colorAttachment.set(_.texture)}o.bindFramebuffer.set(g.framebuffer),o.viewport.set([0,0,p,p]),e.useProgram("hillshadePrepare").draw(o,l.TRIANGLES,a,n,s,Se.disabled,$3(c.tileID,d),null,null,i.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),c.needsHillshadePrepare=!1}}function Sz(e,t,r,i,a){if(a.currentPass!=="translucent"||!i.length)return;let n=e.style.projection.useSubdivision,s=e.getDepthModeForSublayer(0,me.ReadOnly),o=e.colorModeForRenderPass();if(n){let[l,u,h]=e.stencilConfigForOverlapTwoPass(i);ah(e,t,r,h,l,s,o,!1,a),ah(e,t,r,h,u,s,o,!0,a)}else{let[l,u]=e.getStencilConfigForOverlapAndUpdateStencilID(i);ah(e,t,r,u,l,s,o,!1,a)}}let Sg=0;function ah(e,t,r,i,a,n,s,o,l){let u=e.style.projection,h=e.context,c=h.gl,d=e.useProgram("colorRelief"),p=!e.options.moving,f=r.paint.get("resampling")==="nearest"?c.NEAREST:c.LINEAR,m=!0,g=0;for(let _ of i){let y=t.getTile(_),v=y.dem;if(!(v!=null&&v.data))continue;if(m){Sg||(Sg=c.getParameter(c.MAX_TEXTURE_SIZE));let P=Sg,{elevationTexture:S,colorTexture:I}=r.getColorRampTextures(h,P,v.getUnpackVector());h.activeTexture.set(c.TEXTURE1),S.bind(c.NEAREST,c.CLAMP_TO_EDGE),h.activeTexture.set(c.TEXTURE4),I.bind(c.LINEAR,c.CLAMP_TO_EDGE),m=!1,g=S.size[0]}let x=v.stride;h.activeTexture.set(c.TEXTURE0),(!y.demTexture||y.needsColorReliefPrepare)&&(h.pixelStoreUnpackPremultiplyAlpha.set(!1),y.demTexture||(y.demTexture=e.getTileTexture(x)??new dt(h,{width:x,height:x,data:null},c.RGBA)),y.demTexture.update(v.getPixels(),{premultiply:!1}),y.needsColorReliefPrepare=!1),y.demTexture.bind(f,c.CLAMP_TO_EDGE);let w=u.getMeshFromTileID(h,_.canonical,o,!0,"raster"),b=Vt(l,_),T=Ft(l,_,{aligned:p});d.draw(h,c.TRIANGLES,n,a[_.overscaledZ],s,Se.backCCW,N3(r,y.dem,g),b,T,r.id,w.vertexBuffer,w.indexBuffer,w.segments)}}const nh=[new C(0,0),new C(k,0),new C(k,k),new C(0,k)];function Ez(e,t,r,i,a){if(a.currentPass!=="translucent"||r.paint.get("raster-opacity")===0||!i.length)return;let n=t.getSource(),s=e.style.projection.useSubdivision;if(n instanceof Ts)yo(e,t,r,i,null,!1,!1,n.tileCoords,n.imageWarp,n.flippedWindingOrder,a,n.getMesh(e.context,s));else if(s){let[o,l,u]=e.stencilConfigForOverlapTwoPass(i);yo(e,t,r,u,o,!1,!0,nh,$a,!1,a),yo(e,t,r,u,l,!0,!0,nh,$a,!1,a)}else{let[o,l]=e.getStencilConfigForOverlapAndUpdateStencilID(i);yo(e,t,r,l,o,!1,!0,nh,$a,!1,a)}}function yo(e,t,r,i,a,n,s,o,l,u=!1,h,c=null){let d=i[i.length-1].overscaledZ,p=e.context,f=p.gl,m=e.useProgram("raster"),g=e.style.projection,_=e.colorModeForRenderPass(),y=!e.options.moving,v=r.paint.get("raster-opacity"),x=r.paint.get("resampling")==="nearest"||r.paint.get("raster-resampling")==="nearest"?f.NEAREST:f.LINEAR,w=r.paint.get("raster-fade-duration"),b=!!e.style.map.terrain;for(let T of i){let P=e.getDepthModeForSublayer(T.overscaledZ-d,v===1?me.ReadWrite:me.ReadOnly,f.LESS),S=t.getTile(T);p.activeTexture.set(f.TEXTURE0),S.texture.bind(x,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(f.TEXTURE1);let{parentTile:I,parentScaleBy:R,parentTopLeft:F,fadeValues:D}=Pz(S,t,w,b);S.fadeOpacity=D.tileOpacity,I?(I.fadeOpacity=D.parentTileOpacity,I.texture.bind(x,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):S.texture.bind(x,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),S.texture.useMipmap&&p.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let A=Vt(h,T),E=Ft(h,T,{aligned:y}),z=SI(F,R,D.fadeMix,r,o,l),L=c??g.getMeshFromTileID(p,T.canonical,n,s,"raster"),B=a?a[T.overscaledZ]:Ae.disabled;m.draw(p,f.TRIANGLES,P,B,_,u?Se.frontCCW:Se.backCCW,z,A,E,r.id,L.vertexBuffer,L.indexBuffer,L.segments)}}function Pz(e,t,r,i){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(r===0||i)return a;if(e.fadingParentID){let n=t.getLoadedTile(e.fadingParentID);if(!n)return a;let s=2**(n.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:n,parentScaleBy:s,parentTopLeft:[e.tileID.canonical.x*s%1,e.tileID.canonical.y*s%1],fadeValues:Az(e,n,r)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:Cz(e,r)}:a}function Az(e,t,r){let i=Fe(),a=(i-e.timeAdded)/r,n=(i-t.timeAdded)/r,s=e.fadingDirection===1,o=ne(a,0,1),l=ne(1-n,0,1),u=s?o:l;return{tileOpacity:u,parentTileOpacity:s?l:o,fadeMix:{opacity:1,mix:1-u}}}function Cz(e,t){let r=(Fe()-e.timeAdded)/t,i=ne(r,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}function Iz(e,t,r,i,a){let n=r.paint.get("background-color"),s=r.paint.get("background-opacity");if(s===0)return;let o=e.context,l=o.gl,u=e.style.projection,h=e.transform,c=h.tileSize,d=r.paint.get("background-pattern");if(e.isPatternMissing(d))return;let p=!d&&n.a===1&&s===1&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.currentPass!==p)return;let f=Ae.disabled,m=e.getDepthModeForSublayer(0,p==="opaque"?me.ReadWrite:me.ReadOnly),g=e.colorModeForRenderPass(),_=e.useProgram(d?"backgroundPattern":"background"),y=i||an(h,{tileSize:c,terrain:e.style.map.terrain});d&&(o.activeTexture.set(l.TEXTURE0),e.patternAtlas.bind(e.context));let v=r.getCrossfadeParameters();for(let x of y){let w=Ft(a,x),b=d?o5(s,e,d,{tileID:x,tileSize:c},v):s5(s,n),T=Vt(a,x),P=u.getMeshFromTileID(o,x.canonical,!1,!0,"raster");_.draw(o,l.TRIANGLES,m,f,g,Se.backCCW,b,T,w,r.id,P.vertexBuffer,P.indexBuffer,P.segments)}}const Mz=new se(1,0,0,1),zz=new se(0,1,0,1),Fz=new se(0,0,1,1),Rz=new se(1,0,1,1),kz=new se(0,1,1,1);function Lz(e){let t=e.transform.padding;Eg(e,e.transform.height-(t.top||0),3,Mz),Eg(e,t.bottom||0,3,zz),Pg(e,t.left||0,3,Fz),Pg(e,e.transform.width-(t.right||0),3,Rz);let r=e.transform.centerPoint;Bz(e,r.x,e.transform.height-r.y,kz)}function Bz(e,t,r,i){ml(e,t-1,r-10,2,20,i),ml(e,t-10,r-1,20,2,i)}function Eg(e,t,r,i){ml(e,0,t+r/2,e.transform.width,r,i)}function Pg(e,t,r,i){ml(e,t-r/2,0,r,e.transform.height,i)}function ml(e,t,r,i,a,n){let s=e.context,o=s.gl;o.enable(o.SCISSOR_TEST),o.scissor(t*e.pixelRatio,r*e.pixelRatio,i*e.pixelRatio,a*e.pixelRatio),s.clear({color:n}),o.disable(o.SCISSOR_TEST)}function Oz(e,t,r,i){for(let a of r)$z(e,t,a,i)}function $z(e,t,r,i){var y;let a=e.context,n=a.gl,s=e.useProgram("debug"),o=me.disabled,l=Ae.disabled,u=e.colorModeForRenderPass(),h="$debug",c=Vt(i,r);a.activeTexture.set(n.TEXTURE0);let d=((y=t.getTileByID(r.key).latestRawTileData)==null?void 0:y.byteLength)||0,p=Math.floor(d/1024),f=t.getTile(r).tileSize,m=512/Math.min(f,512)*(r.overscaledZ/e.transform.zoom)*.5,g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),jz(e,`${g} ${p}kB`);let _=Ft(i,r);s.draw(a,n.TRIANGLES,o,l,tt.alphaBlended,Se.disabled,_g(se.transparent,m),null,_,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(a,n.LINE_STRIP,o,l,u,Se.disabled,_g(se.red),c,_,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function jz(e,t){e.initDebugOverlayCanvas();let r=e.debugOverlayCanvas,i=e.context.gl,a=e.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,r.width,r.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(t,5,5),a.strokeText(t,5,5),e.debugOverlayTexture.update(r),e.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}function Vz(e,t){let r=null,i=Object.values(e._layers).flatMap(o=>o.source&&!o.isHidden(t)?[e.tileManagers[o.source]]:[]),a=i.filter(o=>o.getSource().type==="vector"),n=i.filter(o=>o.getSource().type!=="vector"),s=o=>{(!r||r.getSource().maxzoom<o.getSource().maxzoom)&&(r=o)};for(let o of a)s(o);if(!r)for(let o of n)s(o);return r}function Nz(e,t,r,i){let{isRenderingGlobe:a}=i,n=e.context,s=r.implementation,o=e.style.projection,l=e.transform,u=l.getProjectionDataForCustomLayer(a),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:o.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
uniform mat4 u_projection_matrix;
${o.shaderPreludeCode.vertexSource}`,define:o.shaderDefine},defaultProjectionData:u,getProjectionData:d=>l.getProjectionData({overscaledTileID:new St(d.tileID.canonical.z,d.tileID.wrap??0,d.tileID.canonical.z,d.tileID.canonical.x,d.tileID.canonical.y),aligned:d.aligned,applyGlobeMatrix:d.applyGlobeMatrix,applyTerrainMatrix:d.applyTerrainMatrix})},c=s.renderingMode?s.renderingMode:"2d";if(i.currentPass==="offscreen"){let d=s.prerender;d&&(e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),d.call(s,n.gl,h),n.setDirty(),e.setBaseState())}else if(i.currentPass==="translucent"){e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(Ae.disabled);let d=c==="3d"?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,me.ReadOnly);n.setDepthMode(d),s.render(n.gl,h),n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null)}}function Uz(e,t){let r=e.context,i=r.gl,a=e.transform,n=tt.unblended,s=new me(i.LEQUAL,me.ReadWrite,[0,1]),o=t.tileManager.getRenderableTiles(),l=e.useProgram("terrainDepth");r.bindFramebuffer.set(t.getFramebuffer().framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:se.white,depth:1});for(let u of o){let h=t.getTerrainMesh(u.tileID),c=t.getTerrainData(u.tileID),d=a.getProjectionData({overscaledTileID:u.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),p=h3(t.getSkirtLength(a.zoom));l.draw(r,i.TRIANGLES,s,Ae.disabled,n,Se.backCCW,p,c,d,"terrain",h.vertexBuffer,h.indexBuffer,h.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}function Gz(e,t,r,i){let{isRenderingGlobe:a}=i,n=e.context,s=n.gl,o=e.transform,l=e.colorModeForRenderPass(),u=e.getDepthModeFor3D(),h=e.useProgram("terrain");n.bindFramebuffer.set(null),n.viewport.set([0,0,e.width,e.height]);for(let c of r){let d=t.getTerrainMesh(c.tileID),p=e.renderToTexture.getTexture(c),f=t.getTerrainData(c.tileID);n.activeTexture.set(s.TEXTURE0),p.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_LINEAR);let m=t.getSkirtLength(o.zoom),g=o.calculateFogMatrix(c.tileID.toUnwrapped()),_=u3(m,g,e.style.sky,o.pitch,a),y=Ft(i,c.tileID,{applyTerrainMatrix:!1});h.draw(n,s.TRIANGLES,u,Ae.disabled,l,Se.backCCW,_,f,y,"terrain",d.vertexBuffer,d.indexBuffer,d.segments)}}function xx(e,t){if(!t.mesh){let r=new bi;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new Yr;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),t.mesh=new ws(e.createVertexBuffer(r,Ui.members),e.createIndexBuffer(i),Ze.simpleSegment(0,0,r.length,i.length))}return t.mesh}function qz(e,t){let r=e.context,i=r.gl,a=c5(t,e.transform,e.pixelRatio),n=new me(i.LEQUAL,me.ReadWrite,[0,1]),s=Ae.disabled,o=e.colorModeForRenderPass(),l=e.useProgram("sky"),u=xx(r,t);l.draw(r,i.TRIANGLES,n,s,o,Se.disabled,a,null,void 0,"sky",u.vertexBuffer,u.indexBuffer,u.segments)}function Zz(e,t){let r=e.getCartesianPosition();Wx(r,r);let i=Ar(new Float64Array(16));return e.properties.get("anchor")==="map"&&(xi(i,i,t.rollInRadians),Va(i,i,-t.pitchInRadians),xi(i,i,t.bearingInRadians),Va(i,i,t.center.lat*Math.PI/180),Og(i,i,-t.center.lng*Math.PI/180)),Hx(r,r,i),r}function Wz(e,t,r){let i=e.context,a=i.gl,n=e.useProgram("atmosphere"),s=new me(a.LEQUAL,me.ReadOnly,[0,1]),o=e.transform,l=Zz(r,e.transform),u=o.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),h=Ja(o.worldSize,o.center.lat),c=W1(o),d=H1(Sr(c)-h,h),p=t.properties.get("atmosphere-blend")*u.projectionTransition*d;if(p===0)return;let f=u5(l,p,c,h,o.inverseProjectionMatrix),m=xx(i,t);n.draw(i,a.TRIANGLES,s,Ae.disabled,tt.alphaBlended,Se.disabled,f,null,null,"atmosphere",m.vertexBuffer,m.indexBuffer,m.segments)}const Hz={symbol:rz,circle:lz,heatmap:uz,line:vz,fill:bz,fillExtrusion:wz,hillshade:Tz,colorRelief:Sz,raster:Ez,background:Iz,sky:qz,atmosphere:Wz,custom:Nz,debug:Oz,debugPadding:Lz,terrainDepth:Uz};var Yi,Xz=(Yi=class{constructor(t,r){this.drawFunctions=Hz,this.context=new J5(t),this.transform=r,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:Ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Mc.maxOverzooming+Mc.maxUnderzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new k1}resize(t,r,i){if(this.width=Math.round(t*i),this.height=Math.round(r*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let a of this.style._order)this.style._layers[a].resize()}setup(){let t=this.context,r=new bi;r.emplaceBack(0,0),r.emplaceBack(k,0),r.emplaceBack(0,k),r.emplaceBack(k,k),this.tileExtentBuffer=t.createVertexBuffer(r,Ui.members),this.tileExtentSegments=Ze.simpleSegment(0,0,4,2);let i=new bi;i.emplaceBack(0,0),i.emplaceBack(k,0),i.emplaceBack(0,k),i.emplaceBack(k,k),this.debugBuffer=t.createVertexBuffer(i,Ui.members),this.debugSegments=Ze.simpleSegment(0,0,4,5);let a=new N2;a.emplaceBack(0,0,0,0),a.emplaceBack(k,0,k,0),a.emplaceBack(0,k,0,k),a.emplaceBack(k,k,k,k),this.rasterBoundsBuffer=t.createVertexBuffer(a,a3.members),this.rasterBoundsSegments=Ze.simpleSegment(0,0,4,2);let n=new bi;n.emplaceBack(0,0),n.emplaceBack(k,0),n.emplaceBack(0,k),n.emplaceBack(k,k),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(n,Ui.members),this.rasterBoundsSegmentsPosOnly=Ze.simpleSegment(0,0,4,5);let s=new bi;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,Ui.members),this.viewportSegments=Ze.simpleSegment(0,0,4,2);let o=new ew;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let l=new Yr;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(l);let u=this.context.gl;this.stencilClearMode=new Ae({func:u.ALWAYS,mask:0},0,255,u.ZERO,u.ZERO,u.ZERO),this.tileExtentMesh=new ws(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,r=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let i=Ci();Br(i,0,this.width,this.height,0,0,1),Et(i,i,[r.drawingBufferWidth,r.drawingBufferHeight,0]);let a={mainMatrix:i,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:i,clipAntimeridian:!1};this.useProgram("clippingMask",null,!0).draw(t,r.TRIANGLES,me.disabled,this.stencilClearMode,tt.disabled,Se.disabled,null,null,a,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(t,r){if(this.currentStencilSource===t.source||!t.isTileClipped()||!(r!=null&&r.length))return;this.currentStencilSource=t.source,this.nextStencilID+r.length>256&&this.clearStencil();let i=this.context;i.setColorMode(tt.disabled),i.setDepthMode(me.disabled);let a={};for(let n of r)a[n.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(a,r,!0),this._renderTileMasks(a,r,!1),this._tileClippingMaskIDs=a}_renderTileMasks(t,r,i){let a=this.context,n=a.gl,s=this.style.projection,o=this.renderContext,l=this.useProgram("clippingMask");for(let u of r){let h=t[u.key],c=Vt(o,u),d=s.getMeshFromTileID(this.context,u.canonical,i,!0,"stencil"),p=Ft(o,u);l.draw(a,n.TRIANGLES,me.disabled,new Ae({func:n.ALWAYS,mask:0},h,255,n.KEEP,n.KEEP,n.REPLACE),tt.disabled,o.isRenderingToTexture?Se.disabled:Se.backCCW,null,c,p,"$clipping",d.vertexBuffer,d.indexBuffer,d.segments)}}_renderTilesDepthBuffer(){let t=this.context,r=t.gl,i=this.style.projection,a=this.transform,n=this.useProgram("depth"),s=this.getDepthModeFor3D(),o=an(a,{tileSize:a.tileSize});for(let l of o){let u=Vt(this.renderContext,l),h=i.getMeshFromTileID(this.context,l.canonical,!0,!0,"raster"),c=Ft(this.renderContext,l);n.draw(t,r.TRIANGLES,s,Ae.disabled,tt.disabled,Se.backCCW,null,u,c,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,r=this.context.gl;return new Ae({func:r.NOTEQUAL,mask:255},t,255,r.KEEP,r.KEEP,r.REPLACE)}stencilModeForClipping(t){let r=this.context.gl;return new Ae({func:r.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,r.KEEP,r.KEEP,r.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){let r=this.context.gl,i=t.sort((s,o)=>o.overscaledZ-s.overscaledZ),a=i[i.length-1].overscaledZ,n=i[0].overscaledZ-a+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();let s={};for(let o=0;o<n;o++)s[o+a]=new Ae({func:r.GEQUAL,mask:255},o+this.nextStencilID,255,r.KEEP,r.KEEP,r.REPLACE);return this.nextStencilID+=n,[s,i]}return[{[a]:Ae.disabled},i]}stencilConfigForOverlapTwoPass(t){let r=this.context.gl,i=t.sort((s,o)=>o.overscaledZ-s.overscaledZ),a=i[i.length-1].overscaledZ,n=i[0].overscaledZ-a+1;if(this.clearStencil(),n>1){let s={},o={};for(let l=0;l<n;l++)s[l+a]=new Ae({func:r.GREATER,mask:255},n+1+l,255,r.KEEP,r.KEEP,r.REPLACE),o[l+a]=new Ae({func:r.GREATER,mask:255},1+l,255,r.KEEP,r.KEEP,r.REPLACE);return this.nextStencilID=n*2+1,[s,o,i]}return this.nextStencilID=3,[{[a]:new Ae({func:r.GREATER,mask:255},2,255,r.KEEP,r.KEEP,r.REPLACE)},{[a]:new Ae({func:r.GREATER,mask:255},1,255,r.KEEP,r.KEEP,r.REPLACE)},i]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let r=.125;return new tt([t.CONSTANT_COLOR,t.ONE],new se(r,r,r,0),[!0,!0,!0,!0])}return this.renderContext.currentPass==="opaque"?tt.unblended:tt.alphaBlended}getDepthModeForSublayer(t,r,i){if(!this.opaquePassEnabledForLayer())return me.disabled;let a=1-((1+this.renderContext.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new me(i||this.context.gl.LEQUAL,r,[a,a])}getDepthModeFor3D(){return new me(this.context.gl.LEQUAL,me.ReadWrite,this.renderContext.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.renderContext.currentLayer<this.renderContext.opaquePassCutoff}render(t,r){var h;this.style=t,this.options=r;let i=this.renderContext=Q5(this.transform,t.projection,t.map.terrain??null);this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.patternAtlas=t.patternAtlas,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(Fe()),K5(this.context.frameUniformBuffer,this),this.imageManager.beginFrame(),f3(this.context);let a=this.style._order,n=this.style.tileManagers,s={},o={},l={};for(let c in n){let d=n[c];d.used&&d.prepare(this.context),s[c]=d.getVisibleCoordinates(!1),o[c]=s[c].slice().reverse(),l[c]=d.getVisibleCoordinates(!0).reverse()}i.opaquePassCutoff=1/0;for(let c=0;c<a.length;c++){let d=a[c];if(this.style._layers[d].is3D()){i.opaquePassCutoff=c;break}}this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),i.opaquePassCutoff=0),i.currentPass="offscreen";for(let c of a){let d=this.style._layers[c];if(!d.hasOffscreenPass()||d.isHidden(this.transform.zoom))continue;let p=o[d.source];(d.type==="custom"||p.length)&&this.renderLayer(this,n[d.source],d,p,i)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:r.showOverdrawInspector?se.black:se.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=r.showOverdrawInspector,i.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(i.currentPass="opaque",i.currentLayer=a.length-1;i.currentLayer>=0;i.currentLayer--){let c=this.style._layers[a[i.currentLayer]];if(c.isHidden(this.transform.zoom))continue;let d=n[c.source],p=s[c.source];this.renderTileClippingMasks(c,p),this.renderLayer(this,d,c,p,i)}i.currentPass="translucent";let u=!1;for(i.currentLayer=0;i.currentLayer<a.length;i.currentLayer++){let c=this.style._layers[a[i.currentLayer]];if(c.isHidden(this.transform.zoom))continue;let d=n[c.source];if((h=this.renderToTexture)!=null&&h.renderLayer(c,i))continue;!this.opaquePassEnabledForLayer()&&!u&&(u=!0,i.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let p=(c.type==="symbol"?l:o)[c.source];this.renderTileClippingMasks(c,s[c.source]),this.renderLayer(this,d,c,p,i)}if(i.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let c=Vz(this.style,this.transform.zoom);c&&this.drawFunctions.debug(this,c,c.getVisibleCoordinates(),i)}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.renderToTexture&&!this.options.moving&&this.clearRTTPool(),this.context.setDefault()}markTerrainDepthDirty(){this.terrainFacilitator.depthDirty=!0}maybeDrawDepth(){var a,n;if(!((a=this.style)!=null&&a.projection)||!((n=this.style.map)!=null&&n.terrain))return;let t=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix,i=this.terrainFacilitator.depthDirty;i||(i=!qx(t,r)),i||(i=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),i&&(jx(t,r),this.terrainFacilitator.renderTime=Fe(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}renderLayer(t,r,i,a,n){if(i.isHidden(this.transform.zoom)||i.type!=="background"&&i.type!=="custom"&&!(a||[]).length)return;this.id=i.id;let s=this.drawFunctions;k0(i)?s.symbol(t,r,i,a,this.style.placement.variableOffsets,n):Aw(i)?s.circle(t,r,i,a,n):Fw(i)?s.heatmap(t,r,i,a,n):dD(i)?s.line(t,r,i,a,n):ST(i)?s.fill(t,r,i,a,n):XT(i)?s.fillExtrusion(t,r,i,a,n):Ow(i)?s.hillshade(t,r,i,a,n):Gw(i)?s.colorRelief(t,r,i,a,n):Mh(i)?s.raster(t,r,i,a,n):fE(i)?s.background(t,r,i,a,n):_E(i)&&s.custom(t,r,i,n)}saveTileTexture(t){let r=this._tileTextures[t.size[0]];r?r.length<Yi.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?r.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let r=this._tileTextures[t];return r&&r.length>0?r.pop():null}acquireRTT(t){let r=this.context.gl,i=this._rttObjectRecyclePool.pop();if(i)return i.size!==t&&(i.texture.update({width:t,height:t,data:null},{premultiply:!1,useMipmap:!0}),i.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),i.size=t),i;let a=new dt(this.context,{width:t,height:t,data:null},r.RGBA,{premultiply:!1,useMipmap:!0});return a.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:a,size:t}}bindRTT(t){let r=this.context.gl,i=t.size;if(!this._rttSharedFbo){let a=this.context.createFramebuffer(i,i,!0,!0),n=this.context.createRenderbuffer(r.DEPTH_STENCIL,i,i);a.depthAttachment.set(n),this._rttSharedFbo={fbo:a,depthRenderbuffer:n,size:i}}this._rttSharedFbo.size!==i&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,i,i),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=i,this._rttSharedFbo.fbo.height=i,this._rttSharedFbo.size=i),this._rttSharedFbo.fbo.colorAttachment.set(t.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(t){this._rttObjectRecyclePool.push(t)}clearRTTPool(){for(let t of this._rttObjectRecyclePool)t.texture.destroy();this._rttObjectRecyclePool.length=0}destroyRTTResources(){if(this.clearRTTPool(),!this._rttSharedFbo)return;this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let t=this.context.gl;t.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),t.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let r=this.patternAtlas.getPattern(t.from.toString()),i=this.patternAtlas.getPattern(t.to.toString());return!r||!i}useProgram(t,r,i=!1,a=[]){var m;this.cache||(this.cache={});let n=!!this.style.map.terrain,s=this.style.projection,o=i?Nr.projectionMercator:s.shaderPreludeCode,l=i?L1:s.shaderDefine,u=`/${i?B1:s.shaderVariantName}`,h=r?r.cacheKey:"",c=this._showOverdrawInspector?"/overdraw":"",d=n?"/terrain":"",p=a?`/${a.join("/")}`:"",f=t+h+u+c+d+p;return(m=this.cache)[f]||(m[f]=new x3(this.context,Nr[t],r,d5[t],this._showOverdrawInspector,n,o,l,a)),this.cache[f]}setCustomLayerDefaults(){this.context.setCustomLayerDefaults()}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(){if(this.debugOverlayCanvas==null){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;let t=this.context.gl;this.debugOverlayTexture=new dt(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){var t,r,i;if(this._tileTextures){for(let a in this._tileTextures){let n=this._tileTextures[a];if(n)for(let s of n)s.destroy()}this._tileTextures={}}if(this.destroyRTTResources(),(t=this.layerOpacityFbo)==null||t.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((r=this.tileExtentMesh.vertexBuffer)==null||r.destroy()),this.tileExtentMesh&&((i=this.tileExtentMesh.indexBuffer)==null||i.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),m3(this.context),this.context.terrainUniformBuffer.destroy(),this.context.frameUniformBuffer.destroy(),this.cache){for(let a in this.cache){let n=this.cache[a];n!=null&&n.program&&this.context.gl.deleteProgram(n.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:r}=this.context.gl;return this.width!==t||this.height!==r}},Yi.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50,Yi),Yz=class extends Error{constructor(e,t){super("WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL"),this.name="GPUInitializationError",this.requestedAttributes=e,this.statusMessage=(t==null?void 0:t.statusMessage)??null}};function ip(e,t){let r=!1,i=null,a,n=()=>{i=null,r&&(r=(e(...a),i=setTimeout(n,t),!1))};return(...s)=>(r=!0,a=s,i||n(),i)}var Kz=class{constructor(e){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||"").split("/"):([...t.keys()][0]??"").split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let r=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:r,pitch:+(t[4]||0)}),!0},this._updateHashUnthrottled=()=>{let t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{let t=this._getHashParams();if(this._hashName)t.delete(this._hashName);else{let n=Array.from(t.keys());n.length>0&&t.delete(n[0])}let r=decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,""),i=r?`#${r}`:"",a=window.location.href.replace(/(#.+)?$/,i);a=a.replace("&&","&"),window.history.replaceState(window.history.state,null,a)},this._updateHash=ip(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),r=Math.round(this._map.getZoom()*100)/100,i=10**Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.round(t.lng*i)/i,n=Math.round(t.lat*i)/i,s=this._map.getBearing(),o=this._map.getPitch(),l="";if(l+=e?`/${a}/${n}/${r}`:`${r}/${n}/${a}`,(s||o)&&(l+=`/${Math.round(s*10)/10}`),o&&(l+=`/${Math.round(o)}`),this._hashName){let u=this._getHashParams();return u.set(this._hashName,l),`#${decodeURIComponent(u.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${l}`}_isValidHash(e){if(e.length<3||e.some(a=>isNaN(+a)))return!1;try{new J(+e[2],+e[1])}catch{return!1}let t=+e[0],r=+(e[3]||0),i=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}};const Ds={linearity:.3,easing:Uc(0,0,.3,1)},Jz=W({deceleration:2500,maxSpeed:1400},Ds),Qz=W({deceleration:20,maxSpeed:1400},Ds),eF=W({deceleration:1e3,maxSpeed:360},Ds),tF=W({deceleration:1e3,maxSpeed:90},Ds),rF=W({deceleration:1e3,maxSpeed:360},Ds);var iF=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Fe(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=Fe();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=Fe()-60,r=Math.max(0,e.length-2);for(;r>0&&e[r-1].time>=t;)r--;return e.slice(r)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2){this.clear();return}let r={zoom:0,bearing:0,pitch:0,roll:0,pan:new C(0,0),pinchAround:void 0,around:void 0};for(let{settings:n}of t)n.around&&(r.around=n.around),n.pinchAround&&(r.pinchAround=n.pinchAround);for(let{settings:n}of t.slice(1))r.zoom+=n.zoomDelta||0,r.bearing+=n.bearingDelta||0,r.pitch+=n.pitchDelta||0,r.roll+=n.rollDelta||0,n.panDelta&&r.pan._add(n.panDelta);if(!r.pan.mag()&&!r.zoom&&!r.bearing&&!r.pitch&&!r.roll){this.clear();return}let i=Fe()-t[0].time,a={};if(r.pan.mag()){let n=Pn(r.pan.mag(),i,W({},Jz,e||{})),s=r.pan.mult(n.amount/r.pan.mag()),o=this._map._camera.cameraHelper.handlePanInertia(s,this._map._camera.transform);a.center=o.easingCenter,a.offset=o.easingOffset,En(a,n)}if(r.zoom){let n=Pn(r.zoom,i,Qz);a.zoom=rr(this._map.getZoom()+n.amount,this._map.getZoomSnap(),n.amount),En(a,n)}if(r.bearing){let n=Pn(r.bearing,i,eF);a.bearing=this._map.getBearing()+ne(n.amount,-179,179),En(a,n)}if(r.pitch){let n=Pn(r.pitch,i,tF);a.pitch=this._map.getPitch()+n.amount,En(a,n)}if(r.roll){let n=Pn(r.roll,i,rF);a.roll=this._map.getRoll()+ne(n.amount,-179,179),En(a,n)}if(a.zoom||a.bearing){let n=r.pinchAround===void 0?r.around:r.pinchAround;a.around=n?this._map.unproject(n):this._map.getCenter()}return this.clear(),W(a,{noMoveStart:!0})}};function En(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Pn(e,t,r){let{maxSpeed:i,linearity:a,deceleration:n}=r,s=ne(e*a/(t/1e3),-i,i),o=Math.abs(s)/(n*a);return{easing:r.easing,duration:o*1e3,amount:o/2*s}}var aF=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new bC(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ir(e.type,this._map,e))}mouseup(e){this._map.fire(new ir(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ir(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ir(e.type,this._map,e))}mouseover(e){this._map.fire(new ir(e.type,this._map,e))}mouseout(e){this._map.fire(new ir(e.type,this._map,e))}touchstart(e){return this._firePreventable(new so(e.type,this._map,e))}touchmove(e){this._map.fire(new so(e.type,this._map,e))}touchend(e){this._map.fire(new so(e.type,this._map,e))}touchcancel(e){this._map.fire(new so(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},nF=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent,this._clearLongPress(),this._touchActive=!1}mousemove(e){this._map.fire(new ir(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ir("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}touchstart(e,t,r){if(this._clearLongPress(),this._touchActive=r.length>0,r.length!==1)return;this._longPressStart=t[0];let i=r[0];this._longPressTimer=setTimeout(()=>{this._longPressTimer=void 0;let a=new MouseEvent("contextmenu",{clientX:i.clientX,clientY:i.clientY,button:2,bubbles:!0,cancelable:!0});this._map.fire(new ir("contextmenu",this._map,a))},500)}touchmove(e,t,r){this._longPressTimer&&(r.length!==1||!this._longPressStart||t[0].dist(this._longPressStart)>this._clickTolerance)&&this._clearLongPress()}touchend(){this._touchActive=!1,this._clearLongPress()}touchcancel(){this._touchActive=!1,this._clearLongPress()}_clearLongPress(){this._longPressTimer&&(this._longPressTimer=(clearTimeout(this._longPressTimer),void 0)),this._longPressStart=void 0}contextmenu(e){if(this._touchActive){e.preventDefault();return}this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ir(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},sF=class{constructor(e,t,r){this._map=e,this._tr=r,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&typeof t.boxZoom=="object"&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&e.button===0&&(Je.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let r=t;if(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)<this._clickTolerance)return;let i=this._startPos;this._lastPos=r,this._box||(this._box=Je.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let a=Math.min(i.x,r.x),n=Math.max(i.x,r.x),s=Math.min(i.y,r.y),o=Math.max(i.y,r.y);this._box.style.transform=`translate(${a}px,${s}px)`,this._box.style.width=`${n-a}px`,this._box.style.height=`${o-s}px`}mouseupWindow(e,t){if(!this._active||e.button!==0)return;let r=this._startPos,i=t;if(this.reset(),Je.suppressClick(),r.x===i.x&&r.y===i.y)this._fireEvent("boxzoomcancel",e);else{if(this._map.fire(new Tm("boxzoomend",{originalEvent:e})),this._boxZoomEnd){this._boxZoomEnd(this._map,r,i,e);return}return{cameraAnimation:a=>a.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})}}}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(this._box=(this._box.remove(),null)),Je.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Tm(e,{originalEvent:t}))}};function Bc(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let r={};for(let i=0;i<e.length;i++)r[e[i].identifier]=t[i];return r}function oF(e){let t=new C(0,0);for(let r of e)t._add(r);return t.div(e.length)}var lF=class{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,t,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(this.startTime===void 0&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=oF(t),this.touches=Bc(r,t)))}touchmove(e,t,r){if(this.aborted||!this.centroid)return;let i=Bc(r,t);for(let a in this.touches){let n=this.touches[a],s=i[a];(!s||s.dist(n)>30)&&(this.aborted=!0)}}touchend(e,t,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),r.length===0){let i=!this.aborted&&this.centroid;if(this.reset(),i)return i}}},Oc=class{constructor(e){this.singleTap=new lF(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,r){this.singleTap.touchstart(e,t,r)}touchmove(e,t,r){this.singleTap.touchmove(e,t,r)}touchend(e,t,r){let i=this.singleTap.touchend(e,t,r);if(i){let a=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(i)<30;if((!a||!n)&&this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}},uF=class{constructor(e,t){this._tr=t,this._zoomIn=new Oc({numTouches:1,numTaps:2}),this._zoomOut=new Oc({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,r){this._zoomIn.touchstart(e,t,r),this._zoomOut.touchstart(e,t,r)}touchmove(e,t,r){this._zoomIn.touchmove(e,t,r),this._zoomOut.touchmove(e,t,r)}touchend(e,t,r){let i=this._zoomIn.touchend(e,t,r),a=this._zoomOut.touchend(e,t,r),n=this._tr;if(i)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:rr(n.zoom+1,s.getZoomSnap()),around:n.transform.isPointOnMapSurface(i)?n.unproject(i):void 0},{originalEvent:e})};if(a)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:rr(n.zoom-1,s.getZoomSnap()),around:n.transform.isPointOnMapSurface(a)?n.unproject(a):void 0},{originalEvent:e})}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Zl=class{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let r=this._lastPoint;if(!r)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e)){this.reset(e);return}let i=Array.isArray(t)?t[0]:t;if(!(!this._moved&&i.dist(r)<this._clickTolerance))return this._moved=!0,this._lastPoint=i,this._move(r,i)}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&Je.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}};const hF={0:1,2:2};function cF(e,t){let r=hF[t];return e.buttons===void 0||(e.buttons&r)!==r}var Wl=class{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=e.button}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!cF(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}};const Hl=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=t=>{t.preventDefault()}};function dF({enable:e,clickTolerance:t}){return new Zl({clickTolerance:t,move:(r,i)=>({around:i,panDelta:i.sub(r)}),activateOnStart:!0,moveStateManager:new Wl({checkCorrectEvent:r=>r.button===0&&!r.ctrlKey}),enable:e,assignEvents:Hl})}function pF({enable:e,clickTolerance:t,aroundCenter:r=!0,minPixelCenterThreshold:i=100,rotateSpeed:a=.8},n){return new Zl({clickTolerance:t,move:(s,o)=>{let l=n();if(r&&Math.abs(l.y-s.y)>i)return{bearingDelta:Sv(new C(s.x,o.y),o,l)};let u=(o.x-s.x)*a;return r&&o.y<l.y&&(u=-u),{bearingDelta:u}},moveStateManager:new Wl({checkCorrectEvent:s=>s.button===0&&s.ctrlKey||s.button===2&&!s.ctrlKey}),enable:e,assignEvents:Hl})}function fF({enable:e,clickTolerance:t,pitchSpeed:r=-.5}){return new Zl({clickTolerance:t,move:(i,a)=>({pitchDelta:(a.y-i.y)*r}),moveStateManager:new Wl({checkCorrectEvent:i=>i.button===0&&i.ctrlKey||i.button===2}),enable:e,assignEvents:Hl})}function mF({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:r=.3},i){return new Zl({clickTolerance:t,move:(a,n)=>{let s=i(),o=(n.x-a.x)*r;return n.y<s.y&&(o=-o),{rollDelta:o}},moveStateManager:new Wl({checkCorrectEvent:a=>a.button===2&&a.ctrlKey}),enable:e,assignEvents:Hl})}var gF=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new C(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,r){return this._calculateTransform(e,t,r)}touchmove(e,t,r){if(this._active){if(this._shouldBePrevented(r.length)){this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);return}return e.preventDefault(),this._calculateTransform(e,t,r)}}touchend(e,t,r){this._calculateTransform(e,t,r),this._active&&this._shouldBePrevented(r.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,r){r.length>0&&(this._active=!0);let i=Bc(r,t),a=new C(0,0),n=new C(0,0),s=0;for(let l in i){let u=i[l],h=this._touches[l];h&&(a._add(u),n._add(u.sub(h)),s++,i[l]=u)}if(this._touches=i,this._shouldBePrevented(s)||!n.mag())return;let o=n.div(s);if(this._sum._add(o),!(this._sum.mag()<this._clickTolerance))return{around:a.div(s),panDelta:o}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},ap=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,r){if(!this._firstTwoTouches)return;e.preventDefault();let[i,a]=this._firstTwoTouches,n=xo(r,t,i),s=xo(r,t,a);if(!n||!s)return;let o=this._aroundCenter?null:n.add(s).div(2);return this._move([n,s],o,e)}touchend(e,t,r){if(!this._firstTwoTouches)return;let[i,a]=this._firstTwoTouches,n=xo(r,t,i),s=xo(r,t,a);n&&s||(this._active&&Je.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}};function xo(e,t,r){for(let i=0;i<e.length;i++)if(e[i].identifier===r)return t[i]}const Ag=.1;function Cg(e,t){return Math.log(e/t)/Math.LN2}var _F=class extends ap{constructor(){super(),this._zoomRate=1,this._zoomThreshold=Ag}setZoomRate(e){this._zoomRate=e??1}setZoomThreshold(e){this._zoomThreshold=e??Ag}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let r=this._distance;if(this._distance=e[0].dist(e[1]),!(!this._active&&Math.abs(Cg(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:Cg(this._distance,r)*this._zoomRate,pinchAround:t}}};function Ig(e,t){return e.angleWith(t)*180/Math.PI}var yF=class extends ap{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,r){let i=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Ig(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,r=Ig(e,this._startVector);return Math.abs(r)<t}};function sh(e){return Math.abs(e.y)>Math.abs(e.x)}var xF=class extends ap{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,r){super.touchstart(e,t,r),this._currentTouchCount=r.length}_start(e){this._lastPoints=e,sh(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,r){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let i=e[0].sub(this._lastPoints[0]),a=e[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(i,a,r.timeStamp),this._valid)return this._lastPoints=e,this._active=!0,{pitchDelta:(i.y+a.y)/2*-.5}}gestureBeginsVertically(e,t,r){if(this._valid!==void 0)return this._valid;let i=e.mag()>=2,a=t.mag()>=2;if(!i&&!a)return;if(!i||!a)return this._firstMove===void 0&&(this._firstMove=r),r-this._firstMove<100&&void 0;let n=e.y>0==t.y>0;return sh(e)&&sh(t)&&n}};const vF={panStep:100,bearingStep:15,pitchStep:10};var bF=class{constructor(e,t){this._tr=t;let r=vF;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,r=0,i=0,a=0,n=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?r=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?i=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?i=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{let o=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:wF,zoom:t?rr(o.zoom+t*(e.shiftKey?2:1),s.getZoomSnap()):o.zoom,bearing:o.bearing+r*this._bearingStep,pitch:o.pitch+i*this._pitchStep,offset:[-a*this._panStep,-n*this._panStep],center:o.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function wF(e){return e*(2-e)}const Mg=4.000244140625;var TF=class{constructor(e,t,r){this._onTimeout=i=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(i)},this._map=e,this._tr=r,this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return this._map.cooperativeGestures.isEnabled()?!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e)):!1}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e)){this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);return}let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*40:e.deltaY,r=Fe(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,t!==0&&t%Mg==0?this._type="wheel":t!==0&&Math.abs(t)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let t=Je.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(J.convert(r.center)):t,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){let s=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=s),typeof this._targetZoom=="number"&&(this._targetZoom+=s)}if(this._delta!==0){let s=this._type==="wheel"&&Math.abs(this._delta)>Mg?this._wheelZoomRate:this._defaultZoomRate,o=2/(1+Math.exp(-Math.abs(this._delta*s)));this._delta<0&&o!==0&&(o=1/o);let l=typeof this._targetZoom=="number"?$t(this._targetZoom):e.scale,u=e.applyConstrain(e.getCameraLngLat(),It(l*o)).zoom,h=this._map.getZoomSnap();if(this._type==="wheel"&&h>0){let c=rr(e.zoom,h);this._targetZoom=rr(u,h,u-c)}else this._targetZoom=u;this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let t=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,r=this._startZoom,i=this._easing,a=!1,n;if(this._type==="wheel"&&r&&i){let s=Fe()-this._lastWheelEventTime,o=Math.min((s+5)/200,1),l=i(o);n=We.number(r,t,l),o<1?this._needsRerender=!0:a=!0}else n=t,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=n,{noInertia:!0,needsRenderFrame:!a,zoomDelta:n-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=fh;if(this._prevEase){let r=this._prevEase,i=(Fe()-r.start)/r.duration,a=r.easing(i+.01)-r.easing(i),n=.27/Math.sqrt(a*a+1e-4)*.01,s=Math.sqrt(.0729-n*n);t=Uc(n,s,.25,1)}return this._prevEase={start:Fe(),duration:e,easing:t},t}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},DF=class{constructor(e,t){this._clickZoom=e,this._tapZoom=t}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()}},SF=class{constructor(e,t){this._tr=t,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:rr(this._tr.zoom+(e.shiftKey?-1:1),r.getZoomSnap()),around:this._tr.transform.isPointOnMapSurface(t)?this._tr.unproject(t):void 0},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},EF=class{constructor(){this._tap=new Oc({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,r){if(!this._swipePoint)if(!this._tapTime)this._tap.touchstart(e,t,r);else{let i=t[0],a=e.timeStamp-this._tapTime<500,n=this._tapPoint.dist(i)<30;!a||!n?this.reset():r.length>0&&(this._swipePoint=i,this._swipeTouch=r[0].identifier)}}touchmove(e,t,r){if(!this._tapTime)this._tap.touchmove(e,t,r);else if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;let i=t[0],a=i.y-this._swipePoint.y;return this._swipePoint=i,e.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}touchend(e,t,r){if(this._tapTime)this._swipePoint&&r.length===0&&this.reset();else{let i=this._tap.touchend(e,t,r);i&&(this._tapTime=e.timeStamp,this._tapPoint=i)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},PF=class{constructor(e,t,r){this._el=e,this._mousePan=t,this._touchPan=r}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}},AF=class{constructor(e,t,r,i){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=r,this._mouseRoll=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},CF=class{constructor(e,t,r,i){this._el=e,this._touchZoom=t,this._touchRotate=r,this._tapDragZoom=i,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},IF=class{constructor(e,t){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=Je.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let r=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),i=document.createElement("div");i.className="maplibregl-desktop-message",i.textContent=t,this._container.appendChild(i);let a=document.createElement("div");a.className="maplibregl-mobile-message",a.textContent=r,this._container.appendChild(a),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,t){this._enabled&&(this._map.fire(new bt("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},MF=class{constructor(e){this._camera=e}get transform(){return this._camera._requestedCameraState||this._camera.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(C.convert(e),this._camera.terrain)}};const vo=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;var zF=class extends ia{};function oh(e){var t;return((t=e.panDelta)==null?void 0:t.mag())||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var FF=class{get _ownerDocument(){var e;return((e=this._el)==null?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,t;return((t=(e=this._el)==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)||window}constructor(e,t,r){this._terrainGesture={inFlight:!1,anchorElevation:null},this.handleWindowEvent=a=>{this.handleEvent(a,`${a.type}Window`)},this.handleEvent=(a,n)=>{if(a.type==="blur"){this.stop(!0);return}this._updatingCamera=!0;let s=a.type==="renderFrame"?void 0:a,o={needsRenderFrame:!1},l={},u={};for(let{handlerName:d,handler:p,allowed:f}of this._handlers){if(!p.isEnabled())continue;let m;if(this._blockedByActive(u,f,d))p.reset();else if(p[n||a.type]){if(Pv(a,n||a.type)){let g=Je.mousePos(this._map.getCanvas(),a);m=p[n||a.type](a,g)}else if(Ev(a,n||a.type)){let g=a.touches,_=this._getMapTouches(g),y=Je.touchPos(this._map.getCanvas(),_);m=p[n||a.type](a,y,_)}else Av(n||a.type)||(m=p[n||a.type](a));this.mergeHandlerResult(o,l,m,d,s),m!=null&&m.needsRenderFrame&&this._triggerRenderFrame()}(m||p.isActive())&&(u[d]=p)}let h={};for(let d in this._previousActiveHandlers)u[d]||(h[d]=s);this._previousActiveHandlers=u,(Object.keys(h).length||oh(o))&&(this._changes.push([o,l,h]),this._triggerRenderFrame()),(Object.keys(u).length||oh(o))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=o;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=e,this._camera=t,this._transformProvider=new MF(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new iF(e),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r);let i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[a,n,s]of this._listeners)a.addEventListener(n,a===this._ownerDocument?this.handleWindowEvent:this.handleEvent,s)}destroy(){for(let[e,t,r]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){let t=this._map,r=t.getCanvasContainer();this._add("mapEvent",new aF(t,e));let i=t.boxZoom=new sF(t,e,this._transformProvider);this._add("boxZoom",i),e.interactive&&e.boxZoom&&i.enable();let a=t.cooperativeGestures=new IF(t,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();let n=new uF(t,this._transformProvider),s=new SF(t,this._transformProvider);t.doubleClickZoom=new DF(s,n),this._add("tapZoom",n),this._add("clickZoom",s),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let o=new EF;this._add("tapDragZoom",o);let l=t.touchPitch=new xF(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let u=()=>this._camera.transform.centerPoint,h=pF(e,u),c=fF(e),d=mF(e,u);t.dragRotate=new AF(e,h,c,d),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",c,["mouseRotate","mouseRoll"]),this._add("mouseRoll",d,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable();let p=dF(e),f=new gF(e,t);t.dragPan=new PF(r,p,f),this._add("mousePan",p),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let m=new yF,g=new _F;t.touchZoomRotate=new CF(r,g,m,o),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",g,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new nF(t,e),["touchPan"]);let _=t.scrollZoom=new TF(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",_,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let y=t.keyboard=new bF(t,this._transformProvider);this._add("keyboard",y),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,r){this._handlers.push({handlerName:e,handler:t,allowed:r}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!vo(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,r){for(let i in e)if(i!==r&&!(t!=null&&t.includes(i)))return!0;return!1}_getMapTouches(e){let t=[];for(let r of e){let i=r.target;this._el.contains(i)&&t.push(r)}return t}mergeHandlerResult(e,t,r,i,a){if(!r)return;W(e,r);let n={handlerName:i,originalEvent:r.originalEvent||a};r.zoomDelta!==void 0&&(t.zoom=n),r.panDelta!==void 0&&(t.drag=n),r.rollDelta!==void 0&&(t.roll=n),r.pitchDelta!==void 0&&(t.pitch=n),r.bearingDelta!==void 0&&(t.rotate=n)}_applyChanges(){let e={},t={},r={};for(let[i,a,n]of this._changes)i.panDelta&&(e.panDelta=(e.panDelta||new C(0,0))._add(i.panDelta)),i.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+i.pitchDelta),i.rollDelta&&(e.rollDelta=(e.rollDelta||0)+i.rollDelta),i.around!==void 0&&(e.around=i.around),i.pinchAround!==void 0&&(e.pinchAround=i.pinchAround),i.noInertia&&(e.noInertia=i.noInertia),W(t,a),W(r,n);this._updateMapTransform(e,t,r),this._changes=[]}_updateMapTransform(e,t,r){let i=this._map.terrain;if(!oh(e)){this._fireEvents(t,r,!0);return}let a=this._camera.getTransformForUpdate();this._camera.stop(!0);let{panDelta:n,zoomDelta:s,bearingDelta:o,pitchDelta:l,rollDelta:u}=e,{around:h,aroundOnSurface:c}=this._resolveAround(e,i,a),d=i?this._terrainGestureElevation(i,h,c,a,t):void 0,p={panDelta:n,zoomDelta:s,rollDelta:u,pitchDelta:l,bearingDelta:o,around:h,aroundElevation:d};this._camera.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(h)&&(h=a.centerPoint);let f=this._computePreZoomAroundLoc(a,h,n,d);this._handleMapControls({terrain:i,tr:a,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:n}),this._camera.applyUpdatedTransform(a),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,r,!0)}_resolveAround(e,t,r){let i=e.pinchAround===void 0?e.around:e.pinchAround;return i||(i=this._camera.transform.centerPoint),t&&!r.isPointOnMapSurface(i)?{around:r.centerPoint,aroundOnSurface:!1}:{around:i,aroundOnSurface:!0}}_terrainGestureElevation(e,t,r,i,a){if(!r)return;if(this._terrainGesture.anchorElevation===null&&(a.drag||a.zoom)){let s=i.screenTerrainPointToMercatorCoordinate(t,e);this._terrainGesture.anchorElevation=s?s.z:void 0}let n=this._terrainGesture.anchorElevation;if(n!=null&&!(t.distSqr(i.centerPoint)<.01)&&!(n-i.elevation>=.9*(i.getCameraAltitude()-i.elevation)))return n}_computePreZoomAroundLoc(e,t,r,i){if(t.distSqr(e.centerPoint)<.01)return e.center;let a=r?t.sub(r):t;return i===void 0?e.screenPointToLocation(a):e.screenPointToLocationAtElevation(a,i)}_handleMapControls({terrain:e,tr:t,deltasForHelper:r,preZoomAroundLoc:i,combinedEventsInProgress:a,panDelta:n}){let s=this._camera.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(r,t),!e&&!s.useGlobeControls&&!t.isPointOnMapSurface(r.around)){n&&t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n)));return}if(!e){s.handleMapControlsPan(r,t,i);return}if(!this._terrainGesture.inFlight){this._terrainGesture.inFlight=!0,this._camera.elevationFreeze=!0,s.handleMapControlsPan(r,t,i);return}if(!s.useGlobeControls&&r.aroundElevation===void 0&&a.drag&&n){t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n)));return}s.handleMapControlsPan(r,t,i)}_fireEvents(e,t,r){let i=vo(this._eventsInProgress),a=vo(e),n={};for(let h in e){let{originalEvent:c}=e[h];this._eventsInProgress[h]||(n[`${h}start`]=c),this._eventsInProgress[h]=e[h]}!i&&a&&this._fireEvent("movestart",a.originalEvent);for(let h in n)this._fireEvent(h,n[h]);a&&this._fireEvent("move",a.originalEvent);for(let h in e){let{originalEvent:c}=e[h];this._fireEvent(h,c)}let s={},o;for(let h in this._eventsInProgress){let{handlerName:c,originalEvent:d}=this._eventsInProgress[h];this._handlersById[c].isActive()||(delete this._eventsInProgress[h],o=t[c]||d,s[`${h}end`]=o)}for(let h in s)this._fireEvent(h,s[h]);let l=vo(this._eventsInProgress),u=(i||a)&&!l;if(u&&this._terrainGesture.inFlight){this._camera.elevationFreeze=!1,this._terrainGesture={inFlight:!1,anchorElevation:null};let h=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&h.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(h)}if(r&&u){this._updatingCamera=!0;let h=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),c=d=>d!==0&&-this._bearingSnap<d&&d<this._bearingSnap;h&&(h.essential||!Xt.prefersReducedMotion)?(c(h.bearing||this._map.getBearing())&&(h.bearing=0),h.freezeElevation=!0,this._map.easeTo(h,{originalEvent:o})):(this._fireEvent("moveend",o),c(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,t){this._camera.fire(new K(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new zF("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}},RF=class extends Rt{constructor(e){super(),this._renderFrameCallback=()=>{let t=Math.min((Fe()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new dl,this.cameraHelper=new pl,e.minZoom!==void 0&&this.transform.setMinZoom(e.minZoom),e.maxZoom!==void 0&&this.transform.setMaxZoom(e.maxZoom),e.minPitch!==void 0&&this.transform.setMinPitch(e.minPitch),e.maxPitch!==void 0&&this.transform.setMaxPitch(e.maxPitch),e.renderWorldCopies!==void 0&&this.transform.setRenderWorldCopies(e.renderWorldCopies),e.transformConstrain!==null&&this.transform.setConstrainOverride(e.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=e.bearingSnap,this._zoomSnap=e.zoomSnap,this._requestRenderFrame=e.requestRenderFrame,this._cancelRenderFrame=e.cancelRenderFrame,this.terrain=e.terrain,this._centerClampedToGround=e.centerClampedToGround??!0,this.transformCameraUpdate=e.transformCameraUpdate??null,this._stopHandlers=e.stopHandlers??(()=>{}),this.on("moveend",()=>{delete this._requestedCameraState})}setTerrain(e){this.terrain=e,this.applyTerrainChange()}migrateProjection(e,t){if(e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t,this._requestedCameraState){let r=e.clone();r.apply(this._requestedCameraState,!0),this._requestedCameraState=r}}getCenter(){return new J(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,t,r){return e=C.convert(e).mult(-1),this.panTo(this.transform.center,W({offset:e},t),r)}panTo(e,t,r){return this.easeTo(W({center:e},t),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,r){return this.easeTo(W({zoom:e},t),r)}zoomIn(e,t){return this.zoomTo(rr(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(rr(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.applyTransformChange(r=>r.setFov(e)),this.fire(new K("movestart",t)).fire(new K("move",t)).fire(new K("moveend",t))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,r){return this.easeTo(W({bearing:e},t),r)}resetNorth(e,t){return this.rotateTo(0,W({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(W({bearing:0,pitch:0,roll:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=ci.convert(e).adjustAntiMeridian();let r=(t==null?void 0:t.bearing)||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),r,t)}_cameraForBoxAndBearing(e,t,r,i){let a={top:0,bottom:0,right:0,left:0};if(i=W({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},i),typeof i.padding=="number"){let u=i.padding;i.padding={top:u,bottom:u,right:u,left:u}}let n=W(a,i.padding);i.padding=n;let s=this.transform,o=new ci(e,t),l=this.cameraHelper.cameraForBoxAndBearing(i,n,o,r,s);return l&&this._zoomSnap&&(l.zoom=rr(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,r){return this._fitInternal(this.cameraForBounds(e,t),t,r)}fitScreenCoordinates(e,t,r,i,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(C.convert(e)),this.transform.screenPointToLocation(C.convert(t)),r,i),i,a)}_fitInternal(e,t,r){return e?(t=W(e,t),delete t.padding,t.linear?this.easeTo(t,r):this.flyTo(t,r)):this}jumpTo(e,t){this.stop(),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=rr(e.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),i=!1,a=!1,n=!1,s=r.zoom;this.terrain&&r.setElevation(this.terrain.getElevationForLngLat(e.center?J.convert(e.center):r.center,r)),this.cameraHelper.handleJumpToCenterZoom(r,e);let o=r.zoom!==s;return e.elevation!==void 0&&r.elevation!==+e.elevation&&r.setElevation(+e.elevation),e.bearing!==void 0&&r.bearing!==+e.bearing&&(i=!0,r.setBearing(+e.bearing)),e.pitch!==void 0&&r.pitch!==+e.pitch&&(a=!0,r.setPitch(+e.pitch)),e.roll!==void 0&&r.roll!==+e.roll&&(n=!0,r.setRoll(+e.roll)),e.padding!=null&&!r.isPaddingEqual(e.padding)&&r.setPadding(e.padding),this.applyUpdatedTransform(r),this.fire(new K("movestart",t)).fire(new K("move",t)),o&&this.fire(new K("zoomstart",t)).fire(new K("zoom",t)).fire(new K("zoomend",t)),i&&this.fire(new K("rotatestart",t)).fire(new K("rotate",t)).fire(new K("rotateend",t)),a&&this.fire(new K("pitchstart",t)).fire(new K("pitch",t)).fire(new K("pitchend",t)),n&&this.fire(new K("rollstart",t)).fire(new K("roll",t)).fire(new K("rollend",t)),this.fire(new K("moveend",t))}calculateAnchoredCameraOptions(e){var n;let t=this.transform.clone(),r=J.convert(e.anchorLocation),i=C.convert(e.anchorScreenPoint),a={panDelta:i.sub(this.transform.locationToScreenPoint(r,this.terrain)),zoomDelta:e.zoom===void 0?0:e.zoom-t.zoom,bearingDelta:0,pitchDelta:0,rollDelta:0,around:i,aroundElevation:(n=this.terrain)==null?void 0:n.getElevationForLngLat(r,t)};return this.cameraHelper.handleMapControlsRollPitchBearingZoom(a,t),this.cameraHelper.handleMapControlsPan(a,t,r),{center:t.center,zoom:t.zoom}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,a){let n=this.transform.calculateCenterFromCameraLngLatAlt(e,t,r,i);return{center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:r,pitch:i,roll:a}}easeTo(e,t){this._stop(!1,e.easeId),e=W({offset:[0,0],duration:500,easing:fh},e),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=rr(e.zoom,this._zoomSnap)),(e.animate===!1||!e.essential&&Xt.prefersReducedMotion)&&(e.duration=0);let r=this.getTransformForUpdate(),i=this.getBearing(),a=r.pitch,n=r.roll,s=e.bearing===void 0?i:this._normalizeBearing(e.bearing,i),o=e.pitch===void 0?a:+e.pitch,l=e.roll===void 0?n:this._normalizeBearing(e.roll,n),u=e.padding===void 0?r.padding:e.padding,h=C.convert(e.offset),c,d;e.around&&(c=J.convert(e.around),d=r.locationToScreenPoint(c));let p={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},f=this.cameraHelper.handleEaseTo(r,{bearing:s,pitch:o,roll:l,padding:u,around:c,aroundPoint:d,offsetAsPoint:h,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||(this._rotating=i!==s),this._pitching||(this._pitching=o!==a),this._rolling||(this._rolling=l!==n),this._padding=!r.isPaddingEqual(u),this._zooming||(this._zooming=f.isZooming),this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,p),this.terrain&&this._prepareElevation(f.elevationCenter,r),this._ease(m=>{f.easeFunc(m),this.terrain&&!e.freezeElevation&&this._updateElevation(m,r),this.applyUpdatedTransform(r),this._fireMoveEvents(t)},m=>{this.terrain&&e.freezeElevation?this._finalizeElevation():this.elevationFreeze=!1,this._afterEase(t,m)},e),this}_prepareEase(e,t,r={}){this._moving=!0,!t&&!r.moving&&this.fire(new K("movestart",e)),this._zooming&&!r.zooming&&this.fire(new K("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new K("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new K("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new K("rollstart",e))}_prepareElevation(e,t){this._elevationCenter=e,this._elevationStart=t.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(e,t),this.elevationFreeze=!0}_updateElevation(e,t){(this._elevationStart===void 0||this._elevationCenter===void 0)&&this._prepareElevation(t.center,t),t.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,t.tileZoom));let r=this.terrain.getElevationForLngLat(this._elevationCenter,t);if(e<1&&r!==this._elevationTarget){let i=this._elevationTarget-this._elevationStart,a=(r-(i*e+this._elevationStart))/(1-e);this._elevationStart+=e*(i-a),this._elevationTarget=r}t.setElevation(We.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}applyTerrainChange(){if(this.elevationFreeze)return;let e=this.transform;e.setMinElevationForCurrentTile(this.terrain?this.terrain.getMinTileElevationForLngLatZoom(e.center,e.tileZoom):0),this.getCenterClampedToGround()&&e.setElevation(this.terrain?this.terrain.getElevationForLngLat(e.center,e):0)}getTransformForUpdate(){return!this.transformCameraUpdate&&!this.terrain?this.transform:(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState)}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let t=e.getCameraLngLat(),r=e.getCameraAltitude(),i=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(r<i){let a=e.calculateCameraOptionsFromTo(t,i,e.center,e.elevation);return{pitch:a.pitch,zoom:a.zoom}}return{}}applyUpdatedTransform(e){let t=[];if(t.push(i=>this._elevateCameraIfInsideTerrain(i)),this.transformCameraUpdate&&t.push(i=>this.transformCameraUpdate(i)),!t.length)return;let r=e.clone();for(let i of t){let a=r.clone(),{center:n,zoom:s,roll:o,pitch:l,bearing:u,elevation:h}=i(a);n&&a.setCenter(n),h!==void 0&&a.setElevation(h),s!==void 0&&a.setZoom(s),o!==void 0&&a.setRoll(o),l!==void 0&&a.setPitch(l),u!==void 0&&a.setBearing(u),r.apply(a,!1)}this.transform.apply(r,!1)}applyTransformChange(e){let t=this._requestedCameraState!==void 0,r=this.getTransformForUpdate();e(r),this.applyUpdatedTransform(r),t||delete this._requestedCameraState}_fireMoveEvents(e){this.fire(new K("move",e)),this._zooming&&this.fire(new K("zoom",e)),this._rotating&&this.fire(new K("rotate",e)),this._pitching&&this.fire(new K("pitch",e)),this._rolling&&this.fire(new K("roll",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;delete this._easeId;let r=this._zooming,i=this._rotating,a=this._pitching,n=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new K("zoomend",e)),i&&this.fire(new K("rotateend",e)),a&&this.fire(new K("pitchend",e)),n&&this.fire(new K("rollend",e)),this.fire(new K("moveend",e))}flyTo(e,t){if(!e.essential&&Xt.prefersReducedMotion){let D=us(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(D,t)}this.stop(),e=W({offset:[0,0],speed:1.2,curve:1.42,easing:fh},e),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=rr(e.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),i=r.bearing,a=r.pitch,n=r.roll,s=r.padding,o=e.bearing===void 0?i:this._normalizeBearing(e.bearing,i),l=e.pitch===void 0?a:+e.pitch,u=e.roll===void 0?n:this._normalizeBearing(e.roll,n),h=e.padding===void 0?r.padding:e.padding,c=C.convert(e.offset),d=r.centerPoint.add(c),p=r.screenPointToLocation(d),f=this.cameraHelper.handleFlyTo(r,{bearing:o,pitch:l,roll:u,padding:h,locationAtOffset:p,offsetAsPoint:c,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),m=e.curve,g=Math.max(r.width,r.height),_=g/f.scaleOfZoom,y=f.pixelPathLength,v=g/f.scaleOfMinZoom;m=Math.min(m,Math.sqrt(v/y*2));let x=m*m;function w(D){let A=(_*_-g*g+(D?-1:1)*x*x*y*y)/(2*(D?_:g)*x*y);return Math.log(Math.sqrt(A*A+1)-A)}function b(D){return(Math.exp(D)-Math.exp(-D))/2}function T(D){return(Math.exp(D)+Math.exp(-D))/2}function P(D){return b(D)/T(D)}let S=w(!1),I=function(D){return T(S)/T(S+m*D)},R=function(D){return g*((T(S)*P(S+m*D)-b(S))/x)/y},F=(w(!0)-S)/m;if(Math.abs(y)<2e-6||!isFinite(F)){if(Math.abs(g-_)<1e-6)return this.easeTo(e,t);let D=_<g?-1:1;F=Math.abs(Math.log(_/g))/m,R=()=>0,I=A=>Math.exp(D*m*A)}if(e.duration!==void 0)e.duration=+e.duration;else{let D=e.screenSpeed===void 0?+e.speed:+e.screenSpeed/m;e.duration=1e3*F/D}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=i!==o,this._pitching=l!==a,this._rolling=u!==n,this._padding=!r.isPaddingEqual(h),this._prepareEase(t,!1),this.terrain&&this._prepareElevation(f.targetCenter,r),this._ease(D=>{let A=D*F,E=1/I(A),z=R(A);this._rotating&&r.setBearing(We.number(i,o,D)),this._pitching&&r.setPitch(We.number(a,l,D)),this._rolling&&r.setRoll(We.number(n,u,D)),this._padding&&(r.interpolatePadding(s,h,D),d=r.centerPoint.add(c)),f.easeFunc(D,E,z,d),this.terrain&&!e.freezeElevation&&this._updateElevation(D,r),this.applyUpdatedTransform(r),this._fireMoveEvents(t)},()=>{this.terrain&&e.freezeElevation?this._finalizeElevation():this.elevationFreeze=!1,this._afterEase(t)},e),this}isEasing(){return!!this._easeFrameId}stop(e){return this._stop(e)}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let r=this._onEaseEnd;delete this._onEaseEnd,r.call(this,t)}return e||this._stopHandlers(),this}_ease(e,t,r){r.animate===!1||r.duration===0?(e(1),t()):(this._easeStart=Fe(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=mr(e,-180,180);let r=Math.abs(e-t);return Math.abs(e-360-t)<r&&(e-=360),Math.abs(e+360-t)<r&&(e+=360),e}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};const vx={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var kF=class{constructor(e=vx){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{t&&(t.type==="terrain"||t.dataType==="style"||t.dataType==="source"&&(t.sourceDataType==="metadata"||t.sourceDataType==="visibility"))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):!this._container.classList.contains("maplibregl-compact")&&!this._container.classList.contains("maplibregl-attrib-empty")&&(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=Je.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=Je.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=Je.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){let r=this._map._getUIString(`AttributionControl.${t}`);e.title=r,e.setAttribute("aria-label",r)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(i=>typeof i=="string"?i:"")):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let i=this._map.style.stylesheet;this.styleOwner=i.owner,this.styleId=i.id}let t=this._map.style.tileManagers;for(let i in t){let a=t[i];if(a.used||a.usedForTerrain){let n=a.getSource();n.attribution&&!e.includes(n.attribution)&&e.push(n.attribution)}}e=e.filter(i=>String(i).trim()),e.sort((i,a)=>i.length-a.length),e=e.filter((i,a)=>{for(let n=a+1;n<e.length;n++)if(e[n].includes(i))return!1;return!0});let r=e.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,e.length?(this._innerContainer.replaceChildren(Je.sanitize(r)),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},LF=class{constructor(e={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let r=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&r.classList.add("maplibregl-compact"):r.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){var r;this._map=e,this._compact=(r=this.options)==null?void 0:r.compact,this._container=Je.create("div","maplibregl-ctrl");let t=Je.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}},BF=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,r=t?this._queue.concat(t):this._queue;for(let i of r)if(i.id===e){i.cancelled=!0;return}}run(e=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let t=this._currentlyRunning=this._queue;this._queue=[];let r=!1,i;for(let a of t)if(!a.cancelled){try{a.callback(e)}catch(n){r||(r=!0,i=n)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,r)throw i}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const zg=["none","zoom","sourceTiles","visibleLayers","revision"];var OF=class{constructor(e,t,r,i){this._tileKeys=e.map(a=>a.key).sort().join(),this._revision=t,this._zoom=r,this._visibleLayerIds=i}difference(e){return this._revision===(e==null?void 0:e._revision)?this._visibleLayerIds===e._visibleLayerIds?this._tileKeys===e._tileKeys?this._zoom===e._zoom?"none":"zoom":"sourceTiles":"visibleLayers":"revision"}};const wa={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var $F=class{constructor(e,t){this.needsFollowUpFrame=!1,this.painter=e,this.terrain=t,this.rttSize=t.tileManager.tileSize*t.qualityFactor}getTexture(e){return e.getRTT(this._stacks.length-1).texture}prepareForRender(e,t){let r=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(o=>!e._layers[o].isHidden(t));let i=this._renderableLayerIds.join(),a=new Set;for(let o of this._renderableLayerIds){let l=e._layers[o],u=l.source;u&&wa[l.type]&&a.add(u)}this._coordsAscending={},this._rttFingerprints={};for(let o of a){let l=e.tileManagers[o];if(!l)continue;this._coordsAscending[o]={};let u=this._coordsAscending[o],h=l.getSource(),c=h instanceof Ts?h.terrainTileRanges:null;for(let f of l.getVisibleCoordinates()){let m=this.terrain.tileManager.getTerrainCoords(f,c);for(let g in m)u[g]||(u[g]=[]),u[g].push(m[g])}this._rttFingerprints[o]={};let d=this._rttFingerprints[o],p=l.getState().revision;for(let f in u)d[f]=new OF(u[f],p,t,i)}this.needsFollowUpFrame=!1;let n=r||this.painter.options.moving,s=!1;for(let o of this._renderableTiles){let l=this._textureDifference(o);l!=="none"&&(l==="zoom"&&n||l==="visibleLayers"&&r?this.needsFollowUpFrame=!0:l==="zoom"||l==="sourceTiles"?(s?this.needsFollowUpFrame=!0:o.releaseRTT(this.painter),s=!0):o.releaseRTT(this.painter))}}_textureDifference(e){let t="none";for(let r in this._rttFingerprints){let i=this._rttFingerprints[r][e.tileID.key];if(!i)continue;let a=i.difference(e.rttFingerprint[r]);zg.indexOf(a)>zg.indexOf(t)&&(t=a)}return t}renderLayer(e,t){if(e.isHidden(this.painter.transform.zoom))return!1;let r=e.type,i=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(wa[r]&&((!this._prevType||!wa[this._prevType])&&this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!a))return!0;if(wa[this._prevType]||wa[r]&&a){this._prevType=r;let n=this._stacks.length-1,s=this._stacks[n]||[];t.isRenderingToTexture=!0;for(let o of this._renderableTiles){if(this._rttTiles.push(o),o.getRTT(n))continue;let l=o.acquireRTT(i,n,this.rttSize);i.bindRTT(l),i.context.clear({color:se.transparent,stencil:0}),i.currentStencilSource=void 0;for(let u of s){let h=i.style._layers[u],c=h.source?this._coordsAscending[h.source][o.tileID.key]:[o.tileID];i.context.viewport.set([0,0,this.rttSize,this.rttSize]),i.renderTileClippingMasks(h,c),i.renderLayer(i,i.style.tileManagers[h.source],h,c,t),h.source&&(o.rttFingerprint[h.source]=this._rttFingerprints[h.source][o.tileID.key])}l.texture.generateMipmap()}return t.isRenderingToTexture=!1,Gz(this.painter,this.terrain,this._rttTiles,t),this._rttTiles=[],wa[r]}return!1}};const jF={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Drag to rotate map, click to reset north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},VF=cC,Fg={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:vx,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:Ei.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var nR=class extends Rt{get _ownerWindow(){var e,t;return((t=(e=this._container)==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)||window}constructor(e){var a,n,s;super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new BF,this._controls=[],this._mapId=Vg(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=o=>{if(o.preventDefault(),this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),!this.style){this.fire(new qu("webglcontextlost",{originalEvent:o}));return}for(let l of Object.values(this.style._layers))if(l.type==="custom"&&console.warn(`Custom layer with id '${l.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),l._listeners)for(let[u]of Object.entries(l._listeners))console.warn(`Custom layer with id '${l.id}' had event listeners for event '${u}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new qu("webglcontextlost",{originalEvent:o}))},this._contextRestored=o=>{if(this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style){this.style.imageManager.images=this._lostContextStyle.images;for(let l in this._lostContextStyle.images){let u=this._lostContextStyle.images[l];u.isWebGLImage&&this.style.imageManager.updateImage(l,u,!1)}}this._lostContextStyle={style:null,images:null};try{this._setupPainter()}catch(l){this.fire(new X(l));return}this.resize(),this._update(),this._resizeInternal(),this.fire(new qu("webglcontextrestored",{originalEvent:o}))},this._onMapScroll=o=>{if(o.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let t={...Fg,...e,canvasContextAttributes:{...Fg.canvasContextAttributes,...e.canvasContextAttributes}};if(t.minZoom!=null&&t.maxZoom!=null&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(t.minPitch!=null&&t.maxPitch!=null&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(t.minPitch!=null&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(t.maxPitch!=null&&t.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");this._camera=new RF({minZoom:t.minZoom,maxZoom:t.maxZoom,minPitch:t.minPitch,maxPitch:t.maxPitch,bearingSnap:t.bearingSnap,zoomSnap:t.zoomSnap,renderWorldCopies:t.renderWorldCopies,centerClampedToGround:t.centerClampedToGround,terrain:this.terrain,transformConstrain:t.transformConstrain,requestRenderFrame:o=>this._requestRenderFrame(o),cancelRenderFrame:o=>this._cancelRenderFrame(o),transformCameraUpdate:t.transformCameraUpdate,stopHandlers:()=>{var o;return(o=this._handlers)==null?void 0:o.stop(!1)}}),this._camera.setEventedParent(this),this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._canvasContextAttributes={...t.canvasContextAttributes},this._trackResize=t.trackResize===!0,this._terrainSkirtLength=t.terrainSkirtLength,this._refreshExpiredTiles=t.refreshExpiredTiles===!0,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions===!0,this._collectResourceTiming=t.collectResourceTiming===!0,this._locale={...jF,...t.locale},this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this._zoomLevelsToOverscale=t.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming===!0,this.setAnisotropicFilterPitch(t.anisotropicFilterPitch),t.reduceMotion!==void 0&&(Xt.prefersReducedMotion=t.reduceMotion),this._requestManager=new vC(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer();try{this._setupPainter()}catch(o){throw this._cleanupContainer(),o}this._imageQueueHandle=Gr.addThrottleControl(()=>this.isMoving()),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.markTerrainDepthDirty(),this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),this._handlers=new FF(this,this._camera,t),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let r=typeof t.hash=="string"&&t.hash||void 0;this._hash=t.hash?new Kz(r).addTo(this):void 0,(a=this._hash)!=null&&a._onHashChange()||(this.jumpTo({center:t.center,elevation:t.elevation,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch,roll:t.roll}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,W({},t.fitBoundsOptions,{duration:0}))));let i=typeof t.style=="string"||((s=(n=t.style)==null?void 0:n.projection)==null?void 0:s.type)!=="globe";this.resize(null,i),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new kF(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new LF,t.logoPosition),this.on("style.load",()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let o=us(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(o)}}),this.on("data",o=>{this._update(o.dataType==="style"),this.fire(o.dataType==="style"?new Dr("styledata",o):new Ne("sourcedata",o))}),this.on("dataloading",o=>{this.fire(o.dataType==="style"?new Dr("styledataloading",o):new Ne("sourcedataloading",o))}),this.on("dataabort",o=>{this.fire(new Ne("sourcedataabort",o))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,t){if(t===void 0&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!(e!=null&&e.onAdd))return this.fire(new X(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let r=e.onAdd(this);this._controls.push(e);let i=this._controlPositions[t];return t.includes("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(e){if(!(e!=null&&e.onRemove))return this.fire(new X(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return an(this._camera.transform,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return new J(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(e,t){return this._camera.setCenter(e,t),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(e,t){return this._camera.setCenterElevation(e,t),this}setCenterClampedToGround(e){this._camera.setCenterClampedToGround(e)}panBy(e,t,r){return this._camera.panBy(e,t,r),this}panTo(e,t,r){return this._camera.panTo(e,t,r),this}getZoom(){return this._camera.transform.zoom}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,r){return this._camera.zoomTo(e,t,r),this}zoomIn(e,t){return this._camera.zoomIn(e,t),this}zoomOut(e,t){return this._camera.zoomOut(e,t),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(e,t){return this._camera.setVerticalFieldOfView(e,t),this}getBearing(){return this._camera.transform.bearing}setBearing(e,t){return this._camera.setBearing(e,t),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(e){return this._camera.setZoomSnap(e),this}getPadding(){return this._camera.transform.padding}setPadding(e,t){return this._camera.setPadding(e,t),this}rotateTo(e,t,r){return this._camera.rotateTo(e,t,r),this}resetNorth(e,t){return this._camera.resetNorth(e,t),this}resetNorthPitch(e,t){return this._camera.resetNorthPitch(e,t),this}snapToNorth(e,t){return this._camera.snapToNorth(e,t),this}getPitch(){return this._camera.transform.pitch}setPitch(e,t){return this._camera.setPitch(e,t),this}getRoll(){return this._camera.transform.roll}setRoll(e,t){return this._camera.setRoll(e,t),this}cameraForBounds(e,t){return this._camera.cameraForBounds(e,t)}fitBounds(e,t,r){return this._camera.fitBounds(e,t,r),this}fitScreenCoordinates(e,t,r,i,a){return this._camera.fitScreenCoordinates(e,t,r,i,a),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateAnchoredCameraOptions(e){return this._camera.calculateAnchoredCameraOptions(e)}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,r,i,a)}easeTo(e,t){return this._camera.easeTo(e,t),this}flyTo(e,t){return this._camera.flyTo(e,t),this}stop(){return this._camera.stop(),this}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(J.convert(e),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,r,i){return i==null&&this.terrain&&(i=this.terrain.getElevationForLngLat(r,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(e,t,r,i??0)}resize(e,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);let r=!this._camera._moving;return r&&(this.stop(),this.fire(new K("movestart",e)).fire(new K("move",e))),this.fire(new bt("resize",e)),r&&this.fire(new K("moveend",e)),this}_resizeInternal(e=!0){let[t,r]=this._containerDimensions(),i=this._getClampedPixelRatio(t,r);if(this._resizeCanvas(t,r,i),this.painter.resize(t,r,i),this.painter.overLimit()){let a=this.painter.context.gl;this._maxCanvasSize=[a.drawingBufferWidth,a.drawingBufferHeight];let n=this._getClampedPixelRatio(t,r);this._resizeCanvas(t,r,n),this.painter.resize(t,r,n)}this._resizeTransform(e)}_resizeTransform(e=!0){var i;let[t,r]=this._containerDimensions();this._camera.transform.resize(t,r,e),(i=this._camera._requestedCameraState)==null||i.resize(t,r,e)}_getClampedPixelRatio(e,t){let{0:r,1:i}=this._maxCanvasSize,a=this.getPixelRatio(),n=e*a,s=t*a,o=n>r?r/n:1,l=s>i?i/s:1,u=Math.min(o,l);return u<1&&_e("The canvas is larger than maxCanvasSize and is rendered at a lower pixel ratio to fit. Increase maxCanvasSize, within MAX_TEXTURE_SIZE, to render at full resolution."),u*a}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(e){return this._camera.applyTransformChange(t=>t.setMaxBounds(ci.convert(e))),this._update()}setMinZoom(e){if(e??(e=-2),e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(r=>r.setMinZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new K("zoomstart")).fire(new K("zoom")).fire(new K("zoomend")).fire(new K("movestart")).fire(new K("move")).fire(new K("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(e=!1){let t=this._camera.transform;return e?t.applyConstrain(t.center,t.minZoom).zoom:t.minZoom}setMaxZoom(e){if(e??(e=22),e>=this._camera.transform.minZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(r=>r.setMaxZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new K("zoomstart")).fire(new K("zoom")).fire(new K("zoomend")).fire(new K("movestart")).fire(new K("move")).fire(new K("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(e){if(e??(e=0),e<0)throw Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this._camera.transform.maxPitch){let t=this._camera.transform.pitch;return this._camera.applyTransformChange(r=>r.setMinPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new K("pitchstart")).fire(new K("pitch")).fire(new K("pitchend")).fire(new K("movestart")).fire(new K("move")).fire(new K("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(e){if(e??(e=60),e>180)throw Error("maxPitch must be less than or equal to 180");if(e>=this._camera.transform.minPitch){let t=this._camera.transform.pitch;return this._camera.applyTransformChange(r=>r.setMaxPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new K("pitchstart")).fire(new K("pitch")).fire(new K("pitchend")).fire(new K("movestart")).fire(new K("move")).fire(new K("moveend")),this}throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if(e??(e=20),e>180)throw Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(e){return this._camera.applyTransformChange(t=>t.setRenderWorldCopies(e)),this._update()}setTransformConstrain(e){return this._camera.applyTransformChange(t=>t.setConstrainOverride(e)),this._update()}project(e){return this._camera.transform.locationToScreenPoint(J.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(C.convert(e),this.terrain)}isMoving(){var e;return this._camera.isMoving()||((e=this._handlers)==null?void 0:e.isMoving())||!1}isZooming(){var e;return this._camera.isZooming()||((e=this._handlers)==null?void 0:e.isZooming())||!1}isRotating(){var e;return this._camera.isRotating()||((e=this._handlers)==null?void 0:e.isRotating())||!1}_createDelegates(e,t,r){if(e==="mouseenter"||e==="mouseover"){let i=!1;return{mousemove:a=>{let n=t.filter(o=>this.getLayer(o)),s=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});s.length?i||(i=!0,r.call(this,new ir(e,this,a.originalEvent,{features:s}))):i=!1},mouseout:()=>{i=!1}}}if(e==="mouseleave"||e==="mouseout"){let i=!1;return{mousemove:a=>{let n=t.filter(s=>this.getLayer(s));(n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n})).length?i=!0:i&&(i=!1,r.call(this,new ir(e,this,a.originalEvent)))},mouseout:a=>{i&&(i=!1,r.call(this,new ir(e,this,a.originalEvent)))}}}{let i=a=>{let n=t.filter(o=>this.getLayer(o)),s=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});s.length&&(a.features=s,r.call(this,a),delete a.features)};return{[e]:i}}}_addDelegatedListener(e,t){var r;this._delegatedListeners||(this._delegatedListeners={}),(r=this._delegatedListeners)[e]||(r[e]=[]),this._delegatedListeners[e].push(t);for(let i in t.delegates)this.on(i,t.delegates[i])}_removeDelegatedListener(e,t,r){var a;if(!((a=this._delegatedListeners)!=null&&a[e]))return;let i=this._delegatedListeners[e];for(let n=0;n<i.length;n++){let s=i[n];if(s.listener===r&&s.layers.length===t.length&&s.layers.every(o=>t.includes(o))){for(let o in s.delegates)this.off(o,s.delegates[o]);i.splice(n,1);return}}}on(e,t,r){if(r===void 0)return super.on(e,t);let i=typeof t=="string"?[t]:t,a={layers:i,listener:r,delegates:this._createDelegates(e,i,r)};return this._addDelegatedListener(e,a),{unsubscribe:()=>{this._removeDelegatedListener(e,i,r)}}}once(e,t,r){if(r===void 0)return super.once(e,t);let i=typeof t=="string"?[t]:t,a={layers:i,listener:r,delegates:this._createDelegates(e,i,n=>{this._removeDelegatedListener(e,i,r),r.call(this,n)})};return this._addDelegatedListener(e,a),this}off(e,t,r){if(r===void 0)return super.off(e,t);let i=typeof t=="string"?[t]:t;return this._removeDelegatedListener(e,i,r),this}queryRenderedFeatures(e,t){if(!this.style)return[];let r,i=e instanceof C||Array.isArray(e),a=i?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||(t=(i?{}:e)||{}),a instanceof C||typeof a[0]=="number")r=[C.convert(a)];else{let n=C.convert(a[0]),s=C.convert(a[1]);r=[n,new C(s.x,n.y),s,new C(n.x,s.y),n]}return this.style.queryRenderedFeatures(r,t,this._camera.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return t=W({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t),this._styleUrl=typeof e=="string"?e:null,t.diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(e,t))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(t==null)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,a,n;if((i=this._diffStyleRequest)==null||i.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded){this.style.once("style.load",()=>this._updateStyle(e,t));return}let r=this.style&&t.transformStyle?this.style.serialize():void 0;if(this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e)this.style=new mg(this,t||{});else return this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),(n=(a=this.style)==null?void 0:a.projection)==null||n.destroy(),delete this.style,this;return this.style.setEventedParent(this,{style:this.style}),typeof e=="string"?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this}_lazyInitEmptyStyle(){this.style||(this.style=new mg(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(e,t){var r;if((r=this._diffStyleRequest)==null||r.abort(),typeof e=="string"){let i=e;this._diffStyleRequest=new AbortController;let a=this._diffStyleRequest;try{let n=await this._requestManager.transformRequest(i,"Style");if(a.signal.aborted){this._diffStyleRequest=null;return}let s=await _l(n,a);this._diffStyleRequest=null,this._updateDiff(s.data,t)}catch(n){this._diffStyleRequest=null,Si(n)||this.fire(new X(zt(n)))}}else typeof e=="object"&&(this._diffStyleRequest=null,this._updateDiff(e,t))}_updateDiff(e,t){try{this.style.setState(e,t)&&this._update(!0)}catch(r){_e(`Unable to perform style diff: ${zt(r).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(!this.style){_e("There is no style added to the map.");return}return this.style.loaded()}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){var r;let t=(r=this.style)==null?void 0:r.tileManagers[e];if(t===void 0){this.fire(new X(Error(`There is no tile manager with ID '${e}'`)));return}return t.loaded()}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&_s(this,Zt.terrain,{value:e},t))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),!e)this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this.painter.destroyRTTResources(),this._camera.setTerrain(null);else{let r=this.style.tileManagers[e.source];if(!r)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&r.reload();for(let i in this.style._layers){let a=this.style._layers[i];a.type==="hillshade"&&a.source===e.source&&_e("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),a.type==="color-relief"&&a.source===e.source&&_e("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain&&this.terrain.destroy(),this.terrain=new jM(this.painter,r,e,this._terrainSkirtLength),this.painter.renderToTexture=new $F(this.painter,this.terrain),this._camera.setTerrain(this.terrain),this._terrainDataCallback=i=>this._handleTerrainDataEvent(i,e.source),this.style.on("data",this._terrainDataCallback)}return this.style.triggerSymbolPlacement(),this.fire(new wC({terrain:e})),this}_handleTerrainDataEvent(e,t){var i;if(e.dataType==="style"){this.terrain.tileManager.releaseAllRTT();return}let r=e.sourceId===t;if(r&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),r&&e.tile&&(this.painter.markTerrainDepthDirty(),this._camera.applyTerrainChange()),e.tile){if(((i=e.source)==null?void 0:i.type)==="image"){this.terrain.tileManager.releaseAllRTT();return}this.terrain.tileManager.releaseRTT(e.tile.tileID)}}getTerrain(){var e;return((e=this.terrain)==null?void 0:e.options)??null}areTilesLoaded(){var t;let e=(t=this.style)==null?void 0:t.tileManagers;for(let r of Object.values(e))if(!r.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){var t;return(t=this.style)==null?void 0:t.getSource(e)}setSourceTileLodParams(e,t,r){if(r){let i=this.getSource(r);if(!i)throw Error(`There is no source with ID "${r}", cannot set LOD parameters`);i.calculateTileZoom=Ic(Math.max(1,e),Math.max(1,t))}else for(let i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=Ic(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let r=this.style.tileManagers[e];if(!r)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);t===void 0?r.reload(!0):r.refreshTiles(t.map(i=>new Vl(i.z,i.x,i.y)))}addImage(e,t,r={}){var a;this._lazyInitEmptyStyle();let i=this._createStyleImage(t,r);return i?(this.style.addImage(e,i),(a=i.userImage)!=null&&a.onAdd&&i.userImage.onAdd(this,e),this):this}setMissingStyleImageResolver(e){var t;return this._missingStyleImageResolver=e,(t=this.style)==null||t.setMissingImageResolver(e),this}_createStyleImage(e,t={}){let{pixelRatio:r=1,sdf:i=!1,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l}=t;if(e instanceof HTMLImageElement||Gi(e)){let{width:u,height:h,data:c}=Xt.getImageData(e);return{data:new $e({width:u,height:h},c),pixelRatio:r,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l,sdf:i,version:0}}if(e.width===void 0||e.height===void 0)return this.fire(new X(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`"))),null;{let{width:u,height:h,data:c}=e,d=e,p=il(d.data);return{data:p?new $e({width:u,height:h}):new $e({width:u,height:h},new Uint8Array(c)),pixelRatio:r,stretchX:a,stretchY:n,content:s,textFitWidth:o,textFitHeight:l,sdf:i,version:0,isWebGLImage:p,userImage:d}}}updateImage(e,t){let r=this.style.getImage(e);if(!r)return this.fire(new X(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:a,data:n}=t instanceof HTMLImageElement||Gi(t)?Xt.getImageData(t):t;if(i===void 0||a===void 0)return this.fire(new X(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(i!==r.data.width||a!==r.data.height)return this.fire(new X(Error("The width and height of the updated image must be that same as the previous version of the image")));if(r.isWebGLImage=il(n),r.isWebGLImage)r.userImage=t;else{let s=!(t instanceof HTMLImageElement||Gi(t));r.data.replace(n,s)}return this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new X(Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await Gr.getImage(await this._requestManager.transformRequest(e,"Image"),new AbortController);if(!t.data)throw Error(`Could not load image ${e}: the response is empty`);return t}listImages(){var e;return((e=this.style)==null?void 0:e.listImages())??[]}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){var t;return(t=this.style)==null?void 0:t.getLayer(e)}getLayersOrder(){var e;return((e=this.style)==null?void 0:e.getLayersOrder())??[]}setLayerZoomRange(e,t,r){return this.style.setLayerZoomRange(e,t,r),this._update(!0)}setFilter(e,t,r={}){var i;return(i=this.style)==null||i.setFilter(e,t,r),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,r,i={}){var a;return(a=this.style)==null||a.setPaintProperty(e,t,r,i),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,r,i={}){return this.style.setLayoutProperty(e,t,r,i),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}setFontFaces(e){return this._lazyInitEmptyStyle(),this.style.setFontFaces(e),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}addSprite(e,t,r={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,r,i=>{i||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,r=>{r||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=Math.floor(this._container.clientWidth)||400,t=Math.floor(this._container.clientHeight)||300),[e,t]}_shouldHandleInitialResize(){var r;if(!((r=this._container)!=null&&r.clientWidth)||!this._container.clientHeight)return!1;let[e,t]=this._containerDimensions();return e!==this._camera.transform.width||t!==this._camera.transform.height}_setupResizeObserver(){let e=!1,t=ip(i=>{this._trackResize&&!this._removed&&(this.resize(i),this.redraw())},50),r=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new r(i=>{!e&&(e=!0,!this._shouldHandleInitialResize())||t(i)}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if(typeof e=="string"){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&typeof e=="object"&&e.nodeType===1)return e;throw Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){let e=this._containerDimensions(),t=this._getClampedPixelRatio(e[0],e[1]),r=this._container;r.classList.add("maplibregl-map");let i=this._canvasContainer=Je.create("div","maplibregl-canvas-container",r);this._interactive&&i.classList.add("maplibregl-interactive"),this._canvas=Je.create("canvas","maplibregl-canvas",i),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._resizeCanvas(e[0],e[1],t);let a=this._controlContainer=Je.create("div","maplibregl-control-container",r),n=this._controlPositions={};for(let s of["top-left","top-right","bottom-left","bottom-right"])n[s]=Je.create("div",`maplibregl-ctrl-${s} `,a);this._container.addEventListener("scroll",this._onMapScroll,!1)}_cleanupContainer(){this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map")}_resizeCanvas(e,t,r){let i=Math.round(r*e),a=Math.round(r*t);this._canvas.width=i,this._canvas.height=a,this._canvas.style.width=`${i/r}px`,this._canvas.style.height=`${a/r}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t=i},{once:!0});let r=this._canvas.getContext("webgl2",e);if(!r)throw new Yz(e,t);this.painter=new Xz(r,this._camera.transform)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.painter.transform=e,this.fire(new TC({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){var t;return(t=this.style)!=null&&t._loaded?(this._styleDirty||(this._styleDirty=e),this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var s,o,l,u,h;let t=this._idleTriggered?this._fadeDuration:0,r=((s=this.style.projection)==null?void 0:s.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let i=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let c=this._camera.transform.zoom,d=Fe();this.style.zoomHistory.update(c,d);let p=new ze(c,{now:d,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),f=p.crossFadingFactor();(f!==1||f!==this._crossFadingFactor)&&(i=!0,this._crossFadingFactor=f),this.style.update(p)}let a=((o=this.style.projection)==null?void 0:o.transitionState)>0!==r;this._camera.transform.setTransitionState((l=this.style.projection)==null?void 0:l.transitionState),this.style&&(this._sourcesDirty||a)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain)&&this.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=(u=this.style)==null?void 0:u._updatePlacement(this._camera.transform,this.showCollisionBoxes,t,this._crossSourceCollisions,a),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new bt("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new bt("load"))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let n=this._sourcesDirty||this._styleDirty||this._placementDirty||((h=this.painter.renderToTexture)==null?void 0:h.needsFollowUpFrame);return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new bt("idle")),this._loaded&&!this._fullyLoaded&&!n&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._render(0)),this}remove(){var t,r;this._hash&&this._hash.remove();for(let i of this._controls)i.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._renderTaskQueue.clear(),(t=this._diffStyleRequest)==null||t.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),Gr.removeThrottleControl(this._imageQueueHandle),(r=this._resizeObserver)==null||r.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new bt("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Xt.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(t){if(!Si(t))throw t}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return VF}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};function NF(e,t,r,i=!1){if(i||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return e==null?void 0:e.wrap();let a=new J(e.lng,e.lat);if(e=new J(e.lng,e.lat),t){let n=new J(e.lng-360,e.lat),s=new J(e.lng+360,e.lat),o=r.locationToScreenPoint(e).distSqr(t);r.locationToScreenPoint(n).distSqr(t)<o?e=n:r.locationToScreenPoint(s).distSqr(t)<o&&(e=s)}for(;Math.abs(e.lng-r.center.lng)>180;){let n=r.locationToScreenPoint(e);if(n.x>=0&&n.y>=0&&n.x<=r.width&&n.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:a}const bx={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function UF(e,t,r){let i=e.classList;for(let a in bx)i.remove(`maplibregl-${r}-anchor-${a}`);i.add(`maplibregl-${r}-anchor-${t}`)}const Rg={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},wx="#3FB1CE";function cr(e,t,r=[]){let i=Je.createNS("http://www.w3.org/2000/svg",e);for(let a in t)i.setAttributeNS(null,a,t[a]);for(let a of r)i.appendChild(a);return i}let lh;function GF(){return lh||(lh=cr("svg",{display:"block",height:"41px",width:"27px",viewBox:"0 0 27 41"},[cr("g",{"fill-rule":"nonzero"},[cr("g",{transform:"translate(3.0, 29.0)",fill:"#000000"},[["10.5","5.25002273"],["10.5","5.25002273"],["9.5","4.77275007"],["8.5","4.29549936"],["7.5","3.81822308"],["6.5","3.34094679"],["5.5","2.86367051"],["4.5","2.38636864"]].map(([e,t])=>cr("ellipse",{opacity:"0.04",cx:"10.5",cy:"5.80029008",rx:e,ry:t}))),cr("g",{fill:wx},[cr("path",{d:"M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"})]),cr("g",{opacity:"0.25",fill:"#000000"},[cr("path",{d:"M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"})]),cr("g",{transform:"translate(6.0, 7.0)",fill:"#FFFFFF"}),cr("g",{transform:"translate(8.0, 8.0)"},[cr("circle",{fill:"#000000",opacity:"0.25",cx:"5.5",cy:"5.5",r:"5.4999962"}),cr("circle",{fill:"#FFFFFF",cx:"5.5",cy:"5.5",r:"5.4999962"})])])]),lh)}function qF(e){return e.firstElementChild.children[1]}var Ta=class extends ia{},ZF=class extends ia{},sR=class extends Rt{constructor(e){if(super(),this._onClick=t=>{this.fire(new ZF("click",{originalEvent:t}))},this._onKeyPress=t=>{(t.code==="Space"||t.code==="Enter")&&this.togglePopup()},this._onKeyDown=t=>{if(!this._defaultMarker||!this._draggable||!this._map||!this._lngLat||t.composedPath()[0]!==this._element||t.altKey||t.ctrlKey||t.metaKey)return;let r=Rg[t.key];if(!r)return;t.preventDefault(),t.stopPropagation();let i=t.shiftKey?10:1,a=this._map.project(this._lngLat);this.setLngLat(this._map.unproject(new C(a.x+r[0]*i,a.y+r[1]*i))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new Ta("dragstart"))),this.fire(new Ta("drag"))},this._onKeyUp=t=>{Rg[t.key]&&this._endKeyboardDrag()},this._onBlur=()=>{this._endKeyboardDrag()},this._onMapClick=t=>{let r=t.originalEvent.target,i=this._element;this._popup&&(r===i||i.contains(r))&&this.togglePopup()},this._updateCoveredUnthrottled=()=>{var i,a;let t=(i=this._map)==null?void 0:i.terrain;if(!t||!this._isInViewport())return;let r=this._isCovered(t);r&&((a=this._popup)!=null&&a.isOpen())&&this._popup.remove(),this._element.style.opacity=r?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",r)},this._updateCovered=ip(this._updateCoveredUnthrottled,100),this._update=t=>{if(!this._map)return;this._lngLat=NF(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?r=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?i="rotateX(0deg)":this._pitchAlignment==="map"&&(i=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(t==null?void 0:t.type)!=="move"&&(this._pos=this._pos.round()),this._element.style.transform=`${bx[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${r}`,this._updateOpacity()},this._onMove=t=>{if(!this._isDragging){let r=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=r}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new Ta("dragstart"))),this.fire(new Ta("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new Ta("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=(e==null?void 0:e.anchor)||"center",this._color=(e==null?void 0:e.color)||wx,this._scale=(e==null?void 0:e.scale)||1,this._draggable=(e==null?void 0:e.draggable)||!1,this._clickTolerance=(e==null?void 0:e.clickTolerance)||0,this._subpixelPositioning=(e==null?void 0:e.subpixelPositioning)||!1,this._isDragging=!1,this._roleManaged=!1,this._tabIndexManaged=!1,this._keyboardDragActive=!1,this._state="inactive",this._rotation=(e==null?void 0:e.rotation)||0,this._rotationAlignment=(e==null?void 0:e.rotationAlignment)||"auto",this._pitchAlignment=e!=null&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e==null?void 0:e.element)this._element=e.element,this._offset=C.convert((e==null?void 0:e.offset)||[0,0]);else{this._defaultMarker=!0,this._element=Je.create("div");let t=GF().cloneNode(!0);t.setAttributeNS(null,"height",`${41*this._scale}px`),t.setAttributeNS(null,"width",`${27*this._scale}px`),qF(t).setAttributeNS(null,"fill",this._color),this._element.appendChild(t),this._offset=C.convert((e==null?void 0:e.offset)||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",t=>{t.preventDefault()}),this._element.addEventListener("mousedown",t=>{t.preventDefault()}),UF(this._element,this._anchor,"marker"),e==null?void 0:e.className)for(let t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._defaultMarker&&!this._element.hasAttribute("aria-label")&&this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._updateAccessibilityRole(),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),e.on("idle",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("idle",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._element.removeEventListener("keypress",this._onKeyPress),this._keyboardDragActive=!1,this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=J.convert(e),this._pos=null,this._update(),this._popup&&this._popup.setLngLat(this._lngLat),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress)),e){if(!("offset"in e.options)){let t=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[t,(24.6+t)*-1],"bottom-right":[-t,(24.6+t)*-1],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=e,this._element.addEventListener("keypress",this._onKeyPress)}return this._updateTabIndex(),this._updateAccessibilityRole(),this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}_endKeyboardDrag(){this._keyboardDragActive&&(this._keyboardDragActive=!1,this.fire(new Ta("dragend")))}getPopup(){return this._popup}togglePopup(){let e=this._popup;if(this._element.style.opacity===this._opacityWhenCovered)return this;if(e)e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map));else return this;return this}_updateOpacity(){var r;if(!this._isInViewport())return;let e=(r=this._map)==null?void 0:r.terrain,t=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!e||t){let i=t?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==i&&(this._element.style.opacity=i,this._element.classList.toggle("maplibregl-marker-covered",t));return}this._updateCovered()}_isInViewport(){let{width:e,height:t}=this._map._camera.transform;return!!this._pos&&this._pos.x>=0&&this._pos.y>=0&&this._pos.x<=e&&this._pos.y<=t}_isCovered(e){let t=this._map._camera.transform,r=e.getElevationForLngLat(this._lngLat,t),i=Math.max(0,-this._offset.y)/t.pixelsPerMeter,a=Math.sin(this._map.getPitch()*Math.PI/180)*i;return t.isLocationOccluded(this._lngLat,e,r+a)}getOffset(){return this._offset}setOffset(e){return this._offset=C.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._element.classList.toggle("maplibregl-marker-draggable",this._draggable),this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this._defaultMarker&&(this._draggable?(this._element.addEventListener("keydown",this._onKeyDown),this._element.addEventListener("keyup",this._onKeyUp),this._element.addEventListener("blur",this._onBlur)):(this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._endKeyboardDrag())),this._updateTabIndex(),this._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateTabIndex(){this._popup||this._defaultMarker&&this._draggable?this._element.hasAttribute("tabindex")||(this._element.setAttribute("tabindex","0"),this._tabIndexManaged=!0):this._tabIndexManaged&&(this._tabIndexManaged=(this._element.getAttribute("tabindex")==="0"&&this._element.removeAttribute("tabindex"),!1))}_updateAccessibilityRole(){if(!this._defaultMarker||this._element.hasAttribute("role")&&!this._roleManaged)return;let e=this._draggable||this._popup?"button":"img";this._element.setAttribute("role",e),this._roleManaged=!0}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(this._opacity===void 0||e===void 0&&t===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=String(e)),t!==void 0&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(),this}};function oR(){return Ei.WORKER_URL}function lR(e){Ei.WORKER_URL=e}const uR="/assets/maplibre-gl-worker-Bm_qEFDl.js";export{oR as I,lR as L,nR as V,uR as a,sR as i,kF as j,ci as w};