Files
ucvl-home-vision/web/ui/assets/controller-Je5cOZA3.js
T

832 lines
1.1 MiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var Nx=Object.create,k_=Object.defineProperty,Ux=Object.getOwnPropertyDescriptor,$x=Object.getOwnPropertyNames,Gx=Object.getPrototypeOf,Zx=Object.prototype.hasOwnProperty,hd=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),qx=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=$x(t),n=0,o=a.length,s;n<o;n++)s=a[n],!Zx.call(e,s)&&s!==i&&k_(e,s,{get:(l=>t[l]).bind(null,s),enumerable:!(r=Ux(t,s))||r.enumerable});return e},Wx=(e,t,i)=>(i=e==null?{}:Nx(Gx(e)),qx(k_(i,"default",{value:e,enumerable:!0}),e)),R_="6.15.0";function M(e,t){this.x=e,this.y=t}M.prototype={clone(){return new M(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,i=e.y-this.y;return t*t+i*i},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,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,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),i=Math.sin(e),r=t*this.x-i*this.y,a=i*this.x+t*this.y;return this.x=r,this.y=a,this},_rotateAround(e,t){let i=Math.cos(e),r=Math.sin(e),a=t.x+i*(this.x-t.x)-r*(this.y-t.y),n=t.y+r*(this.x-t.x)+i*(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:M},M.convert=function(e){if(e instanceof M)return e;if(Array.isArray(e))return new M(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new M(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};function Hx(e,t,i,r){let a=3*e,n=3*(i-e)-a,o=1-a-n,s=3*t,l=3*(r-t)-s,u=1-s-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=((o*d+n)*d+a)*d-h;if(Math.abs(g)<c)return((u*d+l)*d+s)*d;let _=(3*o*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=((o*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+s)*d}}let bn;function cd(){return bn!=null||(bn=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),bn}let rs;function L_(){if(rs==null&&(rs=!1,cd())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;i<25;i++){let r=i*4;e.fillStyle=`rgb(${r},${r+1},${r+2})`,e.fillRect(i%5,Math.floor(i/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let i=0;i<100;i++)if(i%4!=3&&t[i]!==i){rs=!0;break}}}return rs||!1}var Tt=typeof Float32Array<"u"?Float32Array:Array;function B_(){var e=new Tt(4);return Tt!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function Xx(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=i*n-a*r;return o?(o=1/o,e[0]=n*o,e[1]=-r*o,e[2]=-a*o,e[3]=i*o,e):null}function Yx(e){return e[0]*e[3]-e[2]*e[1]}function Kx(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*s,e[1]=a*l+o*s,e[2]=r*-s+n*l,e[3]=a*-s+o*l,e}function O_(){var e=new Tt(9);return Tt!=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 Jx(e){var t=e[0],i=e[1],r=e[2],a=e[3],n=e[4],o=e[5],s=e[6],l=e[7],u=e[8];return t*(u*n-o*l)+i*(-u*a+o*s)+r*(l*a-n*s)}function Qx(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function eb(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=i+i,s=r+r,l=a+a,u=i*o,h=r*o,c=r*s,d=a*o,p=a*s,f=a*l,m=n*o,g=n*s,_=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 la(){var e=new Tt(16);return Tt!=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 zh(e){var t=new Tt(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 tb(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 Ii(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 Js(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=t[4],s=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=i*s-r*o,v=i*l-a*o,x=i*u-n*o,b=r*l-a*s,w=r*u-n*s,T=a*u-n*l,S=h*m-c*f,C=h*g-d*f,F=h*_-p*f,A=c*g-d*m,L=c*_-p*m,I=d*_-p*g,E=y*I-v*L+x*A+b*F-w*C+T*S;return E?(E=1/E,e[0]=(s*I-l*L+u*A)*E,e[1]=(a*L-r*I-n*A)*E,e[2]=(m*T-g*w+_*b)*E,e[3]=(d*w-c*T-p*b)*E,e[4]=(l*F-o*I-u*C)*E,e[5]=(i*I-a*F+n*C)*E,e[6]=(g*x-f*T-_*v)*E,e[7]=(h*T-d*x+p*v)*E,e[8]=(o*L-s*F+u*S)*E,e[9]=(r*F-i*L-n*S)*E,e[10]=(f*w-m*x+_*y)*E,e[11]=(c*x-h*w-p*y)*E,e[12]=(s*C-o*A-l*S)*E,e[13]=(i*A-r*C+a*S)*E,e[14]=(m*v-f*b-g*y)*E,e[15]=(h*b-c*v+d*y)*E,e):null}function Pa(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=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=i[0],x=i[1],b=i[2],w=i[3];return e[0]=v*r+x*s+b*c+w*m,e[1]=v*a+x*l+b*d+w*g,e[2]=v*n+x*u+b*p+w*_,e[3]=v*o+x*h+b*f+w*y,v=i[4],x=i[5],b=i[6],w=i[7],e[4]=v*r+x*s+b*c+w*m,e[5]=v*a+x*l+b*d+w*g,e[6]=v*n+x*u+b*p+w*_,e[7]=v*o+x*h+b*f+w*y,v=i[8],x=i[9],b=i[10],w=i[11],e[8]=v*r+x*s+b*c+w*m,e[9]=v*a+x*l+b*d+w*g,e[10]=v*n+x*u+b*p+w*_,e[11]=v*o+x*h+b*f+w*y,v=i[12],x=i[13],b=i[14],w=i[15],e[12]=v*r+x*s+b*c+w*m,e[13]=v*a+x*l+b*d+w*g,e[14]=v*n+x*u+b*p+w*_,e[15]=v*o+x*h+b*f+w*y,e}function st(e,t,i){var r=i[0],a=i[1],n=i[2],o,s,l,u,h,c,d,p,f,m,g,_;return t===e?(e[12]=t[0]*r+t[4]*a+t[8]*n+t[12],e[13]=t[1]*r+t[5]*a+t[9]*n+t[13],e[14]=t[2]*r+t[6]*a+t[10]*n+t[14],e[15]=t[3]*r+t[7]*a+t[11]*n+t[15]):(o=t[0],s=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]=o,e[1]=s,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]=o*r+h*a+f*n+t[12],e[13]=s*r+c*a+m*n+t[13],e[14]=l*r+d*a+g*n+t[14],e[15]=u*r+p*a+_*n+t[15]),e}function Rt(e,t,i){var r=i[0],a=i[1],n=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,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 Wa(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[4],o=t[5],s=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*r,e[5]=o*a+h*r,e[6]=s*a+c*r,e[7]=l*a+d*r,e[8]=u*a-n*r,e[9]=h*a-o*r,e[10]=c*a-s*r,e[11]=d*a-l*r,e}function j_(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],o=t[1],s=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*r,e[1]=o*a-h*r,e[2]=s*a-c*r,e[3]=l*a-d*r,e[8]=n*r+u*a,e[9]=o*r+h*a,e[10]=s*r+c*a,e[11]=l*r+d*a,e}function Dr(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],o=t[1],s=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*r,e[1]=o*a+h*r,e[2]=s*a+c*r,e[3]=l*a+d*r,e[4]=u*a-n*r,e[5]=h*a-o*r,e[6]=c*a-s*r,e[7]=d*a-l*r,e}function ib(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 rb(e,t,i,r,a){var n=1/Math.tan(t/2);if(e[0]=n/i,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 o=1/(r-a);e[10]=(a+r)*o,e[14]=2*a*r*o}else e[10]=-1,e[14]=-2*r;return e}var kh=rb;function ab(e,t,i,r,a,n,o){var s=1/(t-i),l=1/(r-a),u=1/(n-o);return e[0]=-2*s,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+i)*s,e[13]=(a+r)*l,e[14]=(o+n)*u,e[15]=1,e}var nr=ab;function nb(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 ob(e,t){var i=e[0],r=e[1],a=e[2],n=e[3],o=e[4],s=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],b=t[3],w=t[4],T=t[5],S=t[6],C=t[7],F=t[8],A=t[9],L=t[10],I=t[11],E=t[12],D=t[13],P=t[14],R=t[15];return Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-v)<=1e-6*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-T)<=1e-6*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(l-S)<=1e-6*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(u-C)<=1e-6*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(h-F)<=1e-6*Math.max(1,Math.abs(h),Math.abs(F))&&Math.abs(c-A)<=1e-6*Math.max(1,Math.abs(c),Math.abs(A))&&Math.abs(d-L)<=1e-6*Math.max(1,Math.abs(d),Math.abs(L))&&Math.abs(p-I)<=1e-6*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-E)<=1e-6*Math.max(1,Math.abs(f),Math.abs(E))&&Math.abs(m-D)<=1e-6*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(g-P)<=1e-6*Math.max(1,Math.abs(g),Math.abs(P))&&Math.abs(_-R)<=1e-6*Math.max(1,Math.abs(_),Math.abs(R))}function V_(){var e=new Tt(3);return Tt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Rh(e){var t=new Tt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Pi(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function uf(e,t,i){var r=new Tt(3);return r[0]=e,r[1]=t,r[2]=i,r}function pi(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function dd(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function Ue(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Qs(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function pd(e,t){var i=t[0]-e[0],r=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(i*i+r*r+a*a)}function sb(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function jt(e,t){var i=t[0],r=t[1],a=t[2],n=i*i+r*r+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,i){var r=t[0],a=t[1],n=t[2],o=i[0],s=i[1],l=i[2];return e[0]=a*l-n*s,e[1]=n*o-r*l,e[2]=r*s-a*o,e}function lb(e,t,i,r){var a=t[0],n=t[1],o=t[2];return e[0]=a+r*(i[0]-a),e[1]=n+r*(i[1]-n),e[2]=o+r*(i[2]-o),e}function ub(e,t,i){var r=t[0],a=t[1],n=t[2],o=i[3]*r+i[7]*a+i[11]*n+i[15];return o||(o=1),e[0]=(i[0]*r+i[4]*a+i[8]*n+i[12])/o,e[1]=(i[1]*r+i[5]*a+i[9]*n+i[13])/o,e[2]=(i[2]*r+i[6]*a+i[10]*n+i[14])/o,e}function hb(e,t,i){var r=t[0],a=t[1],n=t[2];return e[0]=r*i[0]+a*i[3]+n*i[6],e[1]=r*i[1]+a*i[4]+n*i[7],e[2]=r*i[2]+a*i[5]+n*i[8],e}function Ou(e,t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=t[0],l=t[1],u=t[2],h=a*u-n*l,c=n*s-r*u,d=r*l-a*s;return h+=h,c+=c,d+=d,e[0]=s+o*h+a*d-n*c,e[1]=l+o*c+n*h-r*d,e[2]=u+o*d+r*c-a*h,e}function wn(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0],n[1]=a[1]*Math.cos(r)-a[2]*Math.sin(r),n[2]=a[1]*Math.sin(r)+a[2]*Math.cos(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function Ta(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[2]*Math.sin(r)+a[0]*Math.cos(r),n[1]=a[1],n[2]=a[2]*Math.cos(r)-a[0]*Math.sin(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function ju(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0]*Math.cos(r)-a[1]*Math.sin(r),n[1]=a[0]*Math.sin(r)+a[1]*Math.cos(r),n[2]=a[2],e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function cb(e){return e[0]=0,e[1]=0,e[2]=0,e}var dr=dd,el=Pi;(function(){var e=V_();return function(t,i,r,a,n,o){var s,l;for(i||(i=3),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,s=r;s<l;s+=i)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],n(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}})();function db(){var e=new Tt(4);return Tt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function pb(e,t,i,r,a){return e[0]=t,e[1]=i,e[2]=r,e[3]=a,e}function fb(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function mb(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function gb(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=i*i+r*r+a*a+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=i*o,e[1]=r*o,e[2]=a*o,e[3]=n*o,e}function Pt(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3];return e[0]=i[0]*r+i[4]*a+i[8]*n+i[12]*o,e[1]=i[1]*r+i[5]*a+i[9]*n+i[13]*o,e[2]=i[2]*r+i[6]*a+i[10]*n+i[14]*o,e[3]=i[3]*r+i[7]*a+i[11]*n+i[15]*o,e}var _b=fb;(function(){var e=db();return function(t,i,r,a,n,o){var s,l;for(i||(i=4),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,s=r;s<l;s+=i)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],n(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}})();function hf(){var e=new Tt(4);return Tt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function yb(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function vb(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function xb(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=i[0],l=i[1],u=i[2],h=i[3];return e[0]=r*h+o*s+a*u-n*l,e[1]=a*h+o*l+n*s-r*u,e[2]=n*h+o*u+r*l-a*s,e[3]=o*h-r*s-a*l-n*u,e}function Ls(e,t,i,r){var a=t[0],n=t[1],o=t[2],s=t[3],l=i[0],u=i[1],h=i[2],c=i[3],d,p=a*l+n*u+o*h+s*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-r)*d)/f,g=Math.sin(r*d)/f):(m=1-r,g=r),e[0]=m*a+g*l,e[1]=m*n+g*u,e[2]=m*o+g*h,e[3]=m*s+g*c,e}function bb(e,t){var i=t[0]+t[4]+t[8],r;if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var a=0;t[4]>t[0]&&(a=1),t[8]>t[a*3+a]&&(a=2);var n=(a+1)%3,o=(a+2)%3;r=Math.sqrt(t[a*3+a]-t[n*3+n]-t[o*3+o]+1),e[a]=.5*r,r=.5/r,e[3]=(t[n*3+o]-t[o*3+n])*r,e[n]=(t[n*3+a]+t[a*3+n])*r,e[o]=(t[o*3+a]+t[a*3+o])*r}return e}function fd(e,t,i,r){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",n=Math.PI/360;t*=n,r*=n,i*=n;var o=Math.sin(t),s=Math.cos(t),l=Math.sin(i),u=Math.cos(i),h=Math.sin(r),c=Math.cos(r);switch(a){case"xyz":e[0]=o*u*c+s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c-o*l*h;break;case"xzy":e[0]=o*u*c-s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c+o*l*h;break;case"yxz":e[0]=o*u*c+s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c+o*l*h;break;case"yzx":e[0]=o*u*c+s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c-o*l*h;break;case"zxy":e[0]=o*u*c-s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c-o*l*h;break;case"zyx":e[0]=o*u*c-s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c+o*l*h;break;default:throw Error("Unknown angle order "+a)}return e}var wb=pb,cf=gb;(function(){var e=V_(),t=uf(1,0,0),i=uf(0,1,0);return function(r,a,n){var o=lt(a,n);return o<-.999999?(Ht(e,t,a),el(e)<1e-6&&Ht(e,i,a),jt(e,e),vb(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(Ht(e,a,n),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,cf(r,r))}})(),(function(){var e=hf(),t=hf();return function(i,r,a,n,o,s){return Ls(e,r,o,s),Ls(t,a,n,s),Ls(i,e,t,2*s*(1-s)),i}})(),(function(){var e=O_();return function(t,i,r,a){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=a[0],e[4]=a[1],e[7]=a[2],e[2]=-i[0],e[5]=-i[1],e[8]=-i[2],cf(t,bb(t,e))}})();function Lh(){var e=new Tt(2);return Tt!=Float32Array&&(e[0]=0,e[1]=0),e}function df(e,t){var i=new Tt(2);return i[0]=e,i[1]=t,i}function pf(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function ff(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function Tb(e){var t=e[0],i=e[1];return t*t+i*i}function Db(e,t){return e[0]*t[0]+e[1]*t[1]}function mf(e){return e[0]=0,e[1]=0,e}var Sb=Tb;(function(){var e=Lh();return function(t,i,r,a,n,o){var s,l;for(i||(i=2),r||(r=0),l=a?Math.min(a*i+r,t.length):t.length,s=r;s<l;s+=i)e[0]=t[s],e[1]=t[s+1],n(e,e,o),t[s]=e[0],t[s+1]=e[1];return t}})();const O=8192;function oi(e,t,i){return t*(O/(e.tileSize*2**(i-e.tileID.overscaledZ)))}function Dt(e){return e instanceof Error?e:Error(typeof e=="string"?e:String(e))}function sr(){return new Float64Array(4)}function Me(){return new Float64Array(3)}function Gr(){return new Float64Array(16)}function as(){let e=new Float64Array(16);return Ii(e),e}function N_(){let e=new Float32Array(16);return Ii(e),e}function Ir(e,t,i,r,a=!1){if(!i[0]&&!i[1])return[0,0];let n=a?r==="map"?-e.bearingInRadians:0:r==="viewport"?e.bearingInRadians:0;if(n){let o=Math.sin(n),s=Math.cos(n);i=[i[0]*s-i[1]*o,i[0]*o+i[1]*s]}return[a?i[0]:oi(t,i[0],e.zoom),a?i[1]:oi(t,i[1],e.zoom)]}function Bh(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function li(e,t,i){let r=Jx([e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]]);if(r===0)return null;let a=Ht([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),n=Ht([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),o=Ht([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),s=Ue([],a,-e[3]);return pi(s,s,Ue([],n,-t[3])),pi(s,s,Ue([],o,-i[3])),Ue(s,s,1/r),s}function Eb(e,t,i){let r=e[0]*i[0]+e[1]*i[1]+e[2]*i[2],a=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return a===0?null:(-r-i[3])/a}function ns(e,t,i,r){let a=Math.sqrt(e*e+t*t),n=Math.sqrt(i*i+r*r);e/=a,t/=a,i/=n,r/=n;let o=e*i+t*r,s=Math.acos(o);return-t*i+e*r>0?s:-s}function Zt(e,t){let i=ea(e,360),r=ea(t,360),a=r-i,n=r>i?a-360:a+360;return Math.abs(a)<Math.abs(n)?a:n}function os(e,t){let i=ea(e,Math.PI*2),r=ea(t,Math.PI*2);return Math.min(Math.abs(i-r),Math.abs(i-r+Math.PI*2),Math.abs(i-r-Math.PI*2))}function ea(e,t){return(e%t+t)%t}function Zn(e,t,i,r,a){return Cr(r,a,Y((e-t)/(i-t),0,1))}function Cr(e,t,i){return e*(1-i)+t*i}function Cb(e){let t=1/0,i=1/0,r=-1/0,a=-1/0;for(let n of e)t=Math.min(t,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),a=Math.max(a,n.y);return[t,i,r,a]}function Pb(e){if(!e.length)return new Set;let t=Math.max(...e.map(l=>l.canonical.z)),i=1/0,r=-1/0,a=1/0,n=-1/0,o=[];for(let l of e){let{x:u,y:h,z:c}=l.canonical,d=2**(t-c),p=u*d,f=h*d;o.push({id:l,x:p,y:f}),p<i&&(i=p),p>r&&(r=p),f<a&&(a=f),f>n&&(n=f)}let s=new Set;for(let l of o)(l.x===i||l.x===r||l.y===a||l.y===n)&&s.add(l.id);return s}function Ab(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function md(e,t,i,r){return Hx(e,t,i,r)}const Oh=md(.25,.1,.25,1);function Y(e,t,i){return Math.min(i,Math.max(t,e))}function fi(e,t,i){let r=i-t,a=((e-t)%r+r)%r+t;return a===t?i:a}function X(e,...t){for(let i of t)for(let r in i)e[r]=i[r];return e}function zl(e,t){let i={};for(let r of t)r in e&&(i[r]=e[r]);return i}let Mb=1;function U_(){return Mb++}function Ib(e){return Math.log(e)/Math.LN2%1==0}function Fb(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}function pt(e){return 2**e}function _t(e){return Math.log(e)/Math.LN2}function ii(e,t,i){if(t<=0)return e;let r=1/t;return i===void 0||Math.abs(i)<1e-10?Math.round(e*r)/r:(i>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r}function gd(e,t,i){let r={};for(let a in e)r[a]=t.call(this,e[a],a,e);return r}function $_(e,t,i){let r={};for(let a in e)t.call(this,e[a],a,e)&&(r[a]=e[a]);return r}function $i(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!$i(e[i],t[i]))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 i in e)if(!$i(e[i],t[i]))return!1;return!0}return e===t}function Wt(e){return Array.isArray(e)?e.map(Wt):typeof e=="object"&&e?gd(e,Wt):e}const gf={};function _e(e){gf[e]||(typeof console<"u"&&console.warn(e),gf[e]=!0)}function Sr(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function zb(e,t,i,r){let a=t.y-e.y,n=t.x-e.x,o=r.y-i.y,s=r.x-i.x,l=o*n-s*a;if(l===0)return null;let u=e.y-i.y,h=e.x-i.x,c=(s*u-o*h)/l;return new M(e.x+c*n,e.y+c*a)}function G_([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,[e*Math.cos(t)*Math.sin(i),e*Math.sin(t)*Math.sin(i),e*Math.cos(i)]}function Ha(e){return typeof WorkerGlobalScope<"u"&&e!==void 0&&e instanceof WorkerGlobalScope}function kb(e){let t=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,i={};if(e.replace(t,(r,a,n,o)=>{let s=n||o;return i[a]=!s||s.toLowerCase(),""}),i["max-age"]){let r=parseInt(i["max-age"],10);isNaN(r)?delete i["max-age"]:i["max-age"]=r}return i}let Vu=null;function Rb(e){if(Vu==null){let t=e.navigator?e.navigator.userAgent:null;Vu=!!e.safari||!!(t&&(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Vu}function Hr(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap}const Lb=async(e,t)=>{let i=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(i,t)}catch(r){throw Error(`Could not load image because of ${Dt(r).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}},Bb=e=>new Promise((t,i)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>r.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=")},r.onerror=()=>i(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"});r.src=URL.createObjectURL(a)});function Ob(e,t,i,r,a){let n=Math.max(-t,0)*4,o=(Math.max(0,i)-i)*r*4+n,s=r*4,l=Math.max(0,t),u=Math.max(0,i),h=Math.min(e.width,t+r),c=Math.min(e.height,i+a);return{rect:{x:l,y:u,width:h-l,height:c-u},layout:[{offset:o,stride:s}]}}async function jb(e,t,i,r,a){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let n=new VideoFrame(e,{timestamp:0});try{let o=n==null?void 0:n.format;if(!o||!(o.startsWith("BGR")||o.startsWith("RGB")))throw Error(`Unrecognized format ${o}`);let s=o.startsWith("BGR"),l=new Uint8ClampedArray(r*a*4);if(await n.copyTo(l,Ob(e,t,i,r,a)),s)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 tl(e,t,i,r){return e.addEventListener(t,i,r),{unsubscribe:()=>{e.removeEventListener(t,i,r)}}}function Ve(e){return e*Math.PI/180}function Ei(e){return e/Math.PI*180}function Z_(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function Vb(e){let t=new Float64Array(9);eb(t,e);let i=Ei(-Math.asin(Y(t[2],-1,1))),r,a;return Math.hypot(t[5],t[8])<.001?(r=0,a=-Ei(Math.atan2(t[3],t[4]))):(r=Ei(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),a=Ei(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:r,pitch:i+90,bearing:a}}function q_(e,t,i){let r=df(t.x-i.x,t.y-i.y),a=df(e.x-i.x,e.y-i.y),n=r[0]*a[1]-r[1]*a[0];return Ei(Math.atan2(n,Db(r,a)))}function _f(e,t,i){let r=new Float64Array(4);return fd(r,e,t-90,i),r}const Fi=85.051129,W_={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},H_={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Nb(e,t){return W_[t]&&"touches"in e}function Ub(e,t){var a,n;if(!H_[t])return!1;let i=e,r=((n=(a=i==null?void 0:i.target)==null?void 0:a.ownerDocument)==null?void 0:n.defaultView)||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function $b(e){return W_[e]||H_[e]}const yf="AbortError";var To=class extends Error{constructor(e=yf){super(e instanceof Error?e.message:e),this.name=yf,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function Fr(e){return e instanceof Error&&e.name==="AbortError"}function _d(e){if(e.aborted)throw new To(e.reason)}let ss,Tn,Nu;const Xt={frame(e,t,i,r){let a=r||window,n=a.requestAnimationFrame(s=>{o(),t(s)}),{unsubscribe:o}=tl(e.signal,"abort",()=>{o(),a.cancelAnimationFrame(n),i(new To(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((i,r)=>{this.frame(e,i,r,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(cd()&&!L_())t=new OffscreenCanvas(e.width,e.height).getContext("2d",{willReadFrequently:!0});else{let i=window.document.createElement("canvas");i.width=e.width,i.height=e.height,t=i.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 ss||(ss=document.createElement("a")),ss.href=e,ss.href},get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return Nu===void 0?matchMedia?(Tn!=null||(Tn=matchMedia("(prefers-reduced-motion: reduce)")),Tn.matches):!1:Nu},set prefersReducedMotion(e){Nu=e}},Gb=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 ke(){return Gb.getCurrentTime()}const Zb=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(".")),qb=new Set(["alt","class","datetime","dir","height","href","hreflang","lang","referrerpolicy","rel","role","src","target","title","translate","type","width"]),Wb=new Set(["href","src"]),Hb=new Set(["http:","https:","mailto:"]);let Dn;function Uu(){return Dn!=null||(Dn={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}),Dn}var t,Be,De=(Be=class{static create(t,i,r){let a=window.document.createElement(t);return i!==void 0&&(a.className=i),r&&r.appendChild(a),a}static createNS(t,i){return window.document.createElementNS(t,i)}static disableDrag(){Be.docStyle&&Be.selectProp&&(Be.userSelect=Be.docStyle[Be.selectProp],Be.docStyle[Be.selectProp]="none")}static enableDrag(){Be.docStyle&&Be.selectProp&&(Be.docStyle[Be.selectProp]=Be.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",Be.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",Be.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",Be.suppressClickInternal,!0)},0)}static getScale(t){let i=t.getBoundingClientRect();return{x:i.width/t.offsetWidth||1,y:i.height/t.offsetHeight||1,boundingClientRect:i}}static getPoint(t,i,r){let a=i.boundingClientRect;return new M((r.clientX-a.left)/i.x-t.clientLeft,(r.clientY-a.top)/i.y-t.clientTop)}static mousePos(t,i){let r=Be.getScale(t);return Be.getPoint(t,r,i)}static touchPos(t,i){let r=[],a=Be.getScale(t);for(let n of i)r.push(Be.getPoint(t,a,n));return r}static sanitize(t){let i=new DOMParser().parseFromString(t,"text/html").body,{querySelectorAll:r,remove:a}=Uu();for(let o of Array.from(r.call(i,"*")))Be.isAllowedElement(o)?Be.removeDisallowedAttributes(o):a.call(o);let n=document.createDocumentFragment();return n.append(...i.childNodes),n}static isAllowedElement(t){let{namespaceURI:i,localName:r}=Uu();return i.call(t)==="http://www.w3.org/1999/xhtml"&&Zb.has(r.call(t))}static removeDisallowedAttributes(t){let{getAttributeNames:i,getAttribute:r,removeAttribute:a}=Uu();for(let n of i.call(t))Be.isAllowedAttribute(n,r.call(t,n))||a.call(t,n)}static isAllowedAttribute(t,i){if(!qb.has(t)&&!t.startsWith("aria-"))return!1;if(!Wb.has(t))return!0;try{return Hb.has(new URL(i,"https://maplibre.invalid/").protocol)}catch(r){return!1}}},Be.docStyle=typeof window<"u"&&((t=window.document)==null?void 0:t.documentElement.style),Be.selectProp=!Be.docStyle||"userSelect"in Be.docStyle?"userSelect":"webkitUserSelect",Be);const ta={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function X_(e){return ta.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const jh="global-dispatcher";var il=class extends Error{constructor(e,t,i,r){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=r}};function yd(){var e;if(Ha(self))return(e=self.worker)==null?void 0:e.referrer;if(window.location.protocol==="blob:")try{return window.parent.location.href}catch(t){}return window.location.href}const Xb=e=>{var t;return e.startsWith("file:")||((t=yd())==null?void 0:t.startsWith("file:"))&&!/^\w+:/.test(e)};async function Yb(e,t){let i=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:yd(),referrerPolicy:e.referrerPolicy,signal:t.signal});e.type==="json"&&!i.headers.has("Accept")&&i.headers.set("Accept","application/json");let r;try{r=await fetch(i)}catch(o){throw Fr(o)?o:new il(0,Dt(o).message,e.url,new Blob)}if(!r.ok){let o=await r.blob();throw new il(r.status,r.statusText,e.url,o)}let a;a=e.type==="arrayBuffer"||e.type==="image"?r.arrayBuffer():e.type==="json"?r.json():r.text();let n=await a;return _d(t.signal),{data:n,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),etag:r.headers.get("ETag")}}function Kb(e,t){return new Promise((i,r)=>{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 o in e.headers)a.setRequestHeader(o,e.headers[o]);e.type==="json"&&(a.responseType="text",(n=e.headers)!=null&&n.Accept||a.setRequestHeader("Accept","application/json")),a.withCredentials=e.credentials==="include",a.onerror=()=>{r(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||a.status===0)&&a.response!==null){let o=a.response;if(e.type==="json")try{o=JSON.parse(a.response)}catch(s){r(s);return}i({data:o,cacheControl:a.getResponseHeader("Cache-Control"),expires:a.getResponseHeader("Expires"),etag:a.getResponseHeader("ETag")})}else{let o=new Blob([a.response],{type:a.getResponseHeader("Content-Type")});r(new il(a.status,a.statusText,e.url,o))}},t.signal.addEventListener("abort",()=>{a.abort(),r(new To(t.signal.reason))}),a.send(e.body)})}const kl=async function(e,t){var i,r;if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){let a=X_(e.url);if(a){let n=await a(e,t);return!n.data&&e.type==="arrayBuffer"?X(n,{data:new ArrayBuffer(0)}):n}if(Ha(self)&&((i=self.worker)!=null&&i.actor))return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:jh},t)}if(!Xb(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return Yb(e,t);if(Ha(self)&&((r=self.worker)!=null&&r.actor))return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:jh},t)}return Kb(e,t)},Rl=(e,t)=>kl(X(e,{type:"json"}),t),Y_=(e,t)=>kl(X(e,{type:"arrayBuffer"}),t);function K_(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),i=window.location;return t.protocol===i.protocol&&t.host===i.host}const Jb=e=>{let t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(let r of e){let a=window.document.createElement("source");K_(r)||(t.crossOrigin="Anonymous"),a.src=r,t.appendChild(a)}})};let Ci;(function(e){let t,i,r,a;e.resetRequestQueue=()=>{t=[],i=0,r=0,a={}},e.addThrottleControl=c=>{let d=r++;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 o(c,d,p,f,m=!0,g){let _=await c.transformRequest(d,p);return _d(f.signal),Ci.getImage(_,f,m,g)}e.transformAndGetImage=o,e.getImage=(c,d,p=!0,f)=>new Promise((m,g)=>{c.headers||(c.headers={}),c.headers.accept="image/webp,*/*",X(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 s=(c,d)=>typeof createImageBitmap=="function"?Lb(c,d):Bb(c),l=async c=>{c.state="running";let{requestParameters:d,supportImageRefresh:p,imageBitmapOptions:f,onError:m,onSuccess:g,abortController:_}=c,y=p===!1&&!f&&!Ha(self)&&!X_(d.url)&&(!d.headers||Object.keys(d.headers).reduce((x,b)=>x&&b==="accept",!0));i++;let v=y?h(d,_):kl(d,_);try{let x=await v;delete c.abortController,c.state="completed",x.data instanceof HTMLImageElement||Hr(x.data)?g(x):!x.data||x.data.byteLength===0?g({data:null,cacheControl:x.cacheControl,expires:x.expires}):g({data:await s(x.data,f),cacheControl:x.cacheControl,expires:x.expires})}catch(x){delete c.abortController,m(Dt(x))}finally{i--,u()}},u=()=>{let c=n()?ta.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:ta.MAX_PARALLEL_IMAGE_REQUESTS;for(let d=i;d<c&&t.length>0;d++){let p=t.shift();p.abortController.signal.aborted?d--: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"||!K_(g))&&(m.crossOrigin="anonymous"),d.signal.addEventListener("abort",()=>{m.src="",f(new To(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})})(Ci||(Ci={})),Ci.resetRequestQueue();var Qb=class{constructor(e){this._transformRequestFn=e!=null?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}};function vf(e,t,i){var r;(r=i[e])!=null&&r.includes(t)||(i[e]||(i[e]=[]),i[e].push(t))}function $u(e,t,i){if(i!=null&&i[e]){let r=i[e].indexOf(t);r!==-1&&i[e].splice(r,1)}}var ua=class{constructor(e,t={}){X(this,t),this.type=e}},K=class extends ua{constructor(e,t={}){super("error",X({error:e},t))}},Ft=class{on(e,t){return this._listeners||(this._listeners={}),vf(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return $u(e,t,this._listeners),$u(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||(this._oneTimeListeners={}),vf(e,t,this._oneTimeListeners),this):new Promise(i=>this.once(e,i))}fire(e,t){var a,n,o,s,l,u;let i=typeof e=="string"?new ua(e,t||{}):e,r=i.type;if(this.listens(r)){i.target=this;let h=(o=(n=(a=this._listeners)==null?void 0:a[r])==null?void 0:n.slice())!=null?o:[];for(let p of h)p.call(this,i);let c=(u=(l=(s=this._oneTimeListeners)==null?void 0:s[r])==null?void 0:l.slice())!=null?u:[];for(let p of c)$u(r,p,this._oneTimeListeners),p.call(this,i);let d=this._eventedParent;d&&(X(i,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),d.fire(i))}else i instanceof K&&console.error(i.error);return this}listens(e){var t,i,r,a,n;return!!((i=(t=this._listeners)==null?void 0:t[e])!=null&&i.length||(a=(r=this._oneTimeListeners)==null?void 0:r[e])!=null&&a.length||(n=this._eventedParent)!=null&&n.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},wt=class extends ua{},ee=class extends wt{},xf=class extends wt{constructor(e={}){super("style.load",e)}},Di=class extends wt{constructor(e,t={}){super(e,t),this.dataType="style"}},$e=class extends wt{constructor(e,t={}){super(e,t),this.dataType="source"}},ri=class extends wt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){i=i instanceof MouseEvent?i:new MouseEvent(e,i);let a=De.mousePos(t.getCanvas(),i),n=t.unproject(a);super(e,X({point:a,lngLat:n,originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}},ls=class extends wt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){let r=e==="touchend"?i.changedTouches:i.touches,a=De.touchPos(t.getCanvasContainer(),r),n=a.map(l=>t.unproject(l)),o=a.reduce((l,u,h,c)=>l.add(u.div(c.length)),new M(0,0)),s=t.unproject(o);super(e,{points:a,point:o,lngLats:n,lngLat:s,originalEvent:i}),this._defaultPrevented=!1}},e2=class extends wt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},bf=class extends wt{},t2=class extends wt{constructor(e={}){super("terrain",e)}},i2=class extends wt{constructor(e={}){super("projectiontransition",e)}},Gu=class extends wt{},r2=class extends wt{constructor(e={}){super("styleimagemissing",e)}},J_={$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 z=J_,a2=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function n2(e,t){let i={};for(let r in e)r!=="ref"&&(i[r]=e[r]);return a2.forEach(r=>{r in t&&(i[r]=t[r])}),i}function wf(e){e=e.slice();let t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=n2(e[i],t[e[i].ref]));return e}function Fe(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Fe(e[i],t[i]))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 i in e)if(!Fe(e[i],t[i]))return!1;return!0}return e===t}function ti(e,t){e.push(t)}function Q_(e,t,i){ti(i,{command:"addSource",args:[e,t[e]]})}function ey(e,t,i){ti(t,{command:"removeSource",args:[e]}),i[e]=!0}function o2(e,t,i,r){ey(e,i,r),Q_(e,t,i)}function s2(e,t,i){let r;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&r!=="data"&&!Fe(e[i][r],t[i][r]))return!1;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&r!=="data"&&!Fe(e[i][r],t[i][r]))return!1;return!0}function l2(e,t,i,r){e||(e={}),t||(t={});let a;for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&(Object.prototype.hasOwnProperty.call(t,a)||ey(a,i,r));for(a in t)Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)?Fe(e[a],t[a])||(e[a].type==="geojson"&&t[a].type==="geojson"&&s2(e,t,a)?ti(i,{command:"setGeoJSONSourceData",args:[a,t[a].data]}):o2(a,t,i,r)):Q_(a,t,i))}function Tf(e,t,i,r,a){ti(t,{command:a,args:[i,r,e[r]]})}function us(e,t,i,r,a){e||(e={}),t||(t={});for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Fe(e[n],t[n])||Tf(t,i,r,n,a));for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&!Object.prototype.hasOwnProperty.call(e,n)&&(Fe(e[n],t[n])||Tf(t,i,r,n,a))}function Df(e){return e.id}function Sf(e,t){return e[t.id]=t,e}function u2(e,t,i){e||(e=[]),t||(t=[]);let r=e.map(Df),a=t.map(Df),n=e.reduce(Sf,{}),o=t.reduce(Sf,{}),s=r.slice(),l=Object.create(null),u,h,c,d,p;for(let f=0,m=0;f<r.length;f++)u=r[f],Object.prototype.hasOwnProperty.call(o,u)?m++:(ti(i,{command:"removeLayer",args:[u]}),s.splice(s.indexOf(u,m),1));for(let f=0,m=0;f<a.length;f++)u=a[a.length-1-f],s[s.length-1-f]!==u&&(Object.prototype.hasOwnProperty.call(n,u)?(ti(i,{command:"removeLayer",args:[u]}),s.splice(s.lastIndexOf(u,s.length-m),1)):m++,d=s[s.length-f],ti(i,{command:"addLayer",args:[o[u],d]}),s.splice(s.length-f,0,u),l[u]=!0);for(let f=0;f<a.length;f++)if(u=a[f],h=n[u],c=o[u],!(l[u]||Fe(h,c)))if(!Fe(h.source,c.source)||!Fe(h["source-layer"],c["source-layer"])||!Fe(h.type,c.type))ti(i,{command:"removeLayer",args:[u]}),d=s[s.lastIndexOf(u)+1],ti(i,{command:"addLayer",args:[c,d]});else{for(p in us(h.layout,c.layout,i,u,"setLayoutProperty"),us(h.paint,c.paint,i,u,"setPaintProperty"),Fe(h.filter,c.filter)||ti(i,{command:"setFilter",args:[u,c.filter]}),(!Fe(h.minzoom,c.minzoom)||!Fe(h.maxzoom,c.maxzoom))&&ti(i,{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?us(h[p],c[p],i,u,"setPaintProperty"):Fe(h[p],c[p])||ti(i,{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?us(h[p],c[p],i,u,"setPaintProperty"):Fe(h[p],c[p])||ti(i,{command:"setLayerProperty",args:[u,p,c[p]]}))}}function h2(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!Fe(e.version,t.version))return[{command:"setStyle",args:[t]}];Fe(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),Fe(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),Fe(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Fe(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),Fe(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),Fe(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),Fe(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),Fe(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),Fe(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),Fe(e["font-faces"],t["font-faces"])||i.push({command:"setFontFaces",args:[t["font-faces"]]}),Fe(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),Fe(e.light,t.light)||i.push({command:"setLight",args:[t.light]});let r=!Fe(e.terrain,t.terrain);r&&!t.terrain&&i.push({command:"setTerrain",args:[void 0]}),Fe(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),Fe(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});let a={},n=[];l2(e.sources,t.sources,n,a);let o=[];e.layers&&e.layers.forEach(s=>{"source"in s&&a[s.source]?i.push({command:"removeLayer",args:[s.id]}):o.push(s)}),i=i.concat(n),u2(o,t.layers,i),r&&t.terrain&&i.push({command:"setTerrain",args:[t.terrain]})}catch(r){console.warn("Unable to compute style diff:",r),i=[{command:"setStyle",args:[t]}]}return i}var j=class{constructor(e,t,i,r,a="error"){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),this.severity=a,t!=null&&t.__line__&&(this.line=t.__line__)}};const Do={kind:"null"},N={kind:"number"},le={kind:"string"},me={kind:"boolean"},Ai={kind:"color"},Ll={kind:"projectionDefinition"},Xr={kind:"object"},he={kind:"value"},c2={kind:"error"},Bl={kind:"collator"},So={kind:"formatted"},Ol={kind:"padding"},io={kind:"colorArray"},jl={kind:"numberArray"},Eo={kind:"resolvedImage"},Vl={kind:"variableAnchorOffsetCollection"};function kt(e,t){return{kind:"array",itemType:e,N:t}}function Je(e){if(e.kind==="array"){let t=Je(e.itemType);return typeof e.N=="number"?`array<${t}, ${e.N}>`:e.itemType.kind==="value"?"array":`array<${t}>`}return e.kind}const d2=[Do,N,le,me,Ai,Ll,So,Xr,kt(he),Ol,jl,io,Eo,Vl];function ro(e,t){if(t.kind==="error")return null;if(e.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!ro(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 i of d2)if(!ro(i,t))return null}}return`Expected ${Je(e)} but found ${Je(t)} instead.`}function vd(e,t){return t.some(i=>i.kind===e.kind)}function Yr(e,t){return t.some(i=>i==="null"?e===null:i==="array"?Array.isArray(e):i==="object"?e&&!Array.isArray(e)&&typeof e=="object":i===typeof e)}function vr(e,t){return e.kind==="array"&&t.kind==="array"?e.itemType.kind===t.itemType.kind&&typeof e.N=="number":e.kind===t.kind}const ty=.96422,iy=.82521,ry=4/29,Vh=6/29,ay=3*Vh*Vh,p2=Math.PI/180,f2=180/Math.PI;function ny(e){return e%=360,e<0&&(e+=360),e}function oy([e,t,i,r]){e=Zu(e),t=Zu(t),i=Zu(i);let a,n,o=qu((.2225045*e+.7168786*t+.0606169*i)/1);e===t&&t===i?a=n=o:(a=qu((.4360747*e+.3850649*t+.1430804*i)/ty),n=qu((.0139322*e+.0971045*t+.7141733*i)/iy));let s=116*o-16;return[s<0?0:s,500*(a-o),200*(o-n),r]}function Zu(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function qu(e){return e>.008856451679035631?e**(1/3):e/ay+ry}function sy([e,t,i,r]){let a=(e+16)/116,n=isNaN(t)?a:a+t/500,o=isNaN(i)?a:a-i/200;return a=1*Hu(a),n=ty*Hu(n),o=iy*Hu(o),[Wu(3.1338561*n-1.6168667*a-.4906146*o),Wu(-.9787684*n+1.9161415*a+.033454*o),Wu(.0719453*n-.2289914*a+1.4052427*o),r]}function Wu(e){return e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055,e<0?0:e>1?1:e}function Hu(e){return e>Vh?e*e*e:ay*(e-ry)}function m2(e){let[t,i,r,a]=oy(e),n=Math.sqrt(i*i+r*r);return[Math.round(n*1e4)?ny(Math.atan2(r,i)*f2):NaN,n,t,a]}function g2([e,t,i,r]){return e=isNaN(e)?0:e*p2,sy([i,Math.cos(e)*t,Math.sin(e)*t,r])}function _2([e,t,i,r]){e=ny(e),t/=100,i/=100;function a(n){let o=(n+e/30)%12,s=t*Math.min(i,1-i);return i-s*Math.max(-1,Math.min(o-3,9-o,1))}return[a(0),a(8),a(4),r]}const y2=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function qn(e,t){return y2(e,t)?e[t]:void 0}function v2(e){if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t=qn(x2,e);if(t){let[r,a,n]=t;return[r/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 r=e.length<6?1:2,a=1;return[hs(e.slice(a,a+=r)),hs(e.slice(a,a+=r)),hs(e.slice(a,a+=r)),hs(e.slice(a,a+r)||"ff")]}if(e.startsWith("rgb")){let r=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){let[a,n,o,s,l,u,h,c,d,p,f,m]=r,g=[s||" ",h||" ",p].join("");if(g===" "||g===" /"||g===",,"||g===",,,"){let _=[o,u,d].join(""),y=_==="%%%"?100:_===""?255:0;if(y){let v=[Aa(+n/y,0,1),Aa(+l/y,0,1),Aa(+c/y,0,1),f?Ef(+f,m):1];if(Cf(v))return v}}return}}let i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[r,a,n,o,s,l,u,h,c]=i,d=[n||" ",s||" ",u].join("");if(d===" "||d===" /"||d===",,"||d===",,,"){let p=[+a,Aa(+o,0,100),Aa(+l,0,100),h?Ef(+h,c):1];if(Cf(p))return _2(p)}}}function hs(e){return parseInt(e.padEnd(2,e),16)/255}function Ef(e,t){return Aa(t?e/100:e,0,1)}function Aa(e,t,i){return Math.min(Math.max(t,e),i)}function Cf(e){return!e.some(Number.isNaN)}const x2={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 Pr(e,t,i){return e+i*(t-e)}function Xa(e,t,i){return e.map((r,a)=>Pr(r,t[a],i))}function b2(e){return e==="rgb"||e==="hcl"||e==="lab"}var xt,se=(xt=class{constructor(t,i,r,a=1,n=!0){this.r=t,this.g=i,this.b=r,this.a=a,n||(this.r*=a,this.g*=a,this.b*=a,a||this.overwriteGetter("rgb",[t,i,r,a]))}static parse(t){if(t instanceof xt)return t;if(typeof t!="string")return;let i=v2(t);if(i)return new xt(...i,!1)}get rgb(){let{r:t,g:i,b:r,a}=this,n=a||1/0;return this.overwriteGetter("rgb",[t/n,i/n,r/n,a])}get hcl(){return this.overwriteGetter("hcl",m2(this.rgb))}get lab(){return this.overwriteGetter("lab",oy(this.rgb))}overwriteGetter(t,i){return Object.defineProperty(this,t,{value:i}),i}toString(){let[t,i,r,a]=this.rgb;return`rgba(${[t,i,r].map(n=>Math.round(n*255)).join(",")},${a})`}static interpolate(t,i,r,a="rgb"){switch(a){case"rgb":{let[n,o,s,l]=Xa(t.rgb,i.rgb,r);return new xt(n,o,s,l,!1)}case"hcl":{let[n,o,s,l]=t.hcl,[u,h,c,d]=i.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+r*v}else isNaN(n)?isNaN(u)?p=NaN:(p=u,(s===1||s===0)&&(f=h)):(p=n,(c===1||c===0)&&(f=o));let[m,g,_,y]=g2([p,f!=null?f:Pr(o,h,r),Pr(s,c,r),Pr(l,d,r)]);return new xt(m,g,_,y,!1)}case"lab":{let[n,o,s,l]=sy(Xa(t.lab,i.lab,r));return new xt(n,o,s,l,!1)}}}},xt.black=new xt(0,0,0,1),xt.white=new xt(1,1,1,1),xt.transparent=new xt(0,0,0,0),xt.red=new xt(1,0,0,1),xt);const w2=["bottom","center","top"];var Nh=class{constructor(e,t,i,r,a,n){this.text=e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=a,this.verticalAlign=n}},pr=class Bs{constructor(t){this.sections=t}static fromString(t){return new Bs([new Nh(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 Bs?t:Bs.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}},Ji=class On{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof On)return t;if(typeof t=="number")return new On([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let i of t)if(typeof i!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new On(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new On(Xa(t.values,i.values,r))}},Qi=class jn{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof jn)return t;if(typeof t=="number")return new jn([t]);if(Array.isArray(t)){for(let i of t)if(typeof i!="number")return;return new jn(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new jn(Xa(t.values,i.values,r))}},_i=class Vn{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Vn)return t;if(typeof t=="string"){let r=se.parse(t);return r?new Vn([r]):void 0}if(!Array.isArray(t))return;let i=[];for(let r of t){if(typeof r!="string")return;let a=se.parse(r);if(!a)return;i.push(a)}return new Vn(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a="rgb"){let n=[];if(t.values.length!=i.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let o=0;o<t.values.length;o++)n.push(se.interpolate(t.values[o],i.values[o],r,a));return new Vn(n)}},qe=class extends Error{constructor(e,t){super(e),this.name="RuntimeError",this.path=t}toJSON(){return this.message}};const T2=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var Xi=class Os{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Os)return t;if(!(!Array.isArray(t)||t.length<1||t.length%2!=0)){for(let i=0;i<t.length;i+=2){let r=t[i],a=t[i+1];if(typeof r!="string"||!T2.has(r)||!Array.isArray(a)||a.length!==2||typeof a[0]!="number"||typeof a[1]!="number")return}return new Os(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a){let n=t.values,o=i.values;if(n.length!==o.length)throw new qe(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`,a);let s=[];for(let l=0;l<n.length;l+=2){if(n[l]!==o[l])throw new qe(`Cannot interpolate values containing mismatched anchors. from[${l}]: ${n[l]}, to[${l}]: ${o[l]}`,a);s.push(n[l]);let[u,h]=n[l+1],[c,d]=o[l+1];s.push([Pr(u,c,r),Pr(h,d,r)])}return new Os(s)}},Yi=class ly{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new ly({name:t,available:!1}):null}},Lr=class Ma{constructor(t,i,r){this.from=t,this.to=i,this.transition=r}toString(){return this.from===this.to&&this.transition===1?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(t,i,r){return new Ma(t,i,r)}static parse(t){if(t instanceof Ma)return t;if(Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number")return new Ma(t[0],t[1],t[2]);if(typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number")return new Ma(t.from,t.to,t.transition);if(typeof t=="string")return new Ma(t,t,1)}},xd=class{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,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 uy(e,t,i,r){return typeof e=="number"&&e>=0&&e<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof i=="number"&&i>=0&&i<=255?r===void 0||typeof r=="number"&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r=="number"?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ya(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||e instanceof Lr||e instanceof se||e instanceof xd||e instanceof pr||e instanceof Ji||e instanceof Qi||e instanceof _i||e instanceof Xi||e instanceof Yi)return!0;if(Array.isArray(e)){for(let t of e)if(!Ya(t))return!1;return!0}if(typeof e=="object"){for(let t in e)if(!Ya(e[t]))return!1;return!0}return!1}function nt(e){if(e===null)return Do;if(typeof e=="string")return le;if(typeof e=="boolean")return me;if(typeof e=="number")return N;if(e instanceof se)return Ai;if(e instanceof Lr)return Ll;if(e instanceof xd)return Bl;if(e instanceof pr)return So;if(e instanceof Ji)return Ol;if(e instanceof Qi)return jl;if(e instanceof _i)return io;if(e instanceof Xi)return Vl;if(e instanceof Yi)return Eo;if(Array.isArray(e)){let t=e.length,i;for(let r of e){let a=nt(r);if(!i)i=a;else{if(i===a)continue;i=he;break}}return kt(i||he,t)}return Xr}function Wn(e){let t=typeof e;return e===null?"":t==="string"||t==="number"||t==="boolean"?String(e):e instanceof se||e instanceof Lr||e instanceof pr||e instanceof Ji||e instanceof Qi||e instanceof _i||e instanceof Xi||e instanceof Yi?e.toString():JSON.stringify(e)}var Ka=class hy{constructor(t,i){this.type=t,this.value=i}static parse(t,i){if(t.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ya(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=nt(r),n=i.expectedType;return a.kind==="array"&&a.N===0&&n&&n.kind==="array"&&(typeof n.N!="number"||n.N===0)&&(a=n),new hy(a,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const D2=["Unknown","Point","LineString","Polygon"];var cy=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"?D2[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(e){let t=this._parseColorCache.get(e);return t||(t=se.parse(e),this._parseColorCache.set(e,t)),t}};function Nl(e,t,i){let r=e.length-1,a=0,n=r,o=0,s,l;for(;a<=n;)if(o=Math.floor((a+n)/2),s=e[o],l=e[o+1],s<=t){if(o===r||t<l)return o;a=o+1}else if(s>t)n=o-1;else throw new qe("Input is not a number.",i);return 0}var bd=class dy{constructor(t,i,r,a){this.type=t,this.input=i,this.key=a,this.labels=[],this.outputs=[];for(let[n,o]of r)this.labels.push(n),this.outputs.push(o)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(t[1],1,N);if(!r)return null;let a=[],n=null;i.expectedType&&i.expectedType.kind!=="value"&&(n=i.expectedType);for(let o=1;o<t.length;o+=2){let s=o===1?-1/0:t[o],l=t[o+1],u=o,h=o+1;if(typeof s!="number")return i.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]>=s)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);let c=i.parse(l,h,n);if(!c)return null;n||(n=c.type),a.push([s,c])}return new dy(n,r,a,i.key)}evaluate(t){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;return a>=i[n-1]?r[n-1].evaluate(t):r[Nl(i,a,this.key)].evaluate(t)}eachChild(t){t(this.input);for(let i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function S2(e,t,i,r){let a=3*e,n=3*(i-e)-a,o=1-a-n,s=3*t,l=3*(r-t)-s,u=1-s-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=((o*d+n)*d+a)*d-h;if(Math.abs(g)<c)return((u*d+l)*d+s)*d;let _=(3*o*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=((o*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+s)*d}}var yi=class Uh{constructor(t,i,r,a,n,o){this.type=t,this.operator=i,this.interpolation=r,this.input=a,this.key=o,this.labels=[],this.outputs=[];for(let[s,l]of n)this.labels.push(s),this.outputs.push(l)}static interpolationFactor(t,i,r,a){let n=0;if(t.name==="exponential")n=Xu(i,t.base,r,a);else if(t.name==="linear")n=Xu(i,1,r,a);else if(t.name==="cubic-bezier"){let o=t.controlPoints;n=S2(o[0],o[1],o[2],o[3])(Xu(i,1,r,a))}return n}static parse(t,i){let[r,a,n,...o]=t;if(!Array.isArray(a)||a.length===0)return i.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 i.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 i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:u}}else return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(n=i.parse(n,2,N),!n)return null;let s=[],l=null;(r==="interpolate-hcl"||r==="interpolate-lab")&&i.expectedType!=io?l=Ai:i.expectedType&&i.expectedType.kind!=="value"&&(l=i.expectedType);for(let u=0;u<o.length;u+=2){let h=o[u],c=o[u+1],d=u+3,p=u+4;if(typeof h!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',d);if(s.length&&s[s.length-1][0]>=h)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);let f=i.parse(c,p,l);if(!f)return null;l||(l=f.type),s.push([h,f])}return!vr(l,N)&&!vr(l,Ll)&&!vr(l,Ai)&&!vr(l,Ol)&&!vr(l,jl)&&!vr(l,io)&&!vr(l,Vl)&&!vr(l,kt(N))?i.error(`Type ${Je(l)} is not interpolatable.`):new Uh(l,r,a,n,s,i.key)}evaluate(t){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;if(a>=i[n-1])return r[n-1].evaluate(t);let o=Nl(i,a,this.key),s=i[o],l=i[o+1],u=Uh.interpolationFactor(this.interpolation,a,s,l),h=r[o].evaluate(t),c=r[o+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Pr(h,c,u);case"color":return se.interpolate(h,c,u);case"padding":return Ji.interpolate(h,c,u);case"colorArray":return _i.interpolate(h,c,u);case"numberArray":return Qi.interpolate(h,c,u);case"variableAnchorOffsetCollection":return Xi.interpolate(h,c,u,this.key);case"array":return Xa(h,c,u);case"projectionDefinition":return Lr.interpolate(h,c,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return se.interpolate(h,c,u,"hcl");case"colorArray":return _i.interpolate(h,c,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return se.interpolate(h,c,u,"lab");case"colorArray":return _i.interpolate(h,c,u,"lab")}}}eachChild(t){t(this.input);for(let i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function Xu(e,t,i,r){let a=r-i,n=e-i;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}const We={color:se.interpolate,number:Pr,padding:Ji.interpolate,numberArray:Qi.interpolate,colorArray:_i.interpolate,variableAnchorOffsetCollection:Xi.interpolate,array:Xa};var py=class fy{constructor(t){this.type=So,this.sections=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[1];if(!Array.isArray(r)&&typeof r=="object")return i.error("First argument must be an image or text section.");let a=[],n=!1;for(let o=1;o<=t.length-1;++o){let s=t[o];if(n&&typeof s=="object"&&!Array.isArray(s)){n=!1;let l=null;if(s["font-scale"]&&(l=i.parse(s["font-scale"],1,N),!l))return null;let u=null;if(s["text-font"]&&(u=i.parse(s["text-font"],1,kt(le)),!u))return null;let h=null;if(s["text-color"]&&(h=i.parse(s["text-color"],1,Ai),!h))return null;let c=null;if(s["vertical-align"]){if(typeof s["vertical-align"]=="string"&&!w2.includes(s["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(c=i.parse(s["vertical-align"],1,le),!c)return null}let d=a[a.length-1];d.scale=l,d.font=u,d.textColor=h,d.verticalAlign=c}else{let l=i.parse(t[o],1,he);if(!l)return null;let u=l.type.kind;if(u!=="string"&&u!=="value"&&u!=="null"&&u!=="resolvedImage")return i.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 fy(a)}evaluate(t){return new pr(this.sections.map(i=>{let r=i.content.evaluate(t);return nt(r)===Eo?new Nh("",r,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(t):null):new Nh(Wn(r),null,i.scale?i.scale.evaluate(t):null,i.font?i.font.evaluate(t).join(","):null,i.textColor?i.textColor.evaluate(t):null,i.verticalAlign?i.verticalAlign.evaluate(t):null)}))}eachChild(t){for(let i of this.sections)t(i.content),i.scale&&t(i.scale),i.font&&t(i.font),i.textColor&&t(i.textColor),i.verticalAlign&&t(i.verticalAlign)}outputDefined(){return!1}};function my(e,t,i=0,r=e.length-1,a=E2){for(;r>i;){if(r-i>600){let l=r-i+1,u=t-i+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);my(e,t,Math.max(i,Math.floor(t-u*c/l+d)),Math.min(r,Math.floor(t+(l-u)*c/l+d)),a)}let n=e[t],o=i,s=r;for(Sn(e,i,t),a(e[r],n)>0&&Sn(e,i,r);o<s;){for(Sn(e,o,s),o++,s--;a(e[o],n)<0;)o++;for(;a(e[s],n)>0;)s--}a(e[i],n)===0?Sn(e,i,s):(s++,Sn(e,s,r)),s<=t&&(i=s+1),t<=s&&(r=s-1)}}function Sn(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function E2(e,t){return e<t?-1:+(e>t)}function Ul(e,t){if(e.length<=1)return[e];let i=[],r,a;for(let n of e){let o=P2(n);o!==0&&(n.area=Math.abs(o),a===void 0&&(a=o<0),a===o<0?(r&&i.push(r),r=[n]):r.push(n))}if(r&&i.push(r),t>1)for(let n=0;n<i.length;n++)i[n].length<=t||(my(i[n],t,1,i[n].length-1,C2),i[n]=i[n].slice(0,t));return i}function C2(e,t){return t.area-e.area}function P2(e){let t=0;for(let i=0,r=e.length,a=r-1,n,o;i<r;a=i++)n=e[i],o=e[a],t+=(o.x-n.x)*(n.y+o.y);return t}const cs={string:le,number:N,boolean:me,object:Xr};var or=class gy{constructor(t,i,r){this.type=t,this.args=i,this.key=r}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=1,a,n=t[0];if(n==="array"){let s;if(t.length>2){let u=t[1];if(typeof u!="string"||!(u in cs)||u==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);s=cs[u],r++}else s=he;let l;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);l=t[2],r++}a=kt(s,l)}else{if(!cs[n])throw Error(`Types doesn't contain name = ${n}`);a=cs[n]}let o=[];for(;r<t.length;r++){let s=i.parse(t[r],r,he);if(!s)return null;o.push(s)}return new gy(a,o,i.key)}evaluate(t){for(let i=0;i<this.args.length;i++){let r=this.args[i].evaluate(t);if(!ro(this.type,nt(r)))return r;if(i===this.args.length-1)throw new qe(`Expected value to be of type ${Je(this.type)}, but found ${Je(nt(r))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};const Pf={"to-boolean":me,"to-color":Ai,"to-number":N,"to-string":le};var Ra=class _y{constructor(t,i,r){this.type=t,this.args=i,this.key=r}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[0];if(!Pf[r])throw Error(`Can't parse ${r} as it is not part of the known types`);if((r==="to-boolean"||r==="to-string")&&t.length!==2)return i.error("Expected one argument.");let a=Pf[r],n=[];for(let o=1;o<t.length;o++){let s=i.parse(t[o],o,he);if(!s)return null;n.push(s)}return new _y(a,n,i.key)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let i,r;for(let a of this.args){if(i=a.evaluate(t),r=null,i instanceof se)return i;if(typeof i=="string"){let n=t.parseColor(i);if(n)return n}else if(Array.isArray(i)&&(r=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:uy(i[0],i[1],i[2],i[3]),!r))return new se(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new qe(r||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"padding":{let i;for(let r of this.args){i=r.evaluate(t);let a=Ji.parse(i);if(a)return a}throw new qe(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"numberArray":{let i;for(let r of this.args){i=r.evaluate(t);let a=Qi.parse(i);if(a)return a}throw new qe(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"colorArray":{let i;for(let r of this.args){i=r.evaluate(t);let a=_i.parse(i);if(a)return a}throw new qe(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"variableAnchorOffsetCollection":{let i;for(let r of this.args){i=r.evaluate(t);let a=Xi.parse(i);if(a)return a}throw new qe(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}case"number":{let i=null;for(let r of this.args){if(i=r.evaluate(t),i===null)return 0;let a=Number(i);if(!isNaN(a))return a}throw new qe(`Could not convert ${JSON.stringify(i)} to number.`,this.key)}case"formatted":return pr.fromString(Wn(this.args[0].evaluate(t)));case"resolvedImage":return Yi.fromString(Wn(this.args[0].evaluate(t)));case"projectionDefinition":{let i=this.args[0].evaluate(t);if(Lr.parse(i))return i;throw new qe(`Could not parse projectionDefinition from value '${typeof i=="string"?i:JSON.stringify(i)}'`,this.key)}default:return Wn(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}},yy=class vy{constructor(t,i){this.type=i.type,this.bindings=[].concat(t),this.result=i}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let i of this.bindings)t(i[1]);t(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let n=1;n<t.length-1;n+=2){let o=t[n];if(typeof o!="string")return i.error(`Expected string, but found ${typeof o} instead.`,n);if(/[^a-zA-Z0-9_]/.test(o))return i.error("Variable names must contain only alphanumeric characters or '_'.",n);let s=i.parse(t[n+1],n+1);if(!s)return null;r.push([o,s])}let a=i.parse(t[t.length-1],t.length-1,i.expectedType,r);return a?new vy(r,a):null}outputDefined(){return this.result.outputDefined()}},xy=class by{constructor(t,i){this.type=i.type,this.name=t,this.boundExpression=i}static parse(t,i){if(t.length!==2||typeof t[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");let r=t[1];return i.scope.has(r)?new by(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}},A2=class wy{constructor(t,i,r,a){this.type=t,this.index=i,this.input=r,this.key=a}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,N),a=i.parse(t[2],2,kt(i.expectedType||he));if(!r||!a)return null;let n=a.type;return new wy(n.itemType,r,a,i.key)}evaluate(t){let i=this.index.evaluate(t),r=this.input.evaluate(t);if(i<0)throw new qe(`Array index out of bounds: ${i} < 0.`,this.key);if(i>=r.length)throw new qe(`Array index out of bounds: ${i} > ${r.length-1}.`,this.key);if(i!==Math.floor(i))throw new qe(`Array index must be an integer, but found ${i} instead.`,this.key);return r[i]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},M2=class Ty{constructor(t,i,r){this.needle=t,this.haystack=i,this.key=r,this.type=me}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,he),a=i.parse(t[2],2,he);return!r||!a?null:vd(r.type,[me,le,N,Do,he])?new Ty(r,a,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Je(r.type)} instead`)}evaluate(t){let i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return!1;if(!Yr(i,["boolean","string","number","null"]))throw new qe(`Expected first argument to be of type boolean, string, number or null, but found ${Je(nt(i))} instead.`,this.key);if(!Yr(r,["string","array"]))throw new qe(`Expected second argument to be of type array or string, but found ${Je(nt(r))} instead.`,this.key);return r.indexOf(i)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},I2=class $h{constructor(t,i,r,a){this.needle=t,this.haystack=i,this.key=r,this.fromIndex=a,this.type=N}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,he),a=i.parse(t[2],2,he);if(!r||!a)return null;if(!vd(r.type,[me,le,N,Do,he]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Je(r.type)} instead`);if(t.length===4){let n=i.parse(t[3],3,N);return n?new $h(r,a,i.key,n):null}return new $h(r,a,i.key)}evaluate(t){let i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Yr(i,["boolean","string","number","null"]))throw new qe(`Expected first argument to be of type boolean, string, number or null, but found ${Je(nt(i))} instead.`,this.key);let a;if(this.fromIndex&&(a=this.fromIndex.evaluate(t)),Yr(r,["string"])){let n=r.indexOf(i,a);return n===-1?-1:[...r.slice(0,n)].length}if(Yr(r,["array"]))return r.indexOf(i,a);throw new qe(`Expected second argument to be of type array or string, but found ${Je(nt(r))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},F2=class Dy{constructor(t,i,r,a,n,o){this.inputType=t,this.type=i,this.input=r,this.cases=a,this.outputs=n,this.otherwise=o}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let r,a;i.expectedType&&i.expectedType.kind!=="value"&&(a=i.expectedType);let n={},o=[];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=i.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(!r)r=nt(f);else if(d.checkSubtype(r,nt(f)))return null;if(n[String(f)]!==void 0)return d.error("Branch labels must be unique.");n[String(f)]=o.length}let p=i.parse(c,u,a);if(!p)return null;a||(a=p.type),o.push(p)}let s=i.parse(t[1],1,he);if(!s)return null;let l=i.parse(t[t.length-1],t.length-1,a);return!l||s.type.kind!=="value"&&i.concat(1).checkSubtype(r,s.type)?null:new Dy(r,a,s,n,o,l)}evaluate(t){let i=this.input.evaluate(t);return(nt(i)===this.inputType&&this.outputs[this.cases[i]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}},z2=class Sy{constructor(t,i,r){this.type=t,this.branches=i,this.otherwise=r}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&i.expectedType.kind!=="value"&&(r=i.expectedType);let a=[];for(let o=1;o<t.length-1;o+=2){let s=i.parse(t[o],o,me);if(!s)return null;let l=i.parse(t[o+1],o+1,r);if(!l)return null;a.push([s,l]),r||(r=l.type)}let n=i.parse(t[t.length-1],t.length-1,r);if(!n)return null;if(!r)throw Error("Can't infer output type");return new Sy(r,a,n)}evaluate(t){for(let[i,r]of this.branches)if(i.evaluate(t))return r.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[i,r]of this.branches)t(i),t(r);t(this.otherwise)}outputDefined(){return this.branches.every(([t,i])=>i.outputDefined())&&this.otherwise.outputDefined()}},k2=class Gh{constructor(t,i,r,a,n){this.type=t,this.input=i,this.beginIndex=r,this.key=a,this.endIndex=n}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,he),a=i.parse(t[2],2,N);if(!r||!a)return null;if(!vd(r.type,[kt(he),le,he]))return i.error(`Expected first argument to be of type array or string, but found ${Je(r.type)} instead`);if(t.length===4){let n=i.parse(t[3],3,N);return n?new Gh(r.type,r,a,i.key,n):null}return new Gh(r.type,r,a,i.key)}evaluate(t){let i=this.input.evaluate(t),r=this.beginIndex.evaluate(t),a;if(this.endIndex&&(a=this.endIndex.evaluate(t)),Yr(i,["string"]))return[...i].slice(r,a).join("");if(Yr(i,["array"]))return i.slice(r,a);throw new qe(`Expected first argument to be of type array or string, but found ${Je(nt(i))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},Ey=class Zh{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=null,a=i.expectedType;a&&a.kind!=="value"&&(r=a);let n=[];for(let o of t.slice(1)){let s=i.parse(o,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!s)return null;r||(r=s.type),n.push(s)}if(!r)throw Error("No output type");return a&&n.some(o=>ro(a,o.type))?new Zh(he,n):new Zh(r,n)}evaluate(t){let i=null,r=0,a;for(let n of this.args)if(r++,i=n.evaluate(t),i&&i instanceof Yi&&!i.available&&(a||(a=i.name),i=null,r===this.args.length&&(i=a)),i!==null)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function Af(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 R2(e,t,i){return t===i}function L2(e,t,i){return t!==i}function B2(e,t,i){return t<i}function O2(e,t,i){return t>i}function j2(e,t,i){return t<=i}function V2(e,t,i){return t>=i}function Cy(e,t,i,r){return r.compare(t,i)===0}function N2(e,t,i,r){return!Cy(e,t,i,r)}function U2(e,t,i,r){return r.compare(t,i)<0}function $2(e,t,i,r){return r.compare(t,i)>0}function G2(e,t,i,r){return r.compare(t,i)<=0}function Z2(e,t,i,r){return r.compare(t,i)>=0}function on(e,t,i){let r=e!=="=="&&e!=="!=";return class Py{constructor(n,o,s,l){this.lhs=n,this.rhs=o,this.key=s,this.collator=l,this.type=me,this.hasUntypedArgument=n.type.kind==="value"||o.type.kind==="value"}static parse(n,o){if(n.length!==3&&n.length!==4)return o.error("Expected two or three arguments.");let s=n[0],l=o.parse(n[1],1,he);if(!l)return null;if(!Af(s,l.type))return o.concat(1).error(`"${s}" comparisons are not supported for type '${Je(l.type)}'.`);let u=o.parse(n[2],2,he);if(!u)return null;if(!Af(s,u.type))return o.concat(2).error(`"${s}" comparisons are not supported for type '${Je(u.type)}'.`);if(l.type.kind!==u.type.kind&&l.type.kind!=="value"&&u.type.kind!=="value")return o.error(`Cannot compare types '${Je(l.type)}' and '${Je(u.type)}'.`);r&&(l.type.kind==="value"&&u.type.kind!=="value"?l=new or(u.type,[l],o.key):l.type.kind!=="value"&&u.type.kind==="value"&&(u=new or(l.type,[u],o.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 o.error("Cannot use collator to compare non-string types.");if(h=o.parse(n[3],3,Bl),!h)return null}return new Py(l,u,o.key,h)}evaluate(n){let o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){let l=nt(o),u=nt(s);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&&!r&&this.hasUntypedArgument){let l=nt(o),u=nt(s);if(l.kind!=="string"||u.kind!=="string")return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(n){n(this.lhs),n(this.rhs),this.collator&&n(this.collator)}outputDefined(){return!0}}}const q2=on("==",R2,Cy),W2=on("!=",L2,N2),H2=on("<",B2,U2),X2=on(">",O2,$2),Y2=on("<=",j2,G2),K2=on(">=",V2,Z2);var Ay=class My{constructor(t,i,r){this.type=Bl,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=i}static parse(t,i){if(t.length!==2)return i.error("Expected one argument.");let r=t[1];if(typeof r!="object"||Array.isArray(r))return i.error("Collator options argument must be an object.");let a=i.parse(r["case-sensitive"]!==void 0&&r["case-sensitive"],1,me);if(!a)return null;let n=i.parse(r["diacritic-sensitive"]!==void 0&&r["diacritic-sensitive"],1,me);if(!n)return null;let o=null;return r.locale&&(o=i.parse(r.locale,1,le),!o)?null:new My(a,n,o)}evaluate(t){return new xd(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}},J2=class Iy{constructor(t,i,r,a,n,o){this.type=le,this.number=t,this.locale=i,this.currency=r,this.unit=a,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(t,i){if(t.length!==3)return i.error("Expected two arguments.");let r=i.parse(t[1],1,N);if(!r)return null;let a=t[2];if(typeof a!="object"||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&(n=i.parse(a.locale,1,le),!n))return null;let o=null;if(a.currency&&(o=i.parse(a.currency,1,le),!o))return null;let s=null;if(a.unit&&(s=i.parse(a.unit,1,le),!s))return null;if(o&&s)return i.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(a["min-fraction-digits"]&&(l=i.parse(a["min-fraction-digits"],1,N),!l))return null;let u=null;return a["max-fraction-digits"]&&(u=i.parse(a["max-fraction-digits"],1,N),!u)?null:new Iy(r,n,o,s,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}},Q2=class Fy{constructor(t){this.type=Eo,this.input=t}static parse(t,i){if(t.length!==2)return i.error("Expected two arguments.");let r=i.parse(t[1],1,le);return r?new Fy(r):i.error("No image name provided.")}evaluate(t){let i=this.input.evaluate(t),r=Yi.fromString(i);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(i)>-1),r}eachChild(t){t(this.input)}outputDefined(){return!1}},ew=class zy{constructor(t,i){this.input=t,this.key=i,this.type=N}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=i.parse(t[1],1);return r?r.type.kind!=="array"&&r.type.kind!=="string"&&r.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${Je(r.type)} instead.`):new zy(r,i.key):null}evaluate(t){let i=this.input.evaluate(t);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new qe(`Expected value to be of type string or array, but found ${Je(nt(i))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}};const Hi=8192;function tw(e,t){let i=iw(e[0]),r=aw(e[1]),a=2**t.z;return[Math.round(i*a*Hi),Math.round(r*a*Hi)]}function wd(e,t){let i=2**t.z,r=(e[0]/Hi+t.x)/i,a=(e[1]/Hi+t.y)/i;return[rw(r),nw(a)]}function iw(e){return(180+e)/360}function rw(e){return e*360-180}function aw(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function nw(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}function Co(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 ao(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ow(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function sw(e,t,i){let r=e[0]-t[0],a=e[1]-t[1],n=e[0]-i[0],o=e[1]-i[1];return r*o-n*a===0&&r*n<=0&&a*o<=0}function $l(e,t,i,r){let a=[t[0]-e[0],t[1]-e[1]];return cw([r[0]-i[0],r[1]-i[1]],a)!==0&&!!(Mf(e,t,i,r)&&Mf(i,r,e,t))}function lw(e,t,i){for(let r of i)for(let a=0;a<r.length-1;++a)if($l(e,t,r[a],r[a+1]))return!0;return!1}function sn(e,t,i=!1){let r=!1;for(let a of t)for(let n=0;n<a.length-1;n++){if(sw(e,a[n],a[n+1]))return i;ow(e,a[n],a[n+1])&&(r=!r)}return r}function uw(e,t){for(let i of t)if(sn(e,i))return!0;return!1}function ky(e,t){for(let i of e)if(!sn(i,t))return!1;for(let i=0;i<e.length-1;++i)if(lw(e[i],e[i+1],t))return!1;return!0}function hw(e,t){for(let i of t)if(ky(e,i))return!0;return!1}function cw(e,t){return e[0]*t[1]-e[1]*t[0]}function Mf(e,t,i,r){let a=e[0]-i[0],n=e[1]-i[1],o=t[0]-i[0],s=t[1]-i[1],l=r[0]-i[0],u=r[1]-i[1],h=a*u-l*n,c=o*u-l*s;return h>0&&c<0||h<0&&c>0}function Td(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=[];for(let o=0;o<e[a].length;o++){let s=tw(e[a][o],i);Co(t,s),n.push(s)}r.push(n)}return r}function Ry(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=Td(e[a],t,i);r.push(n)}return r}function Ly(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){let a=r*.5,n=e[0]-i[0]>a?-r:i[0]-e[0]>a?r:0;n===0&&(n=e[0]-i[2]>a?-r:i[2]-e[0]>a?r:0),e[0]+=n}Co(t,e)}function dw(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}function If(e,t,i,r){let a=2**r.z*Hi,n=[r.x*Hi,r.y*Hi],o=[];for(let s of e)for(let l of s){let u=[l.x+n[0],l.y+n[1]];Ly(u,t,i,a),o.push(u)}return o}function Ff(e,t,i,r){let a=2**r.z*Hi,n=[r.x*Hi,r.y*Hi],o=[];for(let s of e){let l=[];for(let u of s){let h=[u.x+n[0],u.y+n[1]];Co(t,h),l.push(h)}o.push(l)}if(t[2]-t[0]<=a/2){dw(t);for(let s of o)for(let l of s)Ly(l,t,i,a)}return o}function pw(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=Td(t.coordinates,r,a),o=If(e.geometry(),i,r,a);if(!ao(i,r))return!1;for(let s of o)if(!sn(s,n))return!1}if(t.type==="MultiPolygon"){let n=Ry(t.coordinates,r,a),o=If(e.geometry(),i,r,a);if(!ao(i,r))return!1;for(let s of o)if(!uw(s,n))return!1}return!0}function fw(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if(t.type==="Polygon"){let n=Td(t.coordinates,r,a),o=Ff(e.geometry(),i,r,a);if(!ao(i,r))return!1;for(let s of o)if(!ky(s,n))return!1}if(t.type==="MultiPolygon"){let n=Ry(t.coordinates,r,a),o=Ff(e.geometry(),i,r,a);if(!ao(i,r))return!1;for(let s of o)if(!hw(s,n))return!1}return!0}var Dd=class js{constructor(t,i){this.type=me,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ya(t[1])){let r=t[1];if(r.type==="FeatureCollection"){let a=[];for(let n of r.features){let{type:o,coordinates:s}=n.geometry;o==="Polygon"&&a.push(s),o==="MultiPolygon"&&a.push(...s)}if(a.length)return new js(r,{type:"MultiPolygon",coordinates:a})}else if(r.type==="Feature"){let a=r.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new js(r,r.geometry)}else if(r.type==="Polygon"||r.type==="MultiPolygon")return new js(r,r)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return pw(t,this.geometries);if(t.geometryType()==="LineString")return fw(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},By=class{constructor(e=[],t=(i,r)=>i<r?-1:+(i>r)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(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:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(i(r,n)>=0)break;t[e]=n,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let n=(e<<1)+1,o=n+1;if(o<this.length&&i(t[o],t[n])<0&&(n=o),i(t[n],a)>=0)break;t[e]=t[n],e=n}t[e]=a}};const zf=Math.PI/180;var Sd=class{constructor(e){let t=zf*6378.137*1e3,i=Math.cos(e*zf),r=1/(1-.0066943799901413165*(1-i*i)),a=Math.sqrt(r);this.kx=t*a*i,this.ky=t*a*r*.9933056200098587}distance(e,t){let i=this.wrap(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(e,t){let i=1/0,r,a,n,o;for(let s=0;s<e.length-1;s++){let l=e[s][0],u=e[s][1],h=this.wrap(e[s+1][0]-l)*this.kx,c=(e[s+1][1]-u)*this.ky,d=0;(h!==0||c!==0)&&(d=(this.wrap(t[0]-l)*this.kx*h+(t[1]-u)*this.ky*c)/(h*h+c*c),d>1?(l=e[s+1][0],u=e[s+1][1]):d>0&&(l+=h/this.kx*d,u+=c/this.ky*d)),h=this.wrap(t[0]-l)*this.kx,c=(t[1]-u)*this.ky;let p=h*h+c*c;p<i&&(i=p,r=l,a=u,n=s,o=d)}return{point:[r,a],index:n,t:Math.max(0,Math.min(1,o))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}};function Oy(e,t){return t[0]-e[0]}function rl(e){return e[1]-e[0]+1}function fr(e,t){return e[1]>=e[0]&&e[1]<t}function qh(e,t){if(e[0]>e[1])return[null,null];let i=rl(e);if(t){if(i===2)return[e,null];let a=Math.floor(i/2);return[[e[0],e[0]+a],[e[0]+a,e[1]]]}if(i===1)return[e,null];let r=Math.floor(i/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function Wh(e,t){if(!fr(t,e.length))return[1/0,1/0,-1/0,-1/0];let i=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)Co(i,e[r]);return i}function Hh(e){let t=[1/0,1/0,-1/0,-1/0];for(let i of e)for(let r of i)Co(t,r);return t}function kf(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Ed(e,t,i){if(!kf(e)||!kf(t))return NaN;let r=0,a=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(a=e[1]-t[3]),e[3]<t[1]&&(a=t[1]-e[3]),i.distance([0,0],[r,a])}function Zr(e,t,i){let r=i.pointOnLine(t,e);return i.distance(e,r.point)}function Cd(e,t,i,r,a){let n=Math.min(Zr(e,[i,r],a),Zr(t,[i,r],a)),o=Math.min(Zr(i,[e,t],a),Zr(r,[e,t],a));return Math.min(n,o)}function mw(e,t,i,r,a){if(!(fr(t,e.length)&&fr(r,i.length)))return 1/0;let n=1/0;for(let o=t[0];o<t[1];++o){let s=e[o],l=e[o+1];for(let u=r[0];u<r[1];++u){let h=i[u],c=i[u+1];if($l(s,l,h,c))return 0;n=Math.min(n,Cd(s,l,h,c,a))}}return n}function gw(e,t,i,r,a){if(!(fr(t,e.length)&&fr(r,i.length)))return NaN;let n=1/0;for(let o=t[0];o<=t[1];++o)for(let s=r[0];s<=r[1];++s)if(n=Math.min(n,a.distance(e[o],i[s])),n===0)return n;return n}function _w(e,t,i){if(sn(e,t,!0))return 0;let r=1/0;for(let a of t){let n=a[0],o=a[a.length-1];if(n!==o&&(r=Math.min(r,Zr(e,[o,n],i)),r===0))return r;let s=i.pointOnLine(a,e);if(r=Math.min(r,i.distance(e,s.point)),r===0)return r}return r}function yw(e,t,i,r){if(!fr(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(sn(e[n],i,!0))return 0;let a=1/0;for(let n=t[0];n<t[1];++n){let o=e[n],s=e[n+1];for(let l of i)for(let u=0,h=l.length,c=h-1;u<h;c=u++){let d=l[c],p=l[u];if($l(o,s,d,p))return 0;a=Math.min(a,Cd(o,s,d,p,r))}}return a}function Rf(e,t){for(let i of e)for(let r of i)if(sn(r,t,!0))return!0;return!1}function vw(e,t,i,r=1/0){let a=Hh(e),n=Hh(t);if(r!==1/0&&Ed(a,n,i)>=r)return r;if(ao(a,n)){if(Rf(e,t))return 0}else if(Rf(t,e))return 0;let o=1/0;for(let s of e)for(let l=0,u=s.length,h=u-1;l<u;h=l++){let c=s[h],d=s[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($l(c,d,_,y))return 0;o=Math.min(o,Cd(c,d,_,y,i))}}return o}function Lf(e,t,i,r,a,n){if(!n)return;let o=Ed(Wh(r,n),a,i);o<t&&e.push([o,n,[0,0]])}function ds(e,t,i,r,a,n,o){if(!n||!o)return;let s=Ed(Wh(r,n),Wh(a,o),i);s<t&&e.push([s,n,o])}function al(e,t,i,r,a=1/0){let n=Math.min(r.distance(e[0],i[0][0]),a);if(n===0)return n;let o=new By([[0,[0,e.length-1],[0,0]]],Oy),s=Hh(i);for(;o.length>0;){let l=o.pop();if(l[0]>=n)continue;let u=l[1],h=t?50:100;if(rl(u)<=h){if(!fr(u,e.length))return NaN;if(t){let c=yw(e,u,i,r);if(isNaN(c)||c===0)return c;n=Math.min(n,c)}else for(let c=u[0];c<=u[1];++c){let d=_w(e[c],i,r);if(n=Math.min(n,d),n===0)return 0}}else{let c=qh(u,t);Lf(o,n,r,e,s,c[0]),Lf(o,n,r,e,s,c[1])}}return n}function nl(e,t,i,r,a,n=1/0){let o=Math.min(n,a.distance(e[0],i[0]));if(o===0)return o;let s=new By([[0,[0,e.length-1],[0,i.length-1]]],Oy);for(;s.length>0;){let l=s.pop();if(l[0]>=o)continue;let u=l[1],h=l[2],c=t?50:100,d=r?50:100;if(rl(u)<=c&&rl(h)<=d){if(!fr(u,e.length)&&fr(h,i.length))return NaN;let p;if(t&&r)p=mw(e,u,i,h,a),o=Math.min(o,p);else if(t&&!r){let f=e.slice(u[0],u[1]+1);for(let m=h[0];m<=h[1];++m)if(p=Zr(i[m],f,a),o=Math.min(o,p),o===0)return o}else if(!t&&r){let f=i.slice(h[0],h[1]+1);for(let m=u[0];m<=u[1];++m)if(p=Zr(e[m],f,a),o=Math.min(o,p),o===0)return o}else p=gw(e,u,i,h,a),o=Math.min(o,p)}else{let p=qh(u,t),f=qh(h,r);ds(s,o,a,e,i,p[0],f[0]),ds(s,o,a,e,i,p[0],f[1]),ds(s,o,a,e,i,p[1],f[0]),ds(s,o,a,e,i,p[1],f[1])}}return o}function xw(e,t){let i=e.geometry(),r=i.flat().map(o=>wd([o.x,o.y],e.canonical));if(i.length===0)return NaN;let a=new Sd(r[0][1]),n=1/0;for(let o of t){switch(o.type){case"Point":n=Math.min(n,nl(r,!1,[o.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,nl(r,!1,o.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,al(r,!1,o.coordinates,a,n))}if(n===0)return n}return n}function bw(e,t){let i=e.geometry(),r=i.flat().map(o=>wd([o.x,o.y],e.canonical));if(i.length===0)return NaN;let a=new Sd(r[0][1]),n=1/0;for(let o of t){switch(o.type){case"Point":n=Math.min(n,nl(r,!0,[o.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,nl(r,!0,o.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,al(r,!0,o.coordinates,a,n))}if(n===0)return n}return n}function ww(e,t){let i=e.geometry();if(i.length===0||i[0].length===0)return NaN;let r=Ul(i,0).map(o=>o.map(s=>s.map(l=>wd([l.x,l.y],e.canonical)))),a=new Sd(r[0][0][0][1]),n=1/0;for(let o of t)for(let s of r){switch(o.type){case"Point":n=Math.min(n,al([o.coordinates],!1,s,a,n));break;case"LineString":n=Math.min(n,al(o.coordinates,!0,s,a,n));break;case"Polygon":n=Math.min(n,vw(s,o.coordinates,a,n))}if(n===0)return n}return n}function Yu(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 Pd=class Vs{constructor(t,i){this.type=N,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ya(t[1])){let r=t[1];if(r.type==="FeatureCollection")return new Vs(r,r.features.map(a=>Yu(a.geometry)).flat());if(r.type==="Feature")return new Vs(r,Yu(r.geometry));if("type"in r&&"coordinates"in r)return new Vs(r,Yu(r))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return xw(t,this.geometries);if(t.geometryType()==="LineString")return bw(t,this.geometries);if(t.geometryType()==="Polygon")return ww(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},Tw=class jy{constructor(t){let i=null;for(let r of t)if(!i)i=r.type;else{if(i===r.type)continue;i=he;break}this.type=kt(i!=null?i:he,t.length),this.arr=t}static parse(t,i){if(t.length!==2)return i.error(`'semiliteral' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ya(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=nt(r);if(a.kind==="array"){let n=r,o=i.concat(1),s=[];for(let l=0;l<n.length;l++){let u=o.parse(n[l],l,he);if(!u)return null;s.push(u)}return new jy(s)}return new Ka(a,r)}evaluate(t){return this.arr.map(i=>i.evaluate(t))}eachChild(t){this.arr.forEach(t)}outputDefined(){return this.arr.every(t=>t.outputDefined())}},Ad=class Vy{constructor(t){this.key=t,this.type=he}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=t[1];return r==null?i.error("Global state property must be defined."):typeof r=="string"?new Vy(r):i.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(t){var r,a;let i=(r=t.globals)==null?void 0:r.globalState;return!i||Object.keys(i).length===0?null:(a=qn(i,this.key))!=null?a:null}eachChild(){}outputDefined(){return!1}};const ja={"==":q2,"!=":W2,">":X2,"<":H2,">=":K2,"<=":Y2,array:or,at:A2,boolean:or,case:z2,coalesce:Ey,collator:Ay,format:py,image:Q2,in:M2,"index-of":I2,interpolate:yi,"interpolate-hcl":yi,"interpolate-lab":yi,length:ew,let:yy,literal:Ka,match:F2,number:or,"number-format":J2,object:or,semiliteral:Tw,slice:k2,step:bd,string:or,"to-boolean":Ra,"to-color":Ra,"to-number":Ra,"to-string":Ra,var:xy,within:Dd,distance:Pd,"global-state":Ad};var Gi=class extends Error{constructor(e,t){super(t),this.message=t,this.key=e}},Dw=class Ny{constructor(t,i=[]){this.parent=t,this.bindings={};for(let[r,a]of i)this.bindings[r]=a}concat(t){return new Ny(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}},Uy=class $y{constructor(t,i,r=[],a,n=new Dw,o=[]){this.registry=t,this.path=r,this.key=r.map(s=>`[${s}]`).join(""),this.scope=n,this.errors=o,this.expectedType=a,this._isConstant=i}parse(t,i,r,a,n={}){return i==null?this._parse(t,n):this.concat(i,r,a)._parse(t,n)}_parse(t,i){(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number")&&(t=["literal",t]);let r=this.key;function a(n,o,s){return s==="assert"?new or(o,[n],r):s==="coerce"?new Ra(o,[n],r):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 o=this.registry[n];if(o){let s=o.parse(t,this);if(!s)return null;if(this.expectedType){let l=this.expectedType,u=s.type;if((l.kind==="string"||l.kind==="number"||l.kind==="boolean"||l.kind==="object"||l.kind==="array")&&u.kind==="value")s=a(s,l,i.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))s=a(s,l,i.typeAnnotation||"coerce");else if(this.checkSubtype(l,u))return null}if(!(s instanceof Ka)&&s.type.kind!=="resolvedImage"&&this._isConstant(s)){let l=new cy;try{s=new Ka(s.type,s.evaluate(l))}catch(u){return this.error(u.message),null}}return s}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,i,r){let a=typeof t=="number"?this.path.concat(t):this.path,n=r?this.scope.concat(r):this.scope;return new $y(this.registry,this._isConstant,a,i||null,n,this.errors)}error(t,...i){let r=`${this.key}${i.map(a=>`[${a}]`).join("")}`;this.errors.push(new Gi(r,t))}checkSubtype(t,i){let r=ro(t,i);return r&&this.error(r),r}},ha=class Nn{constructor(t,i,r,a,n){this.name=t,this.type=i,this._evaluate=r,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,i){let r=t[0],a=Nn.definitions[r];if(!a)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,o=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,s=o.filter(([u])=>!Array.isArray(u)||u.length===t.length-1),l=null;for(let[u,h]of s){l=new Uy(i.registry,ol,i.path,null,i.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.`);else{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 Nn(r,n,h,c,i.key)}}if(s.length===1)i.errors.push(...l.errors);else{let u=(s.length?s:o).map(([c])=>Ew(c)).join(" | "),h=[];for(let c=1;c<t.length;c++){let d=i.parse(t[c],1+h.length);if(!d)return null;h.push(Je(d.type))}i.error(`Expected arguments of type ${u}, but found (${h.join(", ")}) instead.`)}return null}static register(t,i){Nn.definitions=i;for(let r in i)t[r]=Nn}};function Bf(e,[t,i,r,a],n){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);let o=a?a.evaluate(e):1,s=uy(t,i,r,o);if(s)throw new qe(s,n);return new se(t/255,i/255,r/255,o,!1)}function Of(e,t){return e in t&&t[e]!==void 0}function Ku(e,t){let i=t[e];return i===void 0?null:i}function Sw(e,t,i,r){for(;i<=r;){let a=i+r>>1;if(t[a]===e)return!0;t[a]>e?r=a-1:i=a+1}return!1}function jr(e){return{type:e}}ha.register(ja,{error:[c2,[le],(e,[t],i)=>{throw new qe(t.evaluate(e),i)}],typeof:[le,[he],(e,[t])=>Je(nt(t.evaluate(e)))],"to-rgba":[kt(N,4),[Ai],(e,[t])=>{let[i,r,a,n]=t.evaluate(e).rgb;return[i*255,r*255,a*255,n]}],rgb:[Ai,[N,N,N],Bf],rgba:[Ai,[N,N,N,N],Bf],has:{type:me,overloads:[[[le],(e,[t])=>Of(t.evaluate(e),e.properties())],[[le,Xr],(e,[t,i])=>Of(t.evaluate(e),i.evaluate(e))]]},get:{type:he,overloads:[[[le],(e,[t])=>Ku(t.evaluate(e),e.properties())],[[le,Xr],(e,[t,i])=>Ku(t.evaluate(e),i.evaluate(e))]]},"feature-state":[he,[le],(e,[t])=>Ku(t.evaluate(e),e.featureState||{})],properties:[Xr,[],e=>e.properties()],"geometry-type":[le,[],e=>e.geometryType()],id:[he,[],e=>e.id()],zoom:[N,[],e=>e.globals.zoom],"heatmap-density":[N,[],e=>e.globals.heatmapDensity||0],elevation:[N,[],e=>e.globals.elevation||0],"line-progress":[N,[],e=>e.globals.lineProgress||0],accumulated:[he,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[N,jr(N),(e,t)=>{let i=0;for(let r of t)i+=r.evaluate(e);return i}],"*":[N,jr(N),(e,t)=>{let i=1;for(let r of t)i*=r.evaluate(e);return i}],"-":{type:N,overloads:[[[N,N],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[N],(e,[t])=>-t.evaluate(e)]]},"/":[N,[N,N],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[N,[N,N],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[N,[],()=>Math.LN2],pi:[N,[],()=>Math.PI],e:[N,[],()=>Math.E],"^":[N,[N,N],(e,[t,i])=>t.evaluate(e)**+i.evaluate(e)],sqrt:[N,[N],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[N,[N],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[N,[N],(e,[t])=>Math.log(t.evaluate(e))],log2:[N,[N],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[N,[N],(e,[t])=>Math.sin(t.evaluate(e))],cos:[N,[N],(e,[t])=>Math.cos(t.evaluate(e))],tan:[N,[N],(e,[t])=>Math.tan(t.evaluate(e))],asin:[N,[N],(e,[t])=>Math.asin(t.evaluate(e))],acos:[N,[N],(e,[t])=>Math.acos(t.evaluate(e))],atan:[N,[N],(e,[t])=>Math.atan(t.evaluate(e))],min:[N,jr(N),(e,t)=>Math.min(...t.map(i=>i.evaluate(e)))],max:[N,jr(N),(e,t)=>Math.max(...t.map(i=>i.evaluate(e)))],abs:[N,[N],(e,[t])=>Math.abs(t.evaluate(e))],round:[N,[N],(e,[t])=>{let i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[N,[N],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[N,[N],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[me,[le,he],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[me,[he],(e,[t])=>e.id()===t.value],"filter-type-==":[me,[le],(e,[t])=>e.geometryType()===t.value],"filter-<":[me,[le,he],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<a}],"filter-id-<":[me,[he],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[me,[le,he],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>a}],"filter-id->":[me,[he],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[me,[le,he],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<=a}],"filter-id-<=":[me,[he],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[me,[le,he],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>=a}],"filter-id->=":[me,[he],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[me,[he],(e,[t])=>{let i=t.value,r=e.properties();return i in r&&r[i]!==void 0}],"filter-has-id":[me,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[me,[kt(le)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[me,[kt(he)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[me,[le,kt(he)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[me,[le,kt(he)],(e,[t,i])=>Sw(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:me,overloads:[[[me,me],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[jr(me),(e,t)=>{for(let i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:me,overloads:[[[me,me],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[jr(me),(e,t)=>{for(let i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[me,[me],(e,[t])=>!t.evaluate(e)],"is-supported-script":[me,[le],(e,[t])=>{let i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[le,[le],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[le,[le],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[le,jr(he),(e,t)=>t.map(i=>Wn(i.evaluate(e))).join("")],split:[kt(le),[le,le],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[le,[kt(le),le],(e,[t,i])=>t.evaluate(e).join(i.evaluate(e))],"resolved-locale":[le,[Bl],(e,[t])=>t.evaluate(e).resolvedLocale()]});function Ew(e){return Array.isArray(e)?`(${e.map(Je).join(", ")})`:`(${Je(e.type)}...)`}function ol(e){if(e instanceof xy)return ol(e.boundExpression);if(e instanceof ha&&e.name==="error"||e instanceof Ay||e instanceof Dd||e instanceof Pd||e instanceof Ad)return!1;let t=e instanceof Ra||e instanceof or,i=!0;return e.eachChild(r=>{i&&(i=t?ol(r):r instanceof Ka)}),i?Gl(e)&&Zl(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]):!1}function Gl(e){if(e instanceof ha&&(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 Dd||e instanceof Pd)return!1;let t=!0;return e.eachChild(i=>{t&&!Gl(i)&&(t=!1)}),t}function no(e){if(e instanceof ha&&e.name==="feature-state")return!1;let t=!0;return e.eachChild(i=>{t&&!no(i)&&(t=!1)}),t}function Zl(e,t){if(e instanceof ha&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(r=>{i&&!Zl(r,t)&&(i=!1)}),i}function Ja(e){return e["property-type"]==="data-driven"||e["property-type"]==="cross-faded-data-driven"}function Gy(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Md(e){return!!e.expression&&e.expression.interpolated}const Id=/^(.*)-transition$/;function oo(e,...t){for(let i of t)for(let r in i)e[r]=i[r];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 ql(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&nt(e)===Xr}function Cw(e){return e}function Pw(e){switch(e.type){case"color":return se.parse;case"padding":return Ji.parse;case"numberArray":return Qi.parse;case"colorArray":return _i.parse;default:return null}}function Aw(e){switch(e){case"exponential":return qy;case"interval":return Iw;case"categorical":return Mw;case"identity":return Fw;default:throw Error(`Unknown function type "${e}"`)}}function Zy(e,t){let i=e.stops&&typeof e.stops[0][0]=="object",r=i||e.property!==void 0,a=i||!r,n=e.type||(Md(t)?"exponential":"interval"),o=Pw(t);if(o&&(e=oo({},e),e.stops&&(e.stops=e.stops.map(h=>[h[0],o(h[1])])),e.default?e.default=o(e.default):e.default=o(t.default)),e.colorSpace&&!b2(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let s=Aw(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(i){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,Zy(h[f],t)]);let p={name:"linear"};return{kind:"composite",interpolationType:p,interpolationFactor:yi.interpolationFactor.bind(void 0,p),zoomStops:d.map(f=>f[0]),evaluate({zoom:f},m){return qy({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:yi.interpolationFactor.bind(void 0,h),zoomStops:e.stops.map(c=>c[0]),evaluate:({zoom:c})=>s(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?Po(e.default,t.default):s(e,t,d,l,u)}}}function Po(e,t,i){if(e!==void 0)return e;if(t!==void 0)return t;if(i!==void 0)return i}function Mw(e,t,i,r,a){return Po(typeof i===a?r[i]:void 0,e.default,t.default)}function Iw(e,t,i){if(de(i)!=="number")return Po(e.default,t.default);let r=e.stops.length;if(r===1||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];let a=Nl(e.stops.map(n=>n[0]),i,"");return e.stops[a][1]}function qy(e,t,i){let r=e.base===void 0?1:e.base;if(de(i)!=="number")return Po(e.default,t.default);let a=e.stops.length;if(a===1||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[a-1][0])return e.stops[a-1][1];let n=Nl(e.stops.map(h=>h[0]),i,""),o=zw(i,r,e.stops[n][0],e.stops[n+1][0]),s=e.stops[n][1],l=e.stops[n+1][1],u=We[t.type]||Cw;return typeof s.evaluate=="function"?{evaluate(...h){let c=s.evaluate.apply(void 0,h),d=l.evaluate.apply(void 0,h);if(c!==void 0&&d!==void 0)return u(c,d,o,e.colorSpace)}}:u(s,l,o,e.colorSpace)}function Fw(e,t,i){switch(t.type){case"color":i=se.parse(i);break;case"formatted":i=pr.fromString(i.toString());break;case"resolvedImage":i=Yi.fromString(i.toString());break;case"padding":i=Ji.parse(i);break;case"colorArray":i=_i.parse(i);break;case"numberArray":i=Qi.parse(i);break;default:de(i)!==t.type&&(t.type!=="enum"||!t.values[i])&&(i=void 0)}return Po(i,e.default,t.default)}function zw(e,t,i,r){let a=r-i,n=e-i;return a===0?0:t===1?n/a:(t**+n-1)/(t**+a-1)}function Xh(e){return{result:"success",value:e}}function Ia(e){return{result:"error",value:e}}var Fd=class{constructor(e,t,i,r){this.expression=e,this._warningHistory={},this._evaluator=new cy,this._defaultValue=i?Jy(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=r,this._rootKey=t}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Qa(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=a||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,a,n){this._globalState&&(e=Qa(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=a||null,this._evaluator.formattedSection=n||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(s=>JSON.stringify(s)).join(", ")}, but found ${JSON.stringify(o)} instead.`,"");return o}catch(o){let s=o instanceof qe?o.path:"",l=`${s}|${o.message}`;return this._warningHistory[l]||(this._warningHistory[l]=!0,typeof console<"u"&&console.warn(Wy(this._rootKey,s,o.message,this._defaultValue))),this._defaultValue}}};function Wy(e,t,i,r){return`${e}${t}: ${i}${r==null?"":` Falling back to ${String(r)}.`}`}function Hy(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 Wl(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"&&e[0]in ja}function Hl(e,t,i,r){Hy(t);let a=new Uy(ja,ol,[],i?Lw(i):void 0),n=a.parse(e,void 0,void 0,void 0,i&&i.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?Xh(new Fd(n,t,i,r)):Ia(a.errors)}var so=class{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent=e!=="constant"&&!no(t.expression),this.globalStateRefs=Ao(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Qa(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Qa(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}},sl=class{constructor(e,t,i,r,a){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent=e!=="camera"&&!no(t.expression),this.globalStateRefs=Ao(t.expression),this.interpolationType=r,this._globalState=a}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Qa(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Qa(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}interpolationFactor(e,t,i){return this.interpolationType?yi.interpolationFactor(this.interpolationType,e,t,i):0}};function kw(e){return e._styleExpression!==void 0}function Xy(e,t,i,r){let a=Hl(e,t,i,r);if(a.result==="error")return a;let n=a.value.expression,o=Gl(n);if(!o&&!Ja(i))return Ia([new Gi("","data expressions not supported")]);let s=Zl(n,["zoom"]);if(!s&&!Gy(i))return Ia([new Gi("","zoom expressions not supported")]);let l=Ns(n);if(!l&&!s)return Ia([new Gi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof Gi)return Ia([l]);if(l instanceof yi&&!Md(i))return Ia([new Gi("",'"interpolate" expressions cannot be used with this property')]);if(!l)return Xh(o?new so("constant",a.value,r):new so("source",a.value,r));let u=l instanceof yi?l.interpolation:void 0;return Xh(o?new sl("camera",a.value,l.labels,u,r):new sl("composite",a.value,l.labels,u,r))}var Yy=class Ky{constructor(t,i,r){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,Hy(i),this._parameters=t,this._specification=r,this._rootKey=i,this._defaultValue=Jy(r),this._warningHistory={};let a=Zy(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,i){try{return this._innerEvaluate(t,i)}catch(r){let a=r instanceof Error?r.message:String(r),n=`|${a}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<"u"&&console.warn(Wy(this._rootKey,"",a,this._defaultValue))),this._defaultValue}}static deserialize(t){return new Ky(t._parameters,t._rootKey,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification,_rootKey:t._rootKey}}};function Rw(e,t,i,r){if(ql(e))return new Yy(e,t,i);if(Wl(e)){let a=Xy(e,t,i,r);if(a.result==="error")throw Error(a.value.map(n=>`${n.key}: ${n.message}`).join(", "));return a.value}{let a=e;return i.type==="color"&&typeof e=="string"?a=se.parse(e):i.type==="padding"&&(typeof e=="number"||Array.isArray(e))?a=Ji.parse(e):i.type==="numberArray"&&(typeof e=="number"||Array.isArray(e))?a=Qi.parse(e):i.type==="colorArray"&&(typeof e=="string"||Array.isArray(e))?a=_i.parse(e):i.type==="variableAnchorOffsetCollection"&&Array.isArray(e)?a=Xi.parse(e):i.type==="projectionDefinition"&&typeof e=="string"&&(a=Lr.parse(e)),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>a}}}function Ns(e){let t=null;if(e instanceof yy)t=Ns(e.result);else if(e instanceof Ey){for(let i of e.args)if(t=Ns(i),t)break}else(e instanceof bd||e instanceof yi)&&e.input instanceof ha&&e.input.name==="zoom"&&(t=e);return t instanceof Gi||e.eachChild(i=>{let r=Ns(i);r instanceof Gi?t=r:!t&&r?t=new Gi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&r&&t!==r&&(t=new Gi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Ao(e,t=new Set){return e instanceof Ad&&t.add(e.key),e.eachChild(i=>{Ao(i,t)}),t}function Lw(e){let t={color:Ai,string:le,number:N,enum:le,boolean:me,formatted:So,padding:Ol,numberArray:jl,colorArray:io,projectionDefinition:Ll,resolvedImage:Eo,variableAnchorOffsetCollection:Vl};return e.type==="array"?kt(t[e.value]||he,e.length):t[e.type]}function Jy(e){if(e.type==="color"&&ql(e.default))return new se(0,0,0,0);switch(e.type){case"color":return se.parse(e.default)||null;case"padding":return Ji.parse(e.default)||null;case"numberArray":return Qi.parse(e.default)||null;case"colorArray":return _i.parse(e.default)||null;case"variableAnchorOffsetCollection":return Xi.parse(e.default)||null;case"projectionDefinition":return Lr.parse(e.default)||null;default:return e.default===void 0?null:e.default}}function Qa(e,t){let{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:o,accumulated:s}=e!=null?e:{};return{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:o,accumulated:s,globalState:t}}function Bw(e){let t=!1;for(let i of e){let r=Qy(i);if(r==="expression")return"expression";r==="legacy"&&(t=!0)}return t?"legacy":"neutral"}function Qy(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 Bw(e.slice(1));default:return"expression"}}function zd(e){return Qy(e)!=="legacy"}function jf(e){return e==="$type"?["geometry-type"]:e==="$id"?["id"]:["get",e]}function Ow(e){switch(e[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return e.length!==3||typeof e[1]!="string"?null:[e[0],jf(e[1]),e[2]];case"in":case"!in":{if(e.length<2||typeof e[1]!="string")return null;let t=["in",jf(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 e0(e){if((e[0]==="<"||e[0]==="<="||e[0]===">"||e[0]===">=")&&e[1]==="$type")return`"$type" cannot be use with operator "${e[0]}"`;let t=Ow(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 Ju(e,t,i){let r=i[e];return Array.isArray(r)?zd(r)?kd(r,t.concat(e)):{path:t.concat(e),legacyFilter:r}:null}function kd(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case"all":case"any":case"none":for(let i=1;i<e.length;i++){let r=Ju(i,t,e);if(r)return r}break;case"!":{let i=Ju(1,t,e);if(i)return i;break}case"case":for(let i=1;i<e.length-1;i+=2){let r=Ju(i,t,e);if(r)return r}}return null}function jw(e,t){let i=kd(e);if(!i||typeof console>"u")return;let r=i.path.map(a=>`[${a}]`).join("");console.warn(`${t}${r}: ${e0(i.legacyFilter)}`)}const Vw={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function lo(e,t,i){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};zd(e)?jw(e,t):e=ll(e);let r=Hl(e,t,Vw,i);if(r.result==="error")throw Error(r.value.map(a=>`${a.key}: ${a.message}`).join(", "));return{filter:(a,n,o)=>r.value.evaluate(a,n,{},o),needGeometry:t0(e),getGlobalStateRefs:()=>Ao(r.value.expression)}}function Nw(e,t){return e<t?-1:+(e>t)}function t0(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(t0(e[t]))return!0;return!1}function ll(e){if(!e)return!0;let t=e[0];return e.length<=1?t!=="any":t==="=="?Qu(e[1],e[2],"=="):t==="!="?ps(Qu(e[1],e[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Qu(e[1],e[2],t):t==="any"?Uw(e.slice(1)):t==="all"?["all"].concat(e.slice(1).map(ll)):t==="none"?["all"].concat(e.slice(1).map(ll).map(ps)):t==="in"?Vf(e[1],e.slice(2)):t==="!in"?ps(Vf(e[1],e.slice(2))):t==="has"?Nf(e[1]):t!=="!has"||ps(Nf(e[1]))}function Qu(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function Uw(e){return["any"].concat(e.map(ll))}function Vf(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(i=>typeof i!=typeof t[0])?["filter-in-large",e,["literal",t.sort(Nw)]]:["filter-in-small",e,["literal",t]]}}function Nf(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function ps(e){return["!",e]}function $w(){let e={},t=z.$version;for(let i in z.$root){let r=z.$root[i];if(r.required){let a=null;a=i==="version"?t:r.type==="array"?[]:{},a!=null&&(e[i]=a)}}return e}function i0(e){let t=e.key,i=e.value;return i?[new j(t,i,"constants have been deprecated as of v8")]:[]}function rt(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function ia(e){if(Array.isArray(e))return e.map(ia);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let i in e)t[i]=ia(e[i]);return t}return rt(e)}function ai(e){let t=e.key,i=e.value,r=e.valueSpec||{},a=e.objectElementValidators||{},n=e.style,o=e.styleSpec,s=e.validateSpec,l=[],u=de(i);if(u!=="object")return[new j(t,i,`object expected, ${u} found`)];for(let h in i){let c=h.split(".")[0],d=qn(r,c)||r["*"],p;if(qn(a,c))p=a[c];else if(qn(r,c)){if(i[h]===void 0)continue;p=s}else if(a["*"])p=a["*"];else if(r["*"])p=s;else{l.push(new j(t,i[h],`unknown property "${h}"`));continue}l=l.concat(p({key:(t&&`${t}.`)+h,value:i[h],valueSpec:d,style:n,styleSpec:o,object:i,objectKey:h,validateSpec:s},i))}for(let h in r)a[h]||r[h].required&&r[h].default===void 0&&i[h]===void 0&&l.push(new j(t,i,`missing required property "${h}"`));return l}function Rd(e){let t=e.value,i=e.valueSpec,r=e.validateSpec,a=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||r;if(de(t)!=="array")return[new j(o,t,`array expected, ${de(t)} found`)];if(i.length&&t.length!==i.length)return[new j(o,t,`array length ${i.length} expected, length ${t.length} found`)];let l={type:i.value,values:i.values};n.$version<7&&(l.function=i.function),de(i.value)==="object"&&(l=i.value);let u=[];for(let h=0;h<t.length;h++)u=u.concat(s({array:t,arrayIndex:h,value:t[h],valueSpec:l,validateSpec:e.validateSpec,style:a,styleSpec:n,key:`${o}[${h}]`}));return u}function Xl(e){let t=e.key,i=e.value,r=e.valueSpec,a=de(i);return a==="number"&&i!==i&&(a="NaN"),a==="number"?"minimum"in r&&i<r.minimum?[new j(t,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new j(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new j(t,i,`number expected, ${a} found`)]}function r0(e){let t=e.valueSpec,i=rt(e.value.type),r,a={},n,o,s=i!=="categorical"&&e.value.property===void 0,l=!s,u=de(e.value.stops)==="array"&&de(e.value.stops[0])==="array"&&de(e.value.stops[0][0])==="object",h=ai({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 i==="identity"&&s&&h.push(new j(e.key,e.value,'missing required property "property"')),i!=="identity"&&!e.value.stops&&h.push(new j(e.key,e.value,'missing required property "stops"')),i==="exponential"&&e.valueSpec.expression&&!Md(e.valueSpec)&&h.push(new j(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Ja(e.valueSpec)?h.push(new j(e.key,e.value,"property functions not supported")):s&&!Gy(e.valueSpec)&&h.push(new j(e.key,e.value,"zoom functions not supported"))),(i==="categorical"||u)&&e.value.property===void 0&&h.push(new j(e.key,e.value,'"property" property is required')),h;function c(m){if(i==="identity")return[new j(m.key,m.value,'identity function may not have a "stops" property')];let g=[],_=m.value;return g=g.concat(Rd({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 j(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 j(y,_,`array expected, ${de(_)} found`)];if(_.length!==2)return[new j(y,_,`array length 2 expected, length ${_.length} found`)];if(u){if(de(_[0])!=="object")return[new j(y,_,`object expected, ${de(_[0])} found`)];if(_[0].zoom===void 0)return[new j(y,_,"object stop key must have zoom")];if(_[0].value===void 0)return[new j(y,_,"object stop key must have value")];if(o&&o>rt(_[0].zoom))return[new j(y,_[0].zoom,"stop zoom values must appear in ascending order")];rt(_[0].zoom)!==o&&(o=rt(_[0].zoom),n=void 0,a={}),g=g.concat(ai({key:`${y}[0]`,value:_[0],valueSpec:{zoom:{}},validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec,objectElementValidators:{zoom:Xl,value:p}}))}else g=g.concat(p({key:`${y}[0]`,value:_[0],validateSpec:m.validateSpec,style:m.style,styleSpec:m.styleSpec},_));return Wl(ia(_[1]))?g.concat([new j(`${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=rt(m.value),v=m.value===null?g:m.value;if(!r)r=_;else if(_!==r)return[new j(m.key,v,`${_} stop domain type must match previous stop domain type ${r}`)];if(_!=="number"&&_!=="string"&&_!=="boolean")return[new j(m.key,v,"stop domain value must be a number, string, or boolean")];if(_!=="number"&&i!=="categorical"){let x=`number expected, ${_} found`;return Ja(t)&&i===void 0&&(x+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new j(m.key,v,x)]}return i==="categorical"&&_==="number"&&(!isFinite(y)||Math.floor(y)!==y)?[new j(m.key,v,`integer expected, found ${y}`)]:i!=="categorical"&&_==="number"&&n!==void 0&&y<n?[new j(m.key,v,"stop domain values must appear in ascending order")]:(n=y,i==="categorical"&&y in a?[new j(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 en(e){let t=(e.expressionContext==="property"?Xy:Hl)(ia(e.value),e.key,e.valueSpec);if(t.result==="error")return t.value.map(r=>new j(`${e.key}${r.key}`,e.value,r.message));let i=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext==="property"&&e.propertyKey==="text-font"&&!i.outputDefined())return[new j(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"&&!no(i))return[new j(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if(e.expressionContext==="filter"&&!no(i))return[new j(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&e.expressionContext.indexOf("cluster")===0){if(!Zl(i,["zoom","feature-state"]))return[new j(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(e.expressionContext==="cluster-initial"&&!Gl(i))return[new j(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Gw(e){let t=e.value,i=e.key,r=de(t);return r==="boolean"?[]:[new j(i,t,`boolean expected, ${r} found`)]}function Yh(e){let t=e.key,i=e.value,r=de(i);return r==="string"?se.parse(String(i))?[]:[new j(t,i,`color expected, "${i}" found`)]:[new j(t,i,`color expected, ${r} found`)]}function uo(e){let t=e.key,i=e.value,r=e.valueSpec,a=[];return Array.isArray(r.values)?r.values.indexOf(rt(i))===-1&&a.push(new j(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(r.values).indexOf(rt(i))===-1&&a.push(new j(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),a}function Zw(e,t){let i=e;for(let r of t)i=i[r];return i}function qw(e,t){let i=kd(t);return i?[new j(`${e.key}${i.path.map(r=>`[${r}]`).join("")}`,Zw(e.value,i.path),e0(i.legacyFilter),null,"warning")]:[]}function Ld(e){let t=ia(e.value);return zd(t)?[...qw(e,t),...en(oo({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:a0(e)}function a0(e){let t=e.value,i=e.key;if(de(t)!=="array")return[new j(i,t,`array expected, ${de(t)} found`)];let r=e.styleSpec,a,n=[];if(t.length<1)return[new j(i,t,"filter array must have at least 1 element")];switch(n=n.concat(uo({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),rt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&rt(t[1])==="$type"&&n.push(new j(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&n.push(new j(i,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 j(`${i}[1]`,t[1],`string expected, ${a} found`)));for(let o=2;o<t.length;o++)a=de(t[o]),rt(t[1])==="$type"?n=n.concat(uo({key:`${i}[${o}]`,value:t[o],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):a!=="string"&&a!=="number"&&a!=="boolean"&&n.push(new j(`${i}[${o}]`,t[o],`string, number, or boolean expected, ${a} found`));break;case"any":case"all":case"none":for(let o=1;o<t.length;o++)n=n.concat(a0({key:`${i}[${o}]`,value:t[o],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":a=de(t[1]),t.length===2?a!=="string"&&n.push(new j(`${i}[1]`,t[1],`string expected, ${a} found`)):n.push(new j(i,t,`filter array for "${t[0]}" operator must have 2 elements`))}return n}function n0(e,t){let i=e.key,r=e.validateSpec,a=e.style,n=e.styleSpec,o=e.value,s=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];let u=s.match(Id);if(t==="paint"&&u&&l[u[1]]&&l[u[1]].transition)return r({key:i,value:o,valueSpec:n.transition,style:a,styleSpec:n});let h=e.valueSpec||l[s];if(!h)return[new j(i,o,`unknown property "${s}"`)];let c;if(de(o)==="string"&&Ja(h)&&!h.tokens&&(c=/^{([^}]+)}$/.exec(o)))return[new j(i,o,`"${s}" does not support interpolation syntax
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(c[1])} }\`.`)];let d=[];return e.layerType==="symbol"&&s==="text-font"&&ql(ia(o))&&rt(o.type)==="identity"&&d.push(new j(i,o,'"text-font" does not support identity functions')),d.concat(r({key:e.key,value:o,valueSpec:h,style:a,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:s}))}function o0(e){return n0(e,"paint")}function s0(e){return n0(e,"layout")}function l0(e){var l,u;let t=[],i=e.value,r=e.key,a=e.style,n=e.styleSpec;if(de(i)!=="object")return[new j(r,i,`object expected, ${de(i)} found`)];!i.type&&!i.ref&&t.push(new j(r,i,'either "type" or "ref" is required'));let o=rt(i.type),s=rt(i.ref);if(i.id){let h=rt(i.id);for(let c=0;c<e.arrayIndex;c++){let d=a.layers[c];rt(d.id)===h&&t.push(new j(r,i.id,`duplicate layer id "${i.id}", previously used at line ${d.id.__line__}`))}}if("ref"in i){["type","source","source-layer","filter","layout"].forEach(c=>{c in i&&t.push(new j(r,i[c],`"${c}" is prohibited for ref layers`))});let h;a.layers.forEach(c=>{rt(c.id)===s&&(h=c)}),h?h.ref?t.push(new j(r,i.ref,"ref cannot reference another ref layer")):o=rt(h.type):t.push(new j(r,i.ref,`ref layer "${s}" not found`))}else if(o!=="background")if(!i.source)t.push(new j(r,i,'missing required property "source"'));else{let h=a.sources&&a.sources[i.source],c=h&&rt(h.type);h?c==="vector"&&o==="raster"?t.push(new j(r,i.source,`layer "${i.id}" requires a raster source`)):c!=="raster-dem"&&o==="hillshade"||c!=="raster-dem"&&o==="color-relief"?t.push(new j(r,i.source,`layer "${i.id}" requires a raster-dem source`)):c==="raster"&&o!=="raster"?t.push(new j(r,i.source,`layer "${i.id}" requires a vector source`)):c==="vector"&&!i["source-layer"]?t.push(new j(r,i,`layer "${i.id}" must specify a "source-layer"`)):c==="raster-dem"&&o!=="hillshade"&&o!=="color-relief"?t.push(new j(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):o==="line"&&i.paint&&i.paint["line-gradient"]&&(c!=="geojson"||!h.lineMetrics)&&t.push(new j(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new j(r,i.source,`source "${i.source}" not found`))}return o==="raster"&&((l=i.paint)!=null&&l.resampling)&&((u=i.paint)!=null&&u["raster-resampling"])&&t.push(new j(r,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(ai({key:r,value:i,valueSpec:n.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(){return[]},type(){return e.validateSpec({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"})},filter:Ld,layout(h){return ai({layer:i,key:h.key,value:h.value,style:h.style,styleSpec:h.styleSpec,validateSpec:h.validateSpec,objectElementValidators:{"*"(c){return s0(oo({layerType:o},c))}}})},paint(h){return ai({layer:i,key:h.key,value:h.value,style:h.style,styleSpec:h.styleSpec,validateSpec:h.validateSpec,objectElementValidators:{"*"(c){return o0(oo({layerType:o},c))}}})}}})),t}function zr(e){let t=e.value,i=e.key,r=de(t);return r==="string"?[]:[new j(i,t,`string expected, ${r} found`)]}function Ww(e){var c;let t=(c=e.sourceName)!=null?c:"",i=e.value,r=e.styleSpec,a=r.source_raster_dem,n=e.style,o=[],s=de(i);if(i===void 0)return o;if(s!=="object")return o.push(new j("source_raster_dem",i,`object expected, ${s} found`)),o;let l=rt(i.encoding)==="custom",u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(let d in i)!l&&u.includes(d)?o.push(new j(d,i[d],`In "${t}": "${d}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):a[d]?o=o.concat(e.validateSpec({key:d,value:i[d],valueSpec:a[d],validateSpec:e.validateSpec,style:n,styleSpec:r})):o.push(new j(d,i[d],`unknown property "${d}"`));return o}const Uf={promoteId:Hw};function u0(e){let t=e.value,i=e.key,r=e.styleSpec,a=e.style,n=e.validateSpec;if(!t.type)return[new j(i,t,'"type" is required')];let o=rt(t.type),s;switch(o){case"vector":case"raster":return s=ai({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Uf,validateSpec:n}),s;case"raster-dem":return s=Ww({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:n}),s;case"geojson":if(s=ai({key:i,value:t,valueSpec:r.source_geojson,style:a,styleSpec:r,validateSpec:n,objectElementValidators:Uf}),t.cluster)for(let l in t.clusterProperties){let[u,h]=t.clusterProperties[l],c=typeof u=="string"?[u,["accumulated"],["get",l]]:u;s.push(...en({key:`${i}.${l}.map`,value:h,expressionContext:"cluster-map"})),s.push(...en({key:`${i}.${l}.reduce`,value:c,expressionContext:"cluster-reduce"}))}return s;case"video":return ai({key:i,value:t,valueSpec:r.source_video,style:a,validateSpec:n,styleSpec:r});case"image":return ai({key:i,value:t,valueSpec:r.source_image,style:a,validateSpec:n,styleSpec:r});case"canvas":return[new j(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return uo({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Hw({key:e,value:t}){if(de(t)==="string")return zr({key:e,value:t});{let i=[];for(let r in t)i.push(...zr({key:`${e}.${r}`,value:t[r]}));return i}}function h0(e){let t=e.value,i=e.styleSpec,r=i.light,a=e.style,n=[],o=de(t);if(t===void 0)return n;if(o!=="object")return n=n.concat([new j("light",t,`object expected, ${o} found`)]),n;for(let s in t){let l=s.match(Id);n=l&&r[l[1]]&&r[l[1]].transition?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:a,styleSpec:i})):r[s]?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new j(s,t[s],`unknown property "${s}"`)])}return n}function c0(e){let t=e.value,i=e.styleSpec,r=i.sky,a=e.style,n=de(t);if(t===void 0)return[];if(n!=="object")return[new j("sky",t,`object expected, ${n} found`)];let o=[];for(let s in t){let l=s.match(Id);o=l&&r[l[1]]&&r[l[1]].transition?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:i.transition,style:a,styleSpec:i})):r[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],style:a,styleSpec:i})):o.concat([new j(s,t[s],`unknown property "${s}"`)])}return o}function d0(e){let t=e.value,i=e.styleSpec,r=i.terrain,a=e.style,n=[],o=de(t);if(t===void 0)return n;if(o!=="object")return n=n.concat([new j("terrain",t,`object expected, ${o} found`)]),n;for(let s in t)n=r[s]?n.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new j(s,t[s],`unknown property "${s}"`)]);return n}function Xw(e){return zr(e).length===0?[]:en(e)}function Yw(e){return zr(e).length===0?[]:en(e)}function Kw(e){let t=e.key,i=e.value;if(de(i)==="array"){if(i.length<1||i.length>4)return[new j(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];let r={type:"number"},a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return Xl({key:t,value:i,valueSpec:{}})}function Jw(e){let t=e.key,i=e.value;if(de(i)==="array"){let r={type:"number"};if(i.length<1)return[new j(t,i,"array length at least 1 expected, length 0 found")];let a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return Xl({key:t,value:i,valueSpec:{}})}function Qw(e){let t=e.key,i=e.value;if(de(i)==="array"){if(i.length<1)return[new j(t,i,"array length at least 1 expected, length 0 found")];let r=[];for(let a=0;a<i.length;a++)r=r.concat(Yh({key:`${t}[${a}]`,value:i[a]}));return r}return Yh({key:t,value:i})}function eT(e){let t=e.key,i=e.value,r=de(i),a=e.styleSpec;if(r!=="array"||i.length<1||i.length%2!=0)return[new j(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let o=0;o<i.length;o+=2)n=n.concat(uo({key:`${t}[${o}]`,value:i[o],valueSpec:a.layout_symbol["text-anchor"]})),n=n.concat(Rd({key:`${t}[${o+1}]`,value:i[o+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:a}));return n}function p0(e){let t=[],i=e.value,r=e.key;if(Array.isArray(i)){let a=[],n=[];for(let o in i)i[o].id&&a.includes(i[o].id)&&t.push(new j(r,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),a.push(i[o].id),i[o].url&&n.includes(i[o].url)&&t.push(new j(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),n.push(i[o].url),t=t.concat(ai({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return zr({key:r,value:i})}function tT(e){let t=e.value,i=e.styleSpec,r=i.projection,a=e.style,n=de(t);if(t===void 0)return[];if(n!=="object")return[new j("projection",t,`object expected, ${n} found`)];let o=[];for(let s in t)o=r[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:r[s],style:a,styleSpec:i})):o.concat([new j(s,t[s],`unknown property "${s}"`)]);return o}function iT(e){let t=e.key,i=e.value;i=i instanceof String?i.valueOf():i;let r=de(i);return r==="array"&&!aT(i)&&!rT(i)?[new j(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]:["array","string"].includes(r)?[]:[new j(t,i,`projection expected, invalid type "${r}" found`)]}function rT(e){return!!["interpolate","step","literal"].includes(e[0])}function aT(e){return Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"}function Kh(e){return!!e&&e.constructor===Object}function f0(e){return Kh(e.value)?[]:[new j(e.key,e.value,`object expected, ${de(e.value)} found`)]}const $f=1114111,nT=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function oT(e,t){if(de(t)!=="string")return[];let i=`${t}`,r=()=>[new j(e,t,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],a=i.match(nT);if(!a)return r();let[,n,o,s]=a;if(s!==void 0)return s.length>6?r():[];let l=parseInt(n,16),u=o===void 0?l:parseInt(o,16);return l>$f||u>$f?[new j(e,t,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>u?[new j(e,t,`unicode range start must not be greater than its end, but ${i} is`)]:[]}function m0(e){var s,l;let t=(s=e.key)!=null?s:"font-faces",i=e.value,r=e.validateSpec,a=(l=e.styleSpec)!=null?l:J_,n=e.style;if(!Kh(i))return[new j(t,i,`object expected, ${de(i)} found`)];let o=[];for(let u in i){let h=i[u],c=de(h);if(c==="string")o.push(...zr({key:`${t}.${u}`,value:h}));else if(c==="array"){let d={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[p,f]of h.entries()){let m=`${t}.${u}[${p}]`;o.push(...ai({key:m,value:f,valueSpec:d,styleSpec:a,style:n,validateSpec:r}));let g=Kh(f)?f["unicode-range"]:void 0;if(de(g)==="array")for(let[_,y]of g.entries())o.push(...oT(`${m}.unicode-range[${_}]`,y))}}else o.push(new j(`${t}.${u}`,h,`string or array expected, ${c} found`))}return o}const Gf={"*"(){return[]},array:Rd,boolean:Gw,number:Xl,color:Yh,constants:i0,enum:uo,filter:Ld,function:r0,layer:l0,object:ai,source:u0,light:h0,sky:c0,terrain:d0,projection:tT,projectionDefinition:iT,string:zr,formatted:Xw,resolvedImage:Yw,padding:Kw,numberArray:Jw,colorArray:Qw,variableAnchorOffsetCollection:eT,sprite:p0,state:f0,fontFaces:m0};function ul(e){let t=e.value,i=e.valueSpec,r=e.styleSpec;return e.validateSpec=ul,i.expression&&ql(rt(t))?r0(e):i.expression&&Wl(ia(t))?en(e):i.type&&Gf[i.type]?Gf[i.type](e):ai(oo({},e,{valueSpec:i.type?r[i.type]:i}))}function g0(e){let t=e.value,i=e.key,r=zr(e);return r.length||(t.indexOf("{fontstack}")===-1&&r.push(new j(i,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&r.push(new j(i,t,'"glyphs" url must include a "{range}" token'))),r}function Qt(e,t=z){let i=[];return i=i.concat(ul({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:ul,objectElementValidators:{glyphs:g0,"*"(){return[]}}})),e.constants&&(i=i.concat(i0({key:"constants",value:e.constants}))),_0(i)}Qt.source=hi(ui(u0)),Qt.sprite=hi(ui(p0)),Qt.glyphs=hi(ui(g0)),Qt.fontFaces=hi(ui(m0)),Qt.light=hi(ui(h0)),Qt.sky=hi(ui(c0)),Qt.terrain=hi(ui(d0)),Qt.state=hi(ui(f0)),Qt.layer=hi(ui(l0)),Qt.filter=hi(ui(Ld)),Qt.paintProperty=hi(ui(o0)),Qt.layoutProperty=hi(ui(s0));function ui(e){return function(t){return e(Object.assign({},t,{validateSpec:ul}))}}function _0(e){return[].concat(e).sort((t,i)=>t.line-i.line)}function hi(e){return function(...t){return _0(e.apply(this,t))}}const sT={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var lT=class{constructor(e,t,i){this._rootKey=t,this._globalState=i,this.setValue(e)}evaluate(){var e;return(e=this._literalValue)!=null?e:this._compiledValue.evaluate({})}setValue(e){if(e==null||e==="visible"||e==="none"){this._literalValue=e==="none"?"none":"visible",this._compiledValue=void 0,this._globalStateRefs=new Set;return}let t=Hl(e,this._rootKey,sT,this._globalState);if(t.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,Error(t.value.map(i=>`${i.key}: ${i.message}`).join(", "));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=Ao(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function uT(e,t,i){return new lT(e,t,i)}const qt=Qt,y0=new Set(Object.keys(z).filter(e=>e.startsWith("source_")).map(e=>e.slice(7).replaceAll("_","-")));function hT(e){var t;return Object.entries((t=e.sources)!=null?t:{}).filter(([,i])=>!y0.has(i.type)).map(([i])=>`sources.${i}`)}function Zf(e,t){let i=hT(t);return Bd(e,qt(t).filter(({message:r})=>!i.some(a=>r.startsWith(`${a}:`)||r.startsWith(`${a}.`))))}function Bd(e,t){let i=!1;for(let r of t)r.severity==="warning"?_e(r.message):(e.fire(new K(Error(r.message))),i=!0);return i}function Mo(e,t,i,r){return(r==null?void 0:r.validate)!==!1&&Bd(e,t({styleSpec:z,...i}))}var Jh=class v0{constructor(t,i,r){let a=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let o=new Int32Array(this.arrayBuffer);t=o[0],i=o[1],r=o[2],this.d=i+2*r;for(let u=0;u<this.d*this.d;u++){let h=o[3+u],c=o[3+u+1];a.push(h===c?null:o.subarray(h,c))}let s=o[3+a.length],l=o[3+a.length+1];this.keys=o.subarray(s,l),this.bboxes=o.subarray(l),this.insert=this._insertReadonly}else{this.d=i+2*r;for(let o=0;o<this.d*this.d;o++)a.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=r,this.scale=i/t,this.uid=0;let n=r/i*t;this.min=-n,this.max=t+n}insert(t,i,r,a,n){this._forEachCell(i,r,a,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(n)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,i,r,a,n,o){this.cells[n].push(o)}query(t,i,r,a,n){let o=this.min,s=this.max;if(t<=o&&i<=o&&s<=r&&s<=a&&!n)return[...this.keys];{let l=[];return this._forEachCell(t,i,r,a,this._queryCell,l,{},n),l}}_queryCell(t,i,r,a,n,o,s,l){let u=this.cells[n];if(u!==null){let h=this.keys,c=this.bboxes;for(let d of u)if(s[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]&&i<=c[p+3]&&r>=c[p+0]&&a>=c[p+1])?(s[d]=!0,o.push(h[d])):s[d]=!1}}}_forEachCell(t,i,r,a,n,o,s,l){let u=this._convertToCellCoord(t),h=this._convertToCellCoord(i),c=this._convertToCellCoord(r),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,i,r,a,m,o,s,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,i=3+this.cells.length+1+1,r=0;for(let o of this.cells)r+=o.length;let a=new Int32Array(i+r+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;let n=i;for(let o=0;o<t.length;o++){let s=t[o];a[3+o]=n,a.set(s,n),n+=s.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,i){let r=t.toArrayBuffer();return i&&i.push(r),{buffer:r}}static deserialize(t){return new v0(t.buffer)}};const lr={};function G(e,t,i={}){if(lr[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),lr[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}G("Object",Object),G("Set",Set),G("TransferableGridIndex",Jh),G("Color",se),G("Error",Error),G("AJAXError",il),G("ResolvedImage",Yi),G("StylePropertyFunction",Yy),G("StyleExpression",Fd,{omit:["_evaluator"]}),G("ZoomDependentExpression",sl),G("ZoomConstantExpression",so),G("CompoundExpression",ha,{omit:["_evaluate"]});for(let e in ja)ja[e]._classRegistryKey||G(`Expression_${e}`,ja[e]);function x0(e){var t;return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||((t=e.constructor)==null?void 0:t.name)==="ArrayBuffer")}function Od(e){let t=e.constructor;return e.$name||t._classRegistryKey}function cT(e){if(typeof e!="object"||!e)return!1;let t=Od(e);return t&&t!=="Object"}function b0(e){return!cT(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||x0(e)||Hr(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function Hn(e,t){if(b0(e))return(x0(e)||Hr(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 o of e)n.push(Hn(o,t));return n}if(typeof e!="object")throw Error(`can't serialize object of type ${typeof e}`);let i=Od(e);if(!i)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!lr[i])throw Error(`${i} is not registered.`);let{klass:r}=lr[i],a=r.serialize?r.serialize(e,t):{};if(r.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)||lr[i].omit.includes(n))continue;let o=e[n];o!==void 0&&(a[n]=lr[i].shallow.includes(n)?o:Hn(o,t))}e instanceof Error&&(a.message=e.message)}if(a.$name)throw Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(a.$name=i),a}function Xn(e){if(b0(e))return e;if(Array.isArray(e))return e.map(Xn);if(typeof e!="object")throw Error(`can't deserialize object of type ${typeof e}`);let t=Od(e)||"Object";if(!lr[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:i}=lr[t];if(!i)throw Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);let r=Object.create(i.prototype);for(let a of Object.keys(e)){if(a==="$name")continue;let n=e[a];r[a]=lr[t].shallow.includes(a)?n:Xn(n)}return r}var Qh=class{constructor(){this.first=!0}update(e,t){let i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}},Ie=class{constructor(e,t){this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new Qh,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Qh,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}},ho=class{constructor(e,t,i,r){this.property=e,this.value=t,this.expression=Rw(t===void 0?e.specification.default:t,i,e.specification,r)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}readsGlobalState(e){let t=this.getGlobalStateRefs();return e.some(i=>t.has(i))}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}},ec=class{constructor(e,t,i){this.property=e,this.value=new ho(e,void 0,t,i)}transitioned(e,t){return t.value===this.value?t:new qf(this.property,this.value,t,X({},e.transition,this.transition),e.now)}untransitioned(){return new qf(this.property,this.value,null,{},0)}},Yl=class{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=i,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return Wt(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new ec(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].value=new ho(this._values[e].property,t===null?void 0:Wt(t),this._propertyRootKey(e),this._globalState)}setValues(e){for(let t in e){let i=e[t];t.endsWith("-transition")?this.setTransition(t.slice(0,-11),i):$i(this._values[t].value.value,i)||this.setValue(t,i)}}getTransition(e){return Wt(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new ec(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].transition=Wt(t)||void 0}retainPriorGlobalState(e,t,i){for(let r of Object.keys(i._values))for(let a=i._values[r];a;a=a.prior){let{value:n}=a;n.property.specification.transition&&!n.isDataDriven()&&n.expression._globalState===this._globalState&&n.readsGlobalState(e)&&(a.value=new ho(n.property,n.value,this._propertyRootKey(r),t))}}applyGlobalStateChange(e,t,i,r){this.retainPriorGlobalState(e,t,i);let a=!1;for(let n of Object.keys(this._values)){let{value:o}=this._values[n];o.readsGlobalState(e)&&(this.setValue(n,o.value),a=!0)}return a?this.transitioned(r,i):i}serialize(){let e={};for(let t of Object.keys(this._values)){let i=this.getValue(t);i!==void 0&&(e[t]=i);let r=this.getTransition(t);r!==void 0&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){let i=new Wf(this._properties);for(let r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){let e=new Wf(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}},qf=class{constructor(e,t,i,r,a){this.property=e,this.value=t,this.begin=a+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){let r=e.now||0,a=this.value.possiblyEvaluate(e,t,i),n=this.prior;if(!n)return a;if(r>this.end||this.value.isDataDriven())return this.prior=null,a;if(r<this.begin)return n.possiblyEvaluate(e,t,i);{let o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(e,t,i),a,Ab(o))}}},Wf=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){let r=new Kl(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}},dT=class{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=i,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasValue(e){return this._values[e].value!==void 0}hasProperty(e){return e in this._properties.defaultPropertyValues}getValue(e){return Wt(this._values[e].value)}setValue(e,t){this._values[e]=new ho(this._values[e].property,t===null?void 0:Wt(t),this._propertyRootKey(e),this._globalState)}serialize(){let e={};for(let t of Object.keys(this._values)){let i=this.getValue(t);i!==void 0&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){let r=new Kl(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}},mi=class{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}},Kl=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}};function Hf(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 w0(e,t){let i=Hf(e),r=Hf(t);return i!==void 0&&r!==void 0&&i!==r}var U=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t){if(e.isDataDriven())throw Error("Value should not be data driven");return e.expression.evaluate(t)}interpolate(e,t,i){if(w0(e,t))return _e(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=We[r];return a?a(e,t,i):e}},Q=class{constructor(e,t,i){this.specification=e,this.name=t,this.overrides=i}possiblyEvaluate(e,t,i,r){return e.expression.kind==="constant"||e.expression.kind==="camera"?new mi(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)},t):new mi(this,e.expression,t)}interpolate(e,t,i){if(e.value.kind!=="constant"||t.value.kind!=="constant")return e;if(e.value.value===void 0||t.value.value===void 0)return new mi(this,{kind:"constant",value:void 0},e.parameters);if(w0(e.value.value,t.value.value))return _e(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=We[r];if(a){let n=a(e.value.value,t.value.value,i);return new mi(this,{kind:"constant",value:n},e.parameters)}return e}evaluate(e,t,i,r,a,n){return e.kind==="constant"?e.value:e.evaluate(t,i,r,a,n)}},co=class extends Q{possiblyEvaluate(e,t,i,r){if(e.value===void 0)return new mi(this,{kind:"constant",value:void 0},t);if(e.expression.kind==="constant"){let a=e.expression.evaluate(t,null,{},i,r),n=e.property.specification.type==="resolvedImage"&&typeof a!="string"?a.name:a,o=this._calculate(n,n,n,t);return new mi(this,{kind:"constant",value:o},t)}if(e.expression.kind==="camera"){let a=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new mi(this,{kind:"constant",value:a},t)}return new mi(this,e.expression,t)}evaluate(e,t,i,r,a,n){if(e.kind==="source"){let o=e.evaluate(t,i,r,a,n);return this._calculate(o,o,o,t)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}},T0=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,i,r){if(e.value!==void 0){if(e.expression.kind==="constant"){let a=e.expression.evaluate(t,null,{},i,r);return this._calculate(a,a,a,t)}return this._calculate(e.expression.evaluate(new Ie(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Ie(Math.floor(t.zoom),t)),e.expression.evaluate(new Ie(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}},Jl=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}},St=class{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let i=e[t];i.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new ho(i,void 0,i.name,void 0),a=this.defaultTransitionablePropertyValues[t]=new ec(i,i.name,void 0);this.defaultTransitioningPropertyValues[t]=a.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}};G("DataDrivenProperty",Q),G("DataConstantProperty",U),G("CrossFadedDataDrivenProperty",co),G("CrossFadedProperty",T0),G("ColorRampProperty",Jl);const Xf=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",eh=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var Ri=class extends Ft{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=uT(this.visibility,`layers[${this.id}].layout.visibility`,i),e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=lo(e.filter,`layers[${this.id}].filter`,i)),t.layout&&(this._unevaluatedLayout=new dT(t.layout,`layers[${this.id}].layout`,i)),t.paint)){this._transitionablePaint=new Yl(t.paint,`layers[${this.id}].paint`,i);for(let r in e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(let r in e.layout)this.setLayoutProperty(r,e.layout[r],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Kl(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=lo(e,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){var t;if(e==="visibility")return this.visibility;if((t=this._transitionablePaint)!=null&&t.hasProperty(e))throw Error(e+Xf);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=new Set;for(let t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(let t in this._unevaluatedLayout._values){let i=this._unevaluatedLayout._values[t];for(let r of i.getGlobalStateRefs())e.add(r)}for(let t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var t;let e=new globalThis.Map;if(this._transitionablePaint)for(let i in this._transitionablePaint._values){let r=this._transitionablePaint._values[i].value;for(let a of r.getGlobalStateRefs()){let n=(t=e.get(a))!=null?t:[];n.push({name:i,value:r.value}),e.set(a,n)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,i={}){var r;e==="visibility"?(this.visibility=t,this._visibilityExpression.setValue(t),this.recalculateVisibility()):(r=this._transitionablePaint)!=null&&r.hasProperty(e)?this.fire(new K(Error(e+Xf))):t!=null&&this._validate(qt.layoutProperty,`layers.${this.id}.layout.${e}`,e,t,i)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){var t,i;if(e.endsWith("-transition")){let r=e.slice(0,-11);if(r==="visibility"||(t=this._unevaluatedLayout)!=null&&t.hasProperty(r))throw Error(e+eh);return this._transitionablePaint.getTransition(r)}if(e==="visibility"||(i=this._unevaluatedLayout)!=null&&i.hasProperty(e))throw Error(e+eh);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){var r;if(e==="visibility"||(r=this._unevaluatedLayout)!=null&&r.hasProperty(e))return this.fire(new K(Error(e+eh))),!1;if(t!=null&&this._validate(qt.paintProperty,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith("-transition"))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let a=this._transitionablePaint._values[e],n=a.property.specification["property-type"]==="cross-faded-data-driven",o=a.value.isDataDriven(),s=a.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let l=this._transitionablePaint._values[e].value;return l.isDataDriven()||o||n||this._handleOverridablePaintPropertyUpdate(e,s,l)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e=this.minzoom,t=!1){return this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&e>=this.maxzoom?!0:this._evaluatedVisibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}retainPriorGlobalState(e,t){var i;(i=this._transitionablePaint)==null||i.retainPriorGlobalState(e,t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){var t,i;let e={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:(t=this._unevaluatedLayout)==null?void 0:t.serialize(),paint:(i=this._transitionablePaint)==null?void 0:i.serialize()};return this.visibility&&(e.layout||(e.layout={}),e.layout.visibility=this.visibility),$_(e,(r,a)=>r!==void 0&&!(a==="layout"&&!Object.keys(r).length)&&!(a==="paint"&&!Object.keys(r).length))}_validate(e,t,i,r,a={}){return Mo(this,e,{key:t,layerType:this.type,objectKey:i,value:r},a)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let t=this.paint.get(e);if(t instanceof mi&&Ja(t.property.specification)&&(t.value.kind==="source"||t.value.kind==="composite")&&t.value.isStateDependent)return!0}return!1}};let Yf;const pT=()=>Yf||(Yf=new St({"raster-opacity":new U(z.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new U(z.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new U(z.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new U(z.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new U(z.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new U(z.paint_raster["raster-contrast"],"raster-contrast"),resampling:new U(z.paint_raster.resampling,"resampling"),"raster-resampling":new U(z.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new U(z.paint_raster["raster-fade-duration"],"raster-fade-duration")}));var fT={get paint(){return pT()}};const tc=e=>e.type==="raster";var mT=class extends Ri{constructor(e,t){super(e,fT,t)}};const gT={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var Io=class{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},et=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(this.capacity*5),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function Qe(e,t=1){let i=0,r=0;return{members:e.map(a=>{let n=_T(a.type),o=i=Kf(i,Math.max(t,n)),s=a.components||1;return r=Math.max(r,n),i+=n*s,{name:a.name,type:a.type,components:s,offset:o}}),size:Kf(i,Math.max(r,t)),alignment:t}}function _T(e){return gT[e].BYTES_PER_ELEMENT}function Kf(e,t){return Math.ceil(e/t)*t}var po=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=e*2;return this.int16[r+0]=t,this.int16[r+1]=i,e}};po.prototype.bytesPerElement=4,G("StructArrayLayout2i4",po);var hl=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*3;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,e}};hl.prototype.bytesPerElement=6,G("StructArrayLayout3i6",hl);var ic=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r)}emplace(e,t,i,r,a){let n=e*4;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=a,e}};ic.prototype.bytesPerElement=8,G("StructArrayLayout4i8",ic);var rc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=e*6;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=a,this.int16[s+4]=n,this.int16[s+5]=o,e}};rc.prototype.bytesPerElement=12,G("StructArrayLayout2i4i12",rc);var ac=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.int8=new Int8Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,a,n,o,s)}emplace(e,t,i,r,a,n,o,s,l){let u=e*5,h=e*10;return this.int16[u+0]=t,this.int16[u+1]=i,this.uint8[h+4]=r,this.uint8[h+5]=a,this.uint8[h+6]=n,this.uint8[h+7]=o,this.int8[h+8]=s,this.int8[h+9]=l,e}};ac.prototype.bytesPerElement=10,G("StructArrayLayout2i4ub2b10",ac);var fo=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=e*2;return this.float32[r+0]=t,this.float32[r+1]=i,e}};fo.prototype.bytesPerElement=8,G("StructArrayLayout2f8",fo);var nc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u){let h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,a,n,o,s,l,u)}emplace(e,t,i,r,a,n,o,s,l,u,h){let c=e*10;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=a,this.uint16[c+4]=n,this.uint16[c+5]=o,this.uint16[c+6]=s,this.uint16[c+7]=l,this.uint16[c+8]=u,this.uint16[c+9]=h,e}};nc.prototype.bytesPerElement=20,G("StructArrayLayout10ui20",nc);var oc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,a,n,o,s)}emplace(e,t,i,r,a,n,o,s,l){let u=e*8;return this.uint16[u+0]=t,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=a,this.uint16[u+4]=n,this.uint16[u+5]=o,this.uint16[u+6]=s,this.uint16[u+7]=l,e}};oc.prototype.bytesPerElement=16,G("StructArrayLayout8ui16",oc);var sc=class extends et{_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(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,a,n,o,s,l,u,h,c,d)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=e*14,m=e*7;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=a,this.uint16[f+4]=n,this.uint16[f+5]=o,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=h,this.int16[f+10]=c,this.int16[f+11]=d,this.float32[m+6]=p,e}};sc.prototype.bytesPerElement=28,G("StructArrayLayout4i4ui4i1f28",sc);var lc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*3;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,e}};lc.prototype.bytesPerElement=12,G("StructArrayLayout3f12",lc);var uc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=e*1;return this.uint32[i+0]=t,e}};uc.prototype.bytesPerElement=4,G("StructArrayLayout1ul4",uc);var hc=class extends et{_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(e,t,i,r,a,n,o,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,a,n,o,s,l)}emplace(e,t,i,r,a,n,o,s,l,u){let h=e*10,c=e*5;return this.int16[h+0]=t,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=a,this.int16[h+4]=n,this.int16[h+5]=o,this.uint32[c+3]=s,this.uint16[h+8]=l,this.uint16[h+9]=u,e}};hc.prototype.bytesPerElement=20,G("StructArrayLayout6i1ul2ui20",hc);var cc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=e*6;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=a,this.int16[s+4]=n,this.int16[s+5]=o,e}};cc.prototype.bytesPerElement=12,G("StructArrayLayout2i2i2i12",cc);var dc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r,a)}emplace(e,t,i,r,a,n){let o=e*4,s=e*8;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[s+6]=a,this.int16[s+7]=n,e}};dc.prototype.bytesPerElement=16,G("StructArrayLayout2f1f2i16",dc);var pc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=e*16,l=e*4,u=e*8;return this.uint8[s+0]=t,this.uint8[s+1]=i,this.float32[l+1]=r,this.float32[l+2]=a,this.int16[u+6]=n,this.int16[u+7]=o,e}};pc.prototype.bytesPerElement=16,G("StructArrayLayout2ub2f2i16",pc);var cl=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*3;return this.uint16[a+0]=t,this.uint16[a+1]=i,this.uint16[a+2]=r,e}};cl.prototype.bytesPerElement=6,G("StructArrayLayout3ui6",cl);var fc=class extends et{_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(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_){let y=this.length;return this.resize(y+1),this.emplace(y,e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y){let v=e*26,x=e*13,b=e*52;return this.int16[v+0]=t,this.int16[v+1]=i,this.uint16[v+2]=r,this.uint16[v+3]=a,this.uint32[x+2]=n,this.uint32[x+3]=o,this.uint32[x+4]=s,this.uint16[v+10]=l,this.uint16[v+11]=u,this.uint16[v+12]=h,this.float32[x+7]=c,this.float32[x+8]=d,this.uint8[b+36]=p,this.uint8[b+37]=f,this.uint8[b+38]=m,this.uint32[x+10]=g,this.int16[v+22]=_,this.float32[x+12]=y,e}};fc.prototype.bytesPerElement=52,G("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",fc);var mc=class extends et{_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(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b,w,T,S,C,F,A,L){let I=this.length;return this.resize(I+1),this.emplace(I,e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b,w,T,S,C,F,A,L)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b,w,T,S,C,F,A,L,I){let E=e*34,D=e*17;return this.int16[E+0]=t,this.int16[E+1]=i,this.int16[E+2]=r,this.int16[E+3]=a,this.int16[E+4]=n,this.int16[E+5]=o,this.int16[E+6]=s,this.int16[E+7]=l,this.uint16[E+8]=u,this.uint16[E+9]=h,this.uint16[E+10]=c,this.uint16[E+11]=d,this.uint16[E+12]=p,this.uint16[E+13]=f,this.uint16[E+14]=m,this.uint16[E+15]=g,this.uint16[E+16]=_,this.uint16[E+17]=y,this.uint16[E+18]=v,this.uint16[E+19]=x,this.uint16[E+20]=b,this.uint16[E+21]=w,this.uint16[E+22]=T,this.uint32[D+12]=S,this.float32[D+13]=C,this.float32[D+14]=F,this.uint16[E+30]=A,this.uint16[E+31]=L,this.float32[D+16]=I,e}};mc.prototype.bytesPerElement=68,G("StructArrayLayout8i15ui1ul2f2ui1f68",mc);var dl=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=e*1;return this.float32[i+0]=t,e}};dl.prototype.bytesPerElement=4,G("StructArrayLayout1f4",dl);var gc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*6,n=e*3;return this.uint16[a+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}};gc.prototype.bytesPerElement=12,G("StructArrayLayout1ui2f12",gc);var _c=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=e*2,n=e*4;return this.uint32[a+0]=t,this.uint16[n+2]=i,this.uint16[n+3]=r,e}};_c.prototype.bytesPerElement=8,G("StructArrayLayout1ul2ui8",_c);var yc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=e*2;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}};yc.prototype.bytesPerElement=4,G("StructArrayLayout2ui4",yc);var vc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=e*1;return this.uint16[i+0]=t,e}};vc.prototype.bytesPerElement=2,G("StructArrayLayout1ui2",vc);var xc=class extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r)}emplace(e,t,i,r,a){let n=e*4;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=a,e}};xc.prototype.bytesPerElement=16,G("StructArrayLayout4f16",xc);var D0=class extends Io{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 M(this.anchorPointX,this.anchorPointY)}};D0.prototype.size=20;var S0=class extends hc{get(e){return new D0(this,e)}};G("CollisionBoxArray",S0);var E0=class extends Io{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(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}get heightOffset(){return this._structArray.float32[this._pos4+12]}};E0.prototype.size=52;var C0=class extends fc{get(e){return new E0(this,e)}};G("PlacedSymbolArray",C0);var P0=class extends Io{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(e){this._structArray.uint32[this._pos4+12]=e}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]}};P0.prototype.size=68;var A0=class extends mc{get(e){return new P0(this,e)}};G("SymbolInstanceArray",A0);var M0=class extends dl{getoffsetX(e){return this.float32[e*1+0]}};G("GlyphOffsetArray",M0);var I0=class extends hl{getx(e){return this.int16[e*3+0]}gety(e){return this.int16[e*3+1]}gettileUnitDistanceFromAnchor(e){return this.int16[e*3+2]}};G("SymbolLineVertexArray",I0);var F0=class extends Io{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]}};F0.prototype.size=12;var z0=class extends gc{get(e){return new F0(this,e)}};G("TextAnchorOffsetArray",z0);var k0=class extends Io{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]}};k0.prototype.size=8;var R0=class extends _c{get(e){return new k0(this,e)}};G("FeatureIndexArray",R0);var qr=class extends po{},yT=class extends hl{},vT=class extends ic{},xT=class extends po{},bT=class extends po{},wT=class extends rc{},TT=class extends ac{},DT=class extends fo{},Da=class extends nc{},Jf=class extends oc{},ST=class extends sc{},ET=class extends lc{},CT=class extends uc{},Qf=class extends cc{},PT=class extends dc{},AT=class extends pc{},MT=class extends cl{},Ki=class extends cl{},bc=class extends yc{},IT=class extends vc{};const FT=Qe([{name:"a_pos",components:2,type:"Int16"}],4),zT=FT.members;var Ke=class Fa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,i,r,a){let n=this.segments[this.segments.length-1];return t>Fa.MAX_VERTEX_ARRAY_LENGTH&&_e(`Max vertices per segment is ${Fa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Fa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>Fa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==a?this.createNewSegment(i,r,a):n}createNewSegment(t,i,r){let a={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return r!==void 0&&(a.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(a),a}getOrCreateLatestSegment(t,i,r){return this.prepareSegment(0,t,i,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let t of this.segments)for(let i in t.vaos)t.vaos[i].destroy()}static simpleSegment(t,i,r,a){return new Fa([{vertexOffset:t,primitiveOffset:i,vertexLength:r,primitiveLength:a,vaos:{},sortKey:0}])}};Ke.MAX_VERTEX_ARRAY_LENGTH=2**16-1,G("SegmentVector",Ke);function em(e,t){return e=Y(Math.floor(e),0,255),t=Y(Math.floor(t),0,255),256*e+t}const kT=Qe([{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"}]),RT=Qe([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var LT=hd(((e,t)=>{function i(r,a){for(var n=r.length&3,o=r.length-n,s=a,l,u=3432918353,h=461845907,c,d=0;d<o;)c=r.charCodeAt(d)&255|(r.charCodeAt(++d)&255)<<8|(r.charCodeAt(++d)&255)<<16|(r.charCodeAt(++d)&255)<<24,++d,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)|0,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)|0,s^=c,s=s<<13|s>>>19,l=(s&65535)*5+(((s>>>16)*5&65535)<<16)|0,s=(l&65535)+27492+(((l>>>16)+58964&65535)<<16);switch(c=0,n){case 3:c^=(r.charCodeAt(d+2)&255)<<16;case 2:c^=(r.charCodeAt(d+1)&255)<<8;case 1:c^=r.charCodeAt(d)&255,c=(c&65535)*u+(((c>>>16)*u&65535)<<16)|0,c=c<<15|c>>>17,c=(c&65535)*h+(((c>>>16)*h&65535)<<16)|0,s^=c}return s^=r.length,s^=s>>>16,s=(s&65535)*2246822507+(((s>>>16)*2246822507&65535)<<16)|0,s^=s>>>13,s=(s&65535)*3266489909+(((s>>>16)*3266489909&65535)<<16)|0,s^=s>>>16,s>>>0}t!==void 0&&(t.exports=i)})),BT=hd(((e,t)=>{function i(r,a){for(var n=r.length,o=a^n,s=0,l;n>=4;)l=r.charCodeAt(s)&255|(r.charCodeAt(++s)&255)<<8|(r.charCodeAt(++s)&255)<<16|(r.charCodeAt(++s)&255)<<24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),l^=l>>>24,l=(l&65535)*1540483477+(((l>>>16)*1540483477&65535)<<16),o=(o&65535)*1540483477+(((o>>>16)*1540483477&65535)<<16)^l,n-=4,++s;switch(n){case 3:o^=(r.charCodeAt(s+2)&255)<<16;case 2:o^=(r.charCodeAt(s+1)&255)<<8;case 1:o^=r.charCodeAt(s)&255,o=(o&65535)*1540483477+(((o>>>16)*1540483477&65535)<<16)}return o^=o>>>13,o=(o&65535)*1540483477+(((o>>>16)*1540483477&65535)<<16),o^=o>>>15,o>>>0}t.exports=i})),pl=Wx(hd(((e,t)=>{var i=LT(),r=BT();t.exports=i,t.exports.murmur3=i,t.exports.murmur2=r}))()),L0=class B0{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,i,r,a){this.ids.push(tm(t)),this.positions.push(i,r,a)}getPositions(t){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let i=tm(t),r=0,a=this.ids.length-1;for(;r<a;){let o=r+a>>1;this.ids[o]>=i?a=o:r=o+1}let n=[];for(;this.ids[r]===i;){let o=this.positions[3*r],s=this.positions[3*r+1],l=this.positions[3*r+2];n.push({index:o,start:s,end:l}),r++}return n}static serialize(t,i){let r=new Float64Array(t.ids),a=new Uint32Array(t.positions);return wc(r,a,0,r.length-1),i&&i.push(r.buffer,a.buffer),{ids:r,positions:a}}static deserialize(t){let i=new B0;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}};function tm(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,pl.default)(String(e))}function wc(e,t,i,r){for(;i<r;){let a=e[i+r>>1],n=i-1,o=r+1;for(;;){do n++;while(e[n]<a);do o--;while(e[o]>a);if(n>=o)break;fs(e,n,o),fs(t,3*n,3*o),fs(t,3*n+1,3*o+1),fs(t,3*n+2,3*o+2)}o-i<r-o?(wc(e,t,i,o),i=o+1):(wc(e,t,o+1,r),r=o)}}function fs(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}G("FeaturePositionMap",L0);var gr=class{constructor(e,t){this.gl=e.gl,this.location=t}},J=class extends gr{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},$=class extends gr{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}},ce=class extends gr{constructor(e,t){super(e,t),this.current=[0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1])&&(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},Vt=class extends gr{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1]||e[2]!==this.current[2])&&(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},tn=class extends gr{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1]||e[2]!==this.current[2]||e[3]!==this.current[3])&&(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}},kr=class extends gr{constructor(e,t){super(e,t),this.current=se.transparent}set(e){(e.r!==this.current.r||e.g!==this.current.g||e.b!==this.current.b||e.a!==this.current.a)&&(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}},im=class extends gr{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e.length*4);for(let i=0;i<e.length;i++)t[4*i]=e[i].r,t[4*i+1]=e[i].g,t[4*i+2]=e[i].b,t[4*i+3]=e[i].a;this.gl.uniform4fv(this.location,t)}}},rm=class extends gr{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}};const OT=new Float32Array(16);var zi=class extends gr{constructor(e,t){super(e,t),this.current=OT}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);else for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}};function Tc(e){return[em(255*e.r,255*e.g),em(255*e.b,255*e.a)]}var Un=class{constructor(e,t,i){this.value=e,this.uniformNames=t.map(r=>`u_${r}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return this.type==="color"?new kr(e,t):new $(e,t)}},Ur=class{constructor(e,t){this.uniformNames=t.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,r){let a=null;r==="u_pattern_to"?a=this.patternTo:r==="u_pattern_from"?a=this.patternFrom:r==="u_dasharray_to"?a=this.dashTo:r==="u_dasharray_from"?a=this.dashFrom:r==="u_pixel_ratio_to"?a=this.pixelRatioTo:r==="u_pixel_ratio_from"&&(a=this.pixelRatioFrom),a!==null&&e.set(a)}getBinding(e,t,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new tn(e,t):new $(e,t)}},ir=class{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(a=>({name:`a_${a}`,type:"Float32",components:i==="color"?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i){let r=this.paintVertexArray.length,a=this.expression.evaluate(new Ie(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,a)}updatePaintArray(e,t,i,r,a){let n=this.expression.evaluate(new Ie(0,a),i,r);this._setPaintValue(e,t,n)}_setPaintValue(e,t,i){if(this.type==="color"){let r=Tc(i);for(let a=e;a<t;a++)this.paintVertexArray.emplace(a,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){var t,i;(t=this.paintVertexArray)!=null&&t.arrayBuffer.byteLength&&((i=this.paintVertexBuffer)!=null&&i.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},wi=class{constructor(e,t,i,r,a,n){this.expression=e,this.uniformNames=t.map(o=>`u_${o}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=a,this.maxValue=0,this.paintVertexAttributes=t.map(o=>({name:`a_${o}`,type:"Float32",components:i==="color"?4:2,offset:0})),this.paintVertexArray=new n}populatePaintArray(e,t,i){let r=this.expression.evaluate(new Ie(this.zoom,i),t,{},i.canonical,[],i.formattedSection),a=this.expression.evaluate(new Ie(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),n=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(n,e,r,a)}updatePaintArray(e,t,i,r,a){let n=this.expression.evaluate(new Ie(this.zoom,a),i,r),o=this.expression.evaluate(new Ie(this.zoom+1,a),i,r);this._setPaintValue(e,t,n,o)}_setPaintValue(e,t,i,r){if(this.type==="color"){let a=Tc(i),n=Tc(r);for(let o=e;o<t;o++)this.paintVertexArray.emplace(o,a[0],a[1],n[0],n[1])}else{for(let a=e;a<t;a++)this.paintVertexArray.emplace(a,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){var t,i;(t=this.paintVertexArray)!=null&&t.arrayBuffer.byteLength&&((i=this.paintVertexBuffer)!=null&&i.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){let i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=Y(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new $(e,t)}},br=class{constructor(e,t,i,r,a,n){this.expression=e,this.type=t,this.useIntegerZoom=i,this.zoom=r,this.layerId=n,this.zoomInPaintVertexArray=new a,this.zoomOutPaintVertexArray=new a}populatePaintArray(e,t,i){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,this.getPositionIds(t),i)}updatePaintArray(e,t,i,r,a){this._setPaintValues(e,t,this.getPositionIds(i),a)}_setPaintValues(e,t,i,r){let a=this.getPositions(r);if(!a||!i)return;let n=a[i.min],o=a[i.mid],s=a[i.max];if(n&&o&&s)for(let l=e;l<t;l++)this.emplace(this.zoomInPaintVertexArray,l,n,o),this.emplace(this.zoomOutPaintVertexArray,l,s,o)}upload(e){var t,i;if((t=this.zoomInPaintVertexArray)!=null&&t.arrayBuffer.byteLength&&((i=this.zoomOutPaintVertexArray)!=null&&i.arrayBuffer.byteLength)){let r=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,r,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,r,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}},O0=class extends br{getPositions(e){return e.imagePositions}getPositionIds(e){var t;return(t=e.patterns)==null?void 0:t[this.layerId]}getVertexAttributes(){return kT.members}emplace(e,t,i,r){e.emplace(t,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.pixelRatio,r.pixelRatio)}},j0=class extends br{getPositions(e){return e.dashPositions}getPositionIds(e){var t;return(t=e.dashes)==null?void 0:t[this.layerId]}getVertexAttributes(){return RT.members}emplace(e,t,i,r){e.emplace(t,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},V0=class{constructor(e,t,i){this.binders={},this._buffers=[];let r=[];for(let a in e.paint._values){if(!i(a))continue;let n=e.paint.get(a);if(!(n instanceof mi)||!Ja(n.property.specification))continue;let o=jT(a,e.type),s=n.value,l=n.property.specification.type,u=n.property.useIntegerZoom,h=n.property.specification["property-type"],c=h==="cross-faded"||h==="cross-faded-data-driven";if(s.kind==="constant")this.binders[a]=c?new Ur(s.value,o):new Un(s.value,o,l),r.push(`/u_${a}`);else if(s.kind==="source"||c){let d=am(a,l,"source");this.binders[a]=c?a==="line-dasharray"?new j0(s,l,u,t,d,e.id):new O0(s,l,u,t,d,e.id):new ir(s,o,l,d),r.push(`/a_${a}`)}else{let d=am(a,l,"composite");this.binders[a]=new wi(s,o,l,u,t,d),r.push(`/z_${a}`)}}this.cacheKey=r.sort().join("")}getMaxValue(e){let t=this.binders[e];return t instanceof ir||t instanceof wi?t.maxValue:0}populatePaintArrays(e,t,i){for(let r in this.binders){let a=this.binders[r];(a instanceof ir||a instanceof wi||a instanceof br)&&a.populatePaintArray(e,t,i)}}setConstantPatternPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof Ur&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof Ur&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,i,r,a){let n=!1;for(let o of e){let s=t.getPositions(o.id);for(let l of s){let u=i.feature(l.index);for(let h in this.binders){let c=this.binders[h];(c instanceof ir||c instanceof wi||c instanceof br)&&c.expression.isStateDependent===!0&&(c.expression=r.paint.get(h).value,c.updatePaintArray(l.start,l.end,u,o.state,a),n=!0)}}}return n}defines(){let e=[];for(let t in this.binders){let i=this.binders[t];(i instanceof Un||i instanceof Ur)&&e.push(...i.uniformNames.map(r=>`#define HAS_UNIFORM_${r}`))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let i=this.binders[t];if(i instanceof ir||i instanceof wi)for(let r of i.paintVertexAttributes)e.push(r.name);else if(i instanceof br){let r=i.getVertexAttributes();for(let a of r)e.push(a.name)}}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let i=this.binders[t];if(i instanceof Un||i instanceof Ur||i instanceof wi)for(let r of i.uniformNames)e.push(r)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let i=[];for(let r in this.binders){let a=this.binders[r];if(a instanceof Un||a instanceof Ur||a instanceof wi){for(let n of a.uniformNames)if(t[n]){let o=a.getBinding(e,t[n],n);i.push({name:n,property:r,binding:o})}}}return i}setUniforms(e,t,i,r){for(let{name:a,property:n,binding:o}of t)this.binders[n].setUniform(o,r,i.get(n),a)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let i=this.binders[t];if(e&&i instanceof br){let r=e.fromScale===2?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;r&&this._buffers.push(r)}else(i instanceof ir||i instanceof wi)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(let t in this.binders){let i=this.binders[t];(i instanceof ir||i instanceof wi||i instanceof br)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof ir||t instanceof wi||t instanceof br)&&t.destroy()}}},ra=class{constructor(e,t,i=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new V0(r,t,i);this.needsUpload=!1,this._featureMap=new L0,this._bufferOffset=0}populatePaintArrays(e,t,i,r){for(let a in this.programConfigurations)this.programConfigurations[a].populatePaintArrays(e,t,r);t.id!==void 0&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r){for(let a of i)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,t,a,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}};function jT(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 VT(e){return{"line-pattern":{source:Da,composite:Da},"fill-pattern":{source:Da,composite:Da},"fill-extrusion-pattern":{source:Da,composite:Da},"line-dasharray":{source:Jf,composite:Jf}}[e]}function am(e,t,i){var a;let r={color:{source:fo,composite:xc},number:{source:dl,composite:fo}};return((a=VT(e))==null?void 0:a[i])||r[t][i]}G("ConstantBinder",Un),G("CrossFadedConstantBinder",Ur),G("SourceExpressionBinder",ir),G("CrossFadedPatternBinder",O0),G("CrossFadedDasharrayBinder",j0),G("CompositeExpressionBinder",wi),G("ProgramConfiguration",V0,{omit:["_buffers"]}),G("ProgramConfigurationSet",ra);const Dc=2**14-1,nm=-Dc-1;function ca(e){let t=O/e.extent,i=e.loadGeometry();for(let r of i)for(let a of r){let n=Math.round(a.x*t),o=Math.round(a.y*t);a.x=Y(n,nm,Dc),a.y=Y(o,nm,Dc),(n<a.x||n>a.x+1||o<a.y||o>a.y+1)&&_e("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function da(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?ca(e):[]}}var Mi=class Sc{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 i=new Sc;return i.extend(t(new M(this.minX,this.minY))),i.extend(t(new M(this.maxX,this.minY))),i.extend(t(new M(this.minX,this.maxY))),i.extend(t(new M(this.maxX,this.maxY))),i}static fromPoints(t){let i=new Sc;for(let r of t)i.extend(r);return i}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}};const NT=Mi.fromPoints([new M(0,0),new M(O,O)]);function fl(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function om(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)}function jd(e){return e.x<0||e.x>=8192||e.y<0||e.y>=8192}const sm=-32768;function UT(e,t,i,r,a){e.emplaceBack(sm+t*8+r,sm+i*8+a)}var Vd=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.layoutVertexArray=new xT,this.indexArray=new Ki,this.segments=new Ke,this.programConfigurations=new ra(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){let r=this.layers[0],a=[],n=null,o=!1,s=r.type==="heatmap";if(r.type==="circle"){let c=r;n=c.layout.get("circle-sort-key"),o=!n.isConstant(),s||(s=c.paint.get("circle-pitch-alignment")==="map")}let l=s?t.subdivisionGranularity.circle:1,u=new Ie(this.zoom),h=this.layers[0]._featureFilter.needGeometry;for(let{feature:c,id:d,index:p,sourceLayerIndex:f}of e){let m=da(c,h);if(!this.layers[0]._featureFilter.filter(u,m,i))continue;let g=o?n.evaluate(m,{},i):void 0,_={id:d,properties:c.properties,type:c.type,sourceLayerIndex:f,index:p,geometry:h?m.geometry:ca(c),patterns:{},sortKey:g};a.push(_)}o&&a.sort((c,d)=>c.sortKey-d.sortKey);for(let c of a){let{geometry:d,index:p,sourceLayerIndex:f}=c,m=e[p].feature;this.addFeature(c,d,p,i,l),t.featureIndex.insert(m,d,p,f,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e){}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,zT),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())}addFeature(e,t,i,r,a=1){let n;switch(a){case 1:n=[0,7];break;case 3:n=[0,2,5,7];break;case 5:n=[0,1,3,4,6,7];break;case 7:n=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${a}; valid values are 1, 3, 5, 7.`)}let o=n.length;for(let s of t)for(let l of s){let u=l.x,h=l.y;if(jd(l))continue;let c=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),d=c.vertexLength;for(let p=0;p<o;p++)for(let f=0;f<o;f++)UT(this.layoutVertexArray,u,h,n[f],n[p]);for(let p=0;p<o-1;p++)for(let f=0;f<o-1;f++){let m=d+p*o+f,g=d+(p+1)*o+f;this.indexArray.emplaceBack(m,g+1,m+1),this.indexArray.emplaceBack(m,g,g+1)}c.vertexLength+=o*o,c.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:{},canonical:r})}};G("CircleBucket",Vd,{omit:["layers"]});function N0(e,t){for(let i of e)if(rn(t,i))return!0;for(let i of t)if(rn(e,i))return!0;return Nd(e,t)}function Ql(e,t,i){return rn(e,t)?!0:Ec(t,e,i)}function U0(e,t){if(e.length===1)return lm(t,e[0]);for(let i of t)for(let r of i)if(rn(e,r))return!0;for(let i of e)if(lm(t,i))return!0;for(let i of t)if(Nd(e,i))return!0;return!1}function $T(e,t,i){for(let r of t){if(e.length>=3){for(let a of r)if(rn(e,a))return!0}if(GT(e,r,i))return!0}return!1}function GT(e,t,i){if(e.length>1){if(Nd(e,t))return!0;for(let r of t)if(Ec(r,e,i))return!0}for(let r of e)if(Ec(r,t,i))return!0;return!1}function Nd(e,t){if(e.length===0||t.length===0)return!1;for(let i=0;i<e.length-1;i++){let r=e[i],a=e[i+1];for(let n=0;n<t.length-1;n++){let o=t[n],s=t[n+1];if(ZT(r,a,o,s))return!0}}return!1}function ZT(e,t,i,r){return Sr(e,i,r)!==Sr(t,i,r)&&Sr(e,t,i)!==Sr(e,t,r)}function Ec(e,t,i){let r=i*i;if(t.length===1)return e.distSqr(t[0])<r;for(let a=1;a<t.length;a++){let n=t[a-1],o=t[a];if($0(e,n,o)<r)return!0}return!1}function $0(e,t,i){let r=t.distSqr(i);if(r===0)return e.distSqr(t);let a=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return a<0?e.distSqr(t):a>1?e.distSqr(i):e.distSqr(i.sub(t)._mult(a)._add(t))}function lm(e,t){let i=!1,r,a,n;for(let o of e){r=o;for(let s=0,l=r.length-1;s<r.length;l=s++)a=r[s],n=r[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&&(i=!i)}return i}function rn(e,t){let i=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){let n=e[r],o=e[a];n.y>t.y!=o.y>t.y&&t.x<(o.x-n.x)*(t.y-n.y)/(o.y-n.y)+n.x&&(i=!i)}return i}function qT(e,t,i,r,a){for(let o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&a>=o.y)return!0;let n=[new M(t,i),new M(t,a),new M(r,a),new M(r,i)];if(e.length>2){for(let o of n)if(rn(e,o))return!0}for(let o=0;o<e.length-1;o++){let s=e[o],l=e[o+1];if(WT(s,l,n))return!0}return!1}function WT(e,t,i){let r=i[0],a=i[2];if(e.x<r.x&&t.x<r.x||e.x>a.x&&t.x>a.x||e.y<r.y&&t.y<r.y||e.y>a.y&&t.y>a.y)return!1;let n=Sr(e,t,i[0]);return n!==Sr(e,t,i[1])||n!==Sr(e,t,i[2])||n!==Sr(e,t,i[3])}function Va(e,t,i){let r=t.paint.get(e).value;return r.kind==="constant"?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function eu(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function tu(e,t,i,r,a){if(!t[0]&&!t[1])return e;let n=M.convert(t)._mult(a);i==="viewport"&&n._rotate(-r);let o=[];for(let s of e)o.push(s.sub(n));return o}function HT(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],a=t.at(-1);(i===0||a&&!r.equals(a))&&t.push(r)}return t}function XT(e,t){let i=[];for(let r of e){let a=HT(r),n=[];for(let o=0;o<a.length;o++){let s=a[o],l=a[o-1],u=a[o+1],h=o===0?new M(0,0):s.sub(l)._unit()._perp(),c=o===a.length-1?new M(0,0):u.sub(s)._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(s))}i.push(n)}return i}function YT({queryGeometry:e,size:t},i){return Ql(e,i,t)}function KT({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Ql(e,n,t*(i.projectTileCoordinates(n.x,n.y,r,a==null?void 0:a(n.x,n.y)).signedDistanceFromCamera/i.cameraToCenterDistance))}function JT({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){let o=i.projectTileCoordinates(n.x,n.y,r,a==null?void 0:a(n.x,n.y)).signedDistanceFromCamera,s=t*(i.cameraToCenterDistance/o);return Ql(e,Ud(n,i,r,a),s)}function QT({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Ql(e,Ud(n,i,r,a),t)}function G0({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a,pitchAlignment:n="map",pitchScale:o="map"},s){let l=n==="map"?o==="map"?YT:KT:o==="map"?JT:QT,u={queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a};for(let h of s)for(let c of h)if(l(u,c))return!0;return!1}function Ud(e,t,i,r){let a=t.projectTileCoordinates(e.x,e.y,i,r==null?void 0:r(e.x,e.y)).point;return new M((a.x*.5+.5)*t.width,(-a.y*.5+.5)*t.height)}function eD(e,t,i,r){return e.map(a=>Ud(a,t,i,r))}let um;const tD=()=>um||(um=new St({"circle-sort-key":new Q(z.layout_circle["circle-sort-key"],"circle-sort-key")}));let hm;const iD=()=>hm||(hm=new St({"circle-radius":new Q(z.paint_circle["circle-radius"],"circle-radius"),"circle-color":new Q(z.paint_circle["circle-color"],"circle-color"),"circle-blur":new Q(z.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new Q(z.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new U(z.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new U(z.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new U(z.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new U(z.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new Q(z.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new Q(z.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new Q(z.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")}));var rD={get paint(){return iD()},get layout(){return tD()}};const aD=e=>e.type==="circle";var nD=class extends Ri{constructor(e,t){super(e,rD,t)}createBucket(e){return new Vd(e)}queryRadius(e){let t=e;return Va("circle-radius",this,t)+Va("circle-stroke-width",this,t)+eu(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:s}){let l=tu(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-a.bearingInRadians,n),u=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i),h=this.paint.get("circle-pitch-scale"),c=this.paint.get("circle-pitch-alignment"),d,p;return c==="map"?(d=l,p=u*n):(d=eD(l,a,o,s),p=u),G0({queryGeometry:d,size:p,transform:a,unwrappedTileID:o,getElevation:s,pitchAlignment:c,pitchScale:h},r)}},Z0=class extends Vd{};G("HeatmapBucket",Z0,{omit:["layers"]});let cm;const oD=()=>cm||(cm=new St({"heatmap-radius":new Q(z.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new Q(z.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new U(z.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new Jl(z.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new U(z.paint_heatmap["heatmap-opacity"],"heatmap-opacity")}));var sD={get paint(){return oD()}};function $d(e,{width:t,height:i},r,a){if(!a)a=new Uint8Array(t*i*r);else if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==t*i*r)throw RangeError(`mismatched image size. expected: ${a.length} but got: ${t*i*r}`);return e.width=t,e.height=i,e.data=a,e}function q0(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;let a=$d({},{width:t,height:i},r);Gd(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},r),e.width=t,e.height=i,e.data=a.data}function Gd(e,t,i,r,a,n){if(a.width===0||a.height===0)return t;if(a.width>e.width||a.height>e.height||i.x>e.width-a.width||i.y>e.height-a.height)throw RangeError("out of range source coordinates for image copy");if(a.width>t.width||a.height>t.height||r.x>t.width-a.width||r.y>t.height-a.height)throw RangeError("out of range destination coordinates for image copy");let o=e.data,s=t.data;if(o===s)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<a.height;l++){let u=((i.y+l)*e.width+i.x)*n,h=((r.y+l)*t.width+r.x)*n;for(let c=0;c<a.width*n;c++)s[h+c]=o[u+c]}return t}var Zd=class W0{constructor(t,i){$d(this,t,1,i)}resize(t){q0(this,t,1)}clone(){return new W0({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,r,a,n){Gd(t,i,r,a,n,1)}},Ne=class H0{constructor(t,i){$d(this,t,4,i)}resize(t){q0(this,t,4)}replace(t,i){i?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new H0({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,r,a,n){Gd(t,i,r,a,n,4)}setPixel(t,i,r){let a=(t*this.width+i)*4;this.data[a+0]=Math.round(r.r*255/r.a),this.data[a+1]=Math.round(r.g*255/r.a),this.data[a+2]=Math.round(r.b*255/r.a),this.data[a+3]=Math.round(r.a*255)}};function th(e){let t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=4){let r=e[i+3];t[i+0]=Math.round(e[i+0]*r/255),t[i+1]=Math.round(e[i+1]*r/255),t[i+2]=Math.round(e[i+2]*r/255),t[i+3]=r}return t}G("AlphaImage",Zd),G("RGBAImage",Ne);function X0(e){let t={},i=e.resolution||256,r=e.clips?e.clips.length:1,a=e.image||new Ne({width:i,height:r});if(!Ib(i))throw Error(`width is not a power of 2 - ${i}`);let n=(o,s,l)=>{t[e.evaluationKey]=l;let u=e.expression.evaluate(t);a.setPixel(o/4/i,s/4,u)};if(e.clips)for(let o=0,s=0;o<r;++o,s+=i*4)for(let l=0,u=0;l<i;l++,u+=4){let h=l/(i-1),{start:c,end:d}=e.clips[o],p=c*(1-h)+d*h;n(s,u,p)}else for(let o=0,s=0;o<i;o++,s+=4){let l=o/(i-1);n(0,s,l)}return a}const ml="big-fb",lD=e=>e.type==="heatmap";var uD=class extends Ri{createBucket(e){return new Z0(e)}constructor(e,t){super(e,sD,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){let e=this._transitionablePaint._values["heatmap-color"].value.expression;this.colorRamp=X0({expression:e,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(ml)}queryRadius(e){return Va("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:s}){return G0({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(t,i)*n,transform:a,unwrappedTileID:o,getElevation:s},r)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}};let dm;const hD=()=>dm||(dm=new St({"hillshade-illumination-direction":new U(z.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new U(z.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new U(z.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new U(z.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new U(z.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new U(z.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new U(z.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new U(z.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new U(z.paint_hillshade.resampling,"resampling")}));var cD={get paint(){return hD()}};const dD=e=>e.type==="hillshade";var pD=class extends Ri{constructor(e,t){super(e,cD,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,t=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,r=this.paint.get("hillshade-shadow-color").values,a=Math.max(e.length,t.length,i.length,r.length);e=e.concat(Array(a-e.length).fill(e.at(-1))),t=t.concat(Array(a-t.length).fill(t.at(-1))),i=i.concat(Array(a-i.length).fill(i.at(-1))),r=r.concat(Array(a-r.length).fill(r.at(-1)));let n=t.map(Ve);return{directionRadians:e.map(Ve),altitudeRadians:n,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}};let pm;const fD=()=>pm||(pm=new St({"color-relief-opacity":new U(z["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new Jl(z["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new U(z["paint_color-relief"].resampling,"resampling")}));var mD={get paint(){return fD()}};function ms(e){return"data"in e}var ft=class{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,i){var u;let{width:r,height:a}=e,n=(((u=this.size)==null?void 0:u[0])!==r||this.size[1]!==a)&&!i,{context:o}=this,{gl:s}=o;this.useMipmap=!!(t!=null&&t.useMipmap),n&&this.size&&this.format===s.RGBA&&(s.deleteTexture(this.texture),this.texture=s.createTexture(),this._ownedHandle=this.texture,this.magFilter=void 0,this.minFilter=void 0,this.wrap=void 0),s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let l=this.format===s.RGBA&&(t==null?void 0:t.premultiply)!==!1;if(n)if(this.size=[r,a],this.format===s.RGBA&&r>0&&a>0){let h=this.useMipmap?Math.floor(Math.log2(Math.max(r,a)))+1:1;if(s.texStorage2D(s.TEXTURE_2D,h,s.RGBA8,r,a),ms(e)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:c}=e;l&&c&&(c=th(c)),c&&s.texSubImage2D(s.TEXTURE_2D,0,0,0,r,a,s.RGBA,s.UNSIGNED_BYTE,c)}else o.pixelStoreUnpackPremultiplyAlpha.set(l),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,e)}else ms(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,l,r,a,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(e,s));else{let{x:h,y:c}=i||{x:0,y:0};ms(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,l,h,c,r,a,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(e,h,c,s))}this.useMipmap&&!(ms(e)&&e.data===null)&&s.generateMipmap(s.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,i,r,a){let{data:n}=e;t&&n&&(n=th(n)),a.texImage2D(a.TEXTURE_2D,0,this.format,i,r,0,this.format,a.UNSIGNED_BYTE,n)}_updateDomImage(e,t,i,r){r.texSubImage2D(r.TEXTURE_2D,0,t,i,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,i,r,a,n,o){let{data:s}=e;t&&s&&(s=th(s)),o.texSubImage2D(o.TEXTURE_2D,0,i,r,a,n,o.RGBA,o.UNSIGNED_BYTE,s)}bind(e,t,i){let{context:r}=this,{gl:a}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),a.bindTexture(a.TEXTURE_2D,this.texture),(i===a.LINEAR_MIPMAP_NEAREST||i===a.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(i=a.LINEAR);let n=i||e;e!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),this.magFilter=e),n!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,n),this.minFilter=n),t!==this.wrap&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,t),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,t),this.wrap=t)}generateMipmap(){if(!this.useMipmap)return;let{gl:e}=this.context;e.bindTexture(e.TEXTURE_2D,this.texture),e.generateMipmap(e.TEXTURE_2D)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},hr,gD=(hr=class{constructor(t,i,r,a=1,n=1,o=1,s=0){if(this.uid=t,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r)){_e(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=i.height;let l=this.dim=i.height-4;switch(this.data=new Uint32Array(i.data.buffer),hr.byteViewCache.set(this,new Uint8Array(this.data.buffer)),r){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=o,this.baseShift=s;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,i){let r=this._getByteView(),a=this._idx(t,i)*4;return this._unpackAtIndex(r,a)}sampleBilinear(t,i){let r=Math.floor(t),a=Math.floor(i);if(r<-1||r>=this.dim||a<-1||a>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${i}, dim: ${this.dim}`);let n=this._getByteView(),o=((a+2)*this.stride+r+2)*4,s=this.stride*4,l=t-r,u=i-a,h=this._unpackAtIndex(n,o),c=this._unpackAtIndex(n,o+4),d=this._unpackAtIndex(n,o+s),p=this._unpackAtIndex(n,o+s+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,i){if(t<-2||t>=this.dim+2||i<-2||i>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${i}, dim: ${this.dim}`);return(i+2)*this.stride+(t+2)}unpack(t,i,r){return t*this.redFactor+i*this.greenFactor+r*this.blueFactor-this.baseShift}pack(t){return Y0(t,this.getUnpackVector())}getPixels(){return new Ne({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(t,i,r){if(this.dim!==t.dim)throw Error("dem dimension mismatch");let a=i*this.dim,n=i*this.dim+this.dim,o=r*this.dim,s=r*this.dim+this.dim;switch(i){case-1:a=n-2;break;case 1:n=a+2}switch(r){case-1:o=s-2;break;case 1:s=o+2}let l=-i*this.dim,u=-r*this.dim;for(let h=o;h<s;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=hr.byteViewCache.get(this);return(t==null?void 0:t.buffer)!==this.data.buffer&&(t=new Uint8Array(this.data.buffer),hr.byteViewCache.set(this,t)),t}_unpackAtIndex(t,i){return this.unpack(t[i],t[i+1],t[i+2])}},hr.byteViewCache=new WeakMap,hr);function Y0(e,t){let i=t[0],r=t[1],a=t[2],n=t[3],o=[i,r,a].filter(h=>h!==0);if(o.length===0)return{r:0,g:0,b:0};let s=Math.min(...o),l=Math.round((e+n)/s),u=h=>h===0?0:Math.floor(l*s/h)%256;return{r:u(i),g:u(r),b:u(a)}}G("DEMData",gD);const _D=e=>e.type==="color-relief";var yD=class extends Ri{constructor(e,t){super(e,mD,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof so&&i._styleExpression.expression instanceof yi){this.colorRampExpression=i;let n=i._styleExpression.expression;t.elevationStops=n.labels,t.colorStops=[];for(let o of t.elevationStops)t.colorStops.push(n.evaluate({globals:{elevation:o}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[se.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;let r={elevationStops:[],colorStops:[]},a=(t.elevationStops.length-1)/(e-1);for(let n=0;n<t.elevationStops.length-.5;n+=a)r.elevationStops.push(t.elevationStops[Math.round(n)]),r.colorStops.push(t.colorStops[Math.round(n)]);return _e(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${t.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,t,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(t),a=new Ne({width:r.colorStops.length,height:1}),n=new Ne({width:r.colorStops.length,height:1});for(let o=0;o<r.elevationStops.length;o++){let s=Y0(r.elevationStops[o],i);n.setPixel(0,o,new se(s.r/255,s.g/255,s.b/255,1)),a.setPixel(0,o,r.colorStops[o])}return this.colorRampTextures={elevationTexture:new ft(e,n,e.gl.RGBA),colorTexture:new ft(e,a,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const vD=Qe([{name:"a_pos",components:2,type:"Int16"}],4),xD=vD.members;function gl(e,t,i){let r=i.patternDependencies,a=!1;for(let n of t){let o=n.paint.get(`${e}-pattern`);o.isConstant()||(a=!0);let s=o.constantOr(null);s&&(a=!0,r[s.to]=!0,r[s.from]=!0)}return a}function qd(e,t,i,r,a){let{zoom:n}=r,o=a.patternDependencies;for(let s of t){let l=s.paint.get(`${e}-pattern`).value;if(l.kind!=="constant"){let u=l.evaluate({zoom:n-1},i,{},a.availableImages),h=l.evaluate({zoom:n},i,{},a.availableImages),c=l.evaluate({zoom:n+1},i,{},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,o[u]=!0,o[h]=!0,o[c]=!0,i.patterns[s.id]={min:u,mid:h,max:c}}}return i}const mo=new Set;let Cc=!1;function bD(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length;mo.size&&mo.clear();let n=K0(e,0,a,i,!0),o=[];if(!n||n.next===n.prev)return o;let s=0,l=0,u=0;if(r&&(n=ED(e,t,n,i)),e.length>80*i){s=e[0],l=e[1];let h=s,c=l;for(let d=i;d<a;d+=i){let p=e[d],f=e[d+1];p<s&&(s=p),f<l&&(l=f),p>h&&(h=p),f>c&&(c=f)}u=Math.max(h-s,c-l),u=u===0?0:32767/u}return Pc(n,o,s,l,u),o}function K0(e,t,i,r,a){let n=null;if(a===jD(e,t,i,r)>0)for(let o=t;o<i;o+=r)n=gm(o/r|0,e[o],e[o+1],n);else for(let o=i-r;o>=t;o-=r)n=gm(o/r|0,e[o],e[o+1],n);return n&&go(n,n.next)&&(yo(n),n=n.next),n}function aa(e,t=e){let i=t===e,r=e,a;do a=!1,r!==r.next&&(mo.size===0||!mo.has(r))&&(go(r,r.next)||dt(r.prev,r,r.next)===0)?((i||r===t)&&(t=r.prev),Cc=!0,yo(r),r=r.prev,a=!0):(i||r!==t)&&(r=r.next,a=!i);while(a||r!==t);return t}function Pc(e,t,i,r,a){a&&zD(e,i,r,a);let n=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,l=e.next;if(dt(s,e,l)<0&&(a?TD(e,i,r,a):wD(e)))t.push(s.i,e.i,l.i),yo(e),e=l,n=l;else if(e=l,e===n){if(Cc=!1,e=aa(e),Cc){n=e;continue}if(!o){e=DD(e,t),n=e,o=!0;continue}SD(e,t,i,r,a);break}}}function wD(e){let t=e.prev,i=e,r=e.next,a=t.x,n=i.x,o=r.x,s=t.y,l=i.y,u=r.y,h=Math.min(a,n,o),c=Math.min(s,l,u),d=Math.max(a,n,o),p=Math.max(s,l,u),f=r.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&(a!==f.x||s!==f.y)&&yl(a,s,n,l,o,u,f.x,f.y)&&dt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function TD(e,t,i,r){let a=e.prev,n=e,o=e.next,s=a.x,l=n.x,u=o.x,h=a.y,c=n.y,d=o.y,p=Math.min(s,l,u),f=Math.min(h,c,d),m=Math.max(s,l,u),g=Math.max(h,c,d),_=Fc(p,f,t,i,r),y=Fc(m,g,t,i,r),v=e.prevZ;for(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==o&&(s!==v.x||h!==v.y)&&yl(s,h,l,c,u,d,v.x,v.y)&&dt(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!==o&&(s!==x.x||h!==x.y)&&yl(s,h,l,c,u,d,x.x,x.y)&&dt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function DD(e,t){let i=e,r=!1;do{let a=i.prev,n=i.next.next;Q0(a,i,i.next,n,!1)&&_o(a,n)&&_o(n,a)&&(t.push(a.i,i.i,n.i),yo(i),yo(i.next),i=e=n,r=!0),i=i.next}while(i!==e);return r?aa(i):i}function SD(e,t,i,r,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&LD(n,o)){let s=e1(n,o);n=aa(n,n.next),s=aa(s,s.next),Pc(n,t,i,r,a),Pc(s,t,i,r,a);return}o=o.next}n=n.next}while(n!==e)}let Ac=!1;function ED(e,t,i,r){let a=[];for(let n=0,o=t.length;n<o;n++){let s=K0(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1);s===s.next&&mo.add(s),a.push(RD(s))}a.sort(CD),AD(e.length/r,t.length),J0(i,i),Ac=!0;for(let n=0;n<a.length;n++)i=PD(a[n],i);return Ac=!1,aa(i)}function CD(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 PD(e,t){let i=ID(e,t);if(!i)return t;let r=e1(i,e),a=r.next;return J0(i,a.next),aa(r,r.next),aa(i,i.next)}let it=new Float64Array,_l=0;const Mc=[],Ic=[];function AD(e,t){let i=Math.ceil((e+2*t)/16)+t+2;it.length<i*4&&(it=new Float64Array(i*4)),_l=0}function J0(e,t){let i=e;do{let r=_l++;Mc[r]=i;let a=i.x,n=i.y,o=i.x,s=i.y,l=0;do{let h=i.next;i.z=r,h.x<a&&(a=h.x),h.x>o&&(o=h.x),h.y<n&&(n=h.y),h.y>s&&(s=h.y),i=h}while(++l<16&&i!==t);Ic[r]=i;let u=r*4;it[u]=a,it[u+1]=n,it[u+2]=o,it[u+3]=s}while(i!==t)}function MD(e,t){let i=e.z*4;t.x<it[i]&&(it[i]=t.x),t.y<it[i+1]&&(it[i+1]=t.y),t.x>it[i+2]&&(it[i+2]=t.x),t.y>it[i+3]&&(it[i+3]=t.y)}function fm(e){let t=Ic[e];for(;t.prev.next!==t;)t=t.next;return Ic[e]=t,t}function mm(e){let t=Mc[e];for(;t.prev.next!==t;)t=t.next;return Mc[e]=t,t}function ID(e,t){let i=t,r=e.x,a=e.y,n=-1/0,o;if(go(e,i))return i;for(let d=0,p=0;d<_l;d++,p+=4){if(a<it[p+1]||a>it[p+3]||it[p]>r||it[p+2]<=n)continue;let f=fm(d);i=mm(d);do{if(i.prev.next===i){if(go(e,i.next))return i.next;if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let m=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(m<=r&&m>n&&(n=m,o=i.x<i.next.x?i:i.next,m===r))return o}}i=i.next}while(i!==f)}if(!o)return null;let s=o.x,l=o.y,u=Math.min(a,l),h=Math.max(a,l),c=1/0;for(let d=0,p=0;d<_l;d++,p+=4){if(it[p+2]<s||it[p]>r||it[p+3]<u||it[p+1]>h)continue;let f=fm(d);i=mm(d);do{if(i.prev.next===i&&r>=i.x&&i.x>=s&&r!==i.x&&yl(a<l?r:n,a,s,l,a<l?n:r,a,i.x,i.y)){let m=Math.abs(a-i.y)/(r-i.x);(_o(i,e)||i.y===a&&i.next.y===a&&i.next.x>r)&&(m<c||m===c&&(i.x>o.x||i.x===o.x&&FD(o,i)))&&(o=i,c=m)}i=i.next}while(i!==f)}return o}function FD(e,t){return dt(e.prev,e,t.prev)<0&&dt(t.next,e,e.next)<0}const ei=[];let za=[],Vr=new Uint32Array,En=new Uint32Array;const Cn=new Uint32Array(256);function zD(e,t,i,r){let a=e,n=0;do a.z=Fc(a.x,a.y,t,i,r),ei[n++]=a,a=a.next;while(a!==e);kD(n);let o=null;for(let s=0;s<n;s++){let l=ei[s];l.prevZ=o,o&&(o.nextZ=l),o=l}o.nextZ=null,ei.fill(null,0,n),za.fill(null,0,n)}function kD(e){if(e<=32)for(let t=1;t<e;t++){let i=ei[t],r=i.z,a=t-1;for(;a>=0&&ei[a].z>r;)ei[a+1]=ei[a],a--;ei[a+1]=i}else{Vr.length<e&&(Vr=new Uint32Array(e),En=new Uint32Array(e),za=Array(e));for(let t=0;t<e;t++)Vr[t]=ei[t].z;gs(e,ei,Vr,za,En,0),gs(e,za,En,ei,Vr,8),gs(e,ei,Vr,za,En,16),gs(e,za,En,ei,Vr,24)}}function gs(e,t,i,r,a,n){Cn.fill(0);for(let s=0;s<e;s++)Cn[i[s]>>>n&255]++;let o=0;for(let s=0;s<256;s++){let l=Cn[s];Cn[s]=o,o+=l}for(let s=0;s<e;s++){let l=i[s],u=Cn[l>>>n&255]++;r[u]=t[s],a[u]=l}}function Fc(e,t,i,r,a){return e=(e-i)*a|0,t=(t-r)*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 RD(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function yl(e,t,i,r,a,n,o,s){return(a-o)*(t-s)>=(e-o)*(n-s)&&(e-o)*(r-s)>=(i-o)*(t-s)&&(i-o)*(n-s)>=(a-o)*(r-s)}function LD(e,t){let i=go(e,t)&&dt(e.prev,e,e.next)>0&&dt(t.prev,t,t.next)>0;return e.next.i!==t.i&&(i||_o(e,t)&&_o(t,e)&&(dt(e.prev,e,t.prev)!==0||dt(e,t.prev,t)!==0))&&!BD(e,t)&&(i||OD(e,t))}function dt(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function go(e,t){return e.x===t.x&&e.y===t.y}function Q0(e,t,i,r,a=!0){let n=dt(e,t,i),o=dt(e,t,r),s=dt(i,r,e),l=dt(i,r,t);return(n>0&&o<0||n<0&&o>0)&&(s>0&&l<0||s<0&&l>0)?!0:a?!!(n===0&&_s(e,i,t)||o===0&&_s(e,r,t)||s===0&&_s(i,e,r)||l===0&&_s(i,t,r)):!1}function _s(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function BD(e,t){let i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),a=Math.min(e.y,t.y),n=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.x<i&&s.x<i||o.y>n&&s.y>n||o.y<a&&s.y<a)o=s;else{if(o.i!==e.i&&s.i!==e.i&&o.i!==t.i&&s.i!==t.i&&Q0(o,s,e,t))return!0;o=s}}while(o!==e);return!1}function _o(e,t){return dt(e.prev,e,e.next)<0?dt(e,t,e.next)>=0&&dt(e,e.prev,t)>=0:dt(e,t,e.prev)<0||dt(e,e.next,t)<0}function OD(e,t){let i=e,r=!1,a=(e.x+t.x)/2,n=(e.y+t.y)/2;do{let o=i.next;i.y>n!=o.y>n&&a<(o.x-i.x)*(n-i.y)/(o.y-i.y)+i.x&&(r=!r),i=o}while(i!==e);return r}function e1(e,t){let i=zc(e.i,e.x,e.y),r=zc(t.i,t.x,t.y),a=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function gm(e,t,i,r){let a=zc(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function yo(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&&MD(e.prev,e.next)}function zc(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function jD(e,t,i,r){let a=0;for(let n=t,o=i-r;n<i;n+=r)a+=(e[o]-e[n])*(e[n+1]+e[o+1]),o=n;return a}var ur=class{constructor(e,t){if(t>e)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){let t=1<<e;return Math.max(Math.floor(this._baseZoomGranularity/t),this._minGranularity,1)}},Jr,Wd=(Jr=class{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}},Jr.noSubdivision=new Jr({fill:new ur(0,0),line:new ur(0,0),tile:new ur(0,0),stencil:new ur(0,0),circle:1}),Jr);G("SubdivisionGranularityExpression",ur),G("SubdivisionGranularitySetting",Wd);const Yn=-32768,Kn=32767;var VD=class{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=O/e,this._canonical=t}_getKey(e,t){return e+=32768,t+=32768,e<<16|t}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let i=Math.round(e)|0,r=Math.round(t)|0,a=this._getKey(i,r),n=this._vertexDictionary.get(a);if(n!==void 0)return n;let o=this._vertexBuffer.length/2;return this._vertexDictionary.set(a,o),this._vertexBuffer.push(i,r),o}_subdivideTrianglesScanline(e,t){if(this._granularity<2)return $D(this._vertexBuffer,UD(e,t));let i=[],r=e.length;for(let a=0;a<r;a+=3){let n=[t[e[a+0]],t[e[a+1]],t[e[a+2]]],o=[this._vertexBuffer[n[0]*2+0],this._vertexBuffer[n[0]*2+1],this._vertexBuffer[n[1]*2+0],this._vertexBuffer[n[1]*2+1],this._vertexBuffer[n[2]*2+0],this._vertexBuffer[n[2]*2+1]],s=1/0,l=1/0,u=-1/0,h=-1/0;for(let m=0;m<3;m++){let g=o[m*2],_=o[m*2+1];s=Math.min(s,g),u=Math.max(u,g),l=Math.min(l,_),h=Math.max(h,_)}if(s===u||l===h)continue;let c=Math.floor(s/this._granularityCellSize),d=Math.ceil(u/this._granularityCellSize),p=Math.floor(l/this._granularityCellSize),f=Math.ceil(h/this._granularityCellSize);if(c===d&&p===f)i.push(...n);else for(let m=p;m<f;m++){let g=this._scanlineGenerateVertexRingForCellRow(m,o,n);GD(this._vertexBuffer,g,i)}}return i}_scanlineGenerateVertexRingForCellRow(e,t,i){let r=e*this._granularityCellSize,a=r+this._granularityCellSize,n=[];for(let o=0;o<3;o++){let s=t[o*2],l=t[o*2+1],u=t[(o+1)*2%6],h=t[((o+1)*2+1)%6],c=t[(o+2)*2%6],d=t[((o+2)*2+1)%6],p=u-s,f=h-l,m=p===0,g=f===0,_=(r-l)/f,y=(a-l)/f,v=Math.min(_,y),x=Math.max(_,y);if(!g&&(v>=1||x<=0)||g&&(l<r||l>a)){h>=r&&h<=a&&n.push(i[(o+1)%3]);continue}if(!g&&v>0){let T=s+p*v,S=l+f*v;n.push(this._vertexToIndex(T,S))}let b=s+p*Math.max(v,0),w=s+p*Math.min(x,1);if(m||this._generateIntraEdgeVertices(n,s,l,u,h,b,w),!g&&x<1){let T=s+p*x,S=l+f*x;n.push(this._vertexToIndex(T,S))}(g||h>=r&&h<=a)&&n.push(i[(o+1)%3]),!g&&(h<=r||h>=a)&&this._generateInterEdgeVertices(n,s,l,u,h,c,d,w,r,a)}return n}_generateIntraEdgeVertices(e,t,i,r,a,n,o){let s=r-t,l=a-i,u=l===0,h=u?Math.min(t,r):Math.min(n,o),c=u?Math.max(t,r):Math.max(n,o),d=Math.floor(h/this._granularityCellSize)+1,p=Math.ceil(c/this._granularityCellSize)-1;if(u?t<r:n<o)for(let f=d;f<=p;f++){let m=f*this._granularityCellSize,g=i+l*(m-t)/s;e.push(this._vertexToIndex(m,g))}else for(let f=p;f>=d;f--){let m=f*this._granularityCellSize,g=i+l*(m-t)/s;e.push(this._vertexToIndex(m,g))}}_generateInterEdgeVertices(e,t,i,r,a,n,o,s,l,u){let h=a-i,c=n-r,d=o-a,p=(l-a)/d,f=(u-a)/d,m=Math.min(p,f),g=Math.max(p,f),_=r+c*m,y=Math.floor(Math.min(_,s)/this._granularityCellSize)+1,v=Math.ceil(Math.max(_,s)/this._granularityCellSize)-1,x=s<_,b=d===0;if(b&&(o===l||o===u))return;if(b||m>=1||g<=0){let T=t-n,S=i-o,C=(l-o)/S,F=(u-o)/S,A=n+T*Math.min(C,F);y=Math.floor(Math.min(A,s)/this._granularityCellSize)+1,v=Math.ceil(Math.max(A,s)/this._granularityCellSize)-1,x=s<A}let w=h>0?u:l;if(x)for(let T=y;T<=v;T++){let S=T*this._granularityCellSize;e.push(this._vertexToIndex(S,w))}else for(let T=v;T>=y;T--){let S=T*this._granularityCellSize;e.push(this._vertexToIndex(S,w))}}_generateOutline(e,t){let i=[],r=0;for(let a of e){let n=this._granularity<2?this._ringPathIndices(a,r,t):this._pointArrayToIndices(Wr(a,this._granularity,!0));r+=a.length;let o=[];for(let s=1;s<n.length;s++)o.push(n[s-1]),o.push(n[s]);i.push(o)}return i}_ringPathIndices(e,t,i){let r=i.slice(t,t+e.length);return r.length>=2&&i1(e)&&r.push(r[0]),r}_handlePoles(e){let t=!1,i=!1;this._canonical&&(this._canonical.y===0&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(t||i)&&this._fillPoles(e,t,i)}_ensureNoPoleVertices(){let e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){let i=e[t+1];i===-32768&&(e[t+1]=-32767),i===32767&&(e[t+1]=32766)}}_generatePoleQuad(e,t,i,r,a,n){r>a==(n===-32768)?(e.push(i),e.push(t),e.push(this._vertexToIndex(r,n)),e.push(this._vertexToIndex(a,n)),e.push(i),e.push(this._vertexToIndex(r,n))):(e.push(t),e.push(i),e.push(this._vertexToIndex(r,n)),e.push(i),e.push(this._vertexToIndex(a,n)),e.push(this._vertexToIndex(r,n)))}_fillPoles(e,t,i){let r=this._vertexBuffer,a=O,n=e.length;for(let o=2;o<n;o+=3){let s=e[o-2],l=e[o-1],u=e[o],h=r[s*2],c=r[s*2+1],d=r[l*2],p=r[l*2+1],f=r[u*2],m=r[u*2+1];t&&(c===0&&p===0&&this._generatePoleQuad(e,s,l,h,d,Yn),p===0&&m===0&&this._generatePoleQuad(e,l,u,d,f,Yn),m===0&&c===0&&this._generatePoleQuad(e,u,s,f,h,Yn)),i&&(c===a&&p===a&&this._generatePoleQuad(e,s,l,h,d,Kn),p===a&&m===a&&this._generatePoleQuad(e,l,u,d,f,Kn),m===a&&c===a&&this._generatePoleQuad(e,u,s,f,h,Kn))}}_initializeVertices(e){let t=[];for(let i=0;i<e.length;i+=2)t.push(this._vertexToIndex(e[i],e[i+1]));return t}subdividePolygonInternal(e,t){var s;if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let{flattened:i,holeIndices:r}=ND(e),a=this._initializeVertices(i),n;try{let l=bD(i,r);n=this._subdivideTrianglesScanline(l,a)}catch(l){console.error(l)}let o=[];return t&&(o=this._generateOutline(e,a)),this._ensureNoPoleVertices(),this._handlePoles(n),this._granularity>=2&&((s=this._canonical)==null?void 0:s.z)===0&&(n=this._removeTrianglesOutsideTileX(n),o=o.map(l=>this._removeLinesOutsideTileX(l))),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:o}}_vertexOutsideTileX(e){let t=this._vertexBuffer[e*2];return t<0||t>8192}_removeTrianglesOutsideTileX(e){let t=[];for(let i=0;i<e.length;i+=3)this._vertexOutsideTileX(e[i])||this._vertexOutsideTileX(e[i+1])||this._vertexOutsideTileX(e[i+2])||t.push(e[i],e[i+1],e[i+2]);return t}_removeLinesOutsideTileX(e){let t=[];for(let i=0;i<e.length;i+=2)this._vertexOutsideTileX(e[i])||this._vertexOutsideTileX(e[i+1])||t.push(e[i],e[i+1]);return t}_pointArrayToIndices(e){let t=[];for(let i of e)t.push(this._vertexToIndex(i.x,i.y));return t}};function t1(e,t,i,r=!0){return new VD(i,t).subdividePolygonInternal(e,r)}function Wr(e,t,i=!1){if(!e||e.length<1||e.length<2)return[];let r=i&&i1(e);if(t<2)return r?[...e,e[0]]:[...e];let a=Math.floor(O/t),n=[];n.push(new M(e[0].x,e[0].y));let o=e.length,s=r?o:o-1;for(let l=0;l<s;l++){let u=e[l],h=l<o-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),b=c,w=d;for(;;){let S=_>0?(Math.floor(b/a)+1)*a:(Math.ceil(b/a)-1)*a,C=y>0?(Math.floor(w/a)+1)*a:(Math.ceil(w/a)-1)*a,F=Math.abs(b-S),A=Math.abs(w-C),L=Math.abs(b-p),I=Math.abs(w-f),E=m?F/v:1/0,D=g?A/x:1/0;if((L<=F||!m)&&(I<=A||!g))break;if(E<D&&m||!g){b=S,w+=y*E;let P=new M(b,Math.round(w));(n[n.length-1].x!==P.x||n[n.length-1].y!==P.y)&&n.push(P)}else{b+=_*D,w=C;let P=new M(Math.round(b),w);(n[n.length-1].x!==P.x||n[n.length-1].y!==P.y)&&n.push(P)}}let T=new M(p,f);(n[n.length-1].x!==T.x||n[n.length-1].y!==T.y)&&n.push(T)}return n}function i1(e){return!e[0].equals(e[e.length-1])}function ND(e){let t=[],i=[];for(let r of e)if(r.length!==0){r!==e[0]&&t.push(i.length/2);for(let a of r)i.push(a.x),i.push(a.y)}return{flattened:i,holeIndices:t}}function UD(e,t){let i=Array(e.length);for(let r=0;r<e.length;r++)i[r]=t[e[r]];return i}function $D(e,t){let i=[];for(let r=0;r<t.length;r+=3){let a=t[r],n=t[r+1],o=t[r+2],s=e[a*2],l=e[a*2+1],u=e[n*2],h=e[n*2+1],c=e[o*2],d=e[o*2+1],p=u-s,f=h-l,m=c-s;p*(d-l)-f*m>0?(i.push(a),i.push(o),i.push(n)):(i.push(a),i.push(n),i.push(o))}return i}function GD(e,t,i){if(t.length===0)throw Error("Subdivision vertex ring is empty.");let r=0,a=e[t[0]*2];for(let l=1;l<t.length;l++){let u=e[t[l]*2];u<a&&(a=u,r=l)}let n=t.length,o=r,s=(o+1)%n;for(;;){let l=o-1>=0?o-1:n-1,u=(s+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[o]*2],m=e[t[o]*2+1],g=e[t[s]*2],_=e[t[s]*2+1],y=!1;if(h<d)y=!0;else if(h>d)y=!1;else{let v=_-m,x=-(g-f),b=m<_?1:-1;((h-f)*v+(c-m)*x)*b>((d-f)*v+(p-m)*x)*b&&(y=!0)}if(y){let v=t[l],x=t[o],b=t[s];v!==x&&v!==b&&x!==b&&i.push(b,x,v),o--,o<0&&(o=n-1)}else{let v=t[u],x=t[o],b=t[s];v!==x&&v!==b&&x!==b&&i.push(b,x,v),s++,s>=n&&(s=0)}if(l===u)break}}function r1(e,t,i,r,a,n,o,s,l){let u=a.length/2,h=o&&s&&l;if(u<Ke.MAX_VERTEX_ARRAY_LENGTH){let c=t.prepareSegment(u,i,r),d=c.vertexLength;for(let m=0;m<n.length;m+=3)r.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=o.prepareSegment(u,i,s),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)s.emplaceBack(p+m[g-1],p+m[g]);f.primitiveLength+=m.length/2}}else ZD(t,i,r,a,n,e),h&&qD(o,i,s,a,l,e),t.forceNewSegmentOnNextPrepare(),o==null||o.forceNewSegmentOnNextPrepare()}function Jn(e,t,i,r,a,n,o){if(n){let s=r.count;return i(t[a*2],t[a*2+1]),e[a]=r.count,r.count++,o.vertexLength++,s}return e[a]}function ZD(e,t,i,r,a,n){let o=[];for(let c=0;c<r.length/2;c++)o.push(-1);let s={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),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=o[d]<l,g=o[p]<l,_=o[f]<l,y=+!!m+ +!!g+ +!!_;u.vertexLength+y>Ke.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=s.count,m=!0,g=!0,_=!0,h=0);let v=Jn(o,r,n,s,d,m,u),x=Jn(o,r,n,s,p,g,u),b=Jn(o,r,n,s,f,_,u);i.emplaceBack(h+v-l,h+x-l,h+b-l),u.primitiveLength++}}function qD(e,t,i,r,a,n){let o=[];for(let c=0;c<r.length/2;c++)o.push(-1);let s={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),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=o[p]<l,g=o[f]<l,_=+!!m+ +!!g;u.vertexLength+_>Ke.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=s.count,m=!0,g=!0,h=0);let y=Jn(o,r,n,s,p,m,u),v=Jn(o,r,n,s,f,g,u);i.emplaceBack(h+y-l,h+v-l),u.primitiveLength++}}var a1=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.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new bT,this.indexArray=new Ki,this.indexArray2=new bc,this.programConfigurations=new ra(e.layers,e.zoom),this.segments=new Ke,this.segments2=new Ke,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){this.hasDependencies=gl("fill",this.layers,t);let r=this.layers[0].layout.get("fill-sort-key"),a=!r.isConstant(),n=[],o=new Ie(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=da(l,s);if(!this.layers[0]._featureFilter.filter(o,d,i))continue;let p=a?r.evaluate(d,{},i,t.availableImages):void 0,f={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:s?d.geometry:ca(l),patterns:{},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;if(this.hasDependencies){let p=qd("fill",this.layers,l,{zoom:this.zoom},t);this.patternFeatures.push(p)}else this.addFeature(l,u,h,i,{},t.subdivisionGranularity);let d=e[h].feature;t.featureIndex.insert(d,u,h,c,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures({options:e,canonical:t,patternPositions:i,patternMap:r}){this.detectSdfPatterns(r);for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,i,e.subdivisionGranularity)}detectSdfPatterns(e){for(let t of this.patternFeatures)for(let i in t.patterns){let r=t.patterns[i];this.recordSdfPattern(i,e[r.min]),this.recordSdfPattern(i,e[r.mid]),this.recordSdfPattern(i,e[r.max])}for(let t of this.layers){let i=t.paint.get("fill-pattern").constantOr(null);i&&(this.recordSdfPattern(t.id,e[i.from.toString()]),this.recordSdfPattern(t.id,e[i.to.toString()]))}}recordSdfPattern(e,t){if(!t)return;let i=t.sdf===!0,r=this.sdfPatterns[e];r===void 0?this.sdfPatterns[e]=i:r!==i&&_e(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${e}"`)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xD),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),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(e,t,i,r,a,n){for(let o of Ul(t,500)){let s=t1(o,r,n.fill.getGranularityForZoomLevel(r.z)),l=this.layoutVertexArray;r1((u,h)=>{l.emplaceBack(u,h)},this.segments,this.layoutVertexArray,this.indexArray,s.verticesFlattened,s.indicesTriangles,this.segments2,this.indexArray2,s.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,canonical:r})}};G("FillBucket",a1,{omit:["layers","patternFeatures"]});let _m;const WD=()=>_m||(_m=new St({"fill-sort-key":new Q(z.layout_fill["fill-sort-key"],"fill-sort-key")}));let ym;const HD=()=>ym||(ym=new St({"fill-antialias":new U(z.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new Q(z.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new U(z.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new Q(z.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new Q(z.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new U(z.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new U(z.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new co(z.paint_fill["fill-pattern"],"fill-pattern")}));var XD={get paint(){return HD()},get layout(){return WD()}};const YD=e=>e.type==="fill";var KD=class extends Ri{constructor(e,t){super(e,XD,t)}recalculate(e,t){super.recalculate(e,t);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(e){return new a1(e)}queryRadius(){return eu(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:r}){return U0(tu(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),t)}isTileClipped(){return!0}};const JD=Qe([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),QD=Qe([{name:"a_centroid",components:2,type:"Int16"}],4),eS=JD.members;var Fo=class{constructor(e,t,i,r,a){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=a;e.pos<t;){let n=e.readVarint();if(n===8)this.id=e.readVarint();else if(n===18){let o=e.readVarint()+e.pos;for(;e.pos<o;){let s=r[e.readVarint()],l=a[e.readVarint()];this.properties[s]=l}}else n===24?this.type=e.readVarint():(n===34&&(this._geometry=e.pos),e.skip(n))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,i=[],r,a=1,n=0,o=0,s=0;for(;e.pos<t;){if(n<=0){let l=e.readVarint();if(a=l&7,n=l>>3,n===0)continue}if(n--,a===1)o+=e.readSVarint(),s+=e.readSVarint(),r&&i.push(r),r=[new M(o,s)];else if(a===2)o+=e.readSVarint(),s+=e.readSVarint(),r&&r.push(new M(o,s));else if(a===7)r&&r.push(r[0].clone());else throw Error(`unknown command ${a}`)}return r&&i.push(r),i}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,i=1,r=0,a=0,n=0,o=1/0,s=-1/0,l=1/0,u=-1/0;for(;e.pos<t;){if(r<=0){let h=e.readVarint();if(i=h&7,r=h>>3,r===0)continue}if(r--,i===1||i===2)a+=e.readSVarint(),n+=e.readSVarint(),a<o&&(o=a),a>s&&(s=a),n<l&&(l=n),n>u&&(u=n);else if(i!==7)throw Error(`unknown command ${i}`)}return[o,l,s,u]}toGeoJSON(e,t,i){let r=this.extent*2**i,a=this.extent*e,n=this.extent*t,o=this.loadGeometry();function s(c){return[(c.x+a)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(c.y+n)*2/r)*Math.PI))-90]}function l(c){return c.map(s)}let u;if(this.type===1){let c=[];for(let p of o)c.push(p[0]);let d=l(c);u=c.length===1?{type:"Point",coordinates:d[0]}:{type:"MultiPoint",coordinates:d}}else if(this.type===2){let c=o.map(l);u=c.length===1?{type:"LineString",coordinates:c[0]}:{type:"MultiLineString",coordinates:c}}else if(this.type===3){let c=n1(o),d=[];for(let p of c)d.push(p.map(l));u=d.length===1?{type:"Polygon",coordinates:d[0]}:{type:"MultiPolygon",coordinates:d}}else throw Error("unknown feature type");let h={type:"Feature",geometry:u,properties:this.properties};return this.id!=null&&(h.id=this.id),h}};Fo.types=["Unknown","Point","LineString","Polygon"];function n1(e){let t=e.length;if(t<=1)return[e];let i=[],r,a;for(let n=0;n<t;n++){let o=tS(e[n]);o!==0&&(a===void 0&&(a=o<0),a===o<0?(r&&i.push(r),r=[e[n]]):r&&r.push(e[n]))}return r&&i.push(r),i}function tS(e){let t=0;for(let i=0,r=e.length,a=r-1,n,o;i<r;a=i++)n=e[i],o=e[a],t+=(o.x-n.x)*(n.y+o.y);return t}var iS=class{constructor(e,t){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],t===void 0&&(t=e.length);e.pos<t;){let i=e.readVarint();i===10?this.name=e.readString():i===18?(this._features.push(e.pos),e.skip(i)):i===26?this._keys.push(e.readString()):i===34?this._values.push(rS(e)):i===40?this.extent=e.readVarint():i===120?this.version=e.readVarint():e.skip(i)}this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new Fo(this._pbf,t,this.extent,this._keys,this._values)}};function rS(e){let t=null,i=e.readVarint()+e.pos;for(;e.pos<i;){let r=e.readVarint();t=r===10?e.readString():r===21?e.readFloat():r===25?e.readDouble():r===32?e.readVarint(!0):r===40?e.readVarint():r===48?e.readSVarint():r===56?e.readBoolean():(e.skip(r),null)}if(t==null)throw Error("unknown feature value");return t}var aS=class{constructor(e,t=e.length){let i=Object.create(null);for(;e.pos<t;){let r=e.readVarint();if(r===26){let a=new iS(e,e.readVarint()+e.pos);a.length&&(i[a.name]=a)}else e.skip(r)}this.layers=i}};const Ot=63710088e-1;var W=class $n{constructor(t,i){if(isNaN(t)||isNaN(i))throw Error(`Invalid LngLat object: (${t}, ${i})`);if(this.lng=+t,this.lat=+i,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new $n(fi(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let i=Math.PI/180,r=this.lat*i,a=t.lat*i,n=Math.sin(r)*Math.sin(a)+Math.cos(r)*Math.cos(a)*Math.cos((t.lng-this.lng)*i);return Ot*Math.acos(Math.min(n,1))}static convert(t){if(t instanceof $n)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new $n(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t)return new $n(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 ih=6378137,kc={origin:[-Math.PI*ih,Math.PI*ih],extentAtZoom0:2*Math.PI*ih},Hd=2*Math.PI*Ot;function o1(e){return Hd*Math.cos(e*Math.PI/180)}function vl(e){return(180+e)/360}function xl(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Rc(e,t){return e/o1(t)}function s1(e){return e*360-180}function vo(e){let t=180-e*360;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function nS(e,t){return e*o1(vo(t))}function l1(e){return 1/Math.cos(e*Math.PI/180)}var It=class u1{constructor(t,i,r=0){this.x=+t,this.y=+i,this.z=+r}static fromLngLat(t,i=0){let r=W.convert(t);return new u1(vl(r.lng),xl(r.lat),Rc(i,r.lat))}toLngLat(){return new W(s1(this.x),vo(this.y))}toAltitude(){return nS(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Hd*l1(vo(this.y))}};const ln=new class{constructor(){this.name="mercator",this.wraps=!0,this.tileMatrixSet=kc}worldFromLngLat(e,t,i){return new It(vl(e),xl(t),i===void 0?0:Rc(i,t))}lngLatFromWorld(e,t){return new W(s1(e),vo(t))}hasLngLat(e,t){return!0}metersPerWorldUnit(e,t){return 1/(1/Hd*l1(vo(t)))}worldZFromAltitude(e,t){return Rc(e,t.lat)}},Na=89.25;function h1(e,t,i){let r=1/(1<<i.z);return new It(e/O*r+i.x*r,t/O*r+i.y*r)}function oS(e,t,i){return h1(e,t,i).toLngLat()}function gi(e,t,i){let r=i.wraps?Y(t.lat,-85.051129,Fi):t.lat,{x:a,y:n}=i.worldFromLngLat(t.lng,r);return new M(a*e,n*e)}function wr(e,t,i){return i.lngLatFromWorld(t.x/e,t.y/e)}function Qn(e){return e.cameraToCenterDistance*Math.min(Math.tan(Ve(90-e.pitch))*.85,Math.tan(Ve(Na-e.pitch)))}function rh(e,t){let i=e.canonical,r=t/pt(i.z),a=i.x+2**i.z*e.wrap,n=new Float64Array(16);return Ii(n),st(n,n,[a*r,i.y*r,0]),Rt(n,n,[r/O,r/O,1]),n}function c1(e,t,i,r){let{x:a,y:n,z:o}=Lc(t,i),s=r*-a,l=r*-n,u=r*o;return new It(e.x+s,e.y+l,e.z+u)}function sS(e,t=e.center){let i=e.worldCoordinateHelper,r=i.worldZFromAltitude(1,t),a=r*e.worldSize,n=e.cameraToCenterDistance/a;return c1(i.worldFromLngLat(t.lng,t.lat,e.elevation),e.pitch,e.bearing,n*r)}function Lc(e,t){let i=Ve(e),r=Ve(t),a=Math.cos(-i),n=Math.sin(i);return{x:n*Math.sin(r),y:-n*Math.cos(r),z:a}}function d1(e,t,i,r,a){let n=(c,d)=>{let{x:p,y:f}=e.worldFromLngLat(c,d);return new M(p,f)},o=c=>c===16?r:t+(r-t)*c/16,s=c=>c===16?i:a+(i-a)*c/16,l=[];for(let c=0;c<=16;c++)for(let d=0;d<=16;d++)l.push(n(o(d),s(c)));let u=(c,d)=>l[c*17+d],h=0;for(let c=0;c<16;c++){let d=(o(c)+o(c+1))/2,p=(s(c)+s(c+1))/2,f=[[u(0,c),u(0,c+1),n(d,a)],[u(16,c),u(16,c+1),n(d,i)],[u(c,0),u(c+1,0),n(t,p)],[u(c,16),u(c+1,16),n(r,p)]];for(let[m,g,_]of f){let y=g.sub(m),v=_.sub(m),x=y.mag(),b=x>0?Math.abs(y.x*v.y-y.y*v.x)/x:v.mag();b>h&&(h=b)}}return{points:l,bulge:h}}function p1(e,t,i,r,a){let{points:n,bulge:o}=d1(e,t,i,r,a),s=1/0,l=1/0,u=-1/0,h=-1/0;for(let{x:c,y:d}of n)c<s&&(s=c),d<l&&(l=d),c>u&&(u=c),d>h&&(h=d);return{minX:s-o,minY:l-o,maxX:u+o,maxY:h+o}}function lS(e,t,i,r,a){let n=[e.lngLatFromWorld(t,i),e.lngLatFromWorld(r,i),e.lngLatFromWorld(r,a),e.lngLatFromWorld(t,a)];return{west:Math.min(n[0].lng,n[1].lng,n[2].lng,n[3].lng),south:Math.min(n[0].lat,n[1].lat,n[2].lat,n[3].lat),east:Math.max(n[0].lng,n[1].lng,n[2].lng,n[3].lng),north:Math.max(n[0].lat,n[1].lat,n[2].lat,n[3].lat)}}const ah=1e-4;function uS(e,t){if(e.wraps)return 360;let i=t.lat>0?-1e-4:ah,r=e.worldFromLngLat(t.lng,t.lat),a=e.worldFromLngLat(t.lng+ah,t.lat),n=e.worldFromLngLat(t.lng,t.lat+i),o=Math.max(Math.hypot(a.x-r.x,a.y-r.y),Math.hypot(n.x-r.x,n.y-r.y));return ah/o}function hS(e,t){return t<=0||!e||e.length===0?e:e.map(i=>fS(i,t))}function cS(e,t){let i=oS(O/2,O/2,t),r=It.fromLngLat(i).meterInMercatorCoordinateUnits(),a=(1<<t.z)*O;return e*r*a}const dS=Math.cos(35*Math.PI/180);function pS(e){let t=[null];for(let n=1;n<e.length;n++){let o=e[n].sub(e[n-1]),s=!fl(e[n],e[n-1])&&o.mag()>0;t.push(s?o._perp():null)}let i=e.length-1,r=i>1&&e[0].equals(e[i]),a=[null];for(let n=1;n<=i;n++){let o=t[n];if(!o){a.push(null);continue}let s=r&&n===1?t[i]:t[n-1],l=r&&n===i?t[1]:t[n+1];a.push({start:vm(o,s),end:vm(o,l)})}return a}function vm(e,t){if(!t)return e.unit();let i=e.mag(),r=t.mag();return e.x*t.x+e.y*t.y<dS*i*r||i>=2*r?e.unit():r>=2*i?t.unit():e.add(t)._unit()}function fS(e,t){if(!e||e.length<3)return e;let i=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=i?e.length-1:e.length;if(r<3)return e;let a=[],n=fl(e[r-1],e[0]);for(let s=0;s<r;s++){let l=e[(s-1+r)%r],u=e[s],h=e[(s+1)%r],c=fl(u,h);n||c?a.push(u.clone()):gS(a,l,u,h,t),n=c}let o=mS(a);return o.length<3?e:(i&&o.push(o[0].clone()),o)}function mS(e){let t=[];for(let i of e){let r=i.round(),a=t[t.length-1];((a==null?void 0:a.x)!==r.x||(a==null?void 0:a.y)!==r.y)&&t.push(r)}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 gS(e,t,i,r,a){let n=t.sub(i),o=r.sub(i),s=n.mag(),l=o.mag();if(s<1e-6||l<1e-6){e.push(i.clone());return}n._div(s),o._div(l);let u=n.x*o.x+n.y*o.y;if(Math.abs(u)>Math.cos(5*Math.PI/180)){e.push(i.clone());return}let h=.2,c=Math.min(a,s*h,l*h),d=i.add(n.mult(c)),p=i.add(o.mult(c)),f=Math.sqrt((1+u)/2),m=i.add(n.add(o)._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 nh=8192;function Pn(e,t,i,r,a,n,o,s){e.emplaceBack(t,i,Math.floor(r*nh)*2+o,a*nh*2,n*nh*2,Math.round(s))}var f1=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.layoutVertexArray=new wT,this.centroidVertexArray=new qr,this.indexArray=new Ki,this.programConfigurations=new ra(e.layers,e.zoom),this.segments=new Ke,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){this.features=[],this.hasDependencies=gl("fill-extrusion",this.layers,t);let r=new Ie(this.zoom),a=this.layers[0],n=a.layout.get("fill-extrusion-rounded-corner-distance"),o=n>0?cS(n,i):0,s=a._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=da(l,s);if(!a._featureFilter.filter(r,d,i))continue;let p={id:u,sourceLayerIndex:c,index:h,geometry:hS(s?d.geometry:ca(l),o),properties:l.properties,type:l.type,patterns:{}};this.hasDependencies?this.features.push(qd("fill-extrusion",this.layers,p,{zoom:this.zoom},t)):this.addFeature(p,p.geometry,h,i,{},t.subdivisionGranularity),t.featureIndex.insert(l,p.geometry,h,c,this.index,!0)}}addFeatures({options:e,canonical:t,patternPositions:i}){for(let r of this.features){let{geometry:a}=r;this.addFeature(r,a,r.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,eS),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,QD.members,!0),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(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,r,a,n){for(let o of Ul(t,500)){let s={x:0,y:0,sampleCount:0},l=this.layoutVertexArray.length;this.processPolygon(s,r,e,o,n);let u=this.layoutVertexArray.length-l,h=Math.floor(s.x/s.sampleCount),c=Math.floor(s.y/s.sampleCount);for(let d=0;d<u;d++)this.centroidVertexArray.emplaceBack(h,c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,canonical:r})}processPolygon(e,t,i,r,a){if(r.length<1||om(r[0]))return;for(let h of r)h.length!==0&&_S(e,h);let n={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=a.fill.getGranularityForZoomLevel(t.z),s=Fo.types[i.type]==="Polygon";for(let h of r){if(h.length===0||om(h))continue;let c=Wr(h,o,s);this._generateSideFaces(c,n)}if(!s)return;let l=t1(r,t,o,!1),u=this.layoutVertexArray;r1((h,c)=>{Pn(u,h,c,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0,r=this.layers[0].layout.get("fill-extrusion-rounded-corner-distance")>0?pS(e):null;for(let a=1;a<e.length;a++){let n=e[a],o=e[a-1];if(fl(n,o)||r&&!r[a])continue;t.segment.vertexLength+4>Ke.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let s=n.sub(o)._perp()._unit(),{start:l,end:u}=r?r[a]:{start:s,end:s},h=o.dist(n);i+h>32768&&(i=0),Pn(this.layoutVertexArray,n.x,n.y,u.x,u.y,0,0,i),Pn(this.layoutVertexArray,n.x,n.y,u.x,u.y,0,1,i),i+=h,Pn(this.layoutVertexArray,o.x,o.y,l.x,l.y,0,0,i),Pn(this.layoutVertexArray,o.x,o.y,l.x,l.y,0,1,i);let c=t.segment.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}};function _S(e,t){for(let i=0;i<t.length;i++){let r=t[i];(i!==t.length-1||t[0].x!==r.x||t[0].y!==r.y)&&(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}G("FillExtrusionBucket",f1,{omit:["layers","features"]});let xm;const yS=()=>xm||(xm=new St({"fill-extrusion-rounded-corner-distance":new U(z["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")}));let bm;const vS=()=>bm||(bm=new St({"fill-extrusion-opacity":new U(z["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new Q(z["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new U(z["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new U(z["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new co(z["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new Q(z["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new Q(z["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new U(z["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")}));var xS={get paint(){return vS()},get layout(){return yS()}};const bS=e=>e.type==="fill-extrusion";var wS=class extends Ri{constructor(e,t){super(e,xS,t)}createBucket(e){return new f1(e)}queryRadius(){return eu(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,pixelPosMatrix:o}){let s=tu(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-a.bearingInRadians,n),l=this.paint.get("fill-extrusion-height").evaluate(t,i),u=this.paint.get("fill-extrusion-base").evaluate(t,i),h=SS(s,o,0),c=DS(r,u,l,o),d=c[0],p=c[1];return TS(d,p,h)}};function An(e,t){return e.x*t.x+e.y*t.y}function wm(e,t){if(e.length===1){let i=0,r=t[i++],a;for(;!a||r.equals(a);)if(a=t[i++],!a)return 1/0;for(;i<t.length;i++){let n=t[i],o=e[0],s=a.sub(r),l=n.sub(r),u=o.sub(r),h=An(s,s),c=An(s,l),d=An(l,l),p=An(u,s),f=An(u,l),m=h*d-c*c,g=(d*p-c*f)/m,_=(h*f-c*p)/m,y=1-g-_,v=r.z*y+a.z*g+n.z*_;if(isFinite(v))return v}return 1/0}{let i=1/0;for(let r of t)i=Math.min(i,r.z);return i}}function TS(e,t,i){let r=1/0;U0(i,t)&&(r=wm(i,t[0]));for(let a=0;a<t.length;a++){let n=t[a],o=e[a];for(let s=0;s<n.length-1;s++){let l=n[s],u=n[s+1],h=o[s],c=[l,u,o[s+1],h,l];N0(i,c)&&(r=Math.min(r,wm(i,c)))}}return r!==1/0&&r}function DS(e,t,i,r){let a=[],n=[],o=r[8]*t,s=r[9]*t,l=r[10]*t,u=r[11]*t,h=r[8]*i,c=r[9]*i,d=r[10]*i,p=r[11]*i;for(let f of e){let m=[],g=[];for(let _ of f){let y=_.x,v=_.y,x=r[0]*y+r[4]*v+r[12],b=r[1]*y+r[5]*v+r[13],w=r[2]*y+r[6]*v+r[14],T=r[3]*y+r[7]*v+r[15],S=x+o,C=b+s,F=w+l,A=T+u,L=x+h,I=b+c,E=w+d,D=T+p,P=new M(S/A,C/A);P.z=F/A,m.push(P);let R=new M(L/D,I/D);R.z=E/D,g.push(R)}a.push(m),n.push(g)}return[a,n]}function SS(e,t,i){let r=[];for(let a of e){let n=[a.x,a.y,i,1];Pt(n,n,t),r.push(new M(n[0]/n[3],n[1]/n[3]))}return r}const ES=Qe([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_offset_normal",components:2,type:"Int8"}],2),CS=ES.members,PS=Qe([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),AS=PS.members,MS=Math.cos(75/2*(Math.PI/180)),m1=1/2,Tm=2**14/m1;var g1=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 TT,this.layoutVertexArray2=new DT,this.indexArray=new Ki,this.programConfigurations=new ra(e.layers,e.zoom),this.segments=new Ke,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(e,t,i){this.hasDependencies=gl("line",this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),a=!r.isConstant(),n=[],o=new Ie(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let d=da(l,s);if(!this.layers[0]._featureFilter.filter(o,d,i))continue;let p=a?r.evaluate(d,{},i):void 0,f={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:s?d.geometry:ca(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?(gl("line",this.layers,t)?qd("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,i,{},{},t.subdivisionGranularity);let d=e[h].feature;t.featureIndex.insert(d,u,h,c,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures({options:e,canonical:t,patternPositions:i,dashPositions:r}){for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,i,r,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,AS)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,CS),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.geojsonvt_clip_start,end:+e.properties.geojsonvt_clip_end}}addFeature(e,t,i,r,a,n,o){let s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),u=s.get("line-cap").evaluate(e,{}),h=s.get("line-miter-limit").evaluate(e,{}),c=s.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let d of t)this.addLine(d,e,l,u,h,c,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,dashPositions:n,canonical:r})}addLine(e,t,i,r,a,n,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let l=o?s.line.getGranularityForZoomLevel(o.z):1;if(e=Wr(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=Fo.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;i==="bevel"&&(a=1.05);let d=this.overscaling<=16?15*O/(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 b=_.x*y.x+_.y*y.y,w=x.x*y.x+x.y*y.y,T=w===0?1/0:1/w,S=2*Math.sqrt(2-2*w),C=w<MS&&m&&g,F=_.x*y.y-_.y*y.x>0,A=x.mult(Math.min(T,2)),L=Y((T-3)/5,0,1);if(C&&v>c){let D=f.dist(m);if(D>2*d){let P=f.sub(f.sub(m)._mult(d/D)._round());this.updateDistance(m,P),this.addCurrentVertex(P,_,0,0,p),m=P}}let I=m&&g,E=I?i:u?"butt":r;if(I&&E==="round"&&(T<n?E="miter":T<=2&&(E="fakeround")),E==="miter"&&T>a&&(E="bevel"),E==="bevel"&&(T>2&&(E="flipbevel"),T<a&&(E="miter")),m&&this.updateDistance(m,f),E==="miter")x._mult(T),this.addCurrentVertex(f,x,0,0,p,!1,A);else if(E==="flipbevel"){if(T>100)x=y.mult(-1);else{let D=T*_.add(y).mag()/_.sub(y).mag();x._perp()._mult(D*(F?-1:1))}this.addCurrentVertex(f,x,0,0,p,!1,A,L),this.addCurrentVertex(f,x.mult(-1),0,0,p,!1,A,L)}else if(E==="bevel"||E==="fakeround"){let D=-Math.sqrt(T*T-1),P=F?D:0,R=F?0:D;if(m&&this.addCurrentVertex(f,_,P,R,p,!1,A),E==="fakeround"){let k=Math.round(S*180/Math.PI/20);for(let B=1;B<k;B++){let Z=B/k;if(Z!==.5){let pe=Z-.5,fe=1.0904+b*(-3.2452+b*(3.55645-b*1.43519)),Ee=.848013+b*(-1.06021+b*.215638);Z+=Z*pe*(Z-1)*(fe*pe*pe+Ee)}let oe=y.sub(_)._mult(Z)._add(_)._unit()._mult(F?-1:1);this.addHalfVertex(f,oe.x,oe.y,F?-A.x:A.x,F?-A.y:A.y,!1,F,p)}}g&&this.addCurrentVertex(f,y,-P,-R,p,!1,A)}else if(E==="butt")this.addCurrentVertex(f,x,0,0,p,!1,A);else if(E==="square"){let D=m?1:-1;this.addCurrentVertex(f,x,D,D,p,!1,A)}else E==="round"&&(m&&(this.addCurrentVertex(f,_,0,0,p,!1,A,L),this.addCurrentVertex(f,_,1,1,p,!0,A,L)),g&&(this.addCurrentVertex(f,y,-1,-1,p,!0,A,L),this.addCurrentVertex(f,y,0,0,p,!1,A,L)));if(C&&v<h-1){let D=f.dist(g);if(D>2*d){let P=f.add(g.sub(f)._mult(d/D)._round());this.updateDistance(f,P),this.addCurrentVertex(P,y,0,0,p),f=P}}}}addCurrentVertex(e,t,i,r,a,n=!1,o=t,s=0){let l=t.x+t.y*i,u=t.y-t.x*i,h=-t.x+t.y*r,c=-t.y-t.x*r,d=o.x+(t.x-o.x)*s,p=o.y+(t.y-o.y)*s;this.addHalfVertex(e,l,u,d,p,n,!1,a),this.addHalfVertex(e,h,c,-d,-p,n,!0,a),this.distance>Tm/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,a,n,o,s))}addHalfVertex({x:e,y:t},i,r,a,n,o,s,l){let u=(this.lineClips?this.scaledDistance*(Tm-1):this.scaledDistance)*m1;if(this.layoutVertexArray.emplaceBack((e<<1)+ +!!o,(t<<1)+ +!!s,Math.round(63*i)+128,Math.round(63*r)+128,(u&63)<<2,u>>6,Math.round(63*a),Math.round(63*n)),this.lineClips){let c=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(c,this.lineClipsArray.length)}let h=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,h,this.e2),l.primitiveLength++),s?this.e2=h:this.e1=h}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 i=t.paint.get("line-dasharray");if(i&&!i.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,r){for(let a of e){let n=a.paint.get("line-dasharray");if(!n||n.value.kind==="constant")continue;let o=a.layout.get("line-cap").evaluate(t,{})==="round",s={dasharray:n.value.evaluate({zoom:i-1},t,{}),round:o},l={dasharray:n.value.evaluate({zoom:i},t,{}),round:o},u={dasharray:n.value.evaluate({zoom:i+1},t,{}),round:o},h=`${s.dasharray.join(",")},${s.round}`,c=`${l.dasharray.join(",")},${l.round}`,d=`${u.dasharray.join(",")},${u.round}`;r.dashDependencies[h]=s,r.dashDependencies[c]=l,r.dashDependencies[d]=u,t.dashes[a.id]={min:h,mid:c,max:d}}}};G("LineBucket",g1,{omit:["layers","patternFeatures"]});let Dm;const IS=()=>Dm||(Dm=new St({"line-cap":new Q(z.layout_line["line-cap"],"line-cap"),"line-join":new Q(z.layout_line["line-join"],"line-join"),"line-miter-limit":new Q(z.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new Q(z.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new Q(z.layout_line["line-sort-key"],"line-sort-key")}));let Sm;const FS=()=>Sm||(Sm=new St({"line-opacity":new Q(z.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new U(z.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new Q(z.paint_line["line-color"],"line-color"),"line-translate":new U(z.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new U(z.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new Q(z.paint_line["line-width"],"line-width"),"line-gap-width":new Q(z.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new Q(z.paint_line["line-offset"],"line-offset"),"line-blur":new Q(z.paint_line["line-blur"],"line-blur"),"line-dasharray":new co(z.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new co(z.paint_line["line-pattern"],"line-pattern"),"line-gradient":new Jl(z.paint_line["line-gradient"],"line-gradient")}));var Em={get paint(){return FS()},get layout(){return IS()}},zS=class extends Q{possiblyEvaluate(e,t){return t=new Ie(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=X({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}};let ys;const kS=e=>e.type==="line";var RS=class extends Ri{constructor(e,t){super(e,Em,t),this.gradientVersion=0,ys||(ys=new zS(Em.paint.properties["line-width"].specification,"line-floorwidth"),ys.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){let t=this.gradientExpression();this.stepInterpolant=kw(t)?t._styleExpression.expression instanceof bd:!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"]=ys.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new g1(e)}queryRadius(e){let t=e,i=Cm(Va("line-width",this,t),Va("line-gap-width",this,t)),r=Va("line-offset",this,t);return i/2+Math.abs(r)+eu(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n}){let o=tu(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-a.bearingInRadians,n),s=n/2*Cm(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=XT(r,l*n)),$T(o,r,s)}isTileClipped(){return!0}};function Cm(e,t){return t>0?t+2*e:e}const LS=Qe([{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),BS=Qe([{name:"a_projected_pos",components:3,type:"Float32"}],4);Qe([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const OS=Qe([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Qe([{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 Pm=Qe([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),jS=Qe([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Qe([{name:"triangle",components:3,type:"Uint16"}]),Qe([{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"}]);const VS=Qe([{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"}]);Qe([{type:"Float32",name:"offsetX"}]),Qe([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Qe([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const bl=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(bl.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 i=e.pluginURL,r=new Promise(n=>{this.loadScriptResolve=n}),a=new Promise(n=>setTimeout(()=>n(),this.TIMEOUT));if(await t(i),await Promise.race([r,a]),this.isParsed()){let n={pluginStatus:"loaded",pluginURL:i};return this.setState(n),n}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${i}`)}};function NS(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 US(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 $S(e){return/[\u0900-\u109F\u1700-\u17FF\u1900-\u194F\u19E0-\u1AAF\u1B00-\u1C4F\u1CC0-\u1CCF\uA800-\uA82F\uA880-\uA8FF\uA930-\uA95F\uA980-\uAAFF\uABC0-\uABFF]|\uD802[\uDE00-\uDE5F]|\uD804[\uDC00-\uDCCF\uDD00-\uDD4F\uDD80-\uDE4F\uDEB0-\uDFFF]|\uD805[\uDC00-\uDCDF\uDD80-\uDE5F\uDE80-\uDF4F]|\uD806[\uDC00-\uDC4F\uDD00-\uDD5F\uDDA0-\uDEAF\uDF00-\uDF7F]|\uD807[\uDC00-\uDCBF\uDD00-\uDDAF\uDEE0-\uDF5F\uDFC0-\uDFFF]|\uD818[\uDD00-\uDD3F]/gim.test(String.fromCodePoint(e))}function GS(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 ZS(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 zo(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 qS(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 WS(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 Am(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 HS(e,t){return/(?:[\u1039\u17D2\u1A60\u1BAB\u200D\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807[\uDD45\uDD97\uDF42])$/.test(e)||/^\p{gc=Mc}/u.test(t)}const XS={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"},YS={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]},KS={لآ:[65269,65270],لأ:[65271,65272],لإ:[65273,65274],لا:[65275,65276]},Mm=1604,JS=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function QS(e,t,i){let r=0;for(let a of e.split(";")){let[n,o]=a.split(",").map(l=>parseInt(l,36)),s=r+n;for(let l=s;l<s+o;l++)i.set(l,t);r=s+o}}const _1=new Map;for(let[e,t]of Object.entries(XS))QS(t,e,_1);function eE(e){var t;return(t=_1.get(e))!=null?t:"U"}function tE(e){return e==="D"||e==="L"||e==="C"}function iE(e){return e==="D"||e==="R"||e==="C"}function rE(e,t,i){return e==="D"?t&&i?3:t?1:i?2:0:e==="R"?+!!t:e==="L"?i?2:0:null}function aE(e){return[...e].map(t=>{let i=t.codePointAt(0);return{codePoint:i,type:eE(i),form:null}})}function nE(e){let t=e.filter(i=>i.type!=="T");for(let i=0;i<t.length;i++){let r=t[i],a=i>0&&tE(t[i-1].type),n=i+1<t.length&&iE(t[i+1].type);r.form=rE(r.type,a,n)}}function oE(e){let t=!1;for(let i of e)i.type==="T"?i.form=t?3:0:t=i.form===2||i.form===3}function sE(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(r.codePoint!==Mm){t.push(r);continue}let a=i+1;for(;a<e.length&&e[a].type==="T";)a++;let n=e[a],o=n&&KS[String.fromCodePoint(Mm,n.codePoint)];if(!o){t.push(r);continue}let s=r.form===3||r.form===1;t.push({codePoint:o[+!!s],type:"R",form:0}),t.push(...e.slice(i+1,a)),i=a}return t}function lE(e){if(e.form===null)return e.codePoint;let t=YS[e.codePoint];return t&&(t[e.form]||t[0])||e.codePoint}function uE(e){if(!JS.test(e))return e;let t=aE(e);return nE(t),oE(t),sE(t).map(i=>String.fromCodePoint(lE(i))).join("")}function hE(e,t,i){var a;let r=t.layout.get("text-transform").evaluate(i,{});return r==="uppercase"?e=e.toLocaleUpperCase():r==="lowercase"&&(e=e.toLocaleLowerCase()),((a=bl.applyArabicShaping)!=null?a:uE)(e)}function cE(e,t,i){for(let r of e.sections)r.text=hE(r.text,t,i);return e}function oh(e,t,i){let r=i?t.last.points:t.first.points,a=i?r[r.length-1]:r[0];return`${e}:${a.x}:${a.y}`}function dE(e){let t=e.first.points,i=t.length;for(let n=e.first.next;n;n=n.next)i+=n.points.length-1;let r=Array(i);for(let n=0;n<t.length;n++)r[n]=t[n];let a=t.length;for(let n=e.first.next;n;n=n.next){let o=n.points;for(let s=1;s<o.length;s++)r[a++]=o[s]}return r}function Im(e,t,i,r,a){let n=t[i];delete t[i],t[r]=n;let o=e[n];return o.last.next=a.first,o.last=a.last,n}function Fm(e,t,i,r,a){let n=t[r];delete t[r],t[i]=n;let o=e[n];return a.last.next=o.first,o.first=a.first,n}function pE(e){let t={},i={},r=[];for(let n of e){let o=n.text?n.text.toString():null,s={points:n.geometry[0],next:null},l={feature:n,first:s,last:s};if(!o){r.push(l);continue}let u=oh(o,l),h=oh(o,l,!0);if(u in i&&h in t&&i[u]!==t[h]){let c=Fm(r,t,u,h,l),d=Im(r,i,u,h,r[c]);delete t[u],delete i[h],i[oh(o,r[d],!0)]=d,r[c].feature.geometry=null}else if(u in i)Im(r,i,u,h,l);else if(h in t)Fm(r,t,u,h,l);else{let c=r.push(l)-1;t[u]=c,i[h]=c}}let a=[];for(let n of r){let o=n.feature;o.geometry&&(n.first.next&&(o.geometry[0]=dE(n)),a.push(o))}return a}const y1=typeof Intl<"u"&&"Segmenter"in Intl;let Mn,In;function Bc(e){if(!y1||!WS(e))return[...e];Mn!=null||(Mn=new Intl.Segmenter(void 0,{granularity:"grapheme"}));let t=[];for(let{segment:i}of Mn.segment(e)){let r=t.length-1;r>=0&&HS(t[r],i)?t[r]+=i:t.push(i)}return t}function fE(e){let t=new Set;if(y1){In!=null||(In=new Intl.Segmenter(void 0,{granularity:"word"}));for(let{index:r}of In.segment(e))t.add(r);return t}let i=0;for(let r of e.split(/\b|(?=\p{Ideo})/u))t.add(i),i+=r.length;return t}function xo(e){let t=e.codePointAt(0);return e.length>(t>65535?2:1)}function bo(e){return/\s/u.test(String.fromCodePoint(e))}function iu(e){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function Oc(e){for(let t of e)if(zo(t.codePointAt(0)))return!0;return!1}function mE(e){for(let t of e)if(!gE(t.codePointAt(0)))return!1;return!0}function gE(e){return!NS(e)}function an(e){return!(zo(e)||qS(e))}function v1(e){return/\p{sc=Arab}/u.test(String.fromCodePoint(e))}function x1(e){return US(e)}function b1(e){for(let t of e)if(x1(t.codePointAt(0)))return!0;return!1}const La={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function _E(e){let t="",i={premature:!0,value:void 0},r=e[Symbol.iterator](),a=r.next(),n=e[Symbol.iterator]();n.next();let o=n.next();for(;!a.done;)(o.done||!an(o.value.codePointAt(0))||La[o.value])&&(i.premature||!an(i.value.codePointAt(0))||La[i.value])&&La[a.value]?t+=La[a.value]:t+=a.value,i={value:a.value,premature:!1},a=r.next(),o=n.next();return t}const yE={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},vE={40:!0};function zm(e,t,i,r,a,n){var o;if("fontStack"in t){let s=(o=i[t.fontStack])==null?void 0:o.default,l=s==null?void 0:s[e];if(l)return l.metrics.advance*t.scale+a;let u=0;for(let h of e){let c=s==null?void 0:s[h];c&&(u+=c.metrics.advance*t.scale+a)}return u}{let s=r[t.imageName];return s?s.displaySize[0]*t.scale*24/n+a:0}}function km(e,t,i,r){let a=(e-t)**2;return r?e<t?a/2:a*2:a+Math.abs(i)*i}function Rm(e){return/^\s+$/u.test(e)}function xE(e,t,i){let r=0;return(e===10||e===13)&&(r-=1e4),i&&(r+=150),(e===40||e===65288)&&(r+=50),(t===41||t===65289)&&(r+=50),r}function Lm(e,t,i,r,a,n){let o=null,s=km(t,i,a,n);for(let l of r){let u=km(t-l.x,i,a,n)+l.badness;u<=s&&(o=l,s=u)}return{index:e,x:t,priorBreak:o,badness:s}}function w1(e){return e?w1(e.priorBreak).concat(e.index):[]}var Xd=class jc{constructor(t="",i=[],r=[]){this.text=t,this.sections=i,this.sectionIndex=r,this.imageSectionID=null,this.cachedGraphemes=null}graphemes(){var t;return(t=this.cachedGraphemes)!=null||(this.cachedGraphemes=Bc(this.text)),this.cachedGraphemes}static fromFeature(t,i,r,a){let n=new jc;for(let o of t.sections)o.image?n.addImageSection(o):n.addTextSection(o,i);return r&&n.verticalizePunctuation(a),n}length(){return this.graphemes().length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}verticalizePunctuation(t={},i){let r=_E(this.text),a=0;this.cachedGraphemes=this.graphemes().map((n,o)=>{var u,h;let s=r.slice(a,a+n.length);a+=n.length;let l=this.getSection(o);return(i==null?void 0:i[o])!==!1&&"fontStack"in l&&((h=(u=t[l.fontStack])==null?void 0:u.vertical)!=null&&h[n])?n:s}),this.text=this.cachedGraphemes.join("")}hasZeroWidthSpaces(){return this.text.includes("​")}trim(){let t=this.graphemes(),i=0;for(;i<t.length&&Rm(t[i]);)i++;let r=t.length;for(;r>i&&Rm(t[r-1]);)r--;this.text=t.slice(i,r).join(""),this.sectionIndex=this.sectionIndex.slice(i,r),this.cachedGraphemes=null}substring(t,i){let r=this.graphemes().slice(t,i).join(""),a=this.sectionIndex.slice(t,i);return new jc(r,this.sections,a)}toCodeUnitIndex(t){return this.graphemes().slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,i)=>Math.max(t,this.sections[i].scale),0)}getMaxImageSize(t){let i=0,r=0;for(let a=0;a<this.length();a++){let n=this.getSection(a);if("imageName"in n){let o=t[n.imageName];if(!o)continue;let s=o.displaySize;i=Math.max(i,s[0]),r=Math.max(r,s[1])}}return{maxImageWidth:i,maxImageHeight:r}}_appendSection(t,i){let r=this.graphemes(),a=r.length>0?r[r.length-1]:"",n=Bc(a+t);this.text+=t,this.cachedGraphemes=r.slice(0,a?-1:void 0).concat(n);let o=n.length-+!!a;for(let s=0;s<o;s++)this.sectionIndex.push(i)}addTextSection(t,i){this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||i}),this._appendSection(t.text,this.sections.length-1)}addImageSection(t){let i=t.image?t.image.name:"";if(i.length===0){_e("Can't add FormattedSection with an empty image.");return}let r=this.getNextImageSectionCharCode();r?(this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:i}),this._appendSection(String.fromCharCode(r),this.sections.length-1)):_e("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,i,r,a,n){let o=this.determineTotalWidth(t,r,a,n);if(t>=0&&o>0&&o<=i&&!/[\n\r]/.test(this.text))return[this.length()];let s=[],l=o/Math.max(1,Math.ceil(o/i)),u=this.hasZeroWidthSpaces(),h=this.graphemes(),c=null,d=0,p=0;for(let f=0;f<h.length;f++){let m=h[f];if(f>0){let g=h[f-1].codePointAt(0),_=m.codePointAt(0),y=ZS(g),v=Am(g)&&Am(_);(yE[g]||y||"imageName"in this.getSection(f-1)||h[f+1]!==void 0&&vE[_]||v&&(c!=null?c:c=fE(this.text)).has(p))&&s.push(Lm(f,d,l,s,xE(g,_,y&&u),!1))}bo(m.codePointAt(0))||(d+=zm(m,this.getSection(f),r,a,t,n)),p+=m.length}return w1(Lm(this.length(),d,l,s,0,!0))}determineTotalWidth(t,i,r,a){let n=0,o=0;for(let s of this.graphemes()){let l=this.getSection(o);n+=zm(s,l,i,r,t,a),o++}return n}};function bE(){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"},i={},r={};i.L=1,r[1]="L",Object.keys(t).forEach(function(H,xe){i[H]=1<<xe+1,r[i[H]]=H}),Object.freeze(i);var a=i.LRI|i.RLI|i.FSI,n=i.L|i.R|i.AL,o=i.B|i.S|i.WS|i.ON|i.FSI|i.LRI|i.RLI|i.PDI,s=i.BN|i.RLE|i.LRE|i.RLO|i.LRO|i.PDF,l=i.S|i.WS|i.B|a|i.PDI|s,u=null;function h(){if(!u){u=new Map;var H=0;for(var xe in t)if(t.hasOwnProperty(xe))for(var ie=t[xe],V="",ye=void 0,te=!1,ae=0,q=0;q<=ie.length+1;q+=1){var ve=ie[q];if(ve!==","&&q!==ie.length)ve==="+"?(te=!0,ae=H=ae+parseInt(V,36),V=""):V+=ve;else{te?ye=H+parseInt(V,36):(ae=H=ae+parseInt(V,36),ye=H),te=!1,V="",ae=ye;for(var be=H;be<ye+1;be+=1)u.set(be,i[xe])}}}}function c(H){return h(),u.get(H.codePointAt(0))||i.L}function d(H){return r[c(H)]}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(H,xe){var ie=0,V=new Map,ye=xe&&new Map,te;return H.split(",").forEach(function ae(q){if(q.indexOf("+")!==-1)for(var ve=+q;ve--;)ae(te);else{te=q;var be=q.split(">"),ne=be[0],Ze=be[1];ne=String.fromCodePoint(ie+=parseInt(ne,36)),Ze=String.fromCodePoint(ie+=parseInt(Ze,36)),V.set(ne,Ze),xe&&ye.set(Ze,ne)}}),{map:V,reverseMap:ye}}var m,g,_;function y(){if(!m){var H=f(p.pairs,!0),xe=H.map,ie=H.reverseMap;m=xe,g=ie,_=f(p.canonical,!1).map}}function v(H){return y(),m.get(H)||null}function x(H){return y(),g.get(H)||null}function b(H){return y(),_.get(H)||null}var w=i.L,T=i.R,S=i.EN,C=i.ES,F=i.ET,A=i.AN,L=i.CS,I=i.B,E=i.S,D=i.ON,P=i.BN,R=i.NSM,k=i.AL,B=i.LRO,Z=i.RLO,oe=i.LRE,pe=i.RLE,fe=i.PDF,Ee=i.LRI,Te=i.RLI,Ge=i.FSI,Ce=i.PDI;function mt(H,xe){for(var ie=125,V=new Uint32Array(H.length),ye=0;ye<H.length;ye++)V[ye]=c(H[ye]);var te=new Map;function ae(Ut,bi){var $t=V[Ut];V[Ut]=bi,te.set($t,te.get($t)-1),$t&o&&te.set(o,te.get(o)-1),te.set(bi,(te.get(bi)||0)+1),bi&o&&te.set(o,(te.get(o)||0)+1)}for(var q=new Uint8Array(H.length),ve=new Map,be=[],ne=null,Ze=0;Ze<H.length;Ze++)ne||be.push(ne={start:Ze,end:H.length-1,level:xe==="rtl"?1:xe==="ltr"?0:sf(Ze,!1)}),V[Ze]&I&&(ne.end=Ze,ne=null);for(var Br=pe|oe|Z|B|a|Ce|fe|I,tr=function(Ut){return Ut+(Ut&1?1:2)},Bi=function(Ut){return Ut+(Ut&1?2:1)},Oi=0;Oi<be.length;Oi++){ne=be[Oi];var Oe=[{_level:ne.level,_override:0,_isolate:0}],Le=void 0,si=0,xi=0,ma=0;te.clear();for(var ot=ne.start;ot<=ne.end;ot++){var ut=V[ot];if(Le=Oe[Oe.length-1],te.set(ut,(te.get(ut)||0)+1),ut&o&&te.set(o,(te.get(o)||0)+1),ut&Br)if(ut&(pe|oe)){q[ot]=Le._level;var ga=(ut===pe?Bi:tr)(Le._level);ga<=ie&&!si&&!xi?Oe.push({_level:ga,_override:0,_isolate:0}):si||xi++}else if(ut&(Z|B)){q[ot]=Le._level;var Rp=(ut===Z?Bi:tr)(Le._level);Rp<=ie&&!si&&!xi?Oe.push({_level:Rp,_override:ut&Z?T:w,_isolate:0}):si||xi++}else if(ut&a){ut&Ge&&(ut=sf(ot+1,!0)===1?Te:Ee),q[ot]=Le._level,Le._override&&ae(ot,Le._override);var Lp=(ut===Te?Bi:tr)(Le._level);Lp<=ie&&si===0&&xi===0?(ma++,Oe.push({_level:Lp,_override:0,_isolate:1,_isolInitIndex:ot})):si++}else if(ut&Ce){if(si>0)si--;else if(ma>0){for(xi=0;!Oe[Oe.length-1]._isolate;)Oe.pop();var pu=Oe[Oe.length-1]._isolInitIndex;pu!=null&&(ve.set(pu,ot),ve.set(ot,pu)),Oe.pop(),ma--}Le=Oe[Oe.length-1],q[ot]=Le._level,Le._override&&ae(ot,Le._override)}else ut&fe?(si===0&&(xi>0?xi--:!Le._isolate&&Oe.length>1&&(Oe.pop(),Le=Oe[Oe.length-1])),q[ot]=Le._level):ut&I&&(q[ot]=ne.level);else q[ot]=Le._level,Le._override&&ut!==P&&ae(ot,Le._override)}for(var _a=[],ji=null,Or=ne.start;Or<=ne.end;Or++){var fu=V[Or];if(!(fu&s)){var Bp=q[Or],Op=fu&a,Rx=fu===Ce;ji&&Bp===ji._level?(ji._end=Or,ji._endsWithIsolInit=Op):_a.push(ji={_start:Or,_end:Or,_level:Bp,_startsWithPDI:Rx,_endsWithIsolInit:Op})}}for(var mu=[],No=0;No<_a.length;No++){var Uo=_a[No];if(!Uo._startsWithPDI||Uo._startsWithPDI&&!ve.has(Uo._start)){for(var gu=[ji=Uo],jp=void 0;ji&&ji._endsWithIsolInit&&(jp=ve.get(ji._end))!=null;)for(var $o=No+1;$o<_a.length;$o++)if(_a[$o]._start===jp){gu.push(ji=_a[$o]);break}for(var ya=[],_u=0;_u<gu.length;_u++)for(var Vp=gu[_u],yu=Vp._start;yu<=Vp._end;yu++)ya.push(yu);for(var Lx=q[ya[0]],Np=ne.level,Go=ya[0]-1;Go>=0;Go--)if(!(V[Go]&s)){Np=q[Go];break}var vu=ya[ya.length-1],Bx=q[vu],Up=ne.level;if(!(V[vu]&a)){for(var Zo=vu+1;Zo<=ne.end;Zo++)if(!(V[Zo]&s)){Up=q[Zo];break}}mu.push({_seqIndices:ya,_sosType:Math.max(Np,Lx)%2?T:w,_eosType:Math.max(Up,Bx)%2?T:w})}}for(var xu=0;xu<mu.length;xu++){var bu=mu[xu],re=bu._seqIndices,cn=bu._sosType,Ox=bu._eosType,va=q[re[0]]&1?T:w;if(te.get(R))for(var qo=0;qo<re.length;qo++){var $p=re[qo];if(V[$p]&R){for(var wu=cn,Wo=qo-1;Wo>=0;Wo--)if(!(V[re[Wo]]&s)){wu=V[re[Wo]];break}ae($p,wu&(a|Ce)?D:wu)}}if(te.get(S))for(var Ho=0;Ho<re.length;Ho++){var Gp=re[Ho];if(V[Gp]&S)for(var Xo=Ho-1;Xo>=-1;Xo--){var Zp=Xo===-1?cn:V[re[Xo]];if(Zp&n){Zp===k&&ae(Gp,A);break}}}if(te.get(k))for(var Tu=0;Tu<re.length;Tu++){var qp=re[Tu];V[qp]&k&&ae(qp,T)}if(te.get(C)||te.get(L))for(var dn=1;dn<re.length-1;dn++){var Du=re[dn];if(V[Du]&(C|L)){for(var xa=0,Su=0,Eu=dn-1;Eu>=0&&(xa=V[re[Eu]],xa&s);Eu--);for(var Cu=dn+1;Cu<re.length&&(Su=V[re[Cu]],Su&s);Cu++);xa===Su&&(V[Du]===C?xa===S:xa&(S|A))&&ae(Du,xa)}}if(te.get(S)){for(var Vi=0;Vi<re.length;Vi++)if(V[re[Vi]]&S){for(var Yo=Vi-1;Yo>=0&&V[re[Yo]]&(F|s);Yo--)ae(re[Yo],S);for(Vi++;Vi<re.length&&V[re[Vi]]&(F|s|S);Vi++)V[re[Vi]]!==S&&ae(re[Vi],S)}}if(te.get(F)||te.get(C)||te.get(L))for(var pn=0;pn<re.length;pn++){var Wp=re[pn];if(V[Wp]&(F|C|L)){ae(Wp,D);for(var Ko=pn-1;Ko>=0&&V[re[Ko]]&s;Ko--)ae(re[Ko],D);for(var Jo=pn+1;Jo<re.length&&V[re[Jo]]&s;Jo++)ae(re[Jo],D)}}if(te.get(S))for(var Pu=0,Hp=cn;Pu<re.length;Pu++){var Xp=re[Pu],Au=V[Xp];Au&S?Hp===w&&ae(Xp,w):Au&n&&(Hp=Au)}if(te.get(o)){for(var fn=T|S|A,Yp=fn|w,Qo=[],ba=[],wa=0;wa<re.length;wa++)if(V[re[wa]]&o){var mn=H[re[wa]],Kp=void 0;if(v(mn)!==null)if(ba.length<63)ba.push({char:mn,seqIndex:wa});else break;else if((Kp=x(mn))!==null)for(var gn=ba.length-1;gn>=0;gn--){var Mu=ba[gn].char;if(Mu===Kp||Mu===x(b(mn))||v(b(Mu))===mn){Qo.push([ba[gn].seqIndex,wa]),ba.length=gn;break}}}Qo.sort(function(Ut,bi){return Ut[0]-bi[0]});for(var Iu=0;Iu<Qo.length;Iu++){for(var Jp=Qo[Iu],es=Jp[0],Fu=Jp[1],Qp=!1,Ni=0,zu=es+1;zu<Fu;zu++){var ef=re[zu];if(V[ef]&Yp){Qp=!0;var tf=V[ef]&fn?T:w;if(tf===va){Ni=tf;break}}}if(Qp&&!Ni){Ni=cn;for(var ku=es-1;ku>=0;ku--){var rf=re[ku];if(V[rf]&Yp){var af=V[rf]&fn?T:w;Ni=af===va?va:af;break}}}if(Ni){if(V[re[es]]=V[re[Fu]]=Ni,Ni!==va){for(var _n=es+1;_n<re.length;_n++)if(!(V[re[_n]]&s)){c(H[re[_n]])&R&&(V[re[_n]]=Ni);break}}if(Ni!==va){for(var yn=Fu+1;yn<re.length;yn++)if(!(V[re[yn]]&s)){c(H[re[yn]])&R&&(V[re[yn]]=Ni);break}}}}for(var _r=0;_r<re.length;_r++)if(V[re[_r]]&o){for(var nf=_r,Ru=_r,Lu=cn,vn=_r-1;vn>=0;vn--)if(V[re[vn]]&s)nf=vn;else{Lu=V[re[vn]]&fn?T:w;break}for(var of=Ox,xn=_r+1;xn<re.length;xn++)if(V[re[xn]]&(o|s))Ru=xn;else{of=V[re[xn]]&fn?T:w;break}for(var Bu=nf;Bu<=Ru;Bu++)V[re[Bu]]=Lu===of?Lu:va;_r=Ru}}}for(var Jt=ne.start;Jt<=ne.end;Jt++){var jx=q[Jt],ts=V[Jt];if(jx&1?ts&(w|S|A)&&q[Jt]++:ts&T?q[Jt]++:ts&(A|S)&&(q[Jt]+=2),ts&s&&(q[Jt]=Jt===0?ne.level:q[Jt-1]),Jt===ne.end||c(H[Jt])&(E|I))for(var is=Jt;is>=0&&c(H[is])&l;is--)q[is]=ne.level}}return{levels:q,paragraphs:be};function sf(Ut,bi){for(var $t=Ut;$t<H.length;$t++){var yr=V[$t];if(yr&(T|k))return 1;if(yr&(I|w)||bi&&yr===Ce)return 0;if(yr&a){var lf=Vx($t);$t=lf===-1?H.length:lf}}return 0}function Vx(Ut){for(var bi=1,$t=Ut+1;$t<H.length;$t++){var yr=V[$t];if(yr&I)break;if(yr&Ce){if(--bi===0)return $t}else yr&a&&bi++}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",Yt;function Nt(){if(!Yt){var H=f(yt,!0),xe=H.map;H.reverseMap.forEach(function(ie,V){xe.set(V,ie)}),Yt=xe}}function zt(H){return Nt(),Yt.get(H)||null}function Xe(H,xe,ie,V){var ye=H.length;ie=Math.max(0,ie==null?0:+ie),V=Math.min(ye-1,V==null?ye-1:+V);for(var te=new Map,ae=ie;ae<=V;ae++)if(xe[ae]&1){var q=zt(H[ae]);q!==null&&te.set(ae,q)}return te}function Kt(H,xe,ie,V){var ye=H.length;ie=Math.max(0,ie==null?0:+ie),V=Math.min(ye-1,V==null?ye-1:+V);var te=[];return xe.paragraphs.forEach(function(ae){var q=Math.max(ie,ae.start),ve=Math.min(V,ae.end);if(q<ve){for(var be=xe.levels.slice(q,ve+1),ne=ve;ne>=q&&c(H[ne])&l;ne--)be[ne]=ae.level;for(var Ze=ae.level,Br=1/0,tr=0;tr<be.length;tr++){var Bi=be[tr];Bi>Ze&&(Ze=Bi),Bi<Br&&(Br=Bi|1)}for(var Oi=Ze;Oi>=Br;Oi--)for(var Oe=0;Oe<be.length;Oe++)if(be[Oe]>=Oi){for(var Le=Oe;Oe+1<be.length&&be[Oe+1]>=Oi;)Oe++;Oe>Le&&te.push([Le+q,Oe+q])}}}),te}function vi(H,xe,ie,V){var ye=Li(H,xe,ie,V),te=[].concat(H);return ye.forEach(function(ae,q){te[q]=(xe.levels[ae]&1?zt(H[ae]):null)||H[ae]}),te.join("")}function Li(H,xe,ie,V){for(var ye=Kt(H,xe,ie,V),te=[],ae=0;ae<H.length;ae++)te[ae]=ae;return ye.forEach(function(q){for(var ve=q[0],be=q[1],ne=te.slice(ve,be+1),Ze=ne.length;Ze--;)te[be-Ze]=ne[Ze]}),te}return e.closingToOpeningBracket=x,e.getBidiCharType=c,e.getBidiCharTypeName=d,e.getCanonicalBracket=b,e.getEmbeddingLevels=mt,e.getMirroredCharacter=zt,e.getMirroredCharactersMap=Xe,e.getReorderSegments=Kt,e.getReorderedIndices=Li,e.getReorderedString=vi,e.openingToClosingBracket=v,Object.defineProperty(e,"__esModule",{value:!0}),e})({})}const Yd=bE(),wE=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/,TE=new Set(["WS","FSI","LRI","RLI","PDI"]),DE=new Set(["S","B"]);function SE(e,t,i,r){let a=[],n=i;for(let o of Bc(e.slice(i,r)))a.push({index:n,text:o,level:t[n]}),n+=o.length;return a}function EE(e,t){let i=!0;for(let r=e.length-1;r>=0;r--){let a=Yd.getBidiCharTypeName(e[r].text[0]);DE.has(a)?(e[r].level=t,i=!0):i&&TE.has(a)?e[r].level=t:i=!1}}function CE(e,t){let i=t,r=1/0;for(let{level:n}of e)n>i&&(i=n),(n|1)<r&&(r=n|1);let a=e.slice();for(let n=i;n>=r;n--)for(let o=0;o<a.length;o++){if(a[o].level<n)continue;let s=o;for(;s+1<a.length&&a[s+1].level>=n;)s++;for(let l=o,u=s;l<u;l++,u--)[a[l],a[u]]=[a[u],a[l]];o=s}return a}function PE(e){var t;return e.level%2==0?e.text:(t=Yd.getMirroredCharacter(e.text))!=null?t:e.text}function AE(e,t){var i,r;return(r=(i=e.find(a=>t>=a.start&&t<=a.end))==null?void 0:i.level)!=null?r:0}function ME(e,t,i,r,a){let n=SE(e,t,r,a);EE(n,i);let o="",s=[];for(let l of CE(n,i)){if(wE.test(l.text))continue;let u=PE(l);o+=u,s.push(...Array(u.length).fill(l.index))}return{text:o,sourceIndices:s}}function IE(e,t){let i=t.filter(n=>n>0&&n<e.length),r=[...new Set([0,...i,e.length])].sort((n,o)=>n-o),a=[];for(let n=0;n+1<r.length;n++)a.push([r[n],r[n+1]]);return a}function T1(e,t){let{levels:i,paragraphs:r}=Yd.getEmbeddingLevels(e);return IE(e,t.concat(r.map(a=>a.start))).map(([a,n])=>ME(e,i,AE(r,a),a,n))}function FE(e,t){return T1(e,t).map(i=>i.text)}function zE(e,t,i){return T1(e,i).map(r=>[r.text,r.sourceIndices.map(a=>{var n;return(n=t[a])!=null?n:0})])}const Bm=4294967296,Om=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var D1=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,i=this.length){let r;for(;r=this.nextField(i);)e(r,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)*Bm;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Bm;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,i=t[this.pos++];if(i<128)return i;let r=i&127,a;return a=t[this.pos++],r|=(a&127)<<7,a<128||(a=t[this.pos++],r|=(a&127)<<14,a<128)||(a=t[this.pos++],r|=(a&127)<<21,a<128)?r:(a=t[this.pos],r|=(a&15)<<28,kE(r,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&&Om?Om.decode(this.buf.subarray(t,e)):LE(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 i=this.readPackedEnd();for(;this.pos<i;)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 kE(e,t,i){let r=i.buf,a,n;if(n=r[i.pos++],a=(n&112)>>4,n<128||(n=r[i.pos++],a|=(n&127)<<3,n<128)||(n=r[i.pos++],a|=(n&127)<<10,n<128)||(n=r[i.pos++],a|=(n&127)<<17,n<128)||(n=r[i.pos++],a|=(n&127)<<24,n<128)||(n=r[i.pos++],a|=(n&1)<<31,n<128))return RE(e,a,t);throw Error("Expected varint not more than 10 bytes")}function RE(e,t,i){return i?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function LE(e,t,i){let r="",a=t;for(;a<i;){let n=e[a],o=null,s=n>239?4:n>223?3:n>191?2:1;if(a+s>i)break;let l,u,h;s===1?n<128&&(o=n):s===2?(l=e[a+1],(l&192)==128&&(o=(n&31)<<6|l&63,o<=127&&(o=null))):s===3?(l=e[a+1],u=e[a+2],(l&192)==128&&(u&192)==128&&(o=(n&15)<<12|(l&63)<<6|u&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):s===4&&(l=e[a+1],u=e[a+2],h=e[a+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(o=(n&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,s=1):o>65535&&(o-=65536,r+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),r+=String.fromCharCode(o),a+=s}return r}function BE(e,t,i){e===1&&i.readMessage(OE,t)}function OE(e,t,i){if(e===3){let{id:r,bitmap:a,width:n,height:o,left:s,top:l,advance:u}=i.readMessage(jE,{});t.push({id:r,bitmap:new Zd({width:n+6,height:o+6},a),metrics:{width:n,height:o,left:s,top:l,advance:u}})}}function jE(e,t,i){e===1?t.id=i.readVarint():e===2?t.bitmap=i.readBytes():e===3?t.width=i.readVarint():e===4?t.height=i.readVarint():e===5?t.left=i.readSVarint():e===6?t.top=i.readSVarint():e===7&&(t.advance=i.readVarint())}function VE(e){return new D1(e).readFields(BE,[])}function wl(e){return typeof(e==null?void 0:e.renderWithWebGL)=="function"}function NE(e){let{userImage:t}=e;return!(t!=null&&t.render)||!t.render()?!1:(wl(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),!0)}function S1(e){let t=0,i=0;for(let o of e)t+=o.w*o.h,i=Math.max(i,o.w);e.sort((o,s)=>s.h-o.h);let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}],a=0,n=0;for(let o of e)for(let s=r.length-1;s>=0;s--){let l=r[s];if(!(o.w>l.w||o.h>l.h)){if(o.x=l.x,o.y=l.y,n=Math.max(n,o.y+o.h),a=Math.max(a,o.x+o.w),o.w===l.w&&o.h===l.h){let u=r.pop();u&&s<r.length&&(r[s]=u)}else o.h===l.h?(l.x+=o.w,l.w-=o.w):o.w===l.w?(l.y+=o.h,l.h-=o.h):(r.push({x:l.x+o.w,y:l.y,w:l.w-o.w,h:o.h}),l.y+=o.h,l.h-=o.h);break}}return{w:a,h:n,fill:t/(a*n)||0}}var Kd=class{constructor(e,{pixelRatio:t,version:i,isWebGLImage:r=!1,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=a,this.stretchY=n,this.content=o,this.version=i,this.needsFirstWebGLRender=r,this.textFitWidth=s,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]}},UE=class{constructor(e,t){let i={},r={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let a=[];this.addImages(e,i,a),this.addImages(t,r,a);let{w:n,h:o}=S1(a),s=new Ne({width:n||1,height:o||1});for(let l in e){let u=e[l];if(u.isWebGLImage)continue;let h=i[l].paddedRect;Ne.copy(u.data,s,{x:0,y:0},{x:h.x+1,y:h.y+1},u.data)}for(let l in t){let u=t[l],h=r[l].paddedRect,c=h.x+1,d=h.y+1,p=u.data.width,f=u.data.height;Ne.copy(u.data,s,{x:0,y:0},{x:c,y:d},u.data),Ne.copy(u.data,s,{x:0,y:f-1},{x:c,y:d-1},{width:p,height:1}),Ne.copy(u.data,s,{x:0,y:0},{x:c,y:d+f},{width:p,height:1}),Ne.copy(u.data,s,{x:p-1,y:0},{x:c-1,y:d},{width:1,height:f}),Ne.copy(u.data,s,{x:0,y:0},{x:c+p,y:d},{width:1,height:f})}this.image=s,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(let r in e){let a=e[r],n={x:0,y:0,w:a.data.width+2,h:a.data.height+2};i.push(n),t[r]=new Kd(n,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){if(e.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==e.updateVersion){this.patchedUpdateVersion=e.updateVersion;for(let i in this.iconPositions)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t);for(let i in this.patternPositions)this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}}patchUpdatedImage(e,t,i){var l;if(!e||!t||!e.needsFirstWebGLRender&&e.version===t.version)return;e.needsFirstWebGLRender=!1,e.version=t.version;let[r,a]=e.tl,n=(l=t.userImage)==null?void 0:l.data;if(!wl(n)){i.update(t.data,void 0,{x:r,y:a});return}let{width:o,height:s}=t.data;i.context.setCustomLayerDefaults(),n.renderWithWebGL({gl:i.context.gl,texture:i.texture,x:r,y:a,width:o,height:s}),i.context.setDirty()}};G("ImagePosition",Kd),G("ImageAtlas",UE);var E1=(function(e){return e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly",e})(E1||{});function $E(e){for(let t of e)if(t.positionedGlyphs.length!==0)return!1;return!0}function GE(e,t){let i=[],r=0;for(let a of t)i.push(e.substring(r,a)),r=a;return r<e.length()&&i.push(e.substring(r,e.length())),i}const jm=/^\p{gc=M}$/u;function ZE(e){let t=[],i=0;for(;i<e.length;){if(!jm.test(e[i])){t.push(i),i++;continue}let r=i;for(;r<e.length&&jm.test(e[r]);)r++;let a=e[r];if(a!==void 0&&x1(a.codePointAt(0))){t.push(r);for(let n=r-1;n>=i;n--)t.push(n);i=r+1}else{for(let n=i;n<r;n++)t.push(n);i=r}}return t}function qE(e){let t=[],i=0;for(let r of e.graphemes())t.push(...Array(r.length).fill(e.sectionIndex[i])),i++;return t}function WE(e,t){let i=t.map(n=>e.toCodeUnitIndex(n)),r=bl.isParsed()?bl:null;if(e.sections.length===1)return r?r.processBidirectionalText(e.toString(),i).map(n=>Vm(n,e.sections,[...n].map(()=>0))):FE(e.toString(),i).map(n=>Vc([...n],e.sections,[...n].map(()=>0)));let a=qE(e);return r?r.processStyledBidirectionalText(e.text,a,i).map(([n,o])=>Vm(n,e.sections,o)):zE(e.text,a,i).map(([n,o])=>{let s=[...n];return Vc(s,e.sections,C1(s).map(l=>{var u;return(u=o[l])!=null?u:0}))})}function Vc(e,t,i){var n;let r=new Xd(e.join(""),t,[]),a=0;for(let o of r.graphemes())r.sectionIndex.push((n=i[a])!=null?n:0),a+=[...o].length;return r}function C1(e){let t=[],i=0;for(let r of e)t.push(i),i+=r.length;return t}function Vm(e,t,i){let r=[...e],a=C1(r),n=ZE(r);return Vc(n.map(o=>r[o]),t,n.map(o=>{var s;return(s=i[a[o]])!=null?s:0}))}function vs(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f){let m=Xd.fromFeature(e,a,c===2,t),g=m.determineLineBreaks(u,n,t,r,p),_=b1(m.text)?WE(m,g):GE(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 JE(v,t,i,r,_,o,s,l,c,u,d,f),!$E(y)&&v}function ru(e){let t=.5,i=.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":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function HE(e,t,i){let r=t.getMaxScale()*24,{maxImageWidth:a,maxImageHeight:n}=t.getMaxImageSize(e),o=Math.max(r,n*i);return{verticalLineContentWidth:Math.max(r,a*i),horizontalLineContentHeight:o}}function P1(e){switch(e){case"top":return 0;case"center":return .5;default:return 1}}function XE(e,t){return e!=null&&e.rect?e:t?{rect:null,metrics:t.metrics}:null}function A1(e,t,i){return!(e===1||!t&&!zo(i)||t&&(bo(i)||v1(i)))}function Us(e){return/\p{Nd}/u.test(String.fromCodePoint(e))}function M1(e){return/\p{Lu}/u.test(String.fromCodePoint(e))}function I1(e){let t=e.some(Us)&&e.every(r=>Us(r)||iu(r)),i=e.length<=3&&e.every(r=>M1(r)||Us(r));return t||i}function F1(e){return(Us(e)||M1(e))&&!v1(e)}function YE(e,t){return t?A1(2,!0,e):!an(e)||F1(e)||iu(e)}function KE(e,t,i){let r=!1;for(let a=0;a<e.length;a++){if(t[a])continue;let n=La[e[a]];if(n&&(a===0||t[a-1])&&(a===e.length-1||t[a+1])){if(t[a]=!0,i[a])continue;e[a]=n,r=!0}}return r}function Nm(e,t,i){for(;t>=0&&t<e.length&&bo(e[t]);)t+=i;let r=[];for(;t>=0&&t<e.length&&!zo(e[t])&&!bo(e[t]);)r.push(e[t]),t+=i;return!I1(r)&&!r.every(iu)&&r.some(an)}function z1(e,t){let i=e.graphemes().slice(),r=i.map(s=>s.codePointAt(0)),a=i.map((s,l)=>{var h,c;let u=e.getSection(l);return"fontStack"in u&&!!((c=(h=t[u.fontStack])==null?void 0:h.vertical)!=null&&c[s])}),n=r.map(zo),o=s=>!n[s]&&!bo(r[s])&&!("imageName"in e.getSection(s));for(let s=0;s<r.length;s++){if(!o(s))continue;let l=s;for(;l+1<r.length&&o(l+1);)l++;let u=r.slice(s,l+1),h=I1(u),c=u.every(iu),d=c&&(Nm(r,s-1,-1)||Nm(r,l+1,1)),p=!h&&u.some(an);for(let f=s;f<=l;f++)n[f]=h&&F1(r[f])||a[f]&&!d&&(c||!p&&!an(r[f]));s=l}if(a.some((s,l)=>s&&!n[l])){let s=e.text;if(e.verticalizePunctuation(t,n),e.text!==s)return z1(e,t)}return KE(i,n,a)&&(e.text=i.join(""),e.cachedGraphemes=i),n}function JE(e,t,i,r,a,n,o,s,l,u,h,c){var b,w;let d=0,p=0,f=0,m=0,g=s==="right"?1:s==="left"?0:.5,_=24/c,y=0;for(let T of a){T.trim();let S=T.getMaxScale(),C={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=C;let F=C.positionedGlyphs,A=0;if(!T.length()){p+=n,++y;continue}let L=HE(r,T,_),I=l===2&&!h?z1(T,t):null,E=T.graphemes();for(let R=0;R<E.length;R++){let k=T.getSection(R),B=E[R],Z=B.codePointAt(0),oe=I?I[R]:A1(l,h,Z),pe="fontStack"in k&&xo(B)&&!((w=(b=t[k.fontStack])==null?void 0:b.default)!=null&&w[B])?[...B]:[B];for(let fe of pe){let Ee={glyph:fe.codePointAt(0),grapheme:fe,imageName:null,x:d,y:p+-17,vertical:oe,scale:1,fontStack:"",sectionIndex:T.getSectionIndex(R),metrics:null,rect:null},Te;if("fontStack"in k){if(Te=QE(k,fe,oe,L,t,i),!Te)continue;Ee.fontStack=k.fontStack}else{if(e.iconsInText=!0,k.scale*=_,Te=eC(k,oe,S,L,r),!Te)continue;A=Math.max(A,Te.imageOffset),Ee.imageName=k.imageName}let{rect:Ge,metrics:Ce,baselineOffset:mt}=Te;if(Ee.y+=mt,Ee.scale=k.scale,Ee.metrics=Ce,Ee.rect=Ge,F.push(Ee),!oe)d+=Ce.advance*k.scale+u;else{e.verticalizable=!0;let yt="imageName"in k?Ce.advance:24;d+=yt*k.scale+u}}}if(F.length!==0){let R=d-u;f=Math.max(R,f),tC(F,0,F.length-1,g)}d=0;let D=(S-1)*24;C.lineOffset=Math.max(A,D);let P=n*S+A;p+=P,m=Math.max(P,m),++y}let{horizontalAlign:v,verticalAlign:x}=ru(o);iC(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 QE(e,t,i,r,a,n){var c,d,p,f,m,g;let o=i&&((d=(c=a[e.fontStack])==null?void 0:c.vertical)!=null&&d[t])?"vertical":"default",s=(f=(p=n[e.fontStack])==null?void 0:p[o])==null?void 0:f[t],l=(g=(m=a[e.fontStack])==null?void 0:m[o])==null?void 0:g[t],u=XE(s,l);if(u===null)return null;let h;if(i)h=r.verticalLineContentWidth-e.scale*24;else{let _=P1(e.verticalAlign);h=(r.horizontalLineContentHeight-e.scale*24)*_}return{rect:u.rect,metrics:u.metrics,baselineOffset:h}}function eC(e,t,i,r,a){let n=a[e.imageName];if(!n)return null;let o=n.paddedRect,s=n.displaySize,l={width:s[0],height:s[1],left:1,top:-3,advance:t?s[1]:s[0]},u;if(t)u=r.verticalLineContentWidth-s[1]*e.scale;else{let c=P1(e.verticalAlign);u=(r.horizontalLineContentHeight-s[1]*e.scale)*c}let h=(t?s[0]:s[1])*e.scale-24*i;return{rect:o,metrics:l,baselineOffset:u,imageOffset:h}}function tC(e,t,i,r){if(r===0)return;let a=e[i],n=a.metrics.advance*a.scale,o=(e[i].x+n)*r;for(let s=t;s<=i;s++)e[s].x-=o}function iC(e,t,i,r,a,n,o,s,l){let u=(t-i)*a,h=0;h=n===o?-r*l*o+.5*o:-s*r- -17;for(let c of e)for(let d of c.positionedGlyphs)d.x+=u,d.y+=h}function rC(e,t,i){let{horizontalAlign:r,verticalAlign:a}=ru(i),n=t[0],o=t[1],s=n-e.displaySize[0]*r,l=s+e.displaySize[0],u=o-e.displaySize[1]*a;return{image:e,top:u,bottom:u+e.displaySize[1],left:s,right:l}}function k1(e){var h,c;let t=e.left,i=e.top,r=e.right-t,a=e.bottom-i,n=e.image.content[2]-e.image.content[0],o=e.image.content[3]-e.image.content[1],s=(h=e.image.textFitWidth)!=null?h:"stretchOrShrink",l=(c=e.image.textFitHeight)!=null?c:"stretchOrShrink",u=n/o;if(l==="proportional"){if(s==="stretchOnly"&&r/a<u||s==="proportional"){let d=Math.ceil(a*u);t*=d/r,r=d}}else if(s==="proportional"&&l==="stretchOnly"&&u!==0&&r/a>u){let d=Math.ceil(r/u);i*=d/a,a=d}return{x1:t,y1:i,x2:t+r,y2:i+a}}function Um(e,t,i,r,a,n){let o=e.image,s;if(o.content){let g=o.content,_=o.pixelRatio||1;s=[g[0]/_,g[1]/_,o.displaySize[0]-g[2]/_,o.displaySize[1]-g[3]/_]}let l=t.left*n,u=t.right*n,h,c,d,p;i==="width"||i==="both"?(p=a[0]+l-r[3],c=a[0]+u+r[1]):(p=a[0]+(l+u-o.displaySize[0])/2,c=p+o.displaySize[0]);let f=t.top*n,m=t.bottom*n;return i==="height"||i==="both"?(h=a[1]+f-r[0],d=a[1]+m+r[2]):(h=a[1]+(f+m-o.displaySize[1])/2,d=h+o.displaySize[1]),{image:o,top:h,right:c,bottom:d,left:p,collisionPadding:s}}const $m=32640;function Gm(e,t){let{expression:i}=t;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new Ie(e+1))};if(i.kind==="source")return{kind:"source"};if(i.kind==="composite"){let{minZoom:r,maxZoom:a}=aC(i.zoomStops,e);return{kind:"composite",minZoom:r,maxZoom:a,interpolationType:i.interpolationType}}{let r=nC(i),a=i.evaluate(new Ie(e+1));return{kind:"camera",zoomStops:i.zoomStops,sizes:r,layoutSize:a,interpolationType:i.interpolationType}}}function aC(e,t){let i=0;for(;i<e.length&&e[i]<=t;)i++;i=Math.max(0,i-1);let r=i;for(;r<e.length&&e[r]<t+1;)r++;return r=Math.min(e.length-1,r),{minZoom:e[i],maxZoom:e[r]}}function nC(e){return e.zoomStops.map(t=>e.evaluate(new Ie(t===-1/0?e.zoomStops[1]-1:t)))}function Jd(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:a}){return e.kind==="source"?r/128:e.kind==="composite"?We.number(r/128,a/128,i):t}function au(e,t){let i=0,r=0;return e.kind==="constant"?r=e.layoutSize:e.kind==="camera"?r=oC(e,t):e.kind==="composite"&&(i=sC(e,t)),{uSizeT:i,uSize:r}}function oC({zoomStops:e,sizes:t,layoutSize:i,interpolationType:r},a){let n=e.length-1;for(;n>0&&e[n]>a;)n--;let o=Math.min(n+1,e.length-1),s=r?Y(yi.interpolationFactor(r,a,e[n],e[o]),0,1):0;return Math.min(We.number(t[n],t[o],s),i)}function sC({interpolationType:e,minZoom:t,maxZoom:i},r){return e?Y(yi.interpolationFactor(e,r,t,i),0,1):0}var Ua=class R1 extends M{constructor(t,i,r,a){super(t,i),this.angle=r,a!==void 0&&(this.segment=a)}clone(){return new R1(this.x,this.y,this.angle,this.segment)}};G("Anchor",Ua);function L1(e,t,i,r,a){if(t.segment===void 0||i===0)return!0;let n=t,o=t.segment+1,s=0;for(;s>-i/2;){if(o--,o<0)return!1;s-=e[o].dist(n),n=e[o]}s+=e[o].dist(e[o+1]),o++;let l=[],u=0;for(;s<i/2;){let h=e[o-1],c=e[o],d=e[o+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:s,angleDelta:p}),u+=p;s-l[0].distance>r;)u-=l.shift().angleDelta;if(u>a)return!1;o++,s+=c.dist(d)}return!0}function B1(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function O1(e,t,i){return e?3/5*t*i:0}function j1(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function lC(e,t,i,r,a,n){let o=O1(i,a,n),s=j1(i,r)*n,l=0,u=B1(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 Ua(We.number(c.x,d.x,f),We.number(c.y,d.y,f),d.angleTo(c),h);return m._round(),!o||L1(e,m,s,o,t)?m:void 0}l+=p}}function uC(e,t,i,r,a,n,o,s,l){let u=O1(r,n,o),h=j1(r,a),c=h*o,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 V1(e,d?t/2*s%t:(h/2+p)*o*s%t,t,u,i,c,d,!1,l)}function V1(e,t,i,r,a,n,o,s,l){let u=n/2,h=B1(e),c=0,d=t-i,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+i<c+_;){d+=i;let v=(d-c)/_,x=We.number(m.x,g.x,v),b=We.number(m.y,g.y,v);if(x>=0&&x<l&&b>=0&&b<l&&d-u>=0&&d+u<=h){let w=new Ua(x,b,y,f);w._round(),(!r||L1(e,w,n,r,a))&&p.push(w)}}c+=_}return!s&&!p.length&&!o&&(p=V1(e,c/2,i,r,a,n,o,!0,l)),p}function N1(e,t,i,r,a){let n=[];for(let o of e){let s;for(let l=0;l<o.length-1;l++){let u=o[l],h=o[l+1];u.x<t&&h.x<t||(u.x<t?u=new M(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round():h.x<t&&(h=new M(t,u.y+(h.y-u.y)*((t-u.x)/(h.x-u.x)))._round()),!(u.y<i&&h.y<i)&&(u.y<i?u=new M(u.x+(h.x-u.x)*((i-u.y)/(h.y-u.y)),i)._round():h.y<i&&(h=new M(u.x+(h.x-u.x)*((i-u.y)/(h.y-u.y)),i)._round()),!(u.x>=r&&h.x>=r)&&(u.x>=r?u=new M(r,u.y+(h.y-u.y)*((r-u.x)/(h.x-u.x)))._round():h.x>=r&&(h=new M(r,u.y+(h.y-u.y)*((r-u.x)/(h.x-u.x)))._round()),!(u.y>=a&&h.y>=a)&&(u.y>=a?u=new M(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round():h.y>=a&&(h=new M(u.x+(h.x-u.x)*((a-u.y)/(h.y-u.y)),a)._round()),(!s||!u.equals(s[s.length-1]))&&(s=[u],n.push(s)),s.push(h)))))}}return n}function Zm(e,t,i,r){let a=[],n=e.image,o=n.pixelRatio,s=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,s]],c=n.stretchY||[[0,l]],d=(E,D)=>E+D[1]-D[0],p=h.reduce(d,0),f=c.reduce(d,0),m=s-p,g=l-f,_=0,y=p,v=0,x=f,b=0,w=m,T=0,S=g;if(n.content&&r){let E=n.content,D=E[2]-E[0],P=E[3]-E[1];(n.textFitWidth||n.textFitHeight)&&(u=k1(e)),_=xs(h,0,E[0]),v=xs(c,0,E[1]),y=xs(h,E[0],E[2]),x=xs(c,E[1],E[3]),b=E[0]-_,T=E[1]-v,w=D-y,S=P-x}let C=u.x1,F=u.y1,A=u.x2-C,L=u.y2-F,I=(E,D,P,R)=>{let k=bs(E.stretch-_,y,A,C),B=ws(E.fixed-b,w,E.stretch,p),Z=bs(D.stretch-v,x,L,F),oe=ws(D.fixed-T,S,D.stretch,f),pe=bs(P.stretch-_,y,A,C),fe=ws(P.fixed-b,w,P.stretch,p),Ee=bs(R.stretch-v,x,L,F),Te=ws(R.fixed-T,S,R.stretch,f),Ge=new M(k,Z),Ce=new M(pe,Z),mt=new M(pe,Ee),yt=new M(k,Ee),Yt=new M(B/o,oe/o),Nt=new M(fe/o,Te/o),zt=t*Math.PI/180;if(zt){let H=Math.sin(zt),xe=Math.cos(zt),ie=[xe,-H,H,xe];Ge._matMult(ie),Ce._matMult(ie),yt._matMult(ie),mt._matMult(ie)}let Xe=E.stretch+E.fixed,Kt=P.stretch+P.fixed,vi=D.stretch+D.fixed,Li=R.stretch+R.fixed;return{tl:Ge,tr:Ce,bl:yt,br:mt,tex:{x:n.paddedRect.x+1+Xe,y:n.paddedRect.y+1+vi,w:Kt-Xe,h:Li-vi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Yt,pixelOffsetBR:Nt,minFontScaleX:w/o/A,minFontScaleY:S/o/L,isSDF:i}};if(!r||!n.stretchX&&!n.stretchY)a.push(I({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:s+1},{fixed:0,stretch:l+1}));else{let E=qm(h,m,p),D=qm(c,g,f);for(let P=0;P<E.length-1;P++){let R=E[P],k=E[P+1];for(let B=0;B<D.length-1;B++){let Z=D[B],oe=D[B+1];a.push(I(R,Z,k,oe))}}}return a}function xs(e,t,i){let r=0;for(let a of e)r+=Math.max(t,Math.min(i,a[1]))-Math.max(t,Math.min(i,a[0]));return r}function qm(e,t,i){let r=[{fixed:-1,stretch:0}];for(let[a,n]of e){let o=r[r.length-1];r.push({fixed:a-o.stretch,stretch:o.stretch}),r.push({fixed:a-o.stretch,stretch:o.stretch+(n-a)})}return r.push({fixed:t+1,stretch:i}),r}function bs(e,t,i,r){return e/t*i+r}function ws(e,t,i,r){return e-t*i/r}function hC(e,t,i,r,a,n,o,s){let l=r.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||s)&&c.vertical,y=c.metrics.advance*c.scale/2;if(s&&t.verticalizable){let R=(c.scale-1)*24,k=(24-c.metrics.width*c.scale)/2;g=h.lineOffset/2-(c.imageName?-k:R)}if(c.imageName){let R=o[c.imageName];f=R.sdf,m=R.pixelRatio,p=1/m}let v=a?[c.x+y,c.y]:[0,0],x=a?[0,0]:[c.x+y+i[0],c.y+i[1]-g],b=[0,0];_&&(b=x,x=[0,0]);let w=c.metrics.isDoubleResolution?2:1,T=(c.metrics.left-p)*c.scale-y+x[0],S=(-c.metrics.top-p)*c.scale+x[1],C=T+d.w/w*c.scale/m,F=S+d.h/w*c.scale/m,A=new M(T,S),L=new M(C,S),I=new M(T,F),E=new M(C,F);if(_){let R=new M(-y,y- -17),k=-Math.PI/2,B=12-y,Z=c.imageName?B:0,oe=new M(22-B,-Z),pe=new M(...b);A._rotateAround(k,R)._add(oe)._add(pe),L._rotateAround(k,R)._add(oe)._add(pe),I._rotateAround(k,R)._add(oe)._add(pe),E._rotateAround(k,R)._add(oe)._add(pe)}if(l){let R=Math.sin(l),k=Math.cos(l),B=[k,-R,R,k];A._matMult(B),L._matMult(B),I._matMult(B),E._matMult(B)}let D=new M(0,0),P=new M(0,0);u.push({tl:A,tr:L,bl:I,br:E,tex:d,writingMode:t.writingMode,glyphOffset:v,sectionIndex:c.sectionIndex,isSDF:f,pixelOffsetTL:D,pixelOffsetBR:P,minFontScaleX:0,minFontScaleY:0})}return u}var Ts=class{constructor(e,t,i,r,a,n,o,s,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)?k1(n):{x1:n.left,y1:n.top,x2:n.right,y2:n.bottom};c.y1=c.y1*o-s[0],c.y2=c.y2*o+s[2],c.x1=c.x1*o-s[3],c.x2=c.x2*o+s[1];let d=n.collisionPadding;if(d&&(c.x1-=d[0]*o,c.y1-=d[1]*o,c.x2+=d[2]*o,c.y2+=d[3]*o),u){let p=new M(c.x1,c.y1),f=new M(c.x2,c.y1),m=new M(c.x1,c.y2),g=new M(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,i,r,a)}this.boxEndIndex=e.length}},cC=class{constructor(e=[],t=(i,r)=>i<r?-1:+(i>r)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(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:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(i(r,n)>=0)break;t[e]=n,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let n=(e<<1)+1,o=n+1;if(o<this.length&&i(t[o],t[n])<0&&(n=o),i(t[n],a)>=0)break;t[e]=t[n],e=n}t[e]=a}};function dC(e,t=1){let i=Mi.fromPoints(e[0]),r=Math.min(i.width(),i.height()),a=r/2,n=new cC([],pC),{minX:o,minY:s,maxX:l,maxY:u}=i;if(r===0)return new M(o,s);for(let d=o;d<l;d+=r)for(let p=s;p<u;p+=r)n.push(new ka(d+a,p+a,a,e));let h=mC(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 ka(d.p.x-a,d.p.y-a,a,e)),n.push(new ka(d.p.x+a,d.p.y-a,a,e)),n.push(new ka(d.p.x-a,d.p.y+a,a,e)),n.push(new ka(d.p.x+a,d.p.y+a,a,e)))}return h.d>0&&c.d-h.d<=t?h.p:c.p}function pC(e,t){return t.max-e.max}var ka=class{constructor(e,t,i,r){this.p=new M(e,t),this.h=i,this.d=fC(this.p,r),this.max=this.d+this.h*Math.SQRT2}};function fC(e,t){let i=!1,r=1/0;for(let a of t)for(let n=0,o=a.length,s=o-1;n<o;s=n++){let l=a[n],u=a[s];l.y>e.y!=u.y>e.y&&e.x<(u.x-l.x)*(e.y-l.y)/(u.y-l.y)+l.x&&(i=!i),r=Math.min(r,$0(e,l,u))}return(i?1:-1)*Math.sqrt(r)}function mC(e){let t=0,i=0,r=0,a=e[0];for(let n=0,o=a.length,s=o-1;n<o;s=n++){let l=a[n],u=a[s],h=l.x*u.y-u.x*l.y;i+=(l.x+u.x)*h,r+=(l.y+u.y)*h,t+=h*3}return new ka(i/t,r/t,0,e)}let Nc=(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 Qd=1/0;function U1(e,t){function i(a,n){let o=0,s=0;n<0&&(n=0);let l=n/Math.SQRT2;switch(a){case"top-right":case"top-left":s=l-7;break;case"bottom-right":case"bottom-left":s=-l+7;break;case"bottom":s=-n+7;break;case"top":s=n-7}switch(a){case"top-right":case"bottom-right":o=-l;break;case"top-left":case"bottom-left":o=l;break;case"left":o=n;break;case"right":o=-n}return[o,s]}function r(a,n,o){let s=0,l=0;switch(n=Math.abs(n),o=Math.abs(o),a){case"top-right":case"top-left":case"top":l=o-7;break;case"bottom-right":case"bottom-left":case"bottom":l=-o+7}switch(a){case"top-right":case"bottom-right":case"right":s=-n;break;case"top-left":case"bottom-left":case"left":s=n}return[s,l]}return t[1]===Qd?i(e,t[0]):r(e,t[0],t[1])}function $1(e,t,i){var o;let r=e.layout,a=(o=r.get("text-variable-anchor-offset"))==null?void 0:o.evaluate(t,{},i);if(a){let s=a.values,l=[];for(let u=0;u<s.length;u+=2){let h=l[u]=s[u],c=s[u+1].map(d=>d*24);h.startsWith("top")?c[1]-=7:h.startsWith("bottom")&&(c[1]+=7),l[u+1]=c}return new Xi(l)}let n=r.get("text-variable-anchor");if(n){let s;s=e._unevaluatedLayout.getValue("text-radial-offset")===void 0?r.get("text-offset").evaluate(t,{},i).map(u=>u*24):[r.get("text-radial-offset").evaluate(t,{},i)*24,Qd];let l=[];for(let u of n)l.push(u,U1(u,s));return new Xi(l)}return null}function gC(e){var h,c;e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=O/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let i=e.bucket.layers[0],r=i.layout,a=i._unevaluatedLayout._values,n={layoutIconSize:a["icon-size"].possiblyEvaluate(new Ie(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new Ie(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new Ie(18))};if(e.bucket.textSizeData.kind==="composite"){let{minZoom:d,maxZoom:p}=e.bucket.textSizeData;n.compositeTextSizes=[a["text-size"].possiblyEvaluate(new Ie(d),e.canonical),a["text-size"].possiblyEvaluate(new Ie(p),e.canonical)]}if(e.bucket.iconSizeData.kind==="composite"){let{minZoom:d,maxZoom:p}=e.bucket.iconSizeData;n.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new Ie(d),e.canonical),a["icon-size"].possiblyEvaluate(new Ie(p),e.canonical)]}let o=r.get("text-line-height")*24,s=r.get("text-rotation-alignment")!=="viewport"&&r.get("symbol-placement")!=="point",l=r.get("text-keep-upright"),u=r.get("text-size");for(let d of e.bucket.features){let p=r.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(),S=r.get("text-letter-spacing").evaluate(d,{},e.canonical)*24,C=mE(T)?S:0,F=r.get("text-anchor").evaluate(d,{},e.canonical),A=$1(i,d,e.canonical);if(!A){let D=r.get("text-radial-offset").evaluate(d,{},e.canonical);v=D?U1(F,[D*24,Qd]):r.get("text-offset").evaluate(d,{},e.canonical).map(P=>P*24)}let L=s?"center":r.get("text-justify").evaluate(d,{},e.canonical),I=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(d,{},e.canonical)*24:1/0,E=()=>{e.bucket.allowVerticalPlacement&&Oc(T)&&(_.vertical=vs(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,I,o,F,"left",C,v,2,!0,m,f))};if(!s&&A){let D=new Set;if(L==="auto")for(let R=0;R<A.values.length;R+=2)D.add(Uc(A.values[R]));else D.add(L);let P=!1;for(let R of D)if(!_.horizontal[R])if(P)_.horizontal[R]=_.horizontal[0];else{let k=vs(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,I,o,"center",R,C,v,1,!1,m,f);k&&(_.horizontal[R]=k,P=k.positionedLines.length===1)}E()}else{L==="auto"&&(L=Uc(F));let D=vs(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,I,o,F,L,C,v,1,!1,m,f);D&&(_.horizontal[L]=D),E(),Oc(T)&&s&&l&&(_.vertical=vs(y,e.glyphMap,e.glyphPositions,e.imagePositions,p,I,o,F,L,C,v,2,!1,m,f))}}let x,b=!1;if((h=d.icon)!=null&&h.name){let T=e.imageMap[d.icon.name];T&&(x=rC(e.imagePositions[d.icon.name],r.get("icon-offset").evaluate(d,{},e.canonical),r.get("icon-anchor").evaluate(d,{},e.canonical)),b=!!T.sdf,e.bucket.sdfIcons===void 0?e.bucket.sdfIcons=b:e.bucket.sdfIcons!==b&&_e("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),T.pixelRatio===e.bucket.pixelRatio?r.get("icon-rotate").constantOr(1)!==0&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let w=G1(_.horizontal)||_.vertical;(c=e.bucket).iconsInText||(c.iconsInText=w?w.iconsInText:!1),(w||x)&&_C(e.bucket,d,_,x,e.imageMap,n,m,g,v,b,e.canonical,e.subdivisionGranularity,e.hasPromoteId)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}function Uc(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 _C(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=n.textMaxSize.evaluate(t,{});p===void 0&&(p=o);let f=e.layers[0].layout,m=f.get("icon-offset").evaluate(t,{},h),g=G1(i.horizontal),_=o/24,y=e.tilePixelRatio*_,v=e.tilePixelRatio*p/24,x=e.tilePixelRatio*s,b=e.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*e.tilePixelRatio,T=AC(f,t,h,e.tilePixelRatio),S=f.get("text-max-angle")/180*Math.PI,C=f.get("text-rotation-alignment")!=="viewport"&&f.get("symbol-placement")!=="point",F=f.get("icon-rotation-alignment").constantOr("viewport")==="map"&&f.get("symbol-placement")!=="point",A=f.get("symbol-placement"),L=b/2,I=f.get("icon-text-fit"),E;r&&I!=="none"&&(e.allowVerticalPlacement&&i.vertical&&(E=Um(r,i.vertical,I,f.get("icon-text-fit-padding"),m,_)),g&&(r=Um(r,g,I,f.get("icon-text-fit-padding"),m,_)));let D=h?c.line.getGranularityForZoomLevel(h.z):1,P=(R,k)=>{jd(k)||vC(e,k,R,i,r,a,E,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,y,[w,w,w,w],C,l,x,T,F,m,t,n,u,h,o,d)};if(A==="line")for(let R of N1(t.geometry,0,0,O,O)){let k=Wr(R,D),B=uC(k,b,S,i.vertical||g,r,24,v,e.overscaling,O);for(let Z of B){let oe=g;(!oe||!xC(e,oe.text,L,Z))&&P(k,Z)}}else if(A==="line-center"){for(let R of t.geometry)if(R.length>1){let k=Wr(R,D),B=lC(k,S,i.vertical||g,r,24,v);B&&P(k,B)}}else if(t.type==="Polygon")for(let R of Ul(t.geometry,0)){let k=dC(R,16);P(Wr(R[0],D,!0),new Ua(k.x,k.y,0))}else if(t.type==="LineString")for(let R of t.geometry){let k=Wr(R,D);P(k,new Ua(k[0].x,k[0].y,0))}else if(t.type==="Point")for(let R of t.geometry)for(let k of R)P([k],new Ua(k.x,k.y,0))}function yC(e,t){let i=e.length,r=t==null?void 0:t.values;if((r==null?void 0:r.length)>0)for(let a=0;a<r.length;a+=2){let n=Nc[r[a]],o=r[a+1];e.emplaceBack(n,o[0],o[1])}return[i,e.length]}function Wm(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m){let g=hC(t,i,s,a,n,o,r,e.allowVerticalPlacement),_=e.textSizeData,y=null;_.kind==="source"?(y=[128*a.layout.get("text-size").evaluate(o,{})],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(o,{},m),128*f.compositeTextSizes[1].evaluate(o,{},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,s,n,o,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 G1(e){for(let t in e)return e[t];return null}function vC(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b,w,T,S,C){let F=e.addToLineVertexArray(t,i),A=s.layout.get("symbol-height-offset").evaluate(x,{},T);A>e.maxHeightOffset&&(e.maxHeightOffset=A);let L,I,E,D,P=0,R=0,k=0,B=0,Z=-1,oe=-1,pe={},fe=(0,pl.default)("");if(e.allowVerticalPlacement&&r.vertical){let ie=s.layout.get("text-rotate").evaluate(x,{},T)+90,V=r.vertical;E=new Ts(l,t,u,h,c,V,d,p,f,ie),o&&(D=new Ts(l,t,u,h,c,o,g,_,f,ie))}if(a){let ie=s.layout.get("icon-rotate").evaluate(x,{}),V=s.layout.get("icon-text-fit")!=="none",ye=Zm(a,ie,w,V),te=o?Zm(o,ie,w,V):void 0;I=new Ts(l,t,u,h,c,a,g,_,!1,ie),P=ye.length*4;let ae=e.iconSizeData,q=null;ae.kind==="source"?(q=[128*s.layout.get("icon-size").evaluate(x,{})],q[0]>32640&&_e(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):ae.kind==="composite"&&(q=[128*b.compositeIconSizes[0].evaluate(x,{},T),128*b.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,F.lineStartIndex,F.lineLength,-1,T,A),Z=e.icon.placedSymbolArray.length-1,te&&(R=te.length*4,e.addSymbols(e.icon,te,q,v,y,x,2,t,F.lineStartIndex,F.lineLength,-1,T,A),oe=e.icon.placedSymbolArray.length-1)}let Ee=Object.keys(r.horizontal);for(let ie of Ee){let V=r.horizontal[ie];L||(L=(fe=(0,pl.default)(V.text),new Ts(l,t,u,h,c,V,d,p,f,s.layout.get("text-rotate").evaluate(x,{},T))));let ye=V.positionedLines.length===1;if(k+=Wm(e,t,V,n,s,f,x,m,A,F,r.vertical?1:3,ye?Ee:[ie],pe,Z,b,T),ye)break}r.vertical&&(B+=Wm(e,t,r.vertical,n,s,f,x,m,A,F,2,["vertical"],pe,oe,b,T));let Te=L?L.boxStartIndex:e.collisionBoxArray.length,Ge=L?L.boxEndIndex:e.collisionBoxArray.length,Ce=E?E.boxStartIndex:e.collisionBoxArray.length,mt=E?E.boxEndIndex:e.collisionBoxArray.length,yt=I?I.boxStartIndex:e.collisionBoxArray.length,Yt=I?I.boxEndIndex:e.collisionBoxArray.length,Nt=D?D.boxStartIndex:e.collisionBoxArray.length,zt=D?D.boxEndIndex:e.collisionBoxArray.length,Xe=-1,Kt=(ie,V)=>ie!=null&&ie.circleDiameter?Math.max(ie.circleDiameter,V):V;Xe=Kt(L,Xe),Xe=Kt(E,Xe),Xe=Kt(I,Xe),Xe=Kt(D,Xe);let vi=+(Xe>-1);vi&&(Xe*=S/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 Li=$1(s,x,T),[H,xe]=yC(e.textAnchorOffsets,Li);C&&(fe=bC(fe,x)),e.symbolInstances.emplaceBack(t.x,t.y,pe.right>=0?pe.right:-1,pe.center>=0?pe.center:-1,pe.left>=0?pe.left:-1,pe.vertical||-1,Z,oe,fe,Te,Ge,Ce,mt,yt,Yt,Nt,zt,u,k,B,P,R,vi,0,d,Xe,H,xe,A)}function xC(e,t,i,r){let a=e.compareText;if(!(t in a))a[t]=[];else{let n=a[t];for(let o=n.length-1;o>=0;o--)if(r.dist(n[o])<i)return!0}return a[t].push(r),!1}function bC(e,t){var i;return t.id==null||(i=t.properties)!=null&&i.cluster?e:(0,pl.default)(String(t.id),e)}function Tl(e,t,i){let r="never",a=e.get(t);return a?r=a:e.get(i)&&(r="always"),r}const wC=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Ds(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=s?Math.min($m,Math.round(s[0])):0,m=s?Math.min($m,Math.round(s[1])):0;e.emplaceBack(t,i,Math.round(r*32),Math.round(a*32),n,o,(f<<1)+ +!!l,m,u*16,h*16,c*256,d*256,p)}function Dl(e,t,i){e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i)}function TC(e){for(let t of e.sections)if(b1(t.text))return!0;return!1}var $c=class{constructor(e){this.layoutVertexArray=new ST,this.indexArray=new Ki,this.programConfigurations=e,this.segments=new Ke,this.dynamicLayoutVertexArray=new ET,this.opacityVertexArray=new CT,this.hasVisibleVertices=!1,this.placedSymbolArray=new C0}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,LS.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,BS.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,wC,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&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",$c);var Gc=class{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new Ke,this.collisionVertexArray=new AT}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,OS.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};G("CollisionBuffers",Gc);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(o=>o.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=Gm(this.zoom,t["text-size"]),this.iconSizeData=Gm(this.zoom,t["icon-size"]);let i=this.layers[0].layout,r=i.get("symbol-sort-key"),a=i.get("symbol-z-order");this.canOverlap=Tl(i,"text-overlap","text-allow-overlap")!=="never"||Tl(i,"icon-overlap","icon-allow-overlap")!=="never"||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey=a!=="viewport-y"&&!r.isConstant();let n=a==="viewport-y"||a==="auto"&&!this.sortFeaturesByKey;this.sortFeaturesByY=n&&this.canOverlap,i.get("symbol-placement")==="point"&&(this.writingModes=i.get("text-writing-mode").map(o=>E1[o])),this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.sourceID=e.sourceID}createArrays(){this.text=new $c(new ra(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new $c(new ra(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new M0,this.lineVertexArray=new I0,this.symbolInstances=new A0,this.textAnchorOffsets=new z0}calculateGlyphDependencies(e,t,i,r){var o;let a=Xd.fromFeature(e,i,!1),n=a.graphemes();for(let s=0;s<n.length;s++){let l=a.getSection(s);if("imageName"in l)continue;t[o=l.fontStack]||(t[o]={default:{},vertical:{}});let u=t[l.fontStack],h=n[s],c=r&&YE(h.codePointAt(0),this.allowVerticalPlacement);xo(h)&&(u.default[h]=!0),c&&(u.vertical[h]=!0);for(let d of h){if(u.default[d]=!0,!r)continue;c&&xo(h)&&(u.vertical[d]=!0);let p=La[d];p&&(u.default[p]=!0)}}}populate(e,t,i){var _;let r=this.layers[0],a=r.layout,n=a.get("text-font"),o=a.get("text-field"),s=a.get("icon-image"),l=(o.value.kind!=="constant"||o.value.value instanceof pr&&!o.value.value.isEmpty()||o.value.value.toString().length>0)&&(n.value.kind!=="constant"||n.value.value.length>0),u=s.value.kind!=="constant"||!!s.value.value||Object.keys(s.parameters).length>0,h=a.get("symbol-sort-key"),c=a.get("symbol-placement")==="point";if(this.features=[],!l&&!u)return;let d=t.iconDependencies,p=t.glyphDependencies,f=t.availableImages,m=new Ie(this.zoom),g=a.get("text-keep-upright");for(let{feature:y,id:v,index:x,sourceLayerIndex:b}of e){let w=r._featureFilter.needGeometry,T=da(y,w);if(!r._featureFilter.filter(m,T,i)||(w||(T.geometry=ca(y)),c&&y.type===1&&DC(T.geometry)))continue;let S;if(l){let L=r.getValueAndResolveTokens("text-field",T,i,f),I=pr.factory(L);this.hasRTLText||(this.hasRTLText=TC(I)),S=cE(I,r,T)}let C;if(u){let L=r.getValueAndResolveTokens("icon-image",T,i,f);C=L instanceof Yi?L:Yi.fromString(L)}if(!S&&!C)continue;let F=this.sortFeaturesByKey?h.evaluate(T,{},i):void 0,A={id:v,text:S,icon:C,index:x,sourceLayerIndex:b,geometry:T.geometry,properties:y.properties,type:Fo.types[y.type],sortKey:F};if(this.features.push(A),C&&(d[C.name]=!0),S){let L=n.evaluate(T,{},i).join(","),I=a.get("text-rotation-alignment")!=="viewport"&&a.get("symbol-placement")!=="point";this.allowVerticalPlacement=(_=this.writingModes)==null?void 0:_.includes(2);let E=(I&&g||this.allowVerticalPlacement)&&Oc(S.toString());this.calculateGlyphDependencies(S,p,L,E);for(let D of S.sections)D.image&&(d[D.image.name]=!0)}}a.get("symbol-placement")==="line"&&(this.features=pE(this.features)),this.sortFeaturesByKey&&this.features.sort((y,v)=>y.sortKey-v.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}addFeatures({options:e,canonical:t,glyphMap:i,glyphPositions:r,iconMap:a,iconPositions:n,showCollisionBoxes:o}){gC({bucket:this,glyphMap:i,glyphPositions:r,imageMap:a,imagePositions:n,showCollisionBoxes:o,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 i=this.lineVertexArray.length;if(e.segment!==void 0){let r=e.dist(t[e.segment+1]),a=e.dist(t[e.segment]),n={};for(let o=e.segment+1;o<t.length;o++)n[o]={x:t[o].x,y:t[o].y,tileUnitDistanceFromAnchor:r},o<t.length-1&&(r+=t[o+1].dist(t[o]));for(let o=e.segment||0;o>=0;o--)n[o]={x:t[o].x,y:t[o].y,tileUnitDistanceFromAnchor:a},o>0&&(a+=t[o-1].dist(t[o]));for(let o=0;o<t.length;o++){let s=n[o];this.lineVertexArray.emplaceBack(s.x,s.y,s.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,a,n,o,s,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&&o===2?Math.PI/2:0,v=n.text&&n.text.sections;for(let x=0;x<t.length;x++){let{tl:b,tr:w,bl:T,br:S,tex:C,pixelOffsetTL:F,pixelOffsetBR:A,minFontScaleX:L,minFontScaleY:I,glyphOffset:E,isSDF:D,sectionIndex:P}=t[x],R=m.vertexLength,k=E[1];Ds(f,s.x,s.y,b.x,k+b.y,C.x,C.y,i,D,F.x,F.y,L,I,d),Ds(f,s.x,s.y,w.x,k+w.y,C.x+C.w,C.y,i,D,A.x,F.y,L,I,d),Ds(f,s.x,s.y,T.x,k+T.y,C.x,C.y+C.h,i,D,F.x,A.y,L,I,d),Ds(f,s.x,s.y,S.x,k+S.y,C.x+C.w,C.y+C.h,i,D,A.x,A.y,L,I,d),Dl(e.dynamicLayoutVertexArray,s,y),p.emplaceBack(R,R+2,R+1),p.emplaceBack(R+1,R+2,R+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(E[0]),(x===t.length-1||P!==t[x+1].sectionIndex)&&e.programConfigurations.populatePaintArrays(f.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:v==null?void 0:v[P]})}e.placedSymbolArray.emplaceBack(s.x,s.y,g,this.glyphOffsetArray.length-g,_,l,u,s.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],o,0,!1,0,h,d)}_addCollisionDebugVertex(e,t,i,r,a,n){return t.emplaceBack(0,0),e.emplaceBack(i.x,i.y,r,a,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(e,t,i,r,a,n,o){let s=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=s.vertexLength,u=a.layoutVertexArray,h=a.collisionVertexArray,c=o.anchorX,d=o.anchorY;this._addCollisionDebugVertex(u,h,n,c,d,new M(e,t)),this._addCollisionDebugVertex(u,h,n,c,d,new M(i,t)),this._addCollisionDebugVertex(u,h,n,c,d,new M(i,r)),this._addCollisionDebugVertex(u,h,n,c,d,new M(e,r)),s.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),s.primitiveLength+=4}addDebugCollisionBoxes(e,t,i,r){for(let a=e;a<t;a++){let n=this.collisionBoxArray.get(a),o=n.x1,s=n.y1,l=n.x2,u=n.y2;this.addCollisionDebugVertices(o,s,l,u,r?this.textCollisionBox:this.iconCollisionBox,n.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Gc(Qf,Pm.members,bc),this.iconCollisionBox=new Gc(Qf,Pm.members,bc);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,i,r,a,n,o,s,l){let u={};for(let h=t;h<i;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=r;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<o;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=s;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 i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.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 i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+i.numGlyphs*4;for(let a=i.vertexStartIndex;a<r;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),i=Math.cos(e),r=[],a=[],n=[];for(let o=0;o<this.symbolInstances.length;++o){n.push(o);let s=this.symbolInstances.get(o);r.push(Math.round(t*s.anchorX+i*s.anchorY)|0),a.push(s.featureIndex)}return n.sort((o,s)=>r[o]-r[s]||a[s]-a[o]),n}addToSortKeyRanges(e,t){let i=this.sortKeyRanges[this.sortKeyRanges.length-1];(i==null?void 0:i.sortKey)===t?i.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 i=this.symbolInstances.get(t);this.featureSortOrder.push(i.featureIndex);let r=[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex];for(let a=0;a<r.length;a++){let n=r[a];n>=0&&r.indexOf(n)===a&&this.addIndicesForPlacedSymbol(this.text,n)}i.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,i.verticalPlacedTextSymbolIndex),i.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.placedIconSymbolIndex),i.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};function DC(e){return e.every(t=>t.every(jd))}G("SymbolBucket",Sl,{omit:["layers","collisionBoxArray","features","compareText"]});function SC(e,t){return t.replace(/{([^{}]+)}/g,(i,r)=>e&&r in e?String(e[r]):"")}let Hm;const EC=()=>Hm||(Hm=new St({"symbol-placement":new U(z.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new U(z.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new U(z.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new Q(z.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new U(z.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new U(z.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new U(z.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new U(z.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new U(z.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new Q(z.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new Q(z.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new U(z.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new U(z.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new Q(z.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new Q(z.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new Q(z.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new U(z.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new Q(z.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new Q(z.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new U(z.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new U(z.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new U(z.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new Q(z.layout_symbol["text-field"],"text-field"),"text-font":new Q(z.layout_symbol["text-font"],"text-font"),"text-size":new Q(z.layout_symbol["text-size"],"text-size"),"text-max-width":new Q(z.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new U(z.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new Q(z.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new Q(z.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new Q(z.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new U(z.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new Q(z.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new Q(z.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new U(z.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new U(z.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new Q(z.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new U(z.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new U(z.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new Q(z.layout_symbol["text-transform"],"text-transform"),"text-offset":new Q(z.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new U(z.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new U(z.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new U(z.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new U(z.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new Q(z.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new U(z.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")}));let Xm;const CC=()=>Xm||(Xm=new St({"icon-opacity":new Q(z.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new Q(z.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new Q(z.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new Q(z.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new Q(z.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new U(z.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new U(z.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new Q(z.paint_symbol["text-opacity"],"text-opacity"),"text-color":new Q(z.paint_symbol["text-color"],"text-color",{runtimeType:Ai,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Q(z.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new Q(z.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new Q(z.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new U(z.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new U(z.paint_symbol["text-translate-anchor"],"text-translate-anchor")}));var sh={get paint(){return CC()},get layout(){return EC()}},Z1=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:Do,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",Z1,{omit:["defaultValue"]});const q1=e=>e.type==="symbol";var PC=class Zc extends Ri{constructor(t,i){super(t,sh,i)}recalculate(t,i){super.recalculate(t,i);let r=this.layout.get("icon-rotation-alignment");if((r.value.kind!=="constant"||r.value.value==="auto")&&(this.layout._values["icon-rotation-alignment"]=new mi(r.property,{kind:"constant",value:this.layout.get("symbol-placement")==="point"?"viewport":"map"},r.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 o of a)n.includes(o)||n.push(o);this.layout._values["text-writing-mode"]=n}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,i,r,a){let n=this.layout.get(t).evaluate(i,{},r,a),o=this._unevaluatedLayout._values[t];return!o.isDataDriven()&&!Wl(o.value)&&n?SC(i.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 sh.paint.overridableProperties){if(!Zc.hasPaintOverride(this.layout,t))continue;let i=this.paint.get(t),r=new Fd(new Z1(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),a=null;a=i.value.kind==="constant"||i.value.kind==="source"?new so("source",r):new sl("composite",r,i.value.zoomStops),this.paint._values[t]=new mi(i.property,a,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,r){return!this.layout||i.isDataDriven()||r.isDataDriven()?!1:Zc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,i){let r=t.get("text-field"),a=sh.paint.properties[i],n=!1,o=s=>{var l;for(let u of s)if((l=a.overrides)!=null&&l.hasOverride(u)){n=!0;return}};if(r.value.kind==="constant"&&r.value.value instanceof pr)o(r.value.value.sections);else if(r.value.kind==="source"||r.value.kind==="composite"){let s=u=>{if(!n)if(u instanceof Ka&&nt(u.value)===So){let h=u.value;o(h.sections)}else u instanceof py?o(u.sections):u.eachChild(s)},l=r.value;l._styleExpression&&s(l._styleExpression.expression)}return n}};function AC(e,t,i,r=1){var n;let a=(n=e.get("icon-padding").evaluate(t,{},i))==null?void 0:n.values;return[a[0]*r,a[1]*r,a[2]*r,a[3]*r]}let Ym;const MC=()=>Ym||(Ym=new St({"background-color":new U(z.paint_background["background-color"],"background-color"),"background-pattern":new T0(z.paint_background["background-pattern"],"background-pattern"),"background-opacity":new U(z.paint_background["background-opacity"],"background-opacity")}));var IC={get paint(){return MC()}};const FC=e=>e.type==="background";var zC=class extends Ri{constructor(e,t){super(e,IC,t)}};function kC(e){let t=[],i=e.id;return i===void 0&&t.push(new j(`layers.${i}`,null,'missing required property "id"')),e.render===void 0&&t.push(new j(`layers.${i}`,null,'missing required method "render"')),e.renderingMode&&e.renderingMode!=="2d"&&e.renderingMode!=="3d"&&t.push(new j(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}const nu=e=>e.type==="custom";var RC=class extends Ri{constructor(e,t){super(e,{},t),this.onAdd=i=>{this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)},this.onRemove=i=>{this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)},this.implementation=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 lh(e,t){if(e.type==="custom")return new RC(e,t);switch(e.type){case"background":return new zC(e,t);case"circle":return new nD(e,t);case"color-relief":return new yD(e,t);case"fill":return new KD(e,t);case"fill-extrusion":return new wS(e,t);case"heatmap":return new uD(e,t);case"hillshade":return new pD(e,t);case"line":return new RS(e,t);case"raster":return new mT(e,t);case"symbol":return new PC(e,t)}}function $s(e){let t=[];if(typeof e=="string")t.push({id:"default",url:e});else if(e&&e.length>0){let i=[];for(let{id:r,url:a}of e){let n=`${r}${a}`;i.includes(n)||(i.push(n),t.push({id:r,url:a}))}}return t}function Km(e,t,i){try{let r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(r){throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function LC(e,t,i,r){let a=$s(e),n=i>1?"@2x":"",o={},s={};for(let{id:l,url:u}of a){let h=await t.transformRequest(Km(u,n,".json"),"SpriteJSON");o[l]=Rl(h,r);let c=await t.transformRequest(Km(u,n,".png"),"SpriteImage");s[l]=Ci.getImage(c,r)}return await Promise.all([...Object.values(o),...Object.values(s)]),BC(o,s)}async function BC(e,t){let i={};for(let r in e){i[r]={};let a=(await t[r]).data;if(!a)throw Error(`Could not load sprite image for ${r}: the response is empty`);let n=Xt.getImageCanvasContext(a),o=(await e[r]).data;for(let s in o){let{width:l,height:u,x:h,y:c,sdf:d,pixelRatio:p,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y}=o[s],v={width:l,height:u,x:h,y:c,context:n};i[r][s]={data:null,pixelRatio:p,sdf:d,stretchX:f,stretchY:m,content:g,textFitWidth:_,textFitHeight:y,spriteData:v}}}return i}var OC=class extends Ft{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:i}of this.requestors)i(this._getImagesForIds(t));this.requestors=[]}}getImage(e){let t=this.images[e];if(t&&!t.data&&t.spriteData){let i=t.spriteData;t.data=new Ne({width:i.width,height:i.height},i.context.getImageData(i.x,i.y,i.width,i.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 i=!0,r=t.data||t.spriteData;return this._validateStretch(t.stretchX,r==null?void 0:r.width)||(this.fire(new K(Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,r==null?void 0:r.height)||(this.fire(new K(Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new K(Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(let r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(e.length!==4)return!1;let i=t.spriteData,r=(i==null?void 0:i.width)||t.data.width,a=(i==null?void 0:i.height)||t.data.height;return e[0]<0||r<e[0]||e[1]<0||a<e[1]||e[2]<0||r<e[2]||e[3]<0||a<e[3]||e[2]<e[0]?!1:e[3]>=e[1]}updateImage(e,t,i=!0){var a;let r=this.images[e];if(i){let n=r.data||r.spriteData;if(n.width!==t.data.width||n.height!==t.data.height)throw Error(`size mismatch between old image (${n.width}x${n.height}) and new image (${t.data.width}x${t.data.height}).`)}t.version=((a=r.version)!=null?a:0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){var i;let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,(i=t.userImage)!=null&&i.onRemove&&t.userImage.onRemove())}listImages(){var e;return(e=this._imagesIds)!=null||(this._imagesIds=Object.keys(this.images)),this._imagesIds}_getSpriteImageId(e,t){return e==="default"?t:`${e}:${t}`}setSpriteImages(e,t){var o;let i=(o=this._spriteImagesIds[e])!=null?o:[],r=[];for(let s in t){let l=this._getSpriteImageId(e,s);r.push(l),l in this.images?this.updateImage(l,t[s],!1):this.addImage(l,t[s])}let a=new Set(r),n=i.filter(s=>!a.has(s));for(let s of n)this.removeImage(s);return this._spriteImagesIds[e]=r,{loaded:r,removed:n}}removeSpriteImages(e){var i;let t=(i=this._spriteImagesIds[e])!=null?i:[];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,i)=>{let r=!0;if(!this.isLoaded())for(let a of e)this.images[a]||(r=!1);this.isLoaded()||r?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))),i=this.missingImageResolver;i&&await Promise.allSettled(Array.from(t,n=>i(n)));let r={};for(let n of e){let o=this.getImage(n);o&&(t.delete(n),r[n]={data:o.data.clone(),pixelRatio:o.pixelRatio,sdf:o.sdf,version:o.version,stretchX:o.stretchX,stretchY:o.stretchY,content:o.content,textFitWidth:o.textFitWidth,textFitHeight:o.textFitHeight,hasRenderCallback:!!((a=o.userImage)!=null&&a.render),isWebGLImage:o.isWebGLImage})}for(let n of t)this.fire(new r2({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 r}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let i=this.getImage(t);i||_e(`Image with ID: "${t}" was not found`),NE(i)&&this.updateImage(t,i)}}cloneImages(){let e={};for(let t in this.images){let i=this.images[t];e[t]={...i,data:i.data?i.data.clone():null}}return e}},jC=class{constructor(e){this._imageManager=e,this._entries={},this._image=new Ne({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&(this._texture=(this._texture.destroy(),null)),this._entries={},this._image=new Ne({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 i=this._entries[e];if((i==null?void 0:i.image)!==t){let r={w:t.data.width+2,h:t.data.height+2,x:0,y:0};this._entries[e]={bin:r,position:new Kd(r,t),image:t}}else if(i.position.version!==t.version)i.position.version=t.version;else return i.position;return this._update(),this._entries[e].position}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.getPattern(e.from.toString()),i=this.getPattern(e.to.toString());return!t||!i}bind(e){let t=e.gl;this._texture?this._dirty&&(this._dirty=(this._texture.update(this._image),!1)):(this._texture=new ft(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:i}=S1(e),r=this._image;r.resize({width:t||1,height:i||1});for(let a in this._entries){let{bin:n}=this._entries[a],o=n.x+1,s=n.y+1,l=this._entries[a].image.data,u=l.width,h=l.height;Ne.copy(l,r,{x:0,y:0},{x:o,y:s},{width:u,height:h}),Ne.copy(l,r,{x:0,y:h-1},{x:o,y:s-1},{width:u,height:1}),Ne.copy(l,r,{x:0,y:0},{x:o,y:s+h},{width:u,height:1}),Ne.copy(l,r,{x:u-1,y:0},{x:o-1,y:s},{width:1,height:h}),Ne.copy(l,r,{x:0,y:0},{x:o+u,y:s},{width:1,height:h})}this._dirty=!0}};const qc=1114111,VC={start:0,end:qc};let NC=0;function UC(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,a,n]=t;return a.length+n.length>6?null:Jm(parseInt(`${a}${"0".repeat(n.length)}`,16),parseInt(`${a}${"f".repeat(n.length)}`,16))}let i=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!i)return null;let r=parseInt(i[1],16);return Jm(r,i[2]===void 0?r:parseInt(i[2],16))}function Jm(e,t){return e>t||e>qc?null:{start:e,end:Math.min(t,qc)}}function $C(e,t){return e.ranges.some(({start:i,end:r})=>t>=i&&t<=r)}var GC=class{constructor(e){this.requestManager=e,this._faces={},this._registered=new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,i]of Object.entries(e!=null?e:{})){let r=Array.isArray(i)?i:[i];this._faces[t]=r.map(a=>this._declareFontFace(t,a)).filter(a=>a!==null)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t,i){var r,a,n,o,s;for(let l of e.split(","))for(let u of(r=this._faces[l.trim()])!=null?r:[]){if(!$C(u,t))continue;(n=(a=u.loads).normal)!=null||(a.normal=this._loadFontFace(u,"normal"));let h=u.data,c=await u.loads.normal;if(c)return i==="normal"?c:((s=(o=u.loads)[i])!=null||(o[i]=this._loadFontFace(u,i,h)),u.loads[i])}return null}_declareFontFace(e,t){let i=typeof t=="string"?{url:t}:t;if(typeof(i==null?void 0:i.url)!="string")return _e(`Ignoring the font face declared for "${e}": it has no URL.`),null;let r=`maplibre-gl-font-face-${NC++}`,a=i["unicode-range"];if(!(a!=null&&a.length))return{url:i.url,ranges:[VC],family:r,loads:{}};let n=[];for(let o of a){let s=UC(o);s?n.push(s):_e(`Ignoring the unicode range "${o}" of the font face at ${i.url}: it is not a valid range.`)}return n.length?{url:i.url,ranges:n,family:r,loads:{}}:null}async _loadFontFace(e,t,i){var n;let r=t==="normal"?"font face":`font face with "${t}" enabled`;if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return _e(`Ignoring the ${r} at ${e.url}: this environment has no CSS Font Loading API.`),null;let a;try{i||(i=((n=e.data)!=null||(e.data=this._downloadFontFile(e.url)),e.data));let o=t==="normal"?e.family:`${e.family}-${t}`;return a=new FontFace(o,await i,{featureSettings:t==="normal"?"normal":`"${t}" 1`}),!Object.values(this._faces).some(s=>s.includes(e))||t!=="normal"&&(!a.featureSettings||a.featureSettings==="normal")?null:(document.fonts.add(a),this._registered.add(a),await a.load(),this._registered.has(a)?o:null)}catch(o){return a&&this._unregister(a),_e(`Ignoring the ${r} at ${e.url}: ${Dt(o).message}`),null}finally{e.data===i&&delete e.data}}async _downloadFontFile(e){let t=await this.requestManager.transformRequest(e,"Glyphs"),i=await Y_(t,new AbortController);if(!(i!=null&&i.data))throw Error(`the response was empty for the font file at ${e}`);return i.data}_unregister(e){var t;(t=document.fonts)==null||t.delete(e),this._registered.delete(e)}_unregisterAll(){var e;for(let t of Object.values(this._faces))for(let i of t)delete i.data;for(let t of this._registered)(e=document.fonts)==null||e.delete(t);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}};const Wc=1e20,ep=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**.45454545454545453;ep[e]=t*Math.abs(t)}ep[255]=-1e20;var ZC=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:a="sans-serif",fontWeight:n="normal",fontStyle:o="normal",lang:s=null}={}){t=this.buffer=Math.round(t),this.radius=i,this.cutoff=r,this.lang=s;let l=this.size=Math.ceil(e)+t*4,u=this._createCanvas(l),h=this.ctx=u.getContext("2d",{willReadFrequently:!0});h.font=`${o} ${n} ${e}px ${a}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",s&&(h.lang=s);let c=(this.maxGlyphDim=l-t)+2*t;this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_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:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:a,actualBoundingBoxRight:n}=this.ctx.measureText(e),o=Math.ceil(i),s=Math.floor(-a),l=Math.max(0,Math.min(this.maxGlyphDim,Math.ceil(n)-s)),u=Math.max(0,Math.min(this.maxGlyphDim,o+Math.ceil(r))),h=l+2*this.buffer,c=u+2*this.buffer,d=h*c,p=new Uint8ClampedArray(d),f={data:p,width:h,height:c,glyphWidth:l,glyphHeight:u,glyphTop:o,glyphLeft:s,glyphAdvance:t};if(l===0||u===0)return f;let{ctx:m,buffer:g,gridInner:_,gridOuter:y}=this;m.clearRect(g,g,l,u),m.fillText(e,g-s,g+o);let v=m.getImageData(g,g,l,u);y.fill(Wc,0,d),_.fill(0,0,d);let x=3;for(let S=0;S<u;S++){let C=(S+g)*h+g;for(let F=0;F<l;F++,x+=4,C++){let A=v.data[x];if(A===0)continue;let L=ep[A];y[C]=Math.max(0,L),_[C]=Math.max(0,-L)}}Qm(y,0,0,h,c,h,this.f,this.v,this.z,g);let b=Math.min(g,1);Qm(_,g-b,g-b,l+2*b,u+2*b,h,this.f,this.v,this.z);let w=255/this.radius,T=255*(1-this.cutoff);for(let S=0;S<d;S++){let C=Math.sqrt(y[S])-Math.sqrt(_[S]);p[S]=T-w*C}return f}};function Qm(e,t,i,r,a,n,o,s,l,u=0){for(let h=t+u;h<t+r-u;h++)eg(e,i*n+h,n,a,o,s,l);for(let h=i;h<i+a;h++)eg(e,h*n+t,1,r,o,s,l)}function eg(e,t,i,r,a,n,o){n[0]=0,o[0]=-1e20,o[1]=Wc,a[0]=e[t];for(let s=1,l=0;s<r;s++){let u=a[s]=e[t+s*i],h=s*s,c;do{let d=n[l];c=(u-a[d]+h-d*d)/(s-d)/2}while(c<=o[l]&&--l>-1);l++,n[l]=s,o[l]=c,o[l+1]=Wc}for(let s=0,l=0;s<r;s++){for(;o[l+1]<s;)l++;let u=n[l],h=s-u;e[t+s*i]=a[u]+h*h}}const qC=z.layout_symbol["text-font"].default.join(","),WC=(e,t)=>{let i=new ZC(e);return i.buffer=t,i},tg={vertical:"vert"};function HC(e,t){return e.bitmap.width===t.bitmap.width&&e.bitmap.height===t.bitmap.height&&e.metrics.width===t.metrics.width&&e.metrics.height===t.metrics.height&&e.metrics.left===t.metrics.left&&e.metrics.top===t.metrics.top&&e.metrics.advance===t.metrics.advance&&e.bitmap.data.every((i,r)=>i===t.bitmap.data[r])}var XC=class{constructor(e,t,i,r=WC){this.rasterizedGlyphs=new WeakMap,this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i,this.fontFaceManager=new GC(e),this.createRasterizer=r}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){var n;let t=[],i=this.fontFaceManager.hasFontFaces();for(let o in e)for(let s in e[o])if(!tg[s]||i)for(let l of e[o][s])t.push(this._getAndCacheGlyphsPromise(o,l,s));let r=await Promise.all(t),a={};for(let{stack:o,id:s,variant:l,glyph:u}of r)a[o]||(a[o]={}),(n=a[o])[l]||(n[l]={}),a[o][l][s]=u&&{id:u.id,bitmap:u.bitmap.clone(),metrics:u.metrics};return a}async _getAndCacheGlyphsPromise(e,t,i){var l,u,h;(u=(l=this.entries)[e])!=null||(l[e]={glyphs:{default:{}},requests:{},ranges:{}});let r=this.entries[e],a=(h=r.glyphs)[i]||(h[i]={}),n=a[t];if(n!==void 0)return{stack:e,id:t,variant:i,glyph:n};if(i!=="default"){let c=tg[i];return n=c?await this._drawAlternateGlyph(r,e,t,c):null,a[t]=n,{stack:e,id:t,variant:i,glyph:n}}let o=t.codePointAt(0),s=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,o,"normal"):null;return s?(n=await this._drawGlyph(r,e,t,s),a[t]=n,{stack:e,id:t,variant:i,glyph:n}):!this.url||xo(t)||this._charUsesLocalIdeographFontFamily(o)||$S(o)?(n=await this._drawGlyph(r,e,t),a[t]=n,{stack:e,id:t,variant:i,glyph:n}):{...await this._downloadAndCacheRangePromise(e,t),variant:i}}async _drawAlternateGlyph(e,t,i,r){let a=await this._getFontFaceTinySDF(e,t,i,r);if(!a||this.entries[t]!==e)return null;let n=a.draw(i);if(!n.glyphWidth||!n.glyphHeight)return null;let o=await this._getFontFaceTinySDF(e,t,i,"normal");if(!o||this.entries[t]!==e)return null;let s=this._createGlyph(i,n);return HC(this._getRasterizedGlyph(o,i),s)?null:s}async _downloadAndCacheRangePromise(e,t){var n;let i=t.codePointAt(0),r=this.entries[e],a=Math.floor(i/256);if(r.ranges[a])return{stack:e,id:t,glyph:null};(n=r.requests)[a]||(n[a]=this._loadGlyphRange(e,a));try{let o=await r.requests[a];for(let s in o)r.glyphs.default[String.fromCodePoint(+s)]=o[+s];return r.ranges[a]=!0,{stack:e,id:t,glyph:o[i]||null}}catch(o){let s=await this._drawGlyph(r,e,t);return r.glyphs.default[t]=s,this._warnOnMissingGlyphRange(s,a,i,Dt(o)),{stack:e,id:t,glyph:s}}}async _loadGlyphRange(e,t){let i=t*256,r=i+255,a=await this.requestManager.transformRequest(this.url.replace("{fontstack}",e).replace("{range}",`${i}-${r}`),"Glyphs"),n=await Y_(a,new AbortController);if(!(n!=null&&n.data))throw Error(`Could not load glyph range. range: ${t}, ${i}-${r}`);let o={};for(let s of VE(n.data))o[s.id]=s;return o}_warnOnMissingGlyphRange(e,t,i,r){let a=t*256;_e(`Unable to load glyph range ${t}, ${a}-${a+255}. Rendering codepoint U+${i.toString(16).padStart(4,"0").toUpperCase()} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&GS(e)}async _drawGlyph(e,t,i,r){let a=await this._getTinySDF(e,t,i,r);return this._getRasterizedGlyph(a,i)}_getRasterizedGlyph(e,t){var r;let i=this.rasterizedGlyphs.get(e);return i||(i={},this.rasterizedGlyphs.set(e,i)),(r=i[t])!=null||(i[t]=this._createGlyph(t,e.draw(t))),i[t]}_createGlyph(e,t){let i=/^\p{gc=Cf}+$/u.test(e);return{id:e.codePointAt(0),bitmap:new Zd({width:t.width||60,height:t.height||60},t.data),metrics:{width:i?0:t.glyphWidth/2||24,height:t.glyphHeight/2||24,left:t.glyphLeft/2+.5||0,top:t.glyphTop/2-27.5||-8,advance:i?0:t.glyphAdvance/2||24,isDoubleResolution:!0}}}async _getFontFaceTinySDF(e,t,i,r){if(this.entries[t]!==e)return null;let a=await this.fontFaceManager.getFontFamily(t,i.codePointAt(0),r);return!a||this.entries[t]!==e?null:this._getTinySDF(e,t,i,a)}_getTinySDF(e,t,i,r){var l,u,h,c;let a=xo(i);if(r){let d=a?"clusterTinySDFs":"fontFaceTinySDFs";return(l=e[d])!=null||(e[d]={}),(u=e[d])[r]||(u[r]=this._createTinySDF(r,!1,a?3:1)),e[d][r]}let n=t===qC&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(i.codePointAt(0)),o=n?this.localIdeographFontFamily:t;if(a)return(h=e.clusterTinySDFs)!=null||(e.clusterTinySDFs={}),(c=e.clusterTinySDFs)[o]||(c[o]=this._createTinySDF(o,!0,3)),e.clusterTinySDFs[o];let s=n?"ideographTinySDF":"tinySDF";return e[s]||(e[s]=this._createTinySDF(o)),e[s]}async _createTinySDF(e,t=!0,i=1){var s;let r=e?e.split(","):[];r.push("sans-serif");let a=r.map(l=>/[-\w]+/.test(l)?l:`'${CSS.escape(l)}'`).join(","),n=t?this._fontWeight(r[0]):void 0,o=t?this._fontStyle(r[0]):"normal";if(typeof document<"u"&&((s=document.fonts)!=null&&s.load))try{await document.fonts.load(`${o} ${n||"normal"} 48px ${a}`)}catch(l){_e(`Failed to load font "${a}": ${Dt(l).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(i-1)/4)),radius:16,cutoff:.25,fontFamily:a,fontWeight:n,fontStyle:o,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},i;for(let[r,a]of Object.entries(t))RegExp(`\\b${r}\\b`,"i").test(e)&&(i=`${a}`);return i}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 ig;const YC=()=>ig||(ig=new St({anchor:new U(z.light.anchor,"anchor"),position:new U(z.light.position,"position"),color:new U(z.light.color,"color"),intensity:new U(z.light.intensity,"intensity")}));var KC=class extends Ft{constructor(e,t){super(),this._transitionable=new Yl(YC(),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ie(0))}getLight(){return this._transitionable.serialize()}getEvaluated(){return{anchor:this.properties.get("anchor"),position:this.properties.get("position"),color:this.properties.get("color"),intensity:this.properties.get("intensity")}}setLight(e,t={}){this._validate(qt.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,i){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,i)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return Mo(this,e,{value:t},i)}};let rg;const JC=()=>rg||(rg=new St({"sky-color":new U(z.sky["sky-color"],"sky-color"),"horizon-color":new U(z.sky["horizon-color"],"horizon-color"),"fog-color":new U(z.sky["fog-color"],"fog-color"),"fog-ground-blend":new U(z.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new U(z.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new U(z.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new U(z.sky["atmosphere-blend"],"atmosphere-blend")}));var QC=class extends Ft{constructor(e,t){super(),this._transitionable=new Yl(JC(),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ie(0))}setSky(e,t={}){return!this._validate(qt.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,i){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,i)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i={}){return Mo(this,e,{value:t},i)}getEvaluated(){return{"sky-color":this.properties.get("sky-color"),"horizon-color":this.properties.get("horizon-color"),"fog-color":this.properties.get("fog-color"),"fog-ground-blend":this.properties.get("fog-ground-blend"),"horizon-fog-blend":this.properties.get("horizon-fog-blend"),"sky-horizon-blend":this.properties.get("sky-horizon-blend"),"atmosphere-blend":this.properties.get("atmosphere-blend")}}};function eP(e){return e<60?0:e<70?(e-60)/10:1}var tP=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 r;let i=e.join(",")+String(t);return(r=this.dashEntry)[i]||(r[i]=this.addDash(e,t)),this.dashEntry[i]}getDashRanges(e,t,i){let r=e.length%2==1,a=[],n=r?-e[e.length-1]*i:0,o=e[0]*i,s=!0;a.push({left:n,right:o,isDash:s,zeroLength:e[0]===0});let l=e[0];for(let u=1;u<e.length;u++){s=!s;let h=e[u];n=l*i,l+=h,o=l*i,a.push({left:n,right:o,isDash:s,zeroLength:h===0})}return a}addRoundDash(e,t,i){let r=t/2;for(let a=-i;a<=i;a++){let n=this.nextRow+i+a,o=this.width*n,s=0,l=e[s];for(let u=0;u<this.width;u++){u/l.right>1&&(l=e[++s]);let h=Math.abs(u-l.left),c=Math.abs(u-l.right),d=Math.min(h,c),p,f=a/i*(r+1);if(l.isDash){let m=r-Math.abs(f);p=Math.sqrt(d*d+m*m)}else p=r-Math.sqrt(d*d+f*f);this.data[o+u]=Math.max(0,Math.min(255,p+128))}}}addRegularDash(e){for(let o=e.length-1;o>=0;--o){let s=e[o],l=e[o+1];s.zeroLength?e.splice(o,1):(l==null?void 0:l.isDash)===s.isDash&&(l.left=s.left,e.splice(o,1))}let t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);let r=this.width*this.nextRow,a=0,n=e[a];for(let o=0;o<this.width;o++){o/n.right>1&&(n=e[++a]);let s=Math.abs(o-n.left),l=Math.abs(o-n.right),u=Math.min(s,l),h=n.isDash?u:-u;this.data[r+o]=Math.max(0,Math.min(255,h+128))}}addDash(e,t){let i=t?7:0,r=2*i+1;if(this.nextRow+r>this.height)return _e("LineAtlas out of space"),null;let a=0;for(let o of e)a+=o;if(a!==0){let o=this.width/a,s=this.getDashRanges(e,this.width,o);t?this.addRoundDash(s,o,i):this.addRegularDash(s)}let n={y:this.nextRow+i,height:2*i,width:a};return this.nextRow+=r,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))}},iP=class{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>this._invoke()}trigger(){var e;this._triggered||(this._triggered=!0,(e=this._channel)==null||e.port1.postMessage(!0),setTimeout(()=>this._invoke(),0))}_invoke(){this._triggered&&(this._triggered=!1,this._methodToThrottle())}remove(){delete this._channel,this._methodToThrottle=()=>{}}};const rP={once:!0};var aP=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new iP(()=>this.process()),this.subscription=tl(this.target,"message",i=>this.receive(i),!1),this.globalScope=Ha(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,r)=>{let a=Math.round(Math.random()*1e18).toString(36).substring(0,10),n=t?tl(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),r(new To(t.signal.reason))},rP):null;this.resolveRejects[a]={resolve:l=>{n==null||n.unsubscribe(),i(l)},reject:l=>{n==null||n.unsubscribe(),r(l)}};let o=[],s={...e,id:a,sourceMapId:this.mapId,origin:location.origin,data:Hn(e.data,o)};this.target.postMessage(s,{transfer:o})})}receive(e){let t=e.data,i=t.id,r=["file://","resource://android","null"],a=[t.origin,location.origin],n=t.origin===location.origin,o=a.some(s=>r.includes(s));if((n||o)&&!(t.targetMapId&&this.mapId!==t.targetMapId))if(t.type==="<cancel>"){delete this.tasks[i];let s=this.abortControllers[i];delete this.abortControllers[i],s&&s.abort()}else Ha(self)||t.mustQueue?(this.tasks[i]=t,this.taskQueue.push(i),this.invoker.trigger()):this.processTask(i,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(Dt(Xn(t.error))):a.resolve(Xn(t.data));return}if(!this.messageHandlers[t.type]){this.completeTask(e,null,null);return}let i=Xn(t.data),r=new AbortController;this.abortControllers[e]=r;try{let a=await this.messageHandlers[t.type](t.sourceMapId,i,r);this.completeTask(e,null,a)}catch(a){this.completeTask(e,Dt(a))}}completeTask(e,t,i){let r=[];delete this.abortControllers[e];let a={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?Hn(t):null,data:Hn(i,r)};this.target.postMessage(a,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function nP(e){if(!e)return!1;let t=globalThis.location;if(!t)return!1;try{return new URL(e,t.href).origin!==t.origin}catch(i){return!1}}function oP(){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",i=new URL(`./${t}`,e);return i.searchParams.set("v",R_),i.href}function sP(e){return e.endsWith(".cjs")||e.split(/[?#]/)[0].endsWith(".cjs")}function uh(e,t){if(t)try{return new Worker(e,{type:"module"})}catch(i){console.warn("Module worker not supported, falling back to classic worker",i)}return new Worker(e)}async function lP(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);let i=await t.text(),r=new Blob([i],{type:"text/javascript"});return URL.createObjectURL(r)}function uP(e){let t=new Blob([`import ${JSON.stringify(new URL(e,import.meta.url).href)}`],{type:"text/javascript"});return URL.createObjectURL(t)}async function hP(){let e=ta.WORKER_URL||oP(),t=!sP(e);if(!nP(e))return uh(e,t);if(t){let r=uP(e);try{return uh(r,t)}finally{URL.revokeObjectURL(r)}}let i=await lP(e);try{return uh(i,t)}finally{URL.revokeObjectURL(i)}}const cP="maplibre_preloaded_worker_pool";var tp=class W1{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let i=[];for(;i.length<W1.workerCount;)i.push(hP());this.workersPromise=Promise.all(i)}return(await this.workersPromise).slice()}release(t){if(delete this.active[t],this.numActive()===0&&this.workersPromise){let i=this.workersPromise;this.workersPromise=null,i.then(r=>{for(let a of r)a.terminate()})}}isPreloaded(){return!!this.active[cP]}numActive(){return Object.keys(this.active).length}};const dP=Math.floor(Xt.hardwareConcurrency/2);tp.workerCount=Rb(globalThis)?Math.max(Math.min(dP,3),1):1;let hh;function H1(){return hh||(hh=new tp),hh}var X1=class extends Ft{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((i,r)=>{this.workerErrorSubscriptions.push(tl(i,"error",()=>{this.fire(new K(Error("Worker failed to load. Check that the worker URL is correct.")))},!1));let a=new aP(i,e);return a.name=`Worker ${r}`,a}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(e,t){let i=await this.actorsPromise;return Promise.all(i.map(r=>r.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 i=await this.actorsPromise;for(let r of i)r.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let i of t)i.unregisterMessageHandler(e)}};let Ss;function pP(){return Ss||(Ss=new X1(H1(),jh),Ss.registerMessageHandler("GR",(e,t,i)=>kl(t,i))),Ss}function fP(e,t){let i=la();st(i,i,[1,1,0]),Rt(i,i,[e.width*.5,e.height*.5,1]);let r=e.getFastPathSimpleProjectionMatrix(t);return r?Pa(i,i,r):i}function mP(e,t,i){if(e)for(let r of e){let a=t[r];if((a==null?void 0:a.source)===i&&a.type==="fill-extrusion")return!0}else for(let r in t){let a=t[r];if(a.source===i&&a.type==="fill-extrusion")return!0}return!1}function gP(e,t,i,r,a,n,o){var c;let s=mP((c=a==null?void 0:a.layers)!=null?c:null,t,e.id),l=n.maxPitchScaleFactor(),u=e.tilesIn(r,l,s);u.sort(Y1);let h=[];for(let d of u)h.push({wrappedTileID:d.tileID.wrapped().key,queryResults:d.tile.queryRenderedFeatures(t,i,e.getState(),d.queryGeometry,d.cameraQueryGeometry,d.scale,a,n,l,fP(n,d.tileID),o?(p,f)=>o(d.tileID,p,f):void 0)});return xP(vP(h),e)}function _P(e,t,i,r,a,n,o){let s={},l=n.queryRenderedSymbols(r),u=[];for(let h of Object.keys(l).map(Number))u.push(o[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,worldCoordinateHelper:n.transform.worldCoordinateHelper},a.layers,a.availableImages,e);for(let d in c){s[d]||(s[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)s[d].push(f)}}return bP(s,e,i)}function yP(e,t){let i=e.getRenderableIds().map(n=>e.getTileByID(n)),r=[],a={};for(let n of i){let o=n.tileID.canonical.key;a[o]||(a[o]=!0,n.querySourceFeatures(r,t))}return r}function Y1(e,t){let i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function vP(e){let t={},i={};for(let{queryResults:r,wrappedTileID:a}of e){i[a]||(i[a]={});let n=i[a];for(let o in r){let s=r[o];n[o]||(n[o]={});let l=n[o];t[o]||(t[o]=[]);for(let u of s)l[u.featureIndex]||(l[u.featureIndex]=!0,t[o].push(u))}}return t}function xP(e,t){for(let i in e)for(let r of e[i])K1(r,t);return e}function bP(e,t,i){for(let r in e)for(let a of e[r]){let n=i[t[r].source];K1(a,n)}return e}function K1(e,t){let i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}async function J1(e,t,i,r){let a=e;if(e.url?a=(await Rl(await t.transformRequest(e.url,"Source"),i)).data:await Xt.frameAsync(i,r),!a)return null;let n=zl(X(a,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(n.vectorLayerIds=a.vector_layers.map(o=>o.id)),n}var mr=class rr{constructor(t,i){t&&(i?this.setSouthWest(t).setNorthEast(i):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 W?new W(t.lng,t.lat):W.convert(t),this}setSouthWest(t){return this._sw=t instanceof W?new W(t.lng,t.lat):W.convert(t),this}extend(t){let i=this._sw,r=this._ne,a,n;if(t instanceof W)a=t,n=t;else if(t instanceof rr){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 o=t;return this.extend(rr.convert(o))}{let o=t;return this.extend(W.convert(o))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(W.convert(t)):this}return!i&&!r?(this._sw=new W(a.lng,a.lat),this._ne=new W(n.lng,n.lat)):(i.lng=Math.min(a.lng,i.lng),i.lat=Math.min(a.lat,i.lat),r.lng=Math.max(n.lng,r.lng),r.lat=Math.max(n.lat,r.lat)),this}getCenter(){return new W((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 W(this.getWest(),this.getNorth())}getSouthEast(){return new W(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){let{lng:i,lat:r}=W.convert(t),a=this._sw.lat<=r&&r<=this._ne.lat,n=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=i&&i>=this._ne.lng),a&&n}intersects(t){if(t=rr.convert(t),!(t.getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(i>=360||r>=360)return!0;let a=fi(this.getWest(),-180,180),n=fi(this.getEast(),-180,180),o=fi(t.getWest(),-180,180),s=fi(t.getEast(),-180,180),l=a>n,u=o>s;return l&&u?!0:l?s>=a||o<=n:u?n>=o||a<=s:o<=n&&s>=a}static convert(t){return t instanceof rr||!t?t:new rr(t)}static fromLngLat(t,i=0){let r=360*i/40075017,a=r/Math.cos(Math.PI/180*t.lat);return new rr(new W(t.lng-a,t.lat-r),new W(t.lng+a,t.lat+r))}adjustAntiMeridian(){let t=new W(this._sw.lng,this._sw.lat),i=new W(this._ne.lng,this._ne.lat);return t.lng>i.lng?new rr(t,new W(i.lng+360,i.lat)):new rr(t,i)}},Q1=class{constructor(e,t,i,r){this.bounds=mr.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24,this._worldBox=p1(r,this.bounds.getWest(),this.bounds.getSouth(),this.bounds.getEast(),this.bounds.getNorth())}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,i={minX:Math.floor(this._worldBox.minX*t),minY:Math.floor(this._worldBox.minY*t),maxX:Math.ceil(this._worldBox.maxX*t),maxY:Math.ceil(this._worldBox.maxY*t)};return e.x>=i.minX&&e.x<i.maxX&&e.y>=i.minY&&e.y<i.maxY}},wP=class extends Ft{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,X(this,zl(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=X({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,this.tileSize!==512)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}async load(e=!1){this._loaded=!1,this.fire(new $e("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await J1(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(X(this,t),t.bounds&&(this.tileBounds=new Q1(t.bounds,this.minzoom,this.maxzoom,this.map.style.projection.worldCoordinateHelper)),this.fire(new $e("data",{sourceDataType:"metadata"})),this.fire(new $e("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,Fr(t)||this.fire(new K(Dt(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 X({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme,this.map.style.projection.worldCoordinateHelper.tileMatrixSet),i={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(i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete(),e.aborted)return;let r="RT";if(!e.actor||e.state==="expired")e.actor=this.dispatcher.getReadyActor(),r="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:r,data:i},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||Fr(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,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme,this.map.style.projection.worldCoordinateHelper.tileMatrixSet);return{maxZoomTileID:t,overzoomRequest:await this.map._requestManager.transformRequest(i,"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.style),e.reloadPromise){let i=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(i.resolve).catch(i.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}},ev=class extends Ft{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),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=X({type:"raster"},t),X(this,zl(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new $e("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await J1(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(X(this,t),t.bounds&&(this.tileBounds=new Q1(t.bounds,this.minzoom,this.maxzoom,this.map.style.projection.worldCoordinateHelper)),this.fire(new $e("data",{sourceDataType:"metadata"})),this.fire(new $e("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,Fr(t)||this.fire(new K(Dt(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 X({},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){var a;let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme,this.map.style.projection.worldCoordinateHelper.tileMatrixSet),i=this._premultiplyAlpha,r=i?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let n=await Ci.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,r);if(delete e.abortController,e.aborted){e.state="unloaded";return}if(n){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let o=this.map.painter.context,s=o.gl,l=(a=n.data)!=null?a:new Ne({width:1,height:1},new Uint8Array(4));e.texture=this.map.painter.getTileTexture(l.width),e.texture?e.texture.update(l,{useMipmap:!0,premultiply:i}):(e.texture=new ft(o,l,s.RGBA,{useMipmap:!0,premultiply:i}),e.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(n){if(delete e.abortController,e.aborted)e.state="unloaded";else if(n)throw e.state="errored",n}}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}};function TP(e,t,i){return!(e<0||e>25||i<0||i>=2**e||t<0||t>=2**e)}function ch(e,t,i){let{x:r,y:a}=i.worldFromLngLat(t.lng,t.lat);return!(e<0||e>25||a<0||a>=1||r<0||r>=1)}var ou=class{constructor(e,t,i){if(!TP(e,t,i))throw Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=$a(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i,r=kc){let a=DP(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(i==="tms"?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,a).replace(/{bbox-epsg-3857}/g,()=>ag(this.x,this.y,this.z,kc)).replace(/{bbox}/g,()=>ag(this.x,this.y,this.z,r))}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 M((e.x*t-this.x)*O,(e.y*t-this.y)*O)}toString(){return`${this.z}/${this.x}/${this.y}`}},El=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=$a(e,t.z,t.z,t.x,t.y)}},Ct=class di{constructor(t,i,r,a,n){if(this.terrainRttPosMatrix32f=null,t<r)throw Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=i,this.canonical=new ou(r,+a,+n),this.key=$a(i,t,r,a,n)}clone(){return new di(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 i=this.canonical.z-t;return t>this.canonical.z?new di(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new di(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,i){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?$a(this.wrap*+i,t,this.canonical.z,this.canonical.x,this.canonical.y):$a(this.wrap*+i,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap||this.overscaledZ-t.overscaledZ<=0)return!1;if(t.overscaledZ===0)return this.overscaledZ>0;let i=this.canonical.z-t.canonical.z;return i<0?!1:t.canonical.x===this.canonical.x>>i&&t.canonical.y===this.canonical.y>>i}children(t){if(this.overscaledZ>=t)return[new di(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=this.canonical.x*2,a=this.canonical.y*2;return[new di(i,this.wrap,i,r,a),new di(i,this.wrap,i,r+1,a),new di(i,this.wrap,i,r,a+1),new di(i,this.wrap,i,r+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 di(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new di(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new El(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new It(t.x-this.wrap,t.y))}normalizeCoordinates(t,i,r=O){if(t>=0&&t<r&&i>=0&&i<r)return{tileID:this,x:t,y:i};let a=Math.floor(t/r),n=Math.floor(i/r),o=t-a*r,s=i-n*r,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 di(this.overscaledZ,d,l,c,h),x:o,y:s}}};function $a(e,t,i,r,a){e*=2,e<0&&(e=e*-1-1);let n=1<<i;return(n*n*e+n*a+r).toString(36)+i.toString(36)+t.toString(36)}function ag(e,t,i,r){let a=2**i,n=r.extentAtZoom0/a,[o,s]=r.origin,l=s-r.extentAtZoom0,u=a-t-1;return`${o+e*n},${l+u*n},${o+(e+1)*n},${l+(u+1)*n}`}function DP(e,t,i){let r="";for(let a=e;a>0;a--){let n=1<<a-1;r+=(t&n?1:0)+(i&n?2:0)}return r}function ng(e,t){let i=Math.abs(e.wrap*2)-+(e.wrap<0),r=Math.abs(t.wrap*2)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}G("CanonicalTileID",ou),G("OverscaledTileID",Ct,{omit:["terrainRttPosMatrix32f"]});var SP=class extends ev{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=X({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,this.map.style.projection.worldCoordinateHelper.tileMatrixSet);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let i=await Ci.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete e.abortController,e.aborted){e.state="unloaded";return}if(i){if(this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires}),!i.data){e.state="loaded";return}let r=i.data,a=Hr(r)&&cd()?r:await this.readImageNow(r),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(i){if(delete e.abortController,e.aborted)e.state="unloaded";else if(i)throw e.state="errored",i}}async readImageNow(e){if(typeof VideoFrame<"u"&&L_()){let t=e.width+4,i=e.height+4;try{return new Ne({width:t,height:i},await jb(e,-2,-2,t,i))}catch(r){}}return Xt.getImageData(e,2)}_getNeighboringTiles(e){let t=e.canonical,i=2**t.z,r=(t.x-1+i)%i,a=t.x===0?e.wrap-1:e.wrap,n=(t.x+1+i)%i,o=t.x+1===i?e.wrap+1:e.wrap,s={};return s[new Ct(e.overscaledZ,a,t.z,r,t.y).key]={backfilled:!1},s[new Ct(e.overscaledZ,o,t.z,n,t.y).key]={backfilled:!1},t.y>0&&(s[new Ct(e.overscaledZ,a,t.z,r,t.y-1).key]={backfilled:!1},s[new Ct(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new Ct(e.overscaledZ,o,t.z,n,t.y-1).key]={backfilled:!1}),t.y+1<i&&(s[new Ct(e.overscaledZ,a,t.z,r,t.y+1).key]={backfilled:!1},s[new Ct(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},s[new Ct(e.overscaledZ,o,t.z,n,t.y+1).key]={backfilled:!1}),s}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 Cl(e,t){return t?e.properties[t]:e.id}function EP(e,t){let i=new Map;if(e==null||e.type==null)return i;if(e.type==="Feature"){let r=Cl(e,t);return r==null?void 0:(i.set(r,e),i)}if(e.type==="FeatureCollection"){let r=new Set;for(let a of e.features){let n=Cl(a,t);if(n==null||r.has(n))return;r.add(n),i.set(n,a)}return i}}function CP(e,t,i){var a,n;let r=[];if(t.removeAll)e.clear();else if(t.remove)for(let o of t.remove){let s=e.get(o);s&&(r.push(s.geometry),e.delete(o))}if(t.add)for(let o of t.add){let s=Cl(o,i);if(s==null)continue;let l=e.get(s);l&&r.push(l.geometry),r.push(o.geometry),e.set(s,o)}if(t.update)for(let o of t.update){let s=e.get(o.id);if(!s)continue;let l=!!o.newGeometry,u=o.removeAllProperties||((a=o.removeProperties)==null?void 0:a.length)>0||((n=o.addOrUpdateProperties)==null?void 0:n.length)>0;if(!l&&!u)continue;r.push(s.geometry);let h={...s};if(e.set(o.id,h),l&&(r.push(o.newGeometry),h.geometry=o.newGeometry),u){if(h.properties=o.removeAllProperties?{}:{...h.properties||{}},o.removeProperties)for(let c of o.removeProperties)delete h.properties[c];if(o.addOrUpdateProperties)for(let{key:c,value:d}of o.addOrUpdateProperties)h.properties[c]=d}}return r}function PP(e,t,i){if(!e)return t||{};if(!t)return e||{};let r=og(e,i),a=og(t,i);AP(r,a);let n={};if((r.removeAll||a.removeAll)&&(n.removeAll=!0),n.remove=new Set([...r.remove,...a.remove]),n.add=new Map([...r.add,...a.add]),n.update=new Map([...r.update,...a.update]),n.remove.size&&n.add.size)for(let o of n.add.keys())n.remove.delete(o);return IP(n)}function AP(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let i of t.remove)e.add.delete(i),e.update.delete(i);for(let[i,r]of t.update){let a=e.update.get(i);a&&(t.update.set(i,MP(a,r)),e.update.delete(i))}}function MP(e,t){let i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties&&e.addOrUpdateProperties){let r=new Set(t.removeProperties);e.addOrUpdateProperties=e.addOrUpdateProperties.filter(a=>!r.has(a.key))}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function og(e,t){var r,a;if(!e)return{};let i={};return i.removeAll=e.removeAll,i.remove=new Set(e.remove||[]),i.add=new Map((r=e.add)==null?void 0:r.map(n=>[Cl(n,t),n])),i.update=new Map((a=e.update)==null?void 0:a.map(n=>[n.id,n])),i}function IP(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 tv(e){return!e||e.length===0?[]:typeof e[0]=="number"?[e]:e.flatMap(t=>tv(t))}function Gs(e){return e.type==="GeometryCollection"?e.geometries.flatMap(t=>Gs(t)):tv(e.coordinates)}function sg(e){let t=new mr,i;switch(e.type){case"FeatureCollection":i=e.features.flatMap(r=>Gs(r.geometry));break;case"Feature":i=Gs(e.geometry);break;default:i=Gs(e)}if(i.length===0)return t;for(let r of i){let[a,n]=r;t.extend([a,n])}return t}function FP({x:e,y:t,z:i},r,a){let n=2**i,{west:o,south:s,east:l,north:u}=lS(a,(e-r)/n,(t-r)/n,(e+1+r)/n,(t+1+r)/n);return new mr([o,s],[l,u])}var zP=class{constructor(e){this._waiting=[],this._sending=!1,this._replacedWhileSending=!1,this._handlers=e}isIdle(){return!this._sending&&this._waiting.length===0}top(){return this._waiting.length?this._waiting[this._waiting.length-1]:void 0}some(e){return this._waiting.some(e)}enqueue(e){this._waiting.push(e)}replace(e){this._waiting=[e],this._replacedWhileSending=this._sending}clear(){this._waiting=[]}flush(){if(this.isIdle())return Promise.resolve();if(!this._flushing){let t,i=new Promise(r=>{t=r});this._flushing={promise:i,resolve:t}}let{promise:e}=this._flushing;return this._next(),e}_next(){var t;if(this._sending)return;let e=this._waiting.shift();e===void 0?((t=this._flushing)==null||t.resolve(),this._flushing=void 0):(this._sending=!0,this._replacedWhileSending=!1,this._send(e).finally(()=>this._next()))}async _send(e){let t;try{t=await this._handlers.send(e)}catch(i){this._sending=!1,this._handlers.onError(e,i);return}this._sending=!1;try{this._handlers.onResult(e,t,this._replacedWhileSending)}catch(i){this._handlers.onError(e,i)}}},kP=class{constructor(e){this.wraps=!1,this._crs=e,this._originX=e.tileMatrixSet.origin[0],this._originY=e.tileMatrixSet.origin[1],this._extent=e.tileMatrixSet.extentAtZoom0}get name(){return this._crs.name}get tileMatrixSet(){return this._crs.tileMatrixSet}worldFromLngLat(e,t,i){let[r,a]=this._crs.projection.forward([e,t]);return new It((r-this._originX)/this._extent,(this._originY-a)/this._extent,i===void 0?0:i/this._extent)}lngLatFromWorld(e,t){var n,o,s;let i=Y(e,0,1),r=Y(t,0,1),a=(s=(o=(n=this._inverse(e,t))!=null?n:this._inverse(i,r))!=null?o:this._inverseTowardCenter(i,r))!=null?s:this._finiteInverse(i,r);if(!a)throw Error(`The inverse of the projection "${this._crs.name}" has no answer inside its tile matrix set.`);return new W(a[0],Y(a[1],-90,90))}hasLngLat(e,t){return this._inverse(e,t)!==null}_inverse(e,t){let i=this._finiteInverse(e,t);if(!i)return null;let r=this._originX+e*this._extent,a=this._originY-t*this._extent,[n,o]=this._crs.projection.forward(i);return Math.hypot(n-r,o-a)<=.001*this._extent?i:null}_finiteInverse(e,t){let i;try{i=this._crs.projection.inverse([this._originX+e*this._extent,this._originY-t*this._extent])}catch(r){return null}return i&&Number.isFinite(i[0])&&Number.isFinite(i[1])?i:null}_inverseTowardCenter(e,t){let i=0,r=1;for(let a=0;a<30;a++){let n=(i+r)/2;this._inverse(.5+(e-.5)*n,.5+(t-.5)*n)?i=n:r=n}return this._inverse(.5+(e-.5)*i,.5+(t-.5)*i)}metersPerWorldUnit(e,t){return this._extent}worldZFromAltitude(e,t){return e/this._extent}get latitudeRange(){var e;return(e=this._latitudeRange)!=null||(this._latitudeRange=[this._findLatitudeLimit(-90),this._findLatitudeLimit(90)]),this._latitudeRange}_findLatitudeLimit(e){let t=this.lngLatFromWorld(.5,.5),i=10*this._meridianStretch(t.lng,t.lat);if(!(i>0))return e;let r=Math.sign(e-t.lat);for(let a=t.lat;Math.abs(e-a)>1;a+=r)if(!(this._meridianStretch(t.lng,a+r)<=i))return a;return e}_meridianStretch(e,t){let[i,r]=this._crs.projection.forward([e,t]),[a,n]=this._crs.projection.forward([e,t>=0?t-.01:t+.01]);return Math.hypot(a-i,n-r)}},RP=class{forward(e){return[e[0],e[1]]}inverse(e){return[e[0],e[1]]}};const Hc=new class{constructor(){this.name="identity",this.projection=new RP,this.tileMatrixSet={origin:[-90,90],extentAtZoom0:180}}},LP=new Map([[Hc.name,Hc]]);function su(e){return typeof e=="string"?LP.get(e):void 0}var BP=class extends Ft{constructor(e,t,i,r){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._workerUpdates=new zP({send:a=>this._sendWorkerUpdate(a),onResult:(a,n,o)=>this._onWorkerUpdateResult(a,n,o),onError:(a,n)=>this._onWorkerUpdateError(n)}),t.data!==void 0&&this._workerUpdates.enqueue({data:t.data}),this.actorPromise=i.getActor(),this.setEventedParent(r),this._data=typeof t.data=="string"?{url:t.data}:{geojson:t.data},this._options=X({},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=X({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:O,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:O,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}_pixelsToTileUnits(e){return e*(O/this.tileSize)}_tileUnitsToPixels(e){return e/(O/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(){this._workerUpdates.isIdle()?_e(`No pending worker updates for GeoJSONSource ${this.id}.`):await this._workerUpdates.flush()}onAdd(e){this.map=e,this.load()}setData(e){return this._data=typeof e=="string"?{url:e}:{geojson:e},this._workerUpdates.replace({data:e}),this._workerUpdates.flush()}updateData(e){let t=this._getWaitingWorkerChange();return t?t.diff=PP(t.diff,e,this._promoteIdKey):this._workerUpdates.enqueue({diff:e}),this._workerUpdates.flush()}async getData(){for(;this._data.url;)await this.once("data");return this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return sg(await this.getData())}setClusterOptions(e){if(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._workerUpdates.some(t=>"data"in t)){let t=this._getWaitingWorkerChange();t?t.updateCluster=!0:this._workerUpdates.enqueue({updateCluster:!0})}return this._workerUpdates.flush()}_getWaitingWorkerChange(){let e=this._workerUpdates.top();return e&&!("data"in e)?e:void 0}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,i){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}async _getLoadGeoJSONParameters(e){let t=X({type:this.type,source:this.id},this.workerOptions),i=this._getCRSParameters();return i&&(t.crs=i),"data"in e?typeof e.data=="string"?(t.request=await this.map._requestManager.transformRequest(Xt.resolveURL(e.data),"Source"),t.request.collectResourceTiming=this._collectResourceTiming,t):(t.data=e.data,t):(e.diff&&(t.dataDiff=e.diff),e.updateCluster&&(t.updateCluster=!0),t)}_getCRSParameters(){var t,i,r;let e=su((r=(i=(t=this.map)==null?void 0:t.style)==null?void 0:i.projection)==null?void 0:r.name);if(e)if(!e.definition&&e!==Hc)_e(`GeoJSON source "${this.id}" is drawn in the wrong place: the projection "${e.name}" has no \`definition\` to project its data with.`);else return{name:e.name,definition:e.definition,tileMatrixSet:e.tileMatrixSet}}async _sendWorkerUpdate(e){this.fire(new $e("dataloading"));let t=await this._getLoadGeoJSONParameters(e);return(await this.actorPromise).sendAsync({type:"LD",data:t})}_onWorkerUpdateResult(e,t,i){var s,l,u;if(this._removed||t.abandoned){this.fire(new $e("dataabort"));return}t.data&&!i&&(this._data={geojson:t.data});let r="data"in e||i?void 0:e.diff,a=this._applyDiffToSource(r),n=!("data"in e)&&e.updateCluster||((u=(l=(s=this.map)==null?void 0:s.style)==null?void 0:l.projection)==null?void 0:u.worldCoordinateHelper.wraps)===!1?void 0:this._getShouldReloadTileOptions(a),o={};this._applyResourceTiming(o,t),this.fire(new $e("data",{...o,sourceDataType:"metadata"})),this.fire(new $e("data",{...o,sourceDataType:"content",shouldReloadTileOptions:n}))}_onWorkerUpdateError(e){this._removed?this.fire(new $e("dataabort")):this.fire(new K(Dt(e)))}_applyResourceTiming(e,t){var a;if(!this._collectResourceTiming)return;let i=(a=t.resourceTiming)==null?void 0:a[this.id];if(!i)return;let r=i.slice(0);r!=null&&r.length&&X(e,{resourceTiming:r})}_applyDiffToSource(e){if(!e)return;let t=this._promoteIdKey;if(!this._data.url&&!this._data.updateable){let r=EP(this._data.geojson,t);if(!r)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:r}}if(!this._data.updateable)return;let i=CP(this._data.updateable,e,t);if(!(e.removeAll||this.workerOptions.geojsonVtOptions.cluster))return i}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(t=>sg(t))}}shouldReloadTile(e,{affectedBounds:t}){if(e.state==="loading")return!0;if(e.state==="unloaded")return!1;let{buffer:i,extent:r}=this.workerOptions.geojsonVtOptions,a=FP(e.tileID.canonical,i/r,this.map.style.projection.worldCoordinateHelper);for(let n of t)if(a.intersects(n))return!0;return!1}loaded(){return this._workerUpdates.isIdle()}async loadTile(e){let t=e.actor?"RT":"LT";e.actor=await this.actorPromise;let i={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 r=await(await this.actorPromise).sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.style,t==="RT")}catch(r){if(delete e.abortController,e.aborted||Fr(r))return;throw r}}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._workerUpdates.clear(),this.actorPromise.then(e=>e.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return X({},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 Ga=[0,0,1],OP=(e,t)=>({u_tl_parent:new ce(e,t.u_tl_parent),u_scale_parent:new $(e,t.u_scale_parent),u_buffer_scale:new $(e,t.u_buffer_scale),u_image_warp:new Vt(e,t.u_image_warp),u_fade_t:new $(e,t.u_fade_t),u_opacity:new $(e,t.u_opacity),u_image0:new J(e,t.u_image0),u_image1:new J(e,t.u_image1),u_brightness_low:new $(e,t.u_brightness_low),u_brightness_high:new $(e,t.u_brightness_high),u_saturation_factor:new $(e,t.u_saturation_factor),u_contrast_factor:new $(e,t.u_contrast_factor),u_spin_weights:new Vt(e,t.u_spin_weights),u_coords_top:new tn(e,t.u_coords_top),u_coords_bottom:new tn(e,t.u_coords_bottom)}),jP=(e,t,i,r,a,n)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp:n,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:UP(r.paint.get("raster-saturation")),u_contrast_factor:NP(r.paint.get("raster-contrast")),u_spin_weights:VP(r.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 VP(e){e*=Math.PI/180;let t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}function NP(e){return e>0?1/(1-e):1+e}function UP(e){return e>0?1-1/(1.001-e):-e}var wo=class{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const Ba=Qe([{name:"a_pos",type:"Int16",components:2}]);function iv(e,t){let i=$P(t,"16bit"),r=qr.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),a=Ki.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new wo(e.createVertexBuffer(r,Ba.members),e.createIndexBuffer(a),Ke.simpleSegment(0,0,r.length,a.length))}function $P(e,t){let i=e.granularity===void 0?1:Math.max(e.granularity,1),r=i+(e.generateBorders?2:0),a=i+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),n=r+1,o=a+1,s=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=i+ +!!e.generateBorders,h=i+(e.generateBorders||e.extendToSouthPole?1:0),c=n*o,d=r*a*6,p=n*o>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=s;x<=u;x++){let b=x/i*O;x===-1&&(b=-64),x===i+1&&(b=8256);let w=v/i*O;v===-1&&(w=e.extendToNorthPole?Yn:-64),v===i+1&&(w=e.extendToSouthPole?Kn:8256),m[g++]=b,m[g++]=w}let _=f?new Uint32Array(d):new Uint16Array(d),y=0;for(let v=0;v<a;v++)for(let x=0;x<r;x++){let b=x+v*n,w=x+1+v*n,T=x+(v+1)*n,S=x+1+(v+1)*n;_[y++]=b,_[y++]=T,_[y++]=w,_[y++]=w,_[y++]=T,_[y++]=S}return{vertices:m.buffer.slice(0),indices:_.buffer.slice(0),uses32bitIndices:f}}var ko=class extends Ft{constructor(e,t,i,r){super(),this.imageWarp=Ga,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}async load(e){if(this.options.url===void 0)this._loaded=!0,this._finishLoading();else{this._loaded=!1,this.fire(new $e("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await Ci.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 K(Error(`Could not load image ${this.url}: the response is empty`)))}catch(t){if(Fr(t))return;this._abortController=null,this._loaded=!0,this.fire(new K(Dt(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)}_setImage(e){this.image=e,this._imageDirty=!0}getMesh(e,t){var i;return!this._subdividedQuad||t?null:((i=this._subdividedMesh)!=null||(this._subdividedMesh=iv(e,{granularity:16})),this._subdividedMesh)}_disposeTexture(){var e;(e=this.texture)==null||e.destroy(),this.texture=null}_finishLoading(){if(this.map)try{this.setCoordinates(this.coordinates),this.fire(new $e("data",{sourceDataType:"metadata"}))}catch(e){this.fire(new K(Dt(e)))}}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._warp=e,this.tileCoords&&this.setCoordinates(this.coordinates)),this}getWarp(){return this._warp}setCoordinates(e){this.coordinates=e;let t=this.map.style.projection.worldCoordinateHelper,i=e.map(r=>{let a=W.convert(r);return t.worldFromLngLat(a.lng,a.lat)});return this.tileID=GP(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(r=>this.tileID.getTilePoint(r)._round()),this.imageWarp=qP(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!rv(this.tileCoords),this.flippedWindingOrder=ZP(this.tileCoords),this.fire(new $e("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 ft(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let i=!1;for(let r in this.tiles){let a=this.tiles[r];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,i=!0)}i&&this.fire(new $e("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:i,maxX:r,maxY:a}=Mi.fromPoints(e),n={};for(let o=0;o<=25;o++){let s=2**o,l=Math.floor(t*s),u=Math.floor(i*s),h=Math.floor(r*s),c=Math.floor(a*s),d=(l%s+s)%s,p=h%s,f=Math.floor(l/s),m=Math.floor(h/s);n[o]={minWrap:f,maxWrap:m,minTileXWrapped:d,maxTileXWrapped:p,minTileY:u,maxTileY:c}}return n}};function GP(e){let t=Mi.fromPoints(e),i=t.width(),r=t.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(i,r))/Math.LN2)),n=2**a;return new ou(a,Math.floor((t.minX+t.maxX)/2*n),Math.floor((t.minY+t.maxY)/2*n))}function ZP(e){let t=e[1].x-e[0].x,i=e[1].y-e[0].y,r=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-i*r<0}function qP(e,t){if(t==="flat"||rv(e))return Ga;let[i,r,a,n]=e,o=i.x-r.x+a.x-n.x,s=i.y-r.y+a.y-n.y,l=[r.x-a.x,r.y-a.y,n.x-a.x,n.y-a.y],[u,h,c,d]=l,p=Yx(l),f=(o*d-c*s)/p,m=(u*s-o*h)/p,g=[1,1+f,1+f+m,1+m],_=Math.max(...g)/Math.min(...g),y=t==="perspective"?0:WP(_);return!(_>=1&&_<=512)||y>=1?Ga:[f,m,y]}function WP(e){let t=(1-4/e)/.9921875;return Math.max(0,t)}function rv(e){let[t,i,r,a]=e;return t.x+r.x===i.x+a.x&&t.y+r.y===i.y+a.y}var HP=class extends ko{constructor(e,t,i,r){super(e,t,i,r),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 Jb(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 K(Dt(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 K(new j(`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 ft(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let i=!1;for(let r in this.tiles){let a=this.tiles[r];a.state!=="loaded"&&(a.state="loaded",a.texture=this.texture,i=!0)}i&&this.fire(new $e("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},XP=class extends ko{constructor(e,t,i,r){super(e,t,i,r),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 K(new j(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new K(new j(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new K(new j(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas!="string"&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new K(new j(`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 K(new j(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=t.animate===void 0||t.animate}async load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new K(Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this._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,i=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new ft(t,this.canvas,i.RGBA,{premultiply:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(let a in this.tiles){let n=this.tiles[a];n.state!=="loaded"&&(n.state="loaded",n.texture=this.texture,r=!0)}r&&this.fire(new $e("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 YP={},KP=(e,t,i,r)=>{let a=new(JP(t.type))(e,t,i,r);if(a.id!==e)throw Error(`Expected Source id to be ${e} instead of ${a.id}`);return a},JP=e=>{switch(e){case"geojson":return BP;case"image":return ko;case"raster":return ev;case"raster-dem":return SP;case"vector":return wP;case"video":return HP;case"canvas":return XP}return YP[e]};function QP(e,t){let i={};if(!t)return i;for(let r of e){let a=r.layerIds.map(n=>t.getLayer(n)).filter(Boolean);if(a.length!==0){r.layers=a,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(n=>a.filter(o=>o.id===n)[0]));for(let n of a)i[n.id]=r}}return i}const Zs="_geojsonTileLayer";var eA=class{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}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]}},Mr,av=(Mr=class{constructor(t,i,r,a,n,o){this.type="Feature",this._vectorTileFeature=t,this._x=r,this._y=a,this._z=i,o!==ln&&Mr.worldCoordinateHelpers.set(this,o);for(let s in t.properties)typeof t.properties[s]=="string"&&t.properties[s].startsWith("__$json__:")&&(t.properties[s]=JSON.parse(t.properties[s].slice(10)));this.properties=t.properties,this.id=n}projectPoint(t,i,r,a,n){if(n){let o=n.lngLatFromWorld((t.x+i)/a,(t.y+r)/a);return[o.lng,o.lat]}return[(t.x+i)*360/a-180,360/Math.PI*Math.atan(Math.exp((1-(t.y+r)*2/a)*Math.PI))-90]}projectLine(t,i,r,a,n){return t.map(o=>this.projectPoint(o,i,r,a,n))}get geometry(){if(this._geometry)return this._geometry;let t=this._vectorTileFeature,i=Mr.worldCoordinateHelpers.get(this),r=t.extent*2**this._z,a=t.extent*this._x,n=t.extent*this._y,o=t.loadGeometry();switch(t.type){case 1:{let s=[];for(let u of o)s.push(u[0]);let l=this.projectLine(s,a,n,r,i);this._geometry=s.length===1?{type:"Point",coordinates:l[0]}:{type:"MultiPoint",coordinates:l};break}case 2:{let s=o.map(l=>this.projectLine(l,a,n,r,i));this._geometry=s.length===1?{type:"LineString",coordinates:s[0]}:{type:"MultiLineString",coordinates:s};break}case 3:{let s=n1(o),l=[];for(let u of s)l.push(u.map(h=>this.projectLine(h,a,n,r,i)));this._geometry=l.length===1?{type:"Polygon",coordinates:l[0]}:{type:"MultiPolygon",coordinates:l};break}default:throw Error(`unknown feature type: ${t.type}`)}return this._geometry}set geometry(t){this._geometry=t}toJSON(){let t={geometry:this.geometry};for(let i in this)i!=="_geometry"&&i!=="_vectorTileFeature"&&i!=="_x"&&i!=="_y"&&i!=="_z"&&(t[i]=this[i]);return t}},Mr.worldCoordinateHelpers=new WeakMap,Mr),pa=class{constructor(e,t,i){this._name=e,this.dataBuffer=t,typeof i=="number"?this._size=i:(this.nullabilityBuffer=i,this._size=i.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}},lu=class extends pa{},ip=class extends lu{getValueFromBuffer(e){return this.dataBuffer[e]}},rp=class extends lu{getValueFromBuffer(e){return this.dataBuffer[e]}},nv=class extends pa{constructor(e,t,i,r){super(e,t,r),this.delta=i}},ap=class extends nv{constructor(e,t,i,r,a){super(e,a?Int32Array.of(t):Uint32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},np=class extends pa{constructor(e,t,i,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},tA=class{constructor(e,t,i,r,a=4096){if(this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=r,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(){var e;return(e=this._propertyVectors)!=null?e:[]}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 i=0;i<this.numFeatures;i++){let r;if(this.idVector){let o=this.idVector.getValue(i);o!==null&&(r=this.containsMaxSafeIntegerValues(this.idVector)?Number(o):o)}let a={coordinates:t[i],type:this.geometryVector.geometryType(i)},n={};for(let o of this.propertyVectors){if(!o)continue;let s=o.name,l=o.getValue(i);l!==null&&(n[s]=l)}e.push({id:r,geometry:a,properties:n})}return e}containsMaxSafeIntegerValues(e){return e instanceof ip||e instanceof np||e instanceof ap||e instanceof rp}};const Gn={FEATURE:0},Se={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},Ar={GEOMETRY:0,STRUCT:1,MAP:2},ov={ID:0};var sv=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}},ue;(function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON"})(ue||(ue={}));var ni;(function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT"})(ni||(ni={}));const op=new Uint32Array(33);op[0]=0;for(let e=1;e<=32;e++)op[e]=e===32?4294967295:4294967295>>>32-e;const Xc=op,lv=65536;function sp(e,t){return e-e%t}function iA(e){return sp(e+31,32)}function rA(e){if(!Number.isFinite(e)||e<=0)return lv;let t=sp(Math.floor(e),256);return t===0?256:t}function aA(e){let t=e>>>0;return((t&255)<<24|(t&65280)<<8|t>>>8&65280|t>>>24&255)>>>0}function nA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0;i[a++]=n>>>0&3,i[a++]=n>>>2&3,i[a++]=n>>>4&3,i[a++]=n>>>6&3,i[a++]=n>>>8&3,i[a++]=n>>>10&3,i[a++]=n>>>12&3,i[a++]=n>>>14&3,i[a++]=n>>>16&3,i[a++]=n>>>18&3,i[a++]=n>>>20&3,i[a++]=n>>>22&3,i[a++]=n>>>24&3,i[a++]=n>>>26&3,i[a++]=n>>>28&3,i[a++]=n>>>30&3,i[a++]=o>>>0&3,i[a++]=o>>>2&3,i[a++]=o>>>4&3,i[a++]=o>>>6&3,i[a++]=o>>>8&3,i[a++]=o>>>10&3,i[a++]=o>>>12&3,i[a++]=o>>>14&3,i[a++]=o>>>16&3,i[a++]=o>>>18&3,i[a++]=o>>>20&3,i[a++]=o>>>22&3,i[a++]=o>>>24&3,i[a++]=o>>>26&3,i[a++]=o>>>28&3,i[a]=o>>>30&3}function oA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0;i[a++]=n>>>0&7,i[a++]=n>>>3&7,i[a++]=n>>>6&7,i[a++]=n>>>9&7,i[a++]=n>>>12&7,i[a++]=n>>>15&7,i[a++]=n>>>18&7,i[a++]=n>>>21&7,i[a++]=n>>>24&7,i[a++]=n>>>27&7,i[a++]=(n>>>30|(o&1)<<2)&7,i[a++]=o>>>1&7,i[a++]=o>>>4&7,i[a++]=o>>>7&7,i[a++]=o>>>10&7,i[a++]=o>>>13&7,i[a++]=o>>>16&7,i[a++]=o>>>19&7,i[a++]=o>>>22&7,i[a++]=o>>>25&7,i[a++]=o>>>28&7,i[a++]=(o>>>31|(s&3)<<1)&7,i[a++]=s>>>2&7,i[a++]=s>>>5&7,i[a++]=s>>>8&7,i[a++]=s>>>11&7,i[a++]=s>>>14&7,i[a++]=s>>>17&7,i[a++]=s>>>20&7,i[a++]=s>>>23&7,i[a++]=s>>>26&7,i[a]=s>>>29&7}function sA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0;i[a++]=n>>>0&15,i[a++]=n>>>4&15,i[a++]=n>>>8&15,i[a++]=n>>>12&15,i[a++]=n>>>16&15,i[a++]=n>>>20&15,i[a++]=n>>>24&15,i[a++]=n>>>28&15,i[a++]=o>>>0&15,i[a++]=o>>>4&15,i[a++]=o>>>8&15,i[a++]=o>>>12&15,i[a++]=o>>>16&15,i[a++]=o>>>20&15,i[a++]=o>>>24&15,i[a++]=o>>>28&15,i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15,i[a++]=l>>>0&15,i[a++]=l>>>4&15,i[a++]=l>>>8&15,i[a++]=l>>>12&15,i[a++]=l>>>16&15,i[a++]=l>>>20&15,i[a++]=l>>>24&15,i[a]=l>>>28&15}function lA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0;i[a++]=n>>>0&31,i[a++]=n>>>5&31,i[a++]=n>>>10&31,i[a++]=n>>>15&31,i[a++]=n>>>20&31,i[a++]=n>>>25&31,i[a++]=(n>>>30|(o&7)<<2)&31,i[a++]=o>>>3&31,i[a++]=o>>>8&31,i[a++]=o>>>13&31,i[a++]=o>>>18&31,i[a++]=o>>>23&31,i[a++]=(o>>>28|(s&1)<<4)&31,i[a++]=s>>>1&31,i[a++]=s>>>6&31,i[a++]=s>>>11&31,i[a++]=s>>>16&31,i[a++]=s>>>21&31,i[a++]=s>>>26&31,i[a++]=(s>>>31|(l&15)<<1)&31,i[a++]=l>>>4&31,i[a++]=l>>>9&31,i[a++]=l>>>14&31,i[a++]=l>>>19&31,i[a++]=l>>>24&31,i[a++]=(l>>>29|(u&3)<<3)&31,i[a++]=u>>>2&31,i[a++]=u>>>7&31,i[a++]=u>>>12&31,i[a++]=u>>>17&31,i[a++]=u>>>22&31,i[a]=u>>>27&31}function uA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0;i[a++]=n>>>0&63,i[a++]=n>>>6&63,i[a++]=n>>>12&63,i[a++]=n>>>18&63,i[a++]=n>>>24&63,i[a++]=(n>>>30|(o&15)<<2)&63,i[a++]=o>>>4&63,i[a++]=o>>>10&63,i[a++]=o>>>16&63,i[a++]=o>>>22&63,i[a++]=(o>>>28|(s&3)<<4)&63,i[a++]=s>>>2&63,i[a++]=s>>>8&63,i[a++]=s>>>14&63,i[a++]=s>>>20&63,i[a++]=s>>>26&63,i[a++]=l>>>0&63,i[a++]=l>>>6&63,i[a++]=l>>>12&63,i[a++]=l>>>18&63,i[a++]=l>>>24&63,i[a++]=(l>>>30|(u&15)<<2)&63,i[a++]=u>>>4&63,i[a++]=u>>>10&63,i[a++]=u>>>16&63,i[a++]=u>>>22&63,i[a++]=(u>>>28|(h&3)<<4)&63,i[a++]=h>>>2&63,i[a++]=h>>>8&63,i[a++]=h>>>14&63,i[a++]=h>>>20&63,i[a]=h>>>26&63}function hA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0;i[a++]=n>>>0&127,i[a++]=n>>>7&127,i[a++]=n>>>14&127,i[a++]=n>>>21&127,i[a++]=(n>>>28|(o&7)<<4)&127,i[a++]=o>>>3&127,i[a++]=o>>>10&127,i[a++]=o>>>17&127,i[a++]=o>>>24&127,i[a++]=(o>>>31|(s&63)<<1)&127,i[a++]=s>>>6&127,i[a++]=s>>>13&127,i[a++]=s>>>20&127,i[a++]=(s>>>27|(l&3)<<5)&127,i[a++]=l>>>2&127,i[a++]=l>>>9&127,i[a++]=l>>>16&127,i[a++]=l>>>23&127,i[a++]=(l>>>30|(u&31)<<2)&127,i[a++]=u>>>5&127,i[a++]=u>>>12&127,i[a++]=u>>>19&127,i[a++]=(u>>>26|(h&1)<<6)&127,i[a++]=h>>>1&127,i[a++]=h>>>8&127,i[a++]=h>>>15&127,i[a++]=h>>>22&127,i[a++]=(h>>>29|(c&15)<<3)&127,i[a++]=c>>>4&127,i[a++]=c>>>11&127,i[a++]=c>>>18&127,i[a]=c>>>25&127}function cA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=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;i[a++]=n>>>0&255,i[a++]=n>>>8&255,i[a++]=n>>>16&255,i[a++]=n>>>24&255,i[a++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=d>>>0&255,i[a++]=d>>>8&255,i[a++]=d>>>16&255,i[a]=d>>>24&255}function dA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=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;i[a++]=n>>>0&511,i[a++]=n>>>9&511,i[a++]=n>>>18&511,i[a++]=(n>>>27|(o&15)<<5)&511,i[a++]=o>>>4&511,i[a++]=o>>>13&511,i[a++]=o>>>22&511,i[a++]=(o>>>31|(s&255)<<1)&511,i[a++]=s>>>8&511,i[a++]=s>>>17&511,i[a++]=(s>>>26|(l&7)<<6)&511,i[a++]=l>>>3&511,i[a++]=l>>>12&511,i[a++]=l>>>21&511,i[a++]=(l>>>30|(u&127)<<2)&511,i[a++]=u>>>7&511,i[a++]=u>>>16&511,i[a++]=(u>>>25|(h&3)<<7)&511,i[a++]=h>>>2&511,i[a++]=h>>>11&511,i[a++]=h>>>20&511,i[a++]=(h>>>29|(c&63)<<3)&511,i[a++]=c>>>6&511,i[a++]=c>>>15&511,i[a++]=(c>>>24|(d&1)<<8)&511,i[a++]=d>>>1&511,i[a++]=d>>>10&511,i[a++]=d>>>19&511,i[a++]=(d>>>28|(p&31)<<4)&511,i[a++]=p>>>5&511,i[a++]=p>>>14&511,i[a]=p>>>23&511}function pA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=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;i[a++]=n>>>0&1023,i[a++]=n>>>10&1023,i[a++]=n>>>20&1023,i[a++]=(n>>>30|(o&255)<<2)&1023,i[a++]=o>>>8&1023,i[a++]=o>>>18&1023,i[a++]=(o>>>28|(s&63)<<4)&1023,i[a++]=s>>>6&1023,i[a++]=s>>>16&1023,i[a++]=(s>>>26|(l&15)<<6)&1023,i[a++]=l>>>4&1023,i[a++]=l>>>14&1023,i[a++]=(l>>>24|(u&3)<<8)&1023,i[a++]=u>>>2&1023,i[a++]=u>>>12&1023,i[a++]=u>>>22&1023,i[a++]=h>>>0&1023,i[a++]=h>>>10&1023,i[a++]=h>>>20&1023,i[a++]=(h>>>30|(c&255)<<2)&1023,i[a++]=c>>>8&1023,i[a++]=c>>>18&1023,i[a++]=(c>>>28|(d&63)<<4)&1023,i[a++]=d>>>6&1023,i[a++]=d>>>16&1023,i[a++]=(d>>>26|(p&15)<<6)&1023,i[a++]=p>>>4&1023,i[a++]=p>>>14&1023,i[a++]=(p>>>24|(f&3)<<8)&1023,i[a++]=f>>>2&1023,i[a++]=f>>>12&1023,i[a]=f>>>22&1023}function fA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=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;i[a++]=n>>>0&2047,i[a++]=n>>>11&2047,i[a++]=(n>>>22|(o&1)<<10)&2047,i[a++]=o>>>1&2047,i[a++]=o>>>12&2047,i[a++]=(o>>>23|(s&3)<<9)&2047,i[a++]=s>>>2&2047,i[a++]=s>>>13&2047,i[a++]=(s>>>24|(l&7)<<8)&2047,i[a++]=l>>>3&2047,i[a++]=l>>>14&2047,i[a++]=(l>>>25|(u&15)<<7)&2047,i[a++]=u>>>4&2047,i[a++]=u>>>15&2047,i[a++]=(u>>>26|(h&31)<<6)&2047,i[a++]=h>>>5&2047,i[a++]=h>>>16&2047,i[a++]=(h>>>27|(c&63)<<5)&2047,i[a++]=c>>>6&2047,i[a++]=c>>>17&2047,i[a++]=(c>>>28|(d&127)<<4)&2047,i[a++]=d>>>7&2047,i[a++]=d>>>18&2047,i[a++]=(d>>>29|(p&255)<<3)&2047,i[a++]=p>>>8&2047,i[a++]=p>>>19&2047,i[a++]=(p>>>30|(f&511)<<2)&2047,i[a++]=f>>>9&2047,i[a++]=f>>>20&2047,i[a++]=(f>>>31|(m&1023)<<1)&2047,i[a++]=m>>>10&2047,i[a]=m>>>21&2047}function mA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=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;i[a++]=n>>>0&4095,i[a++]=n>>>12&4095,i[a++]=(n>>>24|(o&15)<<8)&4095,i[a++]=o>>>4&4095,i[a++]=o>>>16&4095,i[a++]=(o>>>28|(s&255)<<4)&4095,i[a++]=s>>>8&4095,i[a++]=s>>>20&4095,i[a++]=l>>>0&4095,i[a++]=l>>>12&4095,i[a++]=(l>>>24|(u&15)<<8)&4095,i[a++]=u>>>4&4095,i[a++]=u>>>16&4095,i[a++]=(u>>>28|(h&255)<<4)&4095,i[a++]=h>>>8&4095,i[a++]=h>>>20&4095,i[a++]=c>>>0&4095,i[a++]=c>>>12&4095,i[a++]=(c>>>24|(d&15)<<8)&4095,i[a++]=d>>>4&4095,i[a++]=d>>>16&4095,i[a++]=(d>>>28|(p&255)<<4)&4095,i[a++]=p>>>8&4095,i[a++]=p>>>20&4095,i[a++]=f>>>0&4095,i[a++]=f>>>12&4095,i[a++]=(f>>>24|(m&15)<<8)&4095,i[a++]=m>>>4&4095,i[a++]=m>>>16&4095,i[a++]=(m>>>28|(g&255)<<4)&4095,i[a++]=g>>>8&4095,i[a]=g>>>20&4095}function gA(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=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;i[a++]=n>>>0&65535,i[a++]=n>>>16&65535,i[a++]=o>>>0&65535,i[a++]=o>>>16&65535,i[a++]=s>>>0&65535,i[a++]=s>>>16&65535,i[a++]=l>>>0&65535,i[a++]=l>>>16&65535,i[a++]=u>>>0&65535,i[a++]=u>>>16&65535,i[a++]=h>>>0&65535,i[a++]=h>>>16&65535,i[a++]=c>>>0&65535,i[a++]=c>>>16&65535,i[a++]=d>>>0&65535,i[a++]=d>>>16&65535,i[a++]=p>>>0&65535,i[a++]=p>>>16&65535,i[a++]=f>>>0&65535,i[a++]=f>>>16&65535,i[a++]=m>>>0&65535,i[a++]=m>>>16&65535,i[a++]=g>>>0&65535,i[a++]=g>>>16&65535,i[a++]=_>>>0&65535,i[a++]=_>>>16&65535,i[a++]=y>>>0&65535,i[a++]=y>>>16&65535,i[a++]=v>>>0&65535,i[a++]=v>>>16&65535,i[a++]=x>>>0&65535,i[a]=x>>>16&65535}function _A(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0;i[a++]=s>>>0&1,i[a++]=s>>>1&1,i[a++]=s>>>2&1,i[a++]=s>>>3&1,i[a++]=s>>>4&1,i[a++]=s>>>5&1,i[a++]=s>>>6&1,i[a++]=s>>>7&1,i[a++]=s>>>8&1,i[a++]=s>>>9&1,i[a++]=s>>>10&1,i[a++]=s>>>11&1,i[a++]=s>>>12&1,i[a++]=s>>>13&1,i[a++]=s>>>14&1,i[a++]=s>>>15&1,i[a++]=s>>>16&1,i[a++]=s>>>17&1,i[a++]=s>>>18&1,i[a++]=s>>>19&1,i[a++]=s>>>20&1,i[a++]=s>>>21&1,i[a++]=s>>>22&1,i[a++]=s>>>23&1,i[a++]=s>>>24&1,i[a++]=s>>>25&1,i[a++]=s>>>26&1,i[a++]=s>>>27&1,i[a++]=s>>>28&1,i[a++]=s>>>29&1,i[a++]=s>>>30&1,i[a++]=s>>>31&1}}function yA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0;i[a++]=s>>>0&3,i[a++]=s>>>2&3,i[a++]=s>>>4&3,i[a++]=s>>>6&3,i[a++]=s>>>8&3,i[a++]=s>>>10&3,i[a++]=s>>>12&3,i[a++]=s>>>14&3,i[a++]=s>>>16&3,i[a++]=s>>>18&3,i[a++]=s>>>20&3,i[a++]=s>>>22&3,i[a++]=s>>>24&3,i[a++]=s>>>26&3,i[a++]=s>>>28&3,i[a++]=s>>>30&3,i[a++]=l>>>0&3,i[a++]=l>>>2&3,i[a++]=l>>>4&3,i[a++]=l>>>6&3,i[a++]=l>>>8&3,i[a++]=l>>>10&3,i[a++]=l>>>12&3,i[a++]=l>>>14&3,i[a++]=l>>>16&3,i[a++]=l>>>18&3,i[a++]=l>>>20&3,i[a++]=l>>>22&3,i[a++]=l>>>24&3,i[a++]=l>>>26&3,i[a++]=l>>>28&3,i[a++]=l>>>30&3}}function vA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0;i[a++]=s>>>0&7,i[a++]=s>>>3&7,i[a++]=s>>>6&7,i[a++]=s>>>9&7,i[a++]=s>>>12&7,i[a++]=s>>>15&7,i[a++]=s>>>18&7,i[a++]=s>>>21&7,i[a++]=s>>>24&7,i[a++]=s>>>27&7,i[a++]=(s>>>30|(l&1)<<2)&7,i[a++]=l>>>1&7,i[a++]=l>>>4&7,i[a++]=l>>>7&7,i[a++]=l>>>10&7,i[a++]=l>>>13&7,i[a++]=l>>>16&7,i[a++]=l>>>19&7,i[a++]=l>>>22&7,i[a++]=l>>>25&7,i[a++]=l>>>28&7,i[a++]=(l>>>31|(u&3)<<1)&7,i[a++]=u>>>2&7,i[a++]=u>>>5&7,i[a++]=u>>>8&7,i[a++]=u>>>11&7,i[a++]=u>>>14&7,i[a++]=u>>>17&7,i[a++]=u>>>20&7,i[a++]=u>>>23&7,i[a++]=u>>>26&7,i[a++]=u>>>29&7}}function xA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0;i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15,i[a++]=l>>>0&15,i[a++]=l>>>4&15,i[a++]=l>>>8&15,i[a++]=l>>>12&15,i[a++]=l>>>16&15,i[a++]=l>>>20&15,i[a++]=l>>>24&15,i[a++]=l>>>28&15,i[a++]=u>>>0&15,i[a++]=u>>>4&15,i[a++]=u>>>8&15,i[a++]=u>>>12&15,i[a++]=u>>>16&15,i[a++]=u>>>20&15,i[a++]=u>>>24&15,i[a++]=u>>>28&15,i[a++]=h>>>0&15,i[a++]=h>>>4&15,i[a++]=h>>>8&15,i[a++]=h>>>12&15,i[a++]=h>>>16&15,i[a++]=h>>>20&15,i[a++]=h>>>24&15,i[a++]=h>>>28&15}}function bA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0;i[a++]=s>>>0&31,i[a++]=s>>>5&31,i[a++]=s>>>10&31,i[a++]=s>>>15&31,i[a++]=s>>>20&31,i[a++]=s>>>25&31,i[a++]=(s>>>30|(l&7)<<2)&31,i[a++]=l>>>3&31,i[a++]=l>>>8&31,i[a++]=l>>>13&31,i[a++]=l>>>18&31,i[a++]=l>>>23&31,i[a++]=(l>>>28|(u&1)<<4)&31,i[a++]=u>>>1&31,i[a++]=u>>>6&31,i[a++]=u>>>11&31,i[a++]=u>>>16&31,i[a++]=u>>>21&31,i[a++]=u>>>26&31,i[a++]=(u>>>31|(h&15)<<1)&31,i[a++]=h>>>4&31,i[a++]=h>>>9&31,i[a++]=h>>>14&31,i[a++]=h>>>19&31,i[a++]=h>>>24&31,i[a++]=(h>>>29|(c&3)<<3)&31,i[a++]=c>>>2&31,i[a++]=c>>>7&31,i[a++]=c>>>12&31,i[a++]=c>>>17&31,i[a++]=c>>>22&31,i[a++]=c>>>27&31}}function wA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0,d=e[n++]>>>0;i[a++]=s>>>0&63,i[a++]=s>>>6&63,i[a++]=s>>>12&63,i[a++]=s>>>18&63,i[a++]=s>>>24&63,i[a++]=(s>>>30|(l&15)<<2)&63,i[a++]=l>>>4&63,i[a++]=l>>>10&63,i[a++]=l>>>16&63,i[a++]=l>>>22&63,i[a++]=(l>>>28|(u&3)<<4)&63,i[a++]=u>>>2&63,i[a++]=u>>>8&63,i[a++]=u>>>14&63,i[a++]=u>>>20&63,i[a++]=u>>>26&63,i[a++]=h>>>0&63,i[a++]=h>>>6&63,i[a++]=h>>>12&63,i[a++]=h>>>18&63,i[a++]=h>>>24&63,i[a++]=(h>>>30|(c&15)<<2)&63,i[a++]=c>>>4&63,i[a++]=c>>>10&63,i[a++]=c>>>16&63,i[a++]=c>>>22&63,i[a++]=(c>>>28|(d&3)<<4)&63,i[a++]=d>>>2&63,i[a++]=d>>>8&63,i[a++]=d>>>14&63,i[a++]=d>>>20&63,i[a++]=d>>>26&63}}function TA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=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;i[a++]=s>>>0&127,i[a++]=s>>>7&127,i[a++]=s>>>14&127,i[a++]=s>>>21&127,i[a++]=(s>>>28|(l&7)<<4)&127,i[a++]=l>>>3&127,i[a++]=l>>>10&127,i[a++]=l>>>17&127,i[a++]=l>>>24&127,i[a++]=(l>>>31|(u&63)<<1)&127,i[a++]=u>>>6&127,i[a++]=u>>>13&127,i[a++]=u>>>20&127,i[a++]=(u>>>27|(h&3)<<5)&127,i[a++]=h>>>2&127,i[a++]=h>>>9&127,i[a++]=h>>>16&127,i[a++]=h>>>23&127,i[a++]=(h>>>30|(c&31)<<2)&127,i[a++]=c>>>5&127,i[a++]=c>>>12&127,i[a++]=c>>>19&127,i[a++]=(c>>>26|(d&1)<<6)&127,i[a++]=d>>>1&127,i[a++]=d>>>8&127,i[a++]=d>>>15&127,i[a++]=d>>>22&127,i[a++]=(d>>>29|(p&15)<<3)&127,i[a++]=p>>>4&127,i[a++]=p>>>11&127,i[a++]=p>>>18&127,i[a++]=p>>>25&127}}function DA(e,t,i,r){let a=r,n=t;for(let o=0;o<8;o++){let s=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;i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=d>>>0&255,i[a++]=d>>>8&255,i[a++]=d>>>16&255,i[a++]=d>>>24&255,i[a++]=p>>>0&255,i[a++]=p>>>8&255,i[a++]=p>>>16&255,i[a++]=p>>>24&255,i[a++]=f>>>0&255,i[a++]=f>>>8&255,i[a++]=f>>>16&255,i[a++]=f>>>24&255}}function SA(e,t,i,r){let a=r,n=t;for(let o=0;o<128;o++){let s=e[n++]>>>0;i[a++]=s&65535,i[a++]=s>>>16&65535}}function EA(e,t,i,r,a){let n=Xc[a]>>>0,o=t,s=0,l=e[o]>>>0,u=r;for(let h=0;h<8;h++){for(let c=0;c<32;c++)if(s+a<=32){let d=l>>>s&n;i[u+c]=d|0,s+=a,s===32&&(s=0,o++,c!==31&&(l=e[o]>>>0))}else{let d=32-s,p=l>>>s;o++,l=e[o]>>>0;let f=a-d,m=-1>>>32-f>>>0,g=(p|(l&m)<<d)&n;i[u+c]=g|0,s=f}u+=32,s=0,h<7&&(l=e[o]>>>0)}}const Yc=rA(lv),CA=3*Yc/256+Yc|0;function uv(){let e=new Uint8Array(CA);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 PA(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:uv()}}function AA(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let i=new Uint32Array(Math.max(16,t*2));return e.encodedWords=i,i}function MA(e,t,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(i*2),r.byteContainerI32=void 0);let a=r.byteContainer,n=i>>>2;if(a.byteOffset&3)for(let s=0;s<n;s=s+1|0){let l=e[t+s|0]|0,u=s<<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 s=r.byteContainerI32;(!s||s.buffer!==a.buffer||s.byteOffset!==a.byteOffset||s.length<n)&&(s=r.byteContainerI32=new Int32Array(a.buffer,a.byteOffset,a.byteLength>>>2)),s.set(e.subarray(t,t+n))}let o=i&3;if(o>0){let s=e[t+n|0]|0,l=n<<2;for(let u=0;u<o;u=u+1|0)a[l+u|0]=s>>>(u<<3)&255}return a}function IA(e,t,i){let r=e[t++]|0,a=i.dataToBePacked;for(let n=2;n<=32;n=n+1|0){if(!(r>>>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 o=e[t++]>>>0,s=iA(o),l=o*n+31>>>5;if(t+l>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${n}, size=${o}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let u=a[n];(!u||u.length<s)&&(u=a[n]=new Uint32Array(s));let h=0;for(;h<o;h=h+32|0)NA(e,t,u,h,n),t=t+n|0;let c=h-o|0;t=t-(c*n>>>5)|0,i.exceptionSizes[n]=o}return t}function FA(e,t,i,r,a){switch(a){case 1:_A(e,t,i,r);break;case 2:yA(e,t,i,r);break;case 3:vA(e,t,i,r);break;case 4:xA(e,t,i,r);break;case 5:bA(e,t,i,r);break;case 6:wA(e,t,i,r);break;case 7:TA(e,t,i,r);break;case 8:DA(e,t,i,r);break;case 16:SA(e,t,i,r);break;default:EA(e,t,i,r,a)}return t+(a<<3)|0}function zA(e,t,i,r){if(i+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${t})`);let a=e[i++],n=e[i++];if(a>32)throw Error(`FastPFOR decode: invalid bitWidth=${a} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:a,exceptionCount:n,bytePosIn:i}}function kA(e,t,i,r,a,n){if(i+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${n} (need 1 byte for maxBits, bytePos=${i}, byteSize=${t})`);let o=e[i++];if(o<r||o>32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${n} (bitWidth=${r}, expected ${r}..32)`);let s=o-r|0;if(s<1||s>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${s} at block=${n} (bitWidth=${r}, maxBits=${o})`);if(i+a>t)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${a}, have=${t-i})`);return{maxBits:o,exceptionBitWidth:s,bytePosIn:i}}function RA(e,t,i,r,a,n,o,s,l){let{maxBits:u,exceptionBitWidth:h,bytePosIn:c}=kA(a,n,o,i,r,l);if(o=c,h===1){let g=1<<i;for(let _=0;_<r;_=_+1|0){let y=a[o++];e[y+t|0]|=g}return o}let d=s.dataToBePacked[h];if(!d)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${i}, maxBits=${u}) at block ${l}`);let p=s.dataPointers,f=p[h]|0,m=s.exceptionSizes[h]|0;if(f+r>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${r}, size=${m}) at block ${l}`);for(let g=0;g<r;g=g+1|0){let _=a[o++],y=d[f++]|0;e[_+t|0]|=y<<i}return p[h]=f,o}function LA(e,t,i,r,a,n,o,s,l,u){let h=i|0,c=0;for(let d=0;d<o;d=d+1|0){let p=zA(s,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=FA(e,h,a,g,f)}m>0&&(c=RA(a,g,f,m,s,l,c,u,d))}if(h!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${h}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${e.length})`)}function BA(e,t,i,r,a,n){let o=i|0,s=e[o]|0;if(s<=0||o+s>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${s} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let l=o+1|0,u=o+s|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=${o}, packedEnd=${u}, byteContainerStart=${d}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let f=MA(e,d,h,n),m=h,g=IA(e,p,n);return n.dataPointers.fill(0),LA(e,o,l,u,t,r|0,a/256|0,f,m,n),g}function OA(e,t,i,r,a,n){let o=r+sp(a,256),s=r,l=i;for(;s!==o;){let u=Math.min(Yc,o-s);l=BA(e,t,l,s,u,n),s=s+u|0}return l}function jA(e,t,i,r,a,n){if(n===0)return t;let o=0,s=t,l=t+i,u=a,h=a,c=a+n,d=0,p=0;for(;s<l&&h<c;){let f=e[s]>>>o&255;if(o+=8,s+=o>>>5,o&=31,d|=(f&127)<<p,f&128)r[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=${s}, inEnd=${l})`)}if(h!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${h-u}, expected=${n}, consumedWords=${s-t}/${i}, vbyteStart=${t}, vbyteEnd=${l})`);return s}function VA(e,t,i){let r=0,a=0,n=new Uint32Array(t),o=i!=null?i:uv();if(e.length>0){let u=e[r]|0;if(r=r+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})`);r=OA(e,n,r,a,u,o),a=a+u|0}let s=e.length-r|0,l=t-a|0;return jA(e,r,s,n,a,l),n}function NA(e,t,i,r,a){switch(a){case 2:nA(e,t,i,r);return;case 3:oA(e,t,i,r);return;case 4:sA(e,t,i,r);return;case 5:lA(e,t,i,r);return;case 6:uA(e,t,i,r);return;case 7:hA(e,t,i,r);return;case 8:cA(e,t,i,r);return;case 9:dA(e,t,i,r);return;case 10:pA(e,t,i,r);return;case 11:fA(e,t,i,r);return;case 12:mA(e,t,i,r);return;case 16:gA(e,t,i,r);return;case 32:for(let u=0;u<32;u=u+1|0)i[r+u|0]=e[t+u|0]|0;return}let n=Xc[a]>>>0,o=t,s=0,l=e[o]>>>0;for(let u=0;u<32;u++)if(s+a<=32){let h=l>>>s&n;i[r+u]=h|0,s+=a,s===32&&(s=0,o++,u!==31&&(l=e[o]>>>0))}else{let h=32-s,c=l>>>s;o++,l=e[o]>>>0;let d=Xc[a-h]>>>0,p=(c|(l&d)<<h)&n;i[r+u]=p|0,s=a-h}}function UA(e,t,i,r){if(t<0||i<0||t+i>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${i}, bytes.length=${e.length})`);let a=Math.floor(i/4),n=i%4!=0,o=n?a+1:a;if(r.length<o)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(a>0){let s=e.byteOffset+t;if(s&3)for(let l=0;l<a;l++){let u=t+l*4;r[l]=e[u]<<24|e[u+1]<<16|e[u+2]<<8|e[u+3]}else{let l=new Uint32Array(e.buffer,s,a);for(let u=0;u<a;u++)r[u]=aA(l[u])|0}}if(n){let s=t+a*4,l=i-a*4,u=0;for(let h=0;h<l;h++)u|=e[s+h]<<24-h*8;r[a]=u|0}return o}function Mt(e,t,i){let r=new Uint32Array(i),a=0,n=t.get();for(let o=0;o<r.length;o++){let s=e[n++],l=s&127;s<128||(s=e[n++],l|=(s&127)<<7,s<128||(s=e[n++],l|=(s&127)<<14,s<128||(s=e[n++],l|=(s&127)<<21,s<128||(s=e[n++],l|=(s&15)<<28)))),r[a++]=l}return t.set(n),r}function lp(e,t,i){let r=new BigUint64Array(i);for(let a=0;a<r.length;a++)r[a]=$A(e,t);return r}function $A(e,t){let i=BigInt(0),r=0,a=t.get();for(;a<e.length;){let n=e[a++];if(i|=BigInt(n&127)<<BigInt(r),!(n&128))break;if(r+=7,r>=64)throw Error("Varint too long")}return t.set(a),i}function GA(e,t,i){let r=new Float64Array(i);for(let a=0;a<i;a++)r[a]=ZA(e,t);return r}function ZA(e,t){let i,r;return r=e[t.get()],t.increment(),i=r&127,r<128||(r=e[t.get()],t.increment(),i|=(r&127)<<7,r<128)||(r=e[t.get()],t.increment(),i|=(r&127)<<14,r<128)||(r=e[t.get()],t.increment(),i|=(r&127)<<21,r<128)?i:(r=e[t.get()],i|=(r&15)<<28,qA(i,e,t))}function qA(e,t,i){let r,a;if(a=t[i.get()],i.increment(),r=(a&112)>>4,a<128||(a=t[i.get()],i.increment(),r|=(a&127)<<3,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<10,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<17,a<128)||(a=t[i.get()],i.increment(),r|=(a&127)<<24,a<128)||(a=t[i.get()],i.increment(),r|=(a&1)<<31,a<128))return r*4294967296+(e>>>0);throw Error("Expected varint not more than 10 bytes")}function WA(e,t,i,r){return HA(e,t,i,r,PA(i>>>2))}function HA(e,t,i,r,a){let n=r.get();if(i&3)throw Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${n} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=i>>>2,s=AA(a,o);UA(e,n,i,s);let l=VA(s.subarray(0,o),t,a.decoderWorkspace);return r.add(i),l}function ze(e){return e>>>1^-(e&1)}function At(e){return e>>BigInt(1)^-(e&BigInt(1))}function $r(e){return e%2==1?(e+1)/-2:e/2}function XA(e){let t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=ze(e[i]);return t}function YA(e){let t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=At(e[i]);return t}function Kc(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=e[n]}let r=new Uint32Array(i),a=0;for(let n=0;n<t;n++){let o=e[n],s=e[n+t];r.fill(s,a,a+o),a+=o}return r}function Jc(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=Number(e[n])}let r=new BigUint64Array(i),a=0;for(let n=0;n<t;n++){let o=Number(e[n]),s=e[n+t];r.fill(s,a,a+o),a+=o}return r}function hv(e,t,i){let r=new Float64Array(i),a=0;for(let n=0;n<t;n++){let o=e[n],s=e[n+t];r.fill(s,a,a+o),a+=o}return r}function lg(e){let t=new Int32Array(e.length);t[0]=ze(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],o=e[r+2],s=e[r+3];t[r]=ze(a)+t[r-1],t[r+1]=ze(n)+t[r],t[r+2]=ze(o)+t[r+1],t[r+3]=ze(s)+t[r+2]}for(;r!==e.length;++r)t[r]=ze(e[r])+t[r-1];return t}function ug(e){let t=new BigInt64Array(e.length);t[0]=At(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],o=e[r+2],s=e[r+3];t[r]=At(a)+t[r-1],t[r+1]=At(n)+t[r],t[r+2]=At(o)+t[r+1],t[r+3]=At(s)+t[r+2]}for(;r!==t.length;++r)t[r]=At(e[r])+t[r-1];return t}function KA(e){e[0]=$r(e[0]);let t=e.length/4*4,i=1;if(t>=4)for(;i<t-4;i+=4){let r=e[i],a=e[i+1],n=e[i+2],o=e[i+3];e[i]=$r(r)+e[i-1],e[i+1]=$r(a)+e[i],e[i+2]=$r(n)+e[i+1],e[i+3]=$r(o)+e[i+2]}for(;i!==e.length;++i)e[i]=$r(e[i])+e[i-1]}function JA(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=e[n]}let r=new Int32Array(i),a=0;for(let n=0;n<t;n++){let o=e[n],s=e[n+t];s=ze(s),r.fill(s,a,a+o),a+=o}return r}function QA(e,t,i){if(i===void 0){i=0;for(let n=0;n<t;n++)i+=Number(e[n])}let r=new BigInt64Array(i),a=0;for(let n=0;n<t;n++){let o=Number(e[n]),s=e[n+t];s=At(s),r.fill(s,a,a+o),a+=o}return r}function eM(e,t,i){let r=new Float64Array(i),a=0;for(let n=0;n<t;n++){let o=e[n],s=e[n+t];s=$r(s),r.fill(s,a,a+o),a+=o}return r}function up(e){let t=e.length/4*4,i=1;if(t>=4)for(let r=e[0];i<t-4;i+=4)r=e[i]+=r,r=e[i+1]+=r,r=e[i+2]+=r,r=e[i+3]+=r;for(;i!==e.length;)e[i]+=e[i-1],++i}function tM(e){let t=0;for(let i=0;i<e.length;i++)e[i]+=t,t=e[i]}function iM(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=ze(e[0]),t[1]=ze(e[1]);let i=e.length/4*4,r=2;if(i>=4)for(;r<i-4;r+=4){let a=e[r],n=e[r+1],o=e[r+2],s=e[r+3];t[r]=ze(a)+t[r-2],t[r+1]=ze(n)+t[r-1],t[r+2]=ze(o)+t[r],t[r+3]=ze(s)+t[r+1]}for(;r!==e.length;r+=2)t[r]=ze(e[r])+t[r-2],t[r+1]=ze(e[r+1])+t[r-1];return t}function rM(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=ze(e[0]);let i=t[1];for(let r=2;r!==t.length;++r){let a=e[r-1],n=ze(a);i+=n,t[r]=t[r-1]+i}return new Uint32Array(t)}function aM(e,t,i){let r=new Int32Array(i+1);r[0]=0;let a=1,n=r[0];for(let o=0;o<t;o++){let s=e[o],l=e[o+t];l=ze(l);for(let u=a;u<a+s;u++)r[u]=l+n,n=r[u];a+=s}return r}function nM(e,t,i){let r=new Uint32Array(i+1);r[0]=0;let a=1,n=r[0];for(let o=0;o<t;o++){let s=e[o],l=e[o+t];for(let u=a;u<a+s;u++)r[u]=l+n,n=r[u];a+=s}return r}function oM(e,t,i){let r=new Int32Array(i),a=0,n=0;for(let o=0;o<t;o++){let s=e[o],l=e[o+t],u=ze(l);for(let h=0;h<s;h++)n+=u,r[a++]=n}return r}function sM(e,t,i){let r=new BigInt64Array(i),a=0,n=BigInt(0);for(let o=0;o<t;o++){let s=Number(e[o]),l=e[o+t],u=At(l);for(let h=0;h<s;h++)n+=u,r[a++]=n}return r}function hg(e){let t=new Uint32Array(e.length);t[0]=ze(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+ze(e[i])>>>0;return t}function cg(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,At(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+At(e[i]));return t}function lM(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=ze(e[0])>>>0,t[1]=ze(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+ze(e[i])>>>0,t[i+1]=t[i-1]+ze(e[i+1])>>>0;return t}function uM(e){return e[1]}function hM(e){return ze(e[1])}function cM(e){if(e.length===2){let t=ze(e[1]);return[t,t]}return[ze(e[2]),ze(e[3])]}function dM(e){return e[1]}function pM(e){return At(e[1])}function fM(e){if(e.length===2){let t=At(e[1]);return[t,t]}return[At(e[2]),At(e[3])]}var at;(function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"})(at||(at={}));var Lt;(function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"})(Lt||(Lt={}));var Zi;(function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"})(Zi||(Zi={}));var ct;(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"})(ct||(ct={}));const mM=[at.PRESENT,at.DATA,at.OFFSET,at.LENGTH],dg=[ue.NONE,ue.DELTA,ue.COMPONENTWISE_DELTA,ue.RLE,ue.MORTON],gM=[ni.NONE,ni.FAST_PFOR,ni.VARINT],_M=[Lt.NONE,Lt.SINGLE,Lt.SHARED,Lt.VERTEX,Lt.MORTON,Lt.FSST],yM=[Zi.VERTEX,Zi.INDEX,Zi.STRING,Zi.KEY],vM=[ct.VAR_BINARY,ct.GEOMETRIES,ct.PARTS,ct.RINGS,ct.TRIANGLES,ct.SYMBOL,ct.DICTIONARY];function He(e,t){let i=wM(e,t);return i.logicalLevelTechnique1===ue.MORTON?xM(i,e,t):(ue.RLE===i.logicalLevelTechnique1||ue.RLE===i.logicalLevelTechnique2)&&ni.NONE!==i.physicalLevelTechnique?bM(i,e,t):i}function xM(e,t,i){let r=Mt(t,i,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:r[0],coordinateShift:r[1]}}function bM(e,t,i){let r=Mt(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}function wM(e,t){let i=e[t.get()],r=mM[i>>4],a={};switch(r){case at.DATA:a={dictionaryType:_M[i&15]};break;case at.OFFSET:a={offsetType:yM[i&15]};break;case at.LENGTH:a={lengthType:vM[i&15]}}t.increment();let n=e[t.get()],o=dg[n>>5],s=dg[n>>2&7],l=gM[n&3];t.increment();let u=Mt(e,t,2),h=u[0],c=u[1];return{physicalStreamType:r,logicalStreamType:a,logicalLevelTechnique1:o,logicalLevelTechnique2:s,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 ki=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),i=e%8;return(this.values[t]>>i&1)==1}set(e,t){let i=Math.floor(e/8),r=e%8;this.values[i]=this.values[i]|+!!t<<r}getInt(e){let t=Math.floor(e/8),i=e%8;return this.values[t]>>i&1}size(){return this._size}getBuffer(){return this.values}};function fa(e,t,i){if(!t)return e;let r=t.size(),a=e.constructor,n=new a(r),o=0;for(let s=0;s<r;s++)n[s]=t.get(s)?e[o++]:i;return n}function TM(e,t,i){if(!i)return e;let r=i.size(),a=new ki(e,t),n=new ki(new Uint8Array(Math.ceil(r/8)),r),o=0;for(let s=0;s<r;s++){let l=i.get(s)?a.get(o++):!1;n.set(s,l)}return n.getBuffer()}function un(e,t,i,r,a){let n=DM(e,Math.ceil(t/8),i,r);return a?TM(n,t,a):n}function DM(e,t,i,r){let a=new Uint8Array(t),n=0,o=r.get()+i;for(;n<t&&!(r.get()>=o);){let s=e[r.increment()];if(s<=127){let l=s+3,u=e[r.increment()],h=Math.min(n+l,t);a.fill(u,n,h),n=h}else{let l=256-s;for(let u=0;u<l&&n<t;u++)a[n++]=e[r.increment()]}}return r.set(o),a}function cv(e,t,i,r){let a=t.get(),n=a+i*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(a,n)).buffer,s=new Float32Array(o);return t.set(n),r?fa(s,r,0):s}function dv(e,t,i,r){let a=t.get(),n=a+i*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(a,n)).buffer,s=new Float64Array(o);return t.set(n),r?fa(s,r,0):s}function SM(e,t,i){let r=t.get(),a=i*Uint32Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=new Uint32Array(i);for(let s=0;s<i;s++)o[s]=n.getUint32(r+s*Uint32Array.BYTES_PER_ELEMENT,!0);return t.add(a),o}function EM(e,t,i){let r=t.get(),a=i*BigUint64Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=new BigUint64Array(i);for(let s=0;s<i;s++)o[s]=n.getBigUint64(r+s*BigUint64Array.BYTES_PER_ELEMENT,!0);return t.add(a),o}const CM=new TextDecoder;function hp(e,t,i){return i-t>=12?CM.decode(e.subarray(t,i)):PM(e,t,i)}function PM(e,t,i){let r="",a=t;for(;a<i;){let n=e[a],o=null,s=n>239?4:n>223?3:n>191?2:1;if(a+s>i)break;let l,u,h;s===1?n<128&&(o=n):s===2?(l=e[a+1],(l&192)==128&&(o=(n&31)<<6|l&63,o<=127&&(o=null))):s===3?(l=e[a+1],u=e[a+2],(l&192)==128&&(u&192)==128&&(o=(n&15)<<12|(l&63)<<6|u&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):s===4&&(l=e[a+1],u=e[a+2],h=e[a+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(o=(n&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,s=1):o>65535&&(o-=65536,r+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),r+=String.fromCharCode(o),a+=s}return r}function Pl(e,t,i,r,a){return zM(hn(e,t,i),i,r,a)}function Et(e,t,i,r,a){return kM(hn(e,t,i),i,r,a)}function Tr(e,t,i){return BM(hn(e,t,i),i)}function hn(e,t,i){let r=i.physicalLevelTechnique;switch(r){case ni.FAST_PFOR:return WA(e,i.numValues,i.byteLength,t);case ni.VARINT:return Mt(e,t,i.numValues);case ni.NONE:return SM(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function Ro(e,t,i){let r=i.physicalLevelTechnique;switch(r){case ni.VARINT:return lp(e,t,i.numValues);case ni.NONE:return EM(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function AM(e,t,i){let r=hn(e,t,i);return r.length===1?ze(r[0]):hM(r)}function cp(e,t,i){let r=hn(e,t,i);return r.length===1?i.logicalLevelTechnique1===ue.DELTA?ze(r[0]):r[0]:uM(r)}function pv(e,t,i){return cM(hn(e,t,i))}function fv(e,t,i){return fM(lp(e,t,i.numValues))}function mv(e,t,i,r){return RM(Ro(e,t,i),i,r)}function dp(e,t,i,r){return _v(Ro(e,t,i),i,r)}function MM(e,t,i,r){let a=IM(e,t,i,!1);return r?fa(a,r,0):a}function IM(e,t,i,r){if(i.physicalLevelTechnique===ni.VARINT)return LM(GA(e,t,i.numValues),i,r);let a=Ro(e,t,i),n=_v(a,i);return Float64Array.from(n,Number)}function FM(e,t,i){let r=Ro(e,t,i);return r.length===1?At(r[0]):pM(r)}function gv(e,t,i){let r=Ro(e,t,i);return r.length===1?i.logicalLevelTechnique1===ue.DELTA?At(r[0]):r[0]:dM(r)}function zM(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let n=t;if(!r)return oM(e,n.runs,n.numRleValues);e=Kc(e,n.runs,n.numRleValues),a=lg(e)}else a=lg(e);break;case ue.RLE:a=JA(e,t.runs,t.numRleValues);break;case ue.MORTON:up(e),a=new Int32Array(e);break;case ue.COMPONENTWISE_DELTA:a=iM(e);break;case ue.NONE:a=XA(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?fa(a,r,0):a}function kM(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let n=t;a=hg(Kc(e,n.runs,n.numRleValues))}else a=hg(e);break;case ue.RLE:a=Kc(e,t.runs,t.numRleValues);break;case ue.MORTON:up(e),a=e;break;case ue.COMPONENTWISE_DELTA:a=lM(e);break;case ue.NONE:a=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?fa(a,r,0):a}function RM(e,t,i){let r;switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let a=t;if(!i)return sM(e,a.runs,a.numRleValues);e=Jc(e,a.runs,a.numRleValues),r=ug(e)}else r=ug(e);break;case ue.RLE:r=QA(e,t.runs,t.numRleValues);break;case ue.NONE:r=YA(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?fa(r,i,BigInt(0)):r}function _v(e,t,i){let r;switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let a=t;r=cg(Jc(e,a.runs,a.numRleValues))}else r=cg(e);break;case ue.RLE:r=Jc(e,t.runs,t.numRleValues);break;case ue.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?fa(r,i,BigInt(0)):r}function LM(e,t,i){switch(t.logicalLevelTechnique1){case ue.DELTA:if(t.logicalLevelTechnique2===ue.RLE){let r=t;e=hv(e,r.runs,r.numRleValues)}return KA(e),e;case ue.RLE:return jM(e,t,i);case ue.NONE:return e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}function BM(e,t){if(t.logicalLevelTechnique1===ue.DELTA&&t.logicalLevelTechnique2===ue.NONE)return rM(e);if(t.logicalLevelTechnique1===ue.RLE&&t.logicalLevelTechnique2===ue.NONE){let i=t;return nM(e,i.runs,i.numRleValues)}if(t.logicalLevelTechnique1===ue.NONE&&t.logicalLevelTechnique2===ue.NONE){tM(e);let i=new Uint32Array(t.numValues+1);return i[0]=0,i.set(e,1),i}if(t.logicalLevelTechnique1===ue.DELTA&&t.logicalLevelTechnique2===ue.RLE){let i=t,r=aM(e,i.runs,i.numRleValues);return up(r),new Uint32Array(r)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}function uu(e,t,i,r,a="int32"){let n=e.logicalLevelTechnique1;if(n===ue.RLE)return e.runs===1?je.CONST:je.FLAT;if(n!==ue.DELTA||e.logicalLevelTechnique2!==ue.RLE)return e.numValues===1?je.CONST:je.FLAT;let o=t instanceof ki?t.size():t,s=e;if(s.numRleValues!==o)return je.FLAT;if(s.runs===1)return je.SEQUENCE;if(s.runs!==2)return e.numValues===1?je.CONST:je.FLAT;let l=r.get();if(e.physicalLevelTechnique===ni.VARINT)return OM(i,r,a)?je.SEQUENCE:e.numValues===1?je.CONST:je.FLAT;let u=r.get(),h=new Int32Array(i.buffer,i.byteOffset+u,4);return r.set(l),h[2]===2&&h[3]===2?je.SEQUENCE:e.numValues===1?je.CONST:je.FLAT}function OM(e,t,i){let r=new sv(t.get());if(i==="int64"){let n=lp(e,r,4);return n[2]===BigInt(2)&&n[3]===BigInt(2)}let a=Mt(e,r,4);return a[2]===2&&a[3]===2}function jM(e,t,i){return i?eM(e,t.runs,t.numRleValues):hv(e,t.runs,t.numRleValues)}var yv=class extends lu{getValueFromBuffer(e){return this.dataBuffer[e]}},vv=class extends nv{constructor(e,t,i,r,a){super(e,a?BigInt64Array.of(t):BigUint64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function pp(e,t,i){return{x:pg(e,t)-i,y:pg(e>>1,t)-i}}function pg(e,t){let i=0;for(let r=0;r<t;r++)i|=(e&1<<2*r)>>r;return i}var bt;(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"})(bt||(bt={}));var fg;(function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"})(fg||(fg={}));var Rr;(function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"})(Rr||(Rr={}));function VM(e){let t=Array(e.numGeometries),i=1,r=1,a=1,n=0,o=0,s=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 bt.POINT:{let v,x;if(f)v=g[o++],x=g[o++];else if(e.vertexBufferType===Rr.MORTON){let b=g[p[s++]],w=pp(b,l.numBits,l.coordinateShift);v=w.x,x=w.y}else{let b=p[s++]*2;v=g[b],x=g[b+1]}t[n++]=[[new M(v,x)]],h&&a++,c&&i++,d&&r++}break;case bt.MULTIPOINT:{let v=h[a]-h[a-1];a++;let x;if(f){x=Array(v);for(let b=0;b<v;b++){let w=g[o++],T=g[o++];x[b]=new M(w,T)}}else x=Nr(e.vertexBufferType,g,p,s,v,!1,l),s+=v;t[n++]=x.map(b=>[b]),i+=v,r+=v}break;case bt.LINESTRING:{let v;m?(v=d[r]-d[r-1],r++):v=c[i]-c[i-1],i++;let x;f?(x=Sa(g,o,v,!1),o+=v*2):(x=Nr(e.vertexBufferType,g,p,s,v,!1,l),s+=v),t[n++]=[x],h&&a++}break;case bt.POLYGON:{let v=c[i]-c[i-1];i++;let x=Array(v-1),b,w=d[r]-d[r-1];if(r++,f){b=Sa(g,o,w,!0),o+=w*2;for(let T=0;T<x.length;T++)w=d[r]-d[r-1],r++,x[T]=Sa(g,o,w,!0),o+=w*2}else{b=Nr(e.vertexBufferType,g,p,s,w,!0,l),s+=w;for(let T=0;T<x.length;T++)w=d[r]-d[r-1],r++,x[T]=Nr(e.vertexBufferType,g,p,s,w,!0,l),s+=w}t[n++]=[b].concat(x),h&&a++}break;case bt.MULTILINESTRING:{let v=h[a]-h[a-1];a++;let x=Array(v);for(let b=0;b<v;b++){let w;if(m?(w=d[r]-d[r-1],r++):w=c[i]-c[i-1],i++,f)x[b]=Sa(g,o,w,!1),o+=w*2;else{let T=Nr(e.vertexBufferType,g,p,s,w,!1,l);x[b]=T,s+=w}}t[n++]=x}break;case bt.MULTIPOLYGON:{let v=h[a]-h[a-1];a++;let x=Array(v);for(let b=0;b<v;b++){let w=c[i]-c[i-1];i++;let T,S=Array(w-1),C=d[r]-d[r-1];r++,f?(T=Sa(g,o,C,!0),o+=C*2):(T=Nr(e.vertexBufferType,g,p,s,C,!0,l),s+=C);for(let F=0;F<S.length;F++){let A=d[r]-d[r-1];r++,f?(S[F]=Sa(g,o,A,!0),o+=A*2):(S[F]=Nr(e.vertexBufferType,g,p,s,A,!0,l),s+=A)}x[b]=[T].concat(S)}t[n++]=x.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return t}function Nr(e,t,i,r,a,n,o){return e===Rr.MORTON?UM(t,i,r,a,n,o):NM(t,i,r,a,n)}function Sa(e,t,i,r){let a=Array(r?i+1:i);for(let n=0;n<i*2;n+=2){let o=e[t+n],s=e[t+n+1];a[n/2]=new M(o,s)}return r&&(a[a.length-1]=a[0]),a}function NM(e,t,i,r,a){let n=Array(a?r+1:r);for(let o=0;o<r*2;o+=2){let s=t[i+o/2]*2,l=e[s],u=e[s+1];n[o/2]=new M(l,u)}return a&&(n[n.length-1]=n[0]),n}function UM(e,t,i,r,a,n){let o=Array(a?r+1:r);for(let s=0;s<r;s++){let l=e[t[i+s]],u=pp(l,n.numBits,n.coordinateShift);o[s]=new M(u.x,u.y)}return a&&(o[o.length-1]=o[0]),o}var xv=class{constructor(e,t,i,r,a){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=i,this._vertexBuffer=r,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 i=this.vertexOffsets[e],r=this.vertexBuffer[i],a=pp(r,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 VM(this)}get mortonSettings(){return this._mortonSettings}};function $M(e,t,i,r,a){return new bv(e,t,Rr.VEC_2,i,r,a)}function GM(e,t,i,r,a,n){return new bv(e,t,Rr.MORTON,i,r,a,n)}var bv=class extends xv{constructor(e,t,i,r,a,n,o){super(i,r,a,n,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===bt.POLYGON||this._geometryType===bt.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function wv(e,t,i,r){return new Tv(Rr.VEC_2,e,t,i,r)}function ZM(e,t,i,r,a){return new Tv(Rr.MORTON,e,t,i,r,a)}var Tv=class extends xv{constructor(e,t,i,r,a,n){super(e,i,r,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)===bt.POLYGON||this.geometryType(e)===bt.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},Dv=class{constructor(e,t,i,r){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=i,this._topologyVector=r}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 wv(e,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function mg(e,t,i,r,a,n){return new qM(e,t,i,r,a,n)}var qM=class extends Dv{constructor(e,t,i,r,a,n){super(i,r,a,n),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function gg(e,t,i,r,a){return new WM(e,t,i,r,a)}var WM=class extends Dv{constructor(e,t,i,r,a){super(t,i,r,a),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function HM(e,t,i,r,a){let n=He(e,i),o=uu(n,r,e,i),s,l,u,h;if(o===je.CONST){let v=cp(e,i,n),x,b,w,T;for(let S=0;S<t-1;S++){let C=He(e,i);switch(C.physicalStreamType){case at.LENGTH:switch(C.logicalStreamType.lengthType){case ct.GEOMETRIES:x=Tr(e,i,C);break;case ct.PARTS:b=Tr(e,i,C);break;case ct.RINGS:w=Tr(e,i,C);break;case ct.TRIANGLES:T=Tr(e,i,C)}break;case at.OFFSET:switch(C.logicalStreamType.offsetType){case Zi.VERTEX:s=Et(e,i,C);break;case Zi.INDEX:h=Et(e,i,C)}break;case at.DATA:if(Lt.VERTEX===C.logicalStreamType.dictionaryType)l=Pl(e,i,C,a);else{let F=C;u={numBits:F.numBits,coordinateShift:F.coordinateShift},l=Et(e,i,C,a)}}}return h?x!==void 0||b!==void 0?mg(r,v,T,h,l,{geometryOffsets:x,partOffsets:b,ringOffsets:w}):mg(r,v,T,h,l):u===void 0?$M(r,v,{geometryOffsets:x,partOffsets:b,ringOffsets:w},s,l):GM(r,v,{geometryOffsets:x,partOffsets:b,ringOffsets:w},s,l,u)}let c=Et(e,i,n),d,p,f,m;for(let v=0;v<t-1;v++){let x=He(e,i);switch(x.physicalStreamType){case at.LENGTH:switch(x.logicalStreamType.lengthType){case ct.GEOMETRIES:d=Et(e,i,x);break;case ct.PARTS:p=Et(e,i,x);break;case ct.RINGS:f=Et(e,i,x);break;case ct.TRIANGLES:m=Tr(e,i,x)}break;case at.OFFSET:switch(x.logicalStreamType.offsetType){case Zi.VERTEX:s=Et(e,i,x);break;case Zi.INDEX:h=Et(e,i,x)}break;case at.DATA:if(Lt.VERTEX===x.logicalStreamType.dictionaryType)l=Pl(e,i,x,a);else{let b=x;u={numBits:b.numBits,coordinateShift:b.coordinateShift},l=Et(e,i,x,a)}}}let g,_,y;return d?(g=dh(c,d,2),p&&f?(_=_g(c,g,p,!1),y=YM(c,g,_,f)):p&&(_=XM(c,g,p))):p&&f?(_=dh(c,p,1),y=_g(c,_,f,!0)):p&&(_=dh(c,p,0)),h&&!_?gg(c,m,h,l):h?gg(c,m,h,l,{geometryOffsets:g,partOffsets:_,ringOffsets:y}):u===void 0?wv(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},s,l):ZM(c,{geometryOffsets:g,partOffsets:_,ringOffsets:y},s,l,u)}function dh(e,t,i){let r=new Uint32Array(e.length+1),a=0;r[0]=a;let n=0;for(let o=0;o<e.length;o++)a=r[o+1]=a+(e[o]>i?t[n++]:1);return r}function _g(e,t,i,r){let a=new Uint32Array(t[t.length-1]+1),n=0;a[0]=n;let o=1,s=0;for(let l=0;l<e.length;l++){let u=e[l],h=t[l+1]-t[l];if(u===5||u===2||r&&(u===4||u===1))for(let c=0;c<h;c++)n=a[o++]=n+i[s++];else for(let c=0;c<h;c++)a[o++]=++n}return a}function XM(e,t,i){let r=new Uint32Array(t[t.length-1]+1),a=0;r[0]=a;let n=1,o=0;for(let s=0;s<e.length;s++){let l=e[s],u=t[s+1]-t[s];if(l===4||l===1)for(let h=0;h<u;h++)a=r[n++]=a+i[o++];else for(let h=0;h<u;h++)r[n++]=++a}return r}function YM(e,t,i,r){let a=new Uint32Array(i[i.length-1]+1),n=0;a[0]=n;let o=1,s=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=i[o]-i[o-1];o++;for(let f=0;f<p;f++)n=a[s++]=n+r[l++]}else for(let d=0;d<c;d++)a[s++]=++n,o++}return a}var KM=class extends pa{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}},JM=class extends lu{getValueFromBuffer(e){return this.dataBuffer[e]}},Sv=class extends pa{constructor(e,t,i,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},fp=class extends pa{constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}},yg=class extends fp{constructor(e,t,i,r){super(e,t,i,r!=null?r:t.length-1)}getValueFromBuffer(e){let t=this.offsetBuffer[e],i=this.offsetBuffer[e+1];return hp(this.dataBuffer,t,i)}},Za=class extends fp{constructor(e,t,i,r,a){super(e,i,r,a!=null?a:t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return hp(this.dataBuffer,i,r)}};function QM(e,t){let i=0;for(let r=0;r<t.length;r++){let a=t[r];a===255?(i++,r++):i+=e[a]}return i}function e3(e,t,i){let r=new Uint32Array(t.length);for(let o=1;o<t.length;o++)r[o]=r[o-1]+t[o-1];let a=new Uint8Array(QM(t,i)),n=0;for(let o=0;o<i.length;o++){let s=i[o];if(s===255)o++,a[n++]=i[o];else{let l=t[s],u=r[s];for(;l-- >0;)a[n++]=e[u++]}}return a}var Ev=class extends fp{constructor(e,t,i,r,a,n,o,s){super(e,i,r,o!=null?o:t.length),this.indexBuffer=t,this.symbolOffsetBuffer=a,this.symbolTableBuffer=n,this.sharedDictionaryCache=s}getValueFromBuffer(e){var a,n,o;(o=this.decodedDictionary)!=null||(this.decodedDictionary=(a=this.sharedDictionaryCache)==null?void 0:a.decodedDictionary,(n=this.decodedDictionary)!=null||(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return hp(this.decodedDictionary,i,r)}decodeDictionary(){var e;return(e=this.symbolLengthBuffer)!=null||(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),e3(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),i=e[0];for(let r=1;r<e.length;r++){let a=e[r];t[r-1]=a-i,i=a}return t}};function Cv(e,t,i,r,a){var p,f;let n,o,s,l,u,h=a,c,d;for(let m=0;m<r;m++){let g=He(t,i);switch(g.physicalStreamType){case at.PRESENT:{let _=new ki(un(t,g.numValues,g.byteLength,i),g.numValues);h=a!=null?a:_;break}case at.OFFSET:o=Et(t,i,g,void 0,h);break;case at.LENGTH:{let _=Tr(t,i,g);ct.DICTIONARY===g.logicalStreamType.lengthType?n=_:ct.SYMBOL===g.logicalStreamType.lengthType?l=_:c=_;break}case at.DATA:{let _=t.subarray(i.get(),i.get()+g.byteLength);i.add(g.byteLength);let y=g.logicalStreamType.dictionaryType;Lt.FSST===y?u=_:Lt.SINGLE===y||Lt.SHARED===y?s=_:Lt.NONE===y&&(d=_);break}}}return(f=(p=t3(e,u,o,n,s,l,h))!=null?p:i3(e,s,o,n,h))!=null?f:r3(e,c,d,o,h)}function t3(e,t,i,r,a,n,o){if(t){if(!i||!r||!a||!n)throw Error(`Incomplete FSST dictionary string column "${e}"`);return new Ev(e,i,r,a,n,t,o)}}function i3(e,t,i,r,a){if(t){if(!i||!r)throw Error(`Incomplete dictionary string column "${e}"`);return a?new Za(e,i,r,t,a):new Za(e,i,r,t)}}function r3(e,t,i,r,a){if(t&&i){if(r)return a?new Za(e,r,t,i,a):new Za(e,r,t,i);if(a&&a.size()!==t.length-1){let n=new Uint32Array(a.size()),o=0;for(let s=0;s<a.size();s++)a.get(s)?n[s]=o++:n[s]=0;return new Za(e,n,t,i,a)}return a?new yg(e,t,i,a):new yg(e,t,i)}}function a3(e,t,i,r){let a,n,o,s,l=!1;for(;!l;){let p=He(e,t);switch(p.physicalStreamType){case at.LENGTH:ct.DICTIONARY===p.logicalStreamType.lengthType?a=Tr(e,t,p):o=Tr(e,t,p);break;case at.DATA:Lt.SINGLE===p.logicalStreamType.dictionaryType||Lt.SHARED===p.logicalStreamType.dictionaryType?(n=e.subarray(t.get(),t.get()+p.byteLength),l=!0):s=e.subarray(t.get(),t.get()+p.byteLength),t.add(p.byteLength)}}if(i.type!=="complexType")throw Error(`Shared dictionary column ${i.name} must be a complex (struct) column.`);if(!a||!n)throw Error(`Incomplete shared dictionary for column "${i.name}"`);let u=i.complexType.children,h=[],c=s?{}:void 0,d=0;for(let p of u){let f=Mt(e,t,1)[0];if(f===0)continue;let m=p.name?`${i.name}${p.name}`:i.name;if(p.type!=="scalarField"||p.scalarField.physicalType!==Se.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 ki(un(e,y.numValues,y.byteLength,t),y.numValues)}let _=Et(e,t,He(e,t),void 0,g);if(s){if(!o)throw Error(`Incomplete shared FSST dictionary for column "${m}"`);h[d++]=new Ev(m,_,a,n,o,s,g,c)}else h[d++]=new Za(m,_,a,n,g)}return h}var vg=class extends pa{constructor(e,t,i){super(e,new Uint8Array,i!=null?i:t.length),this.values=t}getValueFromBuffer(e){return this.values[e]}},qi;(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"})(qi||(qi={}));var Er;(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"})(Er||(Er={}));function n3(e,t,i,r){let a=o3(i);if(r===0)return a.map(h=>new vg(h,[]));let n=s3(e,t,r),o=(n.presentStream?n.presentCount:n.lengthStream.length)/a.length,s=[],l=0,u=0;for(let h=0;h<a.length;h++){let c=d3(n,h,o,l,u);s.push(new vg(a[h],c.value,c.nullabilityBuffer)),l=c.countsEnd,u=c.valuesEnd}return s}function o3(e){let t=e.type==="complexType"?e.complexType.children:void 0;return!t||t.length===0?[e.name]:t.map(i=>{var r;return e.name+((r=i.name)!=null?r:"")})}function s3(e,t,i){let r=e[t.get()];t.add(1);let a=Et(e,t,He(e,t)),n=i-1,o=[];r&qi.STRING&&(n-=l3(e,t,o)),n-=u3(e,t,r,o),n-=h3(e,t,r,o);let s,l=0;if(r&qi.PRESENCE){let h=c3(e,t);s=h.value,l=h.count,n--}let u=new Uint32Array;if(n>0&&(u=Et(e,t,He(e,t)),n--),n!==0)throw Error(`Unexpected number of remaining streams while decoding map column: ${n}`);return{lengthStream:a,dictionary:o,presentStream:s,presentCount:l,flattenedValues:u}}function l3(e,t,i){let r=e[t.get()];t.add(1);let a=Cv("",e,t,r);if(a)for(let n=0;n<a.size;n++)i.push(a.getValue(n));return r}function u3(e,t,i,r){let a=0;return i&qi.INT32?(Oa(r,Pl(e,t,He(e,t))),a++):i&qi.INT64&&(Oa(r,mv(e,t,He(e,t))),a++),i&qi.UINT32?(Oa(r,Et(e,t,He(e,t))),a++):i&qi.UINT64&&(Oa(r,dp(e,t,He(e,t))),a++),a}function h3(e,t,i,r){let a=0;return i&qi.FLOAT&&(Oa(r,cv(e,t,He(e,t).numValues)),a++),i&qi.DOUBLE&&(Oa(r,dv(e,t,He(e,t).numValues)),a++),a}function c3(e,t){let i=He(e,t);if(i.physicalStreamType!==at.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${i.physicalStreamType}`);let r=i.numValues,a=t.get(),n=new ki(un(e,r,i.byteLength,t),r);return t.set(a+i.byteLength),{value:n,count:r}}function d3(e,t,i,r,a){let{lengthStream:n,flattenedValues:o,presentStream:s,dictionary:l}=e,u=t*i,h=i,c;if(s){c=new ki(new Uint8Array(Math.ceil(i/8)),i),h=0;for(let y=0;y<i;y++)s.get(u+y)&&(c.set(y,!0),h++)}let d=r+h;if(d>n.length)throw Error("Merged map counts underflow while decoding child streams");let p=Array(i),f=r,m=a;for(let y=0;y<i;y++){if(s&&!s.get(u+y)){p[y]=null;continue}let v=m+n[f++];if(v>o.length)throw Error("Map value stream underflow while decoding feature payload");let x=p3(o,m,v,l);p[y]=x.value,m=x.nextIndex}let g=0;for(let y=r;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 p3(e,t,i,r){return i-t===1||e[t]===Er.START_LIST?mp(e,t,i,r):Pv(e,t,i,r)}function Pv(e,t,i,r){let a=Object.create(null),n=t;for(;n<i;){let o=Av(e[n++],r);if(typeof o!="string")throw Error(`Map key dictionary index does not resolve to a string: ${o}`);let s=mp(e,n,i,r);a[o]=s.value,n=s.nextIndex}return{value:a,nextIndex:n}}function mp(e,t,i,r){if(t>=i)throw Error("Unexpected end of map value stream");let a=e[t];if(a===Er.FALSE)return{value:!1,nextIndex:t+1};if(a===Er.TRUE)return{value:!0,nextIndex:t+1};if(a===Er.START_MAP){let n=xg(e,t,i);return{value:Pv(e,t+2,n,r).value,nextIndex:n}}if(a===Er.START_LIST){let n=xg(e,t,i),o=[],s=t+2;for(;s<n;){let l=mp(e,s,n,r);o.push(l.value),s=l.nextIndex}return{value:o,nextIndex:n}}return{value:Av(a,r),nextIndex:t+1}}function xg(e,t,i){if(t+1>=i)throw Error("Missing length for nested map/list payload");let r=e[t+1];if(r<2)throw Error(`Invalid nested payload length: ${r}`);let a=t+r;if(a>i)throw Error("Nested payload exceeds containing payload bounds");return a}function Av(e,t){let i=e-Er.COUNT;if(i<0||i>=t.length)throw Error(`Scalar dictionary index out of range: ${e}`);return t[i]}function Oa(e,t){for(let i of t)e.push(i)}function f3(e,t,i,r,a,n){var o;return i.type==="scalarType"?m3(r,e,t,a,i.scalarType,i):((o=i.complexType)==null?void 0:o.physicalType)===Ar.MAP?n3(e,t,i,r):r===0?null:a3(e,t,i)}function m3(e,t,i,r,a,n){var l;let o;if(e===0)return null;if(n.nullable){let u=He(t,i),h=u.numValues,c=i.get(),d=un(t,h,u.byteLength,i);i.set(c+u.byteLength),o=new ki(d,u.numValues)}let s=o!=null?o:r;switch(a.physicalType){case Se.UINT_32:case Se.INT_32:return x3(t,i,n,a,s);case Se.STRING:{let u=n.nullable?e-1:e;return(l=Cv(n.name,t,i,u,o))!=null?l:null}case Se.BOOLEAN:return g3(t,i,n,r,s);case Se.UINT_64:case Se.INT_64:return v3(t,i,n,s,a);case Se.FLOAT:return _3(t,i,n,s);case Se.DOUBLE:return y3(t,i,n,s);default:throw Error(`The specified data type for the field is currently not supported: ${a}`)}}function g3(e,t,i,r,a){let n=He(e,t),o=n.numValues,s=t.get(),l=Lo(a)?a:void 0,u=un(e,o,n.byteLength,t,l);t.set(s+n.byteLength);let h=new ki(u,o);return new KM(i.name,h,a)}function _3(e,t,i,r){let a=He(e,t),n=Lo(r)?r:void 0,o=cv(e,t,a.numValues,n);return new JM(i.name,o,r)}function y3(e,t,i,r){let a=He(e,t),n=Lo(r)?r:void 0,o=dv(e,t,a.numValues,n);return new rp(i.name,o,r)}function v3(e,t,i,r,a){let n=He(e,t),o=uu(n,r,e,t,"int64"),s=a.physicalType===Se.INT_64;if(o===je.FLAT){let u=Lo(r)?r:void 0,h=s?mv(e,t,n,u):dp(e,t,n,u);return new yv(i.name,h,r)}if(o===je.SEQUENCE){let u=fv(e,t,n);return new vv(i.name,u[0],u[1],n.numRleValues,s)}let l=s?FM(e,t,n):gv(e,t,n);return new Sv(i.name,l,r,s)}function x3(e,t,i,r,a){let n=He(e,t),o=uu(n,a,e,t),s=r.physicalType===Se.INT_32;if(o===je.FLAT){let u=Lo(a)?a:void 0,h=s?Pl(e,t,n,void 0,u):Et(e,t,n,void 0,u);return new ip(i.name,h,a)}if(o===je.SEQUENCE){let u=pv(e,t,n);return new ap(i.name,u[0],u[1],n.numRleValues,s)}let l=s?AM(e,t,n):cp(e,t,n);return new np(i.name,l,a,s)}function Lo(e){return e instanceof ki}const gt={ID:0,ID_NULLABLE:1,ID_LONG:2,GEOMETRY:4,SCALAR_BASE:10,STRUCT:30,MAP:31};function Mv(e){switch(e){case gt.ID:case gt.ID|gt.ID_NULLABLE:case gt.ID|gt.ID_LONG:case gt.ID|gt.ID_LONG|gt.ID_NULLABLE:return{nullable:(e&gt.ID_NULLABLE)!==0,columnScope:Gn.FEATURE,type:"scalarType",scalarType:{longID:(e&gt.ID_LONG)!==0,type:"logicalType",logicalType:ov.ID}};case gt.GEOMETRY:return{nullable:!1,columnScope:Gn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ar.GEOMETRY,children:[]}};case gt.STRUCT:return{nullable:!1,columnScope:Gn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ar.STRUCT,children:[]}};case gt.MAP:return{nullable:!0,columnScope:Gn.FEATURE,type:"complexType",complexType:{type:"physicalType",physicalType:Ar.MAP,children:[]}};default:return S3(e)}}function b3(e){return e>=gt.SCALAR_BASE}function Iv(e){return e===gt.STRUCT||e===gt.MAP}function w3(e){if(e.type==="scalarType"){let t=e.scalarType;if(t.type==="physicalType")switch(t.physicalType){case Se.BOOLEAN:case Se.INT_8:case Se.UINT_8:case Se.INT_32:case Se.UINT_32:case Se.INT_64:case Se.UINT_64:case Se.FLOAT:case Se.DOUBLE:return!1;case Se.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 Ar.GEOMETRY:case Ar.STRUCT:case Ar.MAP:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function T3(e){var t;return e.type==="scalarType"&&((t=e.scalarType)==null?void 0:t.type)==="logicalType"&&e.scalarType.logicalType===ov.ID}function D3(e){var t;return e.type==="complexType"&&((t=e.complexType)==null?void 0:t.type)==="physicalType"&&e.complexType.physicalType===Ar.GEOMETRY}function S3(e){let t;switch(e){case 10:case 11:t=Se.BOOLEAN;break;case 12:case 13:t=Se.INT_8;break;case 14:case 15:t=Se.UINT_8;break;case 16:case 17:t=Se.INT_32;break;case 18:case 19:t=Se.UINT_32;break;case 20:case 21:t=Se.INT_64;break;case 22:case 23:t=Se.UINT_64;break;case 24:case 25:t=Se.FLOAT;break;case 26:case 27:t=Se.DOUBLE;break;case 28:case 29:t=Se.STRING;break;default:return null}return{nullable:!!(e&1),columnScope:Gn.FEATURE,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:t}}}const E3=new TextDecoder,bg="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function gp(e,t){let i=Mt(e,t,1)[0];if(i===0)return"";let r=t.get(),a=r+i,n=e.subarray(r,a);return t.add(i),E3.decode(n)}function C3(e){let t=e.name,i=e.nullable;return e.type==="scalarType"?{type:"scalarField",scalarField:e.scalarType,name:t,nullable:i}:{type:"complexField",complexField:e.complexType,name:t,nullable:i}}function Fv(e,t){let i=Mt(e,t,1)[0]>>>0,r=i>=gt.SCALAR_BASE?Mv(i):null;if(!r)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let a={...r,name:gp(e,t)};if(a.type==="complexType"&&Iv(i)){let n=a.complexType,o=Mt(e,t,1)[0]>>>0;n.children=Array(o);for(let s=0;s<o;s++)n.children[s]=Fv(e,t)}return C3(a)}function P3(e,t){let i=Mt(e,t,1)[0]>>>0,r=Mv(i);if(!r)throw Error(`Unsupported column type code ${i}. Supported: ${bg}`);let a;if(b3(i))a=gp(e,t);else if(i<gt.GEOMETRY)a="id";else if(i===gt.GEOMETRY)a="geometry";else throw Error(`Unsupported column type code ${i}. Supported: ${bg}`);let n={...r,name:a};if(n.type==="complexType"&&Iv(i)){let o=Mt(e,t,1)[0]>>>0,s=n.complexType;s.children=Array(o);for(let l=0;l<o;l++)s.children[l]=Fv(e,t)}return n}function A3(e,t){let i={};i.featureTables=[];let r={};if(r.name=gp(e,t),r.name.length===0)throw Error("Missing layer name");let a=Mt(e,t,1)[0]>>>0,n=Mt(e,t,1)[0]>>>0;r.columns=Array(n);for(let o=0;o<n;o++)r.columns[o]=P3(e,t);return i.featureTables.push(r),[i,a]}function M3(e,t,i=!0){let r=new sv(0),a=[];for(;r.get()<e.length;){let n=Mt(e,r,1)[0]>>>0,o=r.get()+n;if(o>e.length)throw Error(`Block overruns tile: ${o} > ${e.length}`);let s=Mt(e,r,1)[0]>>>0;if(s!==1&&s!==2){r.set(o);continue}let[l,u]=A3(e,r),h=l.featureTables[0],c=null,d=null,p=[],f=0;for(let g of h.columns){let _=g.name;if(T3(g)){let y=null;if(g.nullable){let x=He(e,r),b=r.get(),w=un(e,x.numValues,x.byteLength,r);r.set(b+x.byteLength),y=new ki(w,x.numValues)}let v=He(e,r);f=y?y.size():v.decompressedCount,c=I3(e,g,r,_,v,y!=null?y:f,i)}else if(D3(g)){let y=Mt(e,r,1)[0];if(f===0){let v=r.get();f=He(e,r).decompressedCount,r.set(v)}d=HM(e,y,r,f,t)}else{let y=w3(g)?Mt(e,r,1)[0]:1;if(y===0)continue;let v=f3(e,r,g,y,f);if(v)if(Array.isArray(v))for(let x of v)p.push(x);else p.push(v)}}let m=new tA(h.name,d,c,p,u);a.push(m),r.set(o)}return a}function I3(e,t,i,r,a,n,o=!1){var h;let s=(h=t.scalarType)!=null&&h.longID?Se.UINT_64:Se.UINT_32,l=typeof n=="number"?void 0:n,u=uu(a,n,e,i,s===Se.UINT_64?"int64":"int32");if(s===Se.UINT_32)switch(u){case je.FLAT:return new ip(r,Et(e,i,a,void 0,l),n);case je.SEQUENCE:{let c=pv(e,i,a);return new ap(r,c[0],c[1],a.numRleValues,!1)}case je.CONST:return new np(r,cp(e,i,a),n,!1)}switch(u){case je.FLAT:return o?new rp(r,MM(e,i,a,l),n):new yv(r,dp(e,i,a,l),n);case je.SEQUENCE:{let c=fv(e,i,a);return new vv(r,c[0],c[1],a.numRleValues,!1)}case je.CONST:return new Sv(r,gv(e,i,a),n,!1)}throw Error("Vector type not supported for id column.")}var F3=class{constructor(e,t){var i;switch(this._featureData=e,this.properties=this._featureData.properties||{},(i=this._featureData.geometry)==null?void 0:i.type){case bt.POINT:case bt.MULTIPOINT:this.type=1;break;case bt.LINESTRING:case bt.MULTILINESTRING:this.type=2;break;case bt.POLYGON:case bt.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 i=[];for(let r of t)i.push(new M(r.x,r.y));e.push(i)}return e}},z3=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 F3(this.features[e],this.extent)}},k3=class{constructor(e){this.layers={};let t=M3(new Uint8Array(e));this.layers=t.reduce((i,r)=>({...i,[r.name]:new z3(r)}),{})}};G("FeatureIndex",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 Jh(O,16,0),this.grid3D=new Jh(O,16,0),this.featureIndexArray=new R0,this.promoteId=t}insert(e,t,i,r,a,n){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,a);let s=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&&s.insert(o,u[0],u[1],u[2],u[3])}}loadVTLayers(){return this.vtLayers||(this.encoding==="mlt"?this.vtLayers=new k3(this.rawTileData).layers:this.vtLayers=new aS(new D1(this.rawTileData)).layers,this.sourceLayerCoder=new eA(this.vtLayers?Object.keys(this.vtLayers).sort():[Zs])),this.vtLayers}query(e,t,i,r){this.loadVTLayers();let a=e.params,n=O/e.tileSize/e.scale,o=lo(a.filter,"queryRenderedFeatures filter",a.globalState),s=e.queryGeometry,l=e.queryPadding*n,u=Mi.fromPoints(s),h=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),c=Mi.fromPoints(e.cameraQueryGeometry).expandBy(l),d=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,(m,g,_,y)=>qT(e.cameraQueryGeometry,m-l,g-l,_+l,y+l));for(let m of d)h.push(m);h.sort(L3);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,o,a.layers,a.availableImages,t,i,e.transform.worldCoordinateHelper,r,(y,v,x)=>(_||(_=ca(y)),v.queryIntersectsFeature({queryGeometry:s,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,i,r,a,n,o,s,l,u,h,c){let d=this.bucketLayerIDs[t];if(n&&!d.some(g=>n.has(g)))return;let p=this.sourceLayerCoder.decode(i),f=this.vtLayers[p].feature(r);if(a.needGeometry){let g=da(f,!0);if(!a.filter(new Ie(this.tileID.overscaledZ),g,this.tileID.canonical))return}else if(!a.filter(new Ie(this.tileID.overscaledZ),f))return;let m=this.getId(f,p);for(let g of d){if(n&&!n.has(g))continue;let _=s[g];if(!_)continue;let y={};m&&h&&(y=h.getState(_.sourceLayer||"_geojsonTileLayer",m));let v=X({},l[g]);v.paint=wg(v.paint,_.paint,f,y,o),v.layout=wg(v.layout,_.layout,f,y,o);let x=!c||c(f,_,y);if(!x)continue;let b=new av(f,this.z,this.x,this.y,m,u);b.layer=v;let w=e[g];w===void 0&&(w=e[g]=[]),w.push({featureIndex:r,feature:b,intersectionZ:x})}}lookupSymbolFeatures(e,t,i,r,a,n,o,s){let l={};this.loadVTLayers();let u=lo(a.filterSpec,"queryRenderedFeatures symbol filter",a.globalState);for(let h of e)this.loadMatchingFeature(l,i,r,h,u,n,o,s,t,a.worldCoordinateHelper);return l}hasLayer(e){for(let t of this.bucketLayerIDs)for(let i of t)if(e===i)return!0;return!1}getId(e,t){var r;let i=e.id;if(this.promoteId){let a=typeof this.promoteId=="string"?this.promoteId:this.promoteId[t];i=e.properties[a],typeof i=="boolean"&&(i=Number(i)),i===void 0&&((r=e.properties)!=null&&r.cluster)&&this.promoteId&&(i=Number(e.properties.cluster_id))}return i}},{omit:["rawTileData","sourceLayerCoder"]});function R3(e){return typeof e=="object"&&!!e&&"evaluate"in e}function wg(e,t,i,r,a){return gd(e,(n,o)=>{let s=t instanceof Kl?t.get(o):null;return R3(s)?s.evaluate(i,r,void 0,a):s})}function L3(e,t){return t-e}const Qc="RTLPluginLoaded";var B3=class extends Ft{constructor(...e){super(...e),this.status="unavailable",this.url=null,this.dispatcher=pP()}_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 ua(Qc))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}};let ph=null;function ed(){return ph||(ph=new B3),ph}var zv=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=U_(),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:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=r}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=ke(),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,i){return this.rttObjects[t]=e.acquireRTT(i)}releaseRTT(e){if(this.rttObjects.length!==0){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}releaseRTTStack(e,t){let i=this.rttObjects[t];i&&(e.releaseRTT(i),this.rttObjects[t]=void 0)}loadVectorData(e,t,i){if((e==null?void 0:e.etagUnmodified)===!0)this.state="loaded";else if(this.hasData()&&this.unloadVectorData(),this.state="loaded",!e)this.collisionBoxArray=new S0;else{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=QP(e.buckets,t),this.hasSymbolBuckets=!1;for(let r in this.buckets){let a=this.buckets[r];if(a instanceof Sl)if(this.hasSymbolBuckets=!0,i)a.justReloaded=!0;else break}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let r in this.buckets){let a=this.buckets[r];if(a instanceof Sl&&a.hasRTLText){this.hasRTLText=!0,ed().lazyLoad();break}}this.queryPadding=0;for(let r in this.buckets){let a=this.buckets[r];this.queryPadding=Math.max(this.queryPadding,t.getLayer(r).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 i in this.buckets){let r=this.buckets[i];r.uploadPending()&&r.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new ft(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasImage=(this.glyphAtlasTexture=new ft(e,this.glyphAtlasImage,t.ALPHA),null))}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,a,n,o,s,l,u,h){var c;return(c=this.latestFeatureIndex)!=null&&c.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:a,scale:n,tileSize:this.tileSize,pixelPosMatrix:u,transform:s,params:o,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,t){let i=this.latestFeatureIndex;if(!(i!=null&&i.rawTileData))return;let r=i.loadVTLayers(),a=t.sourceLayer?t.sourceLayer:"",n=r._geojsonTileLayer||r[a];if(!n)return;let o=lo(t.filter,`querySourceFeatures[${a}].filter`,t.globalState),{z:s,x:l,y:u}=this.tileID.canonical,h={z:s,x:l,y:u};for(let c=0;c<n.length;c++){let d=n.feature(c);if(o.needGeometry){let f=da(d,!0);if(!o.filter(new Ie(this.tileID.overscaledZ),f,this.tileID.canonical))continue}else if(!o.filter(new Ie(this.tileID.overscaledZ),d))continue;let p=new av(d,s,l,u,i.getId(d,a),t.worldCoordinateHelper);p.tile=h,e.push(p)}}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 i=kb(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+i["max-age"]*1e3)}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let i=Date.now(),r=!1;if(this.expirationTime>i)r=!1;else if(!t)r=!0;else if(this.expirationTime<t)r=!0;else{let a=this.expirationTime-t;a?this.expirationTime=i+Math.max(a,3e4):r=!0}r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),2**31-1)}setFeatureState(e,t,i){var a,n;if(!((a=this.latestFeatureIndex)!=null&&a.rawTileData)||Object.keys(e).length===0||this.featureStateRevision===i)return;this.featureStateRevision=i;let r=this.latestFeatureIndex.loadVTLayers();for(let o in this.buckets){if(!t.hasLayer(o))continue;let s=this.buckets[o],l=s.layers[0].sourceLayer||"_geojsonTileLayer",u=r[l],h=e[l];if(!u||!h||h.length===0)continue;s.update(h,u,((n=this.imageAtlas)==null?void 0:n.patternPositions)||{},this.dashPositions||{});let c=t.getLayer(o);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(s)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<ke()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=ke()+e}setDependencies(e,t){let i={};for(let r of t)i[r]=!0;this.dependencies[e]=i}hasDependency(e,t){for(let i of e){let r=this.dependencies[i];if(r){for(let a of t)if(r[a])return!0}}return!1}},O3=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,i){let r=e.wrapped().key;this.data[r]===void 0&&(this.data[r]=[]);let a={value:t,timeout:void 0};if(i!==void 0&&(a.timeout=setTimeout(()=>{this.remove(e,a)},i)),this.data[r].push(a),this.order.push(r),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 i=e.wrapped().key,r=t===void 0?0:this.data[i].indexOf(t),a=this.data[i][r];return this.data[i].splice(r,1),a.timeout&&clearTimeout(a.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(a.value),this.order.splice(this.order.indexOf(i),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 i in this.data)for(let r of this.data[i])e(r.value)||t.push(r);for(let i of t)this.remove(i.value.tileID,i)}};function Tg(e){let t=[];for(let i in e)t.push({id:i,state:e[i]});return t}var j3=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,i){var a,n,o,s,l;let r=String(t);if((a=this.stateChanges)[e]||(a[e]={}),(n=this.stateChanges[e])[r]||(n[r]={}),X(this.stateChanges[e][r],i),this.deletedStates[e]===null){this.deletedStates[e]={};for(let u in this.state[e])if(u===r){this.deletedStates[e][r]={};for(let h in this.state[e][u])i[h]===void 0&&(this.deletedStates[e][r][h]=null)}else this.deletedStates[e][u]=null}else if(((o=this.deletedStates[e])==null?void 0:o[r])===null){this.deletedStates[e][r]={};for(let u in this.state[e][r])i[u]===void 0&&(this.deletedStates[e][r][u]=null)}else for(let u in i)((l=(s=this.deletedStates[e])==null?void 0:s[r])==null?void 0:l[u])===null&&delete this.deletedStates[e][r][u]}removeFeatureState(e,t,i){var a,n,o;if(this.deletedStates[e]===null)return;let r=String(t);if((a=this.deletedStates)[e]||(a[e]={}),i&&t!==void 0)this.deletedStates[e][r]!==null&&((n=this.deletedStates[e])[r]||(n[r]={}),this.deletedStates[e][r][i]=null);else if(t!==void 0)if((o=this.stateChanges[e])!=null&&o[r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){let i=String(t),r=this.state[e]||{},a=this.stateChanges[e]||{},n=X({},r[i],a[i]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let o=this.deletedStates[e][t];if(o===null)return{};for(let s in o)delete n[s]}return n}initializeTileState(e,t){let i={};for(let r in this.state)i[r]=Tg(this.state[r]);e.setFeatureState(i,t,this.revision)}coalesceChanges(e,t){var a,n,o;let i={};for(let s in this.stateChanges){(a=this.state)[s]||(a[s]={}),i[s]||(i[s]={});for(let l in this.stateChanges[s])(n=this.state[s])[l]||(n[l]={}),X(this.state[s][l],this.stateChanges[s][l]),i[s][l]=this.state[s][l]}for(let s in this.deletedStates)if((o=this.state)[s]||(o[s]={}),i[s]||(i[s]={}),this.deletedStates[s]===null)for(let l in this.state[s])this.state[s][l]={},i[s][l]={};else for(let l in this.deletedStates[s]){if(this.deletedStates[s][l]===null)this.state[s][l]={};else if(this.state[s][l])for(let u of Object.keys(this.deletedStates[s][l]))delete this.state[s][l][u];else continue;i[s][l]=this.state[s][l]}if(this.stateChanges={},this.deletedStates={},Object.keys(i).length===0)return;this.revision++;let r={};for(let s in i)r[s]=Tg(i[s]);e.setFeatureState(r,t,this.revision)}},_p=class kv{constructor(t,i){this.min=t,this.max=i,this.center=Ue([],pi([],this.min,this.max),.5)}quadrant(t){let i=[t%2==0,t<2],r=Rh(this.min),a=Rh(this.max);for(let n=0;n<i.length;n++)r[n]=i[n]?this.min[n]:this.center[n],a[n]=i[n]?this.center[n]:this.max[n];return a[2]=this.max[2],new kv(r,a)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let i=!0;for(let r of t.planes){let a=this.intersectsPlane(r);if(a===0)return 0;a===1&&(i=!1)}return i?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 i=t[3],r=t[3];for(let a=0;a<3;a++)t[a]>0?(i+=t[a]*this.min[a],r+=t[a]*this.max[a]):(r+=t[a]*this.min[a],i+=t[a]*this.max[a]);return i>=0?2:r<0?0:1}},yp=class Rv{constructor(t,i,r){this.points=t,this.planes=i,this.aabb=r}static fromInvProjectionMatrix(t,i=1,r=0,a,n){let o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]],s=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**r,u=o.map(p=>V3(p,t,i,l));a&&N3(u,s[0],a,n);let h=s.map(p=>{let f=jt([],Ht([],dr([],u[p[0]],u[p[1]]),dr([],u[p[2]],u[p[1]]))),m=-lt(f,u[p[1]]);return f.concat(m)}),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 Rv(u,h,new _p(c,d))}};function V3(e,t,i,r){let a=Pt([],e,t),n=1/a[3]/i*r;return _b(a,a,[n,n,1/a[3],n])}function N3(e,t,i,r){let a=r?4:0,n=r?0:4,o=0,s=[],l=[];for(let c=0;c<4;c++){let d=dr([],e[c+n],e[c+a]),p=Pi(d);Ue(d,d,1/p),s.push(p),l.push(d)}for(let c=0;c<4;c++){let d=Eb(e[c+a],l[c],i);o=d!==null&&d>=0?Math.max(o,d):Math.max(o,s[c])}let u=U3(e,t),h=$3(i,u);if(h!==null){let c=h/lt(l[0],u);o=Math.min(o,c)}for(let c=0;c<4;c++){let d=Math.min(o,s[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 U3(e,t){let i=dr([],e[t[0]],e[t[1]]),r=dr([],e[t[2]],e[t[1]]),a=[0,0,0,0];return jt(a,Ht([],i,r)),a[3]=-lt(a,e[t[0]]),a}function $3(e,t){let i=mb([],e,1/el(e)),r=dr([],t,Ue([],i,lt(t,i))),a=el(r);if(a>0){let n=Math.sqrt(1-i[3]*i[3]);return Bh(t,pi([],Ue([],i,-i[3]),Ue([],r,n/a)))}return null}function G3(e,t,i){let r=t.intersectsFrustum(e);if(!i||r===0)return r;let a=t.intersectsPlane(i);return a===0?0:r===2&&a===2?2:1}function Dg(e,t,i){let r=0,a=(i-t)/10;for(let n=0;n<10;n++){let o=t+(n+.5)/10*(i-t);r+=a*Math.cos(o)**+e}return r}function td(e,t){return function(i,r,a,n,o){let s=2*((e-1)/_t(Math.cos(Ve(Na-o))/Math.cos(Ve(Na)))-1),l=Math.acos(a/n),u=2*Dg(s-1,0,Ve(o/2)),h=Math.min(Ve(Na),l+Ve(o/2)),c=Math.min(h,l-Ve(o/2)),d=Dg(s-1,c,h),p=Math.atan(r/a),f=Math.hypot(r,a),m=i;return m+=_t(n/f/Math.max(.5,Math.cos(Ve(o/2)))),m+=s*_t(Math.cos(p))/2,m-=_t(Math.max(1,d/u/t))/2,m}}const Z3=td(9.314,3);function vp(e,t){let i=(t.roundZoom?Math.round:Math.floor)(e.zoom+_t(e.tileSize/t.tileSize));return Math.max(0,i)}function q3(e,t){let i=Y((15-(Na-e.pitch-e.fov/2))/15,0,1),r=Math.max(500,t!=null?t:0);return e.elevation+i*r}function W3(e,t,i){let r=e.planes[1],a=e.points.map(l=>{let u=r[0]*l[0]+r[1]*l[1]+r[2]*l[2]+r[3];if(Math.abs(u)>1e-6)return l;let h=[l[0]-i[0],l[1]-i[1],l[2]-i[2]],c=r[0]*h[0]+r[1]*h[1]+r[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),o=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let l of a)for(let u=0;u<3;u++)o[u]=Math.min(o[u],l[u]),s[u]=Math.max(s[u],l[u]);return new yp(a,n,new _p(o,s))}function H3(e,t,i,r){let a=Math.hypot(t[0],t[1],t[2]);if(a===0)return{frustum:e,plane:t};let n=1+r/Ot,o=Y(-t[3]/a,-1,1),s=Math.cos(Math.acos(o)+Math.acos(1/n));return{frustum:W3(e,Math.sqrt(n*n-1),i),plane:[t[0],t[1],t[2],-s*a]}}function Bo(e,t){let i=e.getCameraFrustum(),r=e.getClippingPlane();r&&t.maxContentElevation>0&&({frustum:i,plane:r}=H3(i,r,e.cameraPosition,t.maxContentElevation));let a=e.getCoveringTilesDetailsProvider(),n=a.getCenter(e),o=sS(e,n),s=e.worldCoordinateHelper.worldFromLngLat(n.lng,n.lat,e.elevation),l=q3(e,t.maxContentElevation),u=a.allowVariableZoom(e,t),h=vp(e,t),c=t.minzoom||0,d=t.maxzoom===void 0?e.maxZoom:t.maxzoom,p=Math.min(Math.max(0,h),d),f=2**p,m=[f*o.x,f*o.y,0],g=[f*s.x,f*s.y,0],_=Math.hypot(s.x-o.x,s.y-o.y),y=Math.abs(s.z-o.z),v=Math.hypot(_,y),x=T=>({zoom:0,x:0,y:0,wrap:T,fullyVisible:!1}),b=[],w=[];if(e.renderWorldCopies&&e.worldCoordinateHelper.wraps&&a.allowWorldCopies())for(let T=1;T<=3;T++)b.push(x(-T)),b.push(x(T));for(b.push(x(0));b.length>0;){let T=b.pop(),S=T.x,C=T.y,F=T.fullyVisible,A={x:S,y:C,z:T.zoom},L=a.getTileBoundingVolume(A,T.wrap,l,t);if(!F){let P=G3(i,L,r);if(P===0)continue;F=P===2}let I=a.distanceToTile2d(o.x,o.y,A,L),E=h;u&&(E=(t.calculateTileZoom||Z3)(e.zoom+_t(e.tileSize/t.tileSize),I,y,v,e.fov)),E=(t.roundZoom?Math.round:Math.floor)(E),E=Math.max(0,E);let D=Math.min(E,d);if(T.wrap=a.getWrap(s,A,T.wrap),T.zoom>=D){if(T.zoom<c)continue;let P=p-T.zoom,R=m[0]-.5-(S<<P),k=m[1]-.5-(C<<P),B=t.reparseOverscaled?Math.max(T.zoom,E):T.zoom;w.push({tileID:new Ct(T.zoom===d?B:T.zoom,T.wrap,T.zoom,S,C),distanceSq:Sb([g[0]-.5-S,g[1]-.5-C]),tileDistanceToCamera:Math.sqrt(R*R+k*k)})}else for(let P=0;P<4;P++){let R=(S<<1)+P%2,k=(C<<1)+(P>>1),B=T.zoom+1;b.push({zoom:B,x:R,y:k,wrap:T.wrap,fullyVisible:F})}}return w.sort((T,S)=>T.distanceSq-S.distanceSq).map(T=>T.tileID)}function Sg(e){return e==="raster"||e==="image"||e==="video"}function X3(e,t,i,r,a,n,o){let s=ke(),l=Pb(t);for(let u of t){let h=e.getTileById(u.key);(h.fadingDirection===0||h.fadeOpacity===0)&&h.resetFadeLogic(),!Y3(e,h,i,s,r,a,o)&&(K3(e,h,i,s,n,o)||J3(h,l,s,o)||h.resetFadeLogic())}}function Y3(e,t,i,r,a,n,o){if(!t.hasData())return!1;let{tileID:s,fadingRole:l,fadingDirection:u,fadingParentID:h}=t;if(l===0&&u===1&&h)return i[h.key]=h,!0;let c=Math.max(s.overscaledZ-a,n);for(let d=s.overscaledZ-1;d>=c;d--){let p=s.scaledTo(d),f=e.getLoadedTile(p);if(f)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:f.tileID,fadeEndTime:r+o}),f.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+o}),i[p.key]=p,!0}return!1}function K3(e,t,i,r,a,n){if(!t.hasData())return!1;let o=t.tileID.children(a),s=Eg(e,t,o,i,r,a,n);if(s)return!0;for(let l of o)Eg(e,t,l.children(a),i,r,a,n)&&(s=!0);return s}function Eg(e,t,i,r,a,n,o){if(i[0].overscaledZ>n)return!1;let s=!1;for(let l of i){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+o}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+o})),r[l.key]=l,s=!0}return s}function J3(e,t,i,r){let a=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(a)){let n=i+r;return e.setSelfFadeLogic(n),!0}return!1}function Q3(e,t){if(t<=0)return!1;let i=ke();for(let r of e.getAllTiles())if(r.fadeEndTime>=i)return!0;return!1}function eI(e,t){var r,a,n;let i=t.getRenderableIds();for(let o of i){if(!((r=e.neighboringTiles)!=null&&r[o]))continue;let s=t.getTileById(o);e.neighboringTiles[o].backfilled||Cg(e,s),!((n=(a=s.neighboringTiles)==null?void 0:a[e.tileID.key])!=null&&n.backfilled)&&Cg(s,e)}}function Cg(e,t){var o;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x,r=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,n=t.tileID.key;(i!==0||r!==0)&&(Math.abs(r)>1||(Math.abs(i)>1&&(Math.abs(i+a)===1?i+=a:Math.abs(i-a)===1&&(i-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),(o=e.neighboringTiles)!=null&&o[n]&&(e.neighboringTiles[n].backfilled=!0))))}var Pg=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let i in this._tiles){let r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t,i){for(let r in this._tiles)this._tiles[r].setFeatureState(e,t,i)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(t=>t.tileID).sort(ng).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 i;return(i=this.getTileById(e))==null?void 0:i.isRenderable(t)}getRenderableIds(e=0,t){let i=[];for(let r of this.getAllIds())this.isIdRenderable(r,t)&&i.push(this.getTileById(r));return t?i.sort((r,a)=>{let n=r.tileID,o=a.tileID,s=new M(n.canonical.x,n.canonical.y)._rotate(-e),l=new M(o.canonical.x,o.canonical.y)._rotate(-e);return n.overscaledZ-o.overscaledZ||l.y-s.y||l.x-s.x}).map(r=>r.tileID.key):i.map(r=>r.tileID).sort(ng).map(r=>r.key)}},cr,id=(cr=class extends Ft{constructor(t,i,r){super(),this._maxContentElevationSeen=0,this.id=t,this.dispatcher=r,this.on("data",a=>{this._dataHandler(a)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",a=>{a.tile||(this._sourceErrored=this._source.loaded())}),this._source=KP(t,i,r,this),this._inViewTiles=new Pg,this._outOfViewCache=new O3(0,a=>this._unloadTile(a)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new j3,this._didEmitContent=!1,this._updated=!1}onAdd(t){var i;this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,(i=this._source)!=null&&i.onAdd&&this._source.onAdd(t)}onRemove(t){var i;for(let r of this._inViewTiles.getAllTiles())r.unloadVectorData();this.clearTiles(),(i=this._source)!=null&&i.onRemove&&this._source.onRemove(t),this._inViewTiles=new Pg}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,i,r,a){try{let n=await this._source.loadTile(t);this._tileLoaded(t,i,r,a,n)}catch(n){t.state="errored",n.status===404?this.update(this.transform,this.terrain):this._source.fire(new K(Dt(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 $e("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.style);for(let i of this._inViewTiles.getAllTiles())i.upload(t),i.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var i;return this._inViewTiles.getRenderableIds((i=this.transform)==null?void 0:i.bearingInRadians,t)}hasRenderableParent(t){let i=t.overscaledZ-1;if(i>=this._source.minzoom){let r=this.getLoadedTile(t.scaledTo(i));if(r)return this._inViewTiles.isIdRenderable(r.tileID.key)}return!1}reload(t,i=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let r of this._inViewTiles.getAllIds()){let a=this._inViewTiles.getTileById(r);(!i||this._source.shouldReloadTile(a,i))&&(t?this._reloadTile(r,a.state==="errored"?"loading":"expired"):a.state!=="errored"&&this._reloadTile(r,"reloading"))}}}async _reloadTile(t,i){let r=this._inViewTiles.getTileById(t);if(!r)return;let a=r.hasData();r.state!=="loading"&&(r.state=i),await this._loadTile(r,t,i,a)}_tileLoaded(t,i,r,a,n){a||(t.timeAdded=ke(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration)),r==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),!(n!=null&&n.unmodified)&&(this.getSource().type==="raster-dem"&&t.dem&&eI(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.style),t.aborted||this._source.fire(new $e("data",{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,i){let r=this._getLoadedDescendents(i),a=new Set;for(let n of i){let o=r[n.key];if(!(o!=null&&o.length)){a.add(n);continue}let s=n.overscaledZ+cr.maxOverzooming,l=o.filter(c=>c.tileID.overscaledZ<=s);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 r;let i={};for(let a of this._inViewTiles.getAllTiles().filter(n=>n.hasData()))for(let n of t)a.tileID.isChildOf(n)&&(i[r=n.key]||(i[r]=[]),i[n.key].push(a));return i}_areDescendentsComplete(t,i,r){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===i:4**(i-r)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let i=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),r=this._maxTileCacheZoomLevels===null?ta.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,a=Math.floor(i*r),n=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,a):a;this._outOfViewCache.setMaxSize(n)}handleWrapJump(t){let i=(t-(this._prevLng===void 0?t:this._prevLng))/360,r=Math.round(i);this._prevLng=t,r&&(this._inViewTiles.handleWrapJump(r),this._resetTileReloadTimers())}_updateMaxContentElevation(){var a,n;let t=this._maxContentElevationSeen,i=(n=(a=this.map)==null?void 0:a.style)==null?void 0:n._layers;if(!i)return t;let r=this._inViewTiles.getAllTiles();for(let o in i){let s=i[o];if(s.type!=="symbol"||s.source!==this.id||s.isHidden(this.transform.zoom))continue;let l=s;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 r){let c=h.getBucket(s);c&&c.maxHeightOffset>t&&(t=c.maxHeightOffset)}}return this._maxContentElevationSeen=t,t}update(t,i){if(!this._sourceLoaded||this._paused)return;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.transform.worldCoordinateHelper.wraps&&this.handleWrapJump(this.transform.center.lng);let r;!this.used&&!this.usedForTerrain?r=[]:this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(l=>new Ct(l.canonical.z,l.wrap,l.canonical.z,l.canonical.x,l.canonical.y)):(r=Bo(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:i,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(r=r.filter(l=>this._source.hasTile(l)))),this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let a=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new $e("data",{sourceDataType:"idle",sourceId:this.id}));let n=vp(t,this._source),o=this._updateRetainedTiles(r,n),s=Sg(this._source.type);s&&this._rasterFadeDuration>0&&!i&&X3(this._inViewTiles,r,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),s?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(t){for(let i of this._inViewTiles.getAllIds())t[i]||this._removeTile(i)}_cleanUpVectorTiles(t){for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);t[i]?r.clearSymbolFadeHold():r.hasSymbolBuckets?r.holdingForSymbolFade()?r.symbolFadeFinished()&&this._removeTile(i):r.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(i)}}_addTerrainIdealTiles(t){let i=[];for(let r of t)if(r.canonical.z>this._source.minzoom){let a=r.scaledTo(r.canonical.z-1);i.push(a);let n=r.scaledTo(Math.max(this._source.minzoom,Math.min(r.canonical.z,5)));i.push(n)}return t.concat(i)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,i){var l;let r=new Set;for(let u of t)this._addTile(u).hasData()||r.add(u);let a=t.reduce((u,h)=>(u[h.key]=h,u),{}),n=this._retainLoadedChildren(a,r),o={},s=Math.max(i-cr.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>=s;--d){let p=u.scaledTo(d);if(o[p.key])break;if(o[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 i=this._inViewTiles.getTileById(t.key);if(i)return i;i=this._outOfViewCache.getAndRemove(t),i&&(i.resetFadeLogic(),this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.style));let r=i;return i||(i=new zv(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state,!1)),i.uses++,this._inViewTiles.setTile(t.key,i),r||this._source.fire(new $e("dataloading",{tile:i,coord:i.tileID})),i}_setTileReloadTimer(t,i){this._clearTileReloadTimer(t);let r=i.getExpiryTimeout();if(r){let a=()=>{this._reloadTile(t,"expired"),delete this._timers[t]};this._timers[t]=setTimeout(a,r)}}_clearTileReloadTimer(t){let i=this._timers[t];i&&(clearTimeout(i),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 i=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,i)}}refreshTiles(t){for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);(this._inViewTiles.isIdRenderable(i)||r.state=="errored")&&t.some(a=>a.equals(r.tileID.canonical))&&this._reloadTile(i,"expired")}}_removeTile(t){let i=this._inViewTiles.getTileById(t);i&&(i.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),!(i.uses>0)&&(i.hasData()&&i.state!=="reloading"?this._outOfViewCache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}_dataHandler(t){t.dataType==="source"&&(t.sourceDataType==="metadata"?this._sourceLoaded=!0: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,i,r){let a=[],n=this.transform;if(!n)return a;let o=n.getCoveringTilesDetailsProvider().allowWorldCopies(),s=r?n.getCameraQueryGeometry(t):t,l=p=>n.screenPointToMercatorCoordinate(p,this.terrain),u=this.transformBbox(t,l,!o),h=this.transformBbox(s,l,!o),c=this.getIds(),d=Mi.fromPoints(h);for(let p of c){let f=this._inViewTiles.getTileById(p);if(f.holdingForSymbolFade())continue;let m=o?[f.tileID]:[f.tileID.unwrapTo(-1),f.tileID.unwrapTo(0)],g=2**(n.zoom-f.tileID.overscaledZ),_=i*f.queryPadding*O/f.tileSize/g;for(let y of m){let v=d.map(x=>y.getTilePoint(new It(x.x,x.y)));if(v.expandBy(_),v.intersects(NT)){let x=u.map(w=>y.getTilePoint(w)),b=h.map(w=>y.getTilePoint(w));a.push({tile:f,tileID:o?y:y.unwrapTo(0),queryGeometry:x,cameraQueryGeometry:b,scale:g})}}}return a}transformBbox(t,i,r){let a=t.map(i);if(r){let n=Mi.fromPoints(t);n.shrinkBy(Math.min(n.width(),n.height())*.001);let o=n.map(i);Mi.fromPoints(a).covers(o)||(a=a.map(s=>s.x>.5?new It(s.x-1,s.y,s.z):s))}return a}getVisibleCoordinates(t){let i=this.getRenderableIds(t).map(r=>this._inViewTiles.getTileById(r).tileID);return this.transform&&this.transform.populateCache(i),i}hasTransition(){return this._source.hasTransition()?!0:Sg(this._source.type)&&Q3(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,i,r){t||(t=Zs),this._state.updateState(t,i,r)}removeFeatureState(t,i,r){t||(t=Zs),this._state.removeFeatureState(t,i,r)}getFeatureState(t,i){return t||(t=Zs),this._state.getState(t,i)}setDependencies(t,i,r){let a=this._inViewTiles.getTileById(t);a&&a.setDependencies(i,r)}reloadTilesForDependencies(t,i){for(let r of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(r).hasDependency(t,i)&&this._reloadTile(r,"reloading");this._outOfViewCache.filter(r=>!r.hasDependency(t,i))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}},cr.maxUnderzooming=10,cr.maxOverzooming=3,cr),tI=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let i=1;i<this.points.length;i++)this._distances[i]=this._distances[i-1]+this.points[i].dist(this.points[i-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=Y(e,0,1);let t=1,i=this._distances[t],r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];let a=t-1,n=this._distances[a],o=i-n,s=o>0?(r-n)/o:0;return this.points[a].mult(1-s).add(this.points[t].mult(s))}};function qs(e,t,i,r,a){return a?e?e(t,i)+r:r===0?void 0:r:r}function Es(e,t){let i=!0;return e==="always"||(e==="never"||t==="never")&&(i=!1),i}var Ag=class{constructor(e,t,i){let r=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let n=0;n<this.xCellCount*this.yCellCount;n++)r.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,i,r,a){this._forEachCell(t,i,r,a,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,a,n){this.boxCells[a].push(n)}_insertCircleCell(e,t,i,r,a,n){this.circleCells[a].push(n)}_query(e,t,i,r,a,n,o){if(i<0||e>this.width||r<0||t>this.height)return[];let s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(a)return[{key:null,x1:e,y1:t,x2:i,y2:r}];for(let l=0;l<this.boxKeys.length;l++)s.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];s.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,i,r,this._queryCell,s,l,o)}return s}query(e,t,i,r){return this._query(e,t,i,r,!1,null)}hitTest(e,t,i,r,a,n){return this._query(e,t,i,r,!0,a,n).length>0}hitTestCircle(e,t,i,r,a){let n=e-i,o=e+i,s=t-i,l=t+i;if(o<0||n>this.width||l<0||s>this.height)return!1;let u=[],h={hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}};return this._forEachCell(n,s,o,l,this._queryCellCircle,u,h,a),u.length>0}_queryCell(e,t,i,r,a,n,o,s){let{seenUids:l,hitTest:u,overlapMode:h}=o,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&&i>=f[g+0]-d&&r>=f[g+1]-d&&(!s||s(_))&&(!u||!Es(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,i,r)&&(!s||s(_))&&(!u||!Es(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,i,r,a,n,o,s){let{circle:l,seenUids:u,overlapMode:h}=o,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])&&(!s||s(g))&&!Es(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)&&(!s||s(g))&&!Es(h,g.overlapMode))return n.push(!0),!0}}}_forEachCell(e,t,i,r,a,n,o,s){let l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),c=this._convertToYCellCoord(r);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,i,r,f,n,o,s))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,i,r,a,n){let o=r-e,s=a-t,l=i+n;return l*l>o*o+s*s}_circleAndRectCollide(e,t,i,r,a,n,o){let s=(n-r)/2,l=Math.abs(e-(r+s));if(l>s+i)return!1;let u=(o-a)/2,h=Math.abs(t-(a+u));if(h>u+i)return!1;if(l<=s||h<=u)return!0;let c=l-s,d=h-u;return c*c+d*d<=i*i}};function iI(e,t){let i=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),a=t[0]*i,n=t[4]*i,o=t[8]*r,s=t[1]*i,l=t[5]*i,u=t[9]*r,h=t[2]*i,c=t[6]*i,d=t[10]*r;e[0]=a,e[1]=n,e[2]=o,e[4]=s,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-s*f-h*m,e[13]=-n*p-l*f-c*m,e[14]=-o*p-u*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}function rI(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 aI(e,t){let i=1/(t[0]*t[5]-t[1]*t[4]);return e[0]=t[5]*i,e[1]=-t[1]*i,e[2]=0,e[3]=0,e[4]=-t[4]*i,e[5]=t[0]*i,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 nI=la();function xp(e,t,i){let r=la();if(!e){let{vecSouth:a,vecEast:n}=bp(t),o=B_();o[0]=n[0],o[1]=n[1],o[2]=a[0],o[3]=a[1],Xx(o,o),r[0]=o[0],r[1]=o[1],r[4]=o[2],r[5]=o[3]}return Rt(r,r,[1/i,1/i,1]),r}function oI(e,t,i,r){if(e){let a=la();if(!t){let{vecSouth:n,vecEast:o}=bp(i);a[0]=o[0],a[1]=o[1],a[4]=n[0],a[5]=n[1]}return Rt(a,a,[r,r,1]),a}return i.pixelsToClipSpaceMatrix}function bp(e){let t=Math.cos(e.rollInRadians),i=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),n=Math.sin(e.bearingInRadians),o=Lh();o[0]=-a*r*i-n*t,o[1]=-n*r*i+a*t;let s=ff(o);s<1e-9?mf(o):pf(o,o,1/s);let l=Lh();l[0]=a*r*t-n*i,l[1]=n*r*t+a*i;let u=ff(l);return u<1e-9?mf(l):pf(l,l,1/u),{vecEast:l,vecSouth:o}}function na(e,t,i){var r,a;return qs(e.getElevation,t,i,(r=e.heightOffset)!=null?r:0,(a=e.heightAnchorGround)!=null?a:!0)}function wp(e,t,i,r){let a;r==null?(a=[e,t,0,1],Tp(a,a,i)):(a=[e,t,r,1],Pt(a,a,i));let n=a[3];return{point:new M(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function Lv(e,t){return .5+e/t*.5}function sI(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function lI(e,t,i,r,a,n,o,s,l,u,h,c){let d=r?e.textSizeData:e.iconSizeData,p=au(d,i.zoom),f=[256/t.width*2+1,256/t.height*2+1],m=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;m.clear();let g=e.lineVertexArray,_=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,y=i.width/i.height,v=!1;for(let x=0;x<_.length;x++){let b=_.get(x);if(b.hidden||b.writingMode===2&&!v){qa(b.numGlyphs,m);continue}v=!1;let w={getElevation:c,pitchedLabelPlaneMatrix:a,lineVertexArray:g,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i,tileAnchorPoint:new M(b.anchorX,b.anchorY),unwrappedTileID:u,width:i.width,height:i.height,translation:h},T=jv(b.anchorX,b.anchorY,w);if(!sI(T.point,f)){qa(b.numGlyphs,m);continue}let S=T.signedDistanceFromCamera,C=Lv(i.cameraToCenterDistance,S),F=Jd(d,p,b),A=o?F*i.getPitchedTextCorrection(b.anchorX,b.anchorY,u)/C:F*C,L=Ig({projectionContext:w,pitchedLabelPlaneMatrixInverse:n,symbol:b,fontSize:A,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:m,aspectRatio:y,rotateToLine:l});v=L.useVertical,(L.notEnoughRoom||v||L.needsFlipping&&Ig({projectionContext:w,pitchedLabelPlaneMatrixInverse:n,symbol:b,fontSize:A,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:m,aspectRatio:y,rotateToLine:l}).notEnoughRoom)&&qa(b.numGlyphs,m)}r?e.text.dynamicLayoutVertexBuffer.updateData(m):e.icon.dynamicLayoutVertexBuffer.updateData(m)}function Bv(e,t,i,r,a,n,o,s){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=Al(e*c,i,r,a,n.segment,u,h,s,o);if(!p)return null;let f=Al(e*d,i,r,a,n.segment,u,h,s,o);return!f||s.projectionCache.anyProjectionOccluded?null:{first:p,last:f}}function Mg(e,t,i,r){return e===1&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:(e===2?t.y<i.y:t.x>i.x)?{needsFlipping:!0}:null}function Ig(e){let{projectionContext:t,pitchedLabelPlaneMatrixInverse:i,symbol:r,fontSize:a,flip:n,keepUpright:o,glyphOffsetArray:s,dynamicLayoutVertexArray:l,aspectRatio:u,rotateToLine:h}=e,c=a/24,d=r.lineOffsetX*c,p=r.lineOffsetY*c,f;if(r.numGlyphs>1){let m=r.glyphStartIndex+r.numGlyphs,g=r.lineStartIndex,_=r.lineStartIndex+r.lineLength,y=Bv(c,s,d,p,n,r,h,t);if(!y)return{notEnoughRoom:!0};let v=Cs(y.first.point.x,y.first.point.y,t,i),x=Cs(y.last.point.x,y.last.point.y,t,i);if(o&&!n){let b=Mg(r.writingMode,v,x,u);if(b)return b}f=[y.first];for(let b=r.glyphStartIndex+1;b<m-1;b++){let w=Al(c*s.getoffsetX(b),d,p,n,r.segment,g,_,t,h);if(!w)return{notEnoughRoom:!0};f.push(w)}f.push(y.last)}else{if(o&&!n){let g=oa(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,_=r.lineStartIndex+r.segment+1,y=new M(t.lineVertexArray.getx(_),t.lineVertexArray.gety(_)),v=oa(y.x,y.y,t),x=v.signedDistanceFromCamera>0?v.point:Ov(t.tileAnchorPoint,y,g,1,t),b=Cs(g.x,g.y,t,i),w=Cs(x.x,x.y,t,i),T=Mg(r.writingMode,b,w,u);if(T)return T}let m=Al(c*s.getoffsetX(r.glyphStartIndex),d,p,n,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,t,h);if(!m||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};f=[m]}for(let m of f)Dl(l,m.point,m.angle);return{}}function Ov(e,t,i,r,a){let n=e.add(e.sub(t)._unit()),o=oa(n.x,n.y,a).point,s=i.sub(o);return i.add(s._mult(r/s.mag()))}function rd(e,t,i){let r=t.projectionCache;if(r.projections[e])return r.projections[e];let a=new M(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),n=oa(a.x,a.y,t);if(n.signedDistanceFromCamera>0)return r.projections[e]=n.point,r.anyProjectionOccluded||(r.anyProjectionOccluded=n.isOccluded),n.point;let o=e-i.direction,s=i.distanceFromAnchor===0?t.tileAnchorPoint:new M(t.lineVertexArray.getx(o),t.lineVertexArray.gety(o)),l=i.absOffsetX-i.distanceFromAnchor+1;return Ov(s,a,i.previousVertex,l,t)}function oa(e,t,i){let r=e+i.translation[0],a=t+i.translation[1],n;return i.pitchWithMap?(n=wp(r,a,i.pitchedLabelPlaneMatrix,na(i,r,a)),n.isOccluded=!1):(n=i.transform.projectTileCoordinates(r,a,i.unwrappedTileID,na(i,r,a)),n.point.x=(n.point.x*.5+.5)*i.width,n.point.y=(-n.point.y*.5+.5)*i.height),n}function Cs(e,t,i,r){if(i.pitchWithMap){let a=[e,t,0,1];Pt(a,a,r);let n=a[0]/a[3],o=a[1]/a[3];return i.transform.projectTileCoordinates(n,o,i.unwrappedTileID,na(i,n,o)).point}return{x:e/i.width*2-1,y:1-t/i.height*2}}function jv(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,na(i,e,t))}function ad(e,t,i){return e._unit()._perp()._mult(t*i)}function uI(e,t,i,r,a,n,o,s,l){if(s.projectionCache.offsets[e])return s.projectionCache.offsets[e];let u=i.add(t);if(e+l.direction<r||e+l.direction>=a)return s.projectionCache.offsets[e]=u,u;let h=rd(e+l.direction,s,l),c=ad(h.sub(i),o,l.direction),d=i.add(c),p=h.add(c);return s.projectionCache.offsets[e]=zb(n,u,d,p)||u,s.projectionCache.offsets[e]}function Al(e,t,i,r,a,n,o,s,l){let u=r?e-t:e+t,h=u>0?1:-1,c=0;r&&(h*=-1,c=Math.PI),h<0&&(c+=Math.PI);let d=h>0?n+a:n+a+1,p;s.projectionCache.cachedAnchorPoint?p=s.projectionCache.cachedAnchorPoint:(p=oa(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=p);let f=p,m=p,g,_,y=0,v=0,x=Math.abs(u),b=[],w;for(;y+v<=x;){if(d+=h,d<n||d>=o)return null;y+=v,m=f,_=g;let F={absOffsetX:x,direction:h,distanceFromAnchor:y,previousVertex:m};if(f=rd(d,s,F),i===0)b.push(m),w=f.sub(m);else{let A,L=f.sub(m);A=L.mag()===0?ad(rd(d+h,s,F).sub(f),i,h):ad(L,i,h),_||(_=m.add(A)),g=uI(d,A,f,n,o,_,i,s,F),b.push(_),w=g.sub(_)}v=w.mag()}let T=(x-y)/v,S=w._mult(T)._add(_||m),C=c+Math.atan2(f.y-m.y,f.x-m.x);return b.push(S),{point:S,angle:l?C:0,path:b}}const hI=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function qa(e,t){for(let i=0;i<e;i++){let r=t.length;t.resize(r+4),t.float32.set(hI,r*3)}}function Tp(e,t,i){let r=t[0],a=t[1];return e[0]=i[0]*r+i[4]*a+i[12],e[1]=i[1]*r+i[5]*a+i[13],e[3]=i[3]*r+i[7]*a+i[15],e}function cI(e,t){let i=nI;return aI(i,t.pitchedLabelPlaneMatrix),e.map(r=>{let a=wp(r.x,r.y,i,na(t,r.x,r.y)),n=t.transform.projectTileCoordinates(a.point.x,a.point.y,t.unwrappedTileID,na(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 dI(e){let t=0,i=0,r=0,a=0;for(let n=0;n<e.length;n++)e[n].isOccluded?(r=n+1,a=0):(a++,a>i&&(i=a,t=r));return e.slice(t,t+i)}var pI=class{constructor(e,t=new Ag(e.width+200,e.height+200,25),i=new Ag(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=i,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,i,r,a,n,o,s,l,u,h,c,d=0,p=!0){let f=e.anchorPointX+s[0],m=e.anchorPointY+s[1],g=this.projectAndGetPerspectiveRatio(f,m,a,qs(u,f,m,d,p),c),_=i*g.perspectiveRatio,y;if(!n&&!o){let C=g.x+(h?h.x*_:0),F=g.y+(h?h.y*_:0);y={allPointsOccluded:!1,box:[C+e.x1*_,F+e.y1*_,C+e.x2*_,F+e.y2*_]}}else y=this._projectCollisionBox(e,_,r,a,n,o,s,g,u,h,c,d,p);let[v,x,b,w]=y.box,T=n?y.allPointsOccluded:g.isOccluded,S=T;return S||(S=g.perspectiveRatio<this.perspectiveRatioCutoff),S||(S=!this.isInsideGrid(v,x,b,w)),S||t!=="always"&&this.grid.hitTest(v,x,b,w,t,l)?{box:[v,x,b,w],placeable:!1,offscreen:!1,occluded:T}:{box:[v,x,b,w],placeable:!0,offscreen:this.isOffscreen(v,x,b,w),occluded:T}}placeCollisionCircles(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=[],m=new M(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*_,b={getElevation:p,pitchedLabelPlaneMatrix:o,lineVertexArray:i,pitchWithMap:l,projectionCache:y,transform:this.transform,tileAnchorPoint:m,unwrappedTileID:n,width:this.transform.width,height:this.transform.height,translation:d},w=Bv(_,r,v,x,!1,t,!1,b),T=!1,S=!1,C=!0;if(w){let F=h*.5*g+c,A=new M(-100,-100),L=new M(this.screenRightBoundary,this.screenBottomBoundary),I=new tI,E=w.first,D=w.last,P=[];for(let B=E.path.length-1;B>=1;B--)P.push(E.path[B]);for(let B=1;B<D.path.length;B++)P.push(D.path[B]);let R=F*2.5;if(l){let B=this.projectPathToScreenSpace(P,b);P=B.some(Z=>Z.signedDistanceFromCamera<=0)?[]:B.map(Z=>Z.point)}let k=[];if(P.length>0){let B=P[0].clone(),Z=P[0].clone();for(let oe=1;oe<P.length;oe++)B.x=Math.min(B.x,P[oe].x),B.y=Math.min(B.y,P[oe].y),Z.x=Math.max(Z.x,P[oe].x),Z.y=Math.max(Z.y,P[oe].y);k=B.x>=A.x&&Z.x<=L.x&&B.y>=A.y&&Z.y<=L.y?[P]:Z.x<A.x||B.x>L.x||Z.y<A.y||B.y>L.y?[]:N1([P],A.x,A.y,L.x,L.y)}for(let B of k){I.reset(B,F*.25);let Z=0;Z=I.length<=.5*F?1:Math.ceil(I.paddedLength/R)+1;for(let oe=0;oe<Z;oe++){let pe=oe/Math.max(Z-1,1),fe=I.lerp(pe),Ee=fe.x+100,Te=fe.y+100;f.push(Ee,Te,F,0);let Ge=Ee-F,Ce=Te-F,mt=Ee+F,yt=Te+F;if(C&&(C=this.isOffscreen(Ge,Ce,mt,yt)),S||(S=this.isInsideGrid(Ge,Ce,mt,yt)),e!=="always"&&this.grid.hitTestCircle(Ee,Te,F,e,u)&&(T=!0,!s))return{circles:[],offscreen:!1,collisionDetected:T}}}}return{circles:!s&&T||!S||g<this.perspectiveRatioCutoff?[]:f,offscreen:C,collisionDetected:T}}projectPathToScreenSpace(e,t){return dI(cI(e,t))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let t=[],i=new Mi;for(let h of e){let c=new M(h.x+100,h.y+100);i.extend(c),t.push(c)}let{minX:r,minY:a,maxX:n,maxY:o}=i,s=this.grid.query(r,a,n,o).concat(this.ignoredGrid.query(r,a,n,o)),l={},u={};for(let h of s){let c=h.key;l[c.bucketInstanceId]===void 0&&(l[c.bucketInstanceId]={}),!l[c.bucketInstanceId][c.featureIndex]&&N0(t,[new M(h.x1,h.y1),new M(h.x2,h.y1),new M(h.x2,h.y2),new M(h.x1,h.y2)])&&(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,i,r,a,n){let o=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};o.insert(s,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,a,n){let o=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};for(let l=0;l<e.length;l+=4)o.insertCircle(s,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,t,i,r,a){if(a){let n;r==null?(n=[e,t,0,1],Tp(n,n,a)):(n=[e,t,r,1],Pt(n,n,a));let o=n[3];return{x:(n[0]/o+1)/2*this.transform.width+100,y:(-n[1]/o+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/o),isOccluded:!1,signedDistanceFromCamera:o}}{let n=this.transform.projectTileCoordinates(e,t,i,r);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,i,r){let a=this.transform.projectTileCoordinates(e,t,i,r);return .5+.5*(this.transform.cameraToCenterDistance/a.signedDistanceFromCamera)}isOffscreen(e,t,i,r){return i<100||e>=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=Ii([]);return st(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,i,r,a,n,o,s,l,u,h,c=0,d=!0){let p=1,f=0,m=0,g=1,_=e.anchorPointX+o[0],y=e.anchorPointY+o[1];if(n&&!a){let D=this.projectAndGetPerspectiveRatio(_+1,y,r,qs(l,_+1,y,c,d),h),P=D.x-s.x,R=D.y-s.y,k=Math.atan(R/P)+(P<0?Math.PI:0),B=Math.sin(k),Z=Math.cos(k);p=Z,f=B,m=-B,g=Z}else if(!n&&a){let D=bp(this.transform);p=D.vecEast[0],f=D.vecEast[1],m=D.vecSouth[0],g=D.vecSouth[1]}let v=s.x,x=s.y,b=t;if(a&&(v=_,x=y,b=2**-(this.transform.zoom-i.overscaledZ),b*=this.transform.getPitchedTextCorrection(_,y,r),!u)){let D=Y(.5+.5*(s.signedDistanceFromCamera/this.transform.cameraToCenterDistance),0,4);b*=D}u&&(v+=p*u.x*b+m*u.y*b,x+=f*u.x*b+g*u.y*b);let w=e.x1*b,T=e.x2*b,S=(w+T)/2,C=e.y1*b,F=e.y2*b,A=(C+F)/2,L=[{offsetX:w,offsetY:C},{offsetX:S,offsetY:C},{offsetX:T,offsetY:C},{offsetX:T,offsetY:A},{offsetX:T,offsetY:F},{offsetX:S,offsetY:F},{offsetX:w,offsetY:F},{offsetX:w,offsetY:A}],I=[];for(let{offsetX:D,offsetY:P}of L)I.push(new M(v+p*D+m*P,x+f*D+g*P));let E=!1;if(a){let D=I.map(P=>this.projectAndGetPerspectiveRatio(P.x,P.y,r,qs(l,P.x,P.y,c,d),h));E=D.some(P=>!P.isOccluded),I=D.map(P=>new M(P.x,P.y))}else E=!0;return{box:Cb(I),allPointsOccluded:!E}}},Fg=class{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return this.opacity===0&&!this.placed}},Fn=class{constructor(e,t,i,r,a){this.text=new Fg(e?e.text:null,t,i,a),this.icon=new Fg(e?e.icon:null,t,r,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},zg=class{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}},fI=class{constructor(e,t,i,r,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=a}},mI=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:i=>i.collisionGroupID===t}}return this.collisionGroups[e]}};function kg(e,t,i,r,a){let{horizontalAlign:n,verticalAlign:o}=ru(e),s=-(n-.5)*t,l=-(o-.5)*i;return new M(s+r[0]*a,l+r[1]*a)}const gI=VS.members.find(e=>e.name==="crossTileID").offset/4;var _I=class{constructor(e,t,i,r,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new pI(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new mI(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.lastOpacityInputs=new WeakMap,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;if(t)return(i,r)=>t.getElevation(e,i,r)}getBucketParts(e,t,i,r){let a=i.getBucket(t),n=i.latestFeatureIndex;if(!a||!n||t.id!==a.layerIds[0])return;let o=i.collisionBoxArray,s=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-i.tileID.overscaledZ),h=i.tileSize/O,c=i.tileID.toUnwrapped(),d=s.get("text-rotation-alignment")==="map",p=oi(i,1,this.transform.zoom),f=Ir(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=Ir(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),g=xp(d,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new fI(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,i.tileID);let _={bucket:a,layout:s,translationText:f,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:g,scale:u,textPixelRatio:h,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:au(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(r)for(let y of a.sortKeyRanges){let{sortKey:v,symbolInstanceStart:x,symbolInstanceEnd:b}=y;e.push({sortKey:v,symbolInstanceStart:x,symbolInstanceEnd:b,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:_})}attemptAnchorPlacement(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,v,x,b){var F,A,L;let w=Nc[e.textAnchor],T=[e.textOffset0,e.textOffset1],S=kg(w,i,r,T,a),C=this.collisionIndex.placeCollisionBox(t,c,s,l,u,o,n,m,h.predicate,y,S,v,x,b);if((!_||this.collisionIndex.placeCollisionBox(_,c,s,l,u,o,n,g,h.predicate,y,S,v,x,b).placeable)&&C.placeable){let I;if((F=this.prevPlacement)!=null&&F.variableOffsets[d.crossTileID]&&((L=(A=this.prevPlacement)==null?void 0:A.placements[d.crossTileID])!=null&&L.text)&&(I=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:i,height:r,anchor:w,textBoxScale:a,prevAnchor:I},this.markUsedJustification(p,w,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:S,placedGlyphBoxes:C}}}placeLayerBucketPart(e,t,i){let{bucket:r,layout:a,translationText:n,translationIcon:o,unwrappedTileID:s,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=Tl(a,"text-overlap","text-allow-overlap"),_=g==="always",y=Tl(a,"icon-overlap","icon-allow-overlap"),v=y==="always",x=a.get("text-rotation-alignment")==="map",b=a.get("text-pitch-alignment")==="map",w=a.get("icon-text-fit")!=="none",T=a.get("symbol-z-order")==="viewport-y",S=a.get("symbol-height-anchor")==="ground",C=_&&(v||!r.hasIconData()||m),F=v&&(_||!r.hasTextData()||f);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let A=this.retainedQueryData[r.bucketInstanceId].tileID,L=this._getTerrainElevationFunc(A),I=this.transform.getFastPathSimpleProjectionMatrix(A),E=(D,P,R)=>{var xe,ie;if(t[D.crossTileID])return;if(h){this.placements[D.crossTileID]=new zg(!1,!1,!1);return}let k=D.heightOffset,B=!1,Z=!1,oe=!0,pe=null,fe={box:null,placeable:!1,offscreen:null,occluded:!1},Ee={placeable:!1},Te=null,Ge=null,Ce=null,mt=0,yt=0,Yt=0;P.textFeatureIndex?mt=P.textFeatureIndex:D.useRuntimeCollisionCircles&&(mt=D.featureIndex),P.verticalTextFeatureIndex&&(yt=P.verticalTextFeatureIndex);let Nt=P.textBox;if(Nt){let V=q=>{let ve=1;if(r.allowVerticalPlacement&&!q&&this.prevPlacement){let be=this.prevPlacement.placedOrientations[D.crossTileID];be&&(this.placedOrientations[D.crossTileID]=be,ve=be,this.markUsedOrientation(r,ve,D))}return ve},ye=(q,ve)=>{if(r.allowVerticalPlacement&&D.numVerticalGlyphVertices>0&&P.verticalTextBox){for(let be of r.writingModes)if(be===2?(fe=ve(),Ee=fe):fe=q(),fe==null?void 0:fe.placeable)break}else fe=q()},te=D.textAnchorOffsetStartIndex,ae=D.textAnchorOffsetEndIndex;if(ae===te){let q=(ve,be)=>{let ne=this.collisionIndex.placeCollisionBox(ve,g,u,A,s,b,x,n,p.predicate,L,void 0,I,k,S);return ne!=null&&ne.placeable&&(this.markUsedOrientation(r,be,D),this.placedOrientations[D.crossTileID]=be),ne};ye(()=>q(Nt,1),()=>{let ve=P.verticalTextBox;return r.allowVerticalPlacement&&D.numVerticalGlyphVertices>0&&ve?q(ve,2):{box:null,offscreen:null}}),V(fe==null?void 0:fe.placeable)}else{let q=Nc[(ie=(xe=this.prevPlacement)==null?void 0:xe.variableOffsets[D.crossTileID])==null?void 0:ie.anchor],ve=(ne,Ze,Br)=>{let tr=ne.x2-ne.x1,Bi=ne.y2-ne.y1,Oi=D.textBoxScale,Oe=w&&y==="never"?Ze:null,Le=null,si=g==="never"?1:2,xi="never";q&&si++;for(let ma=0;ma<si;ma++){for(let ot=te;ot<ae;ot++){let ut=r.textAnchorOffsets.get(ot);if(q&&ut.textAnchor!==q)continue;let ga=this.attemptAnchorPlacement(ut,ne,tr,Bi,Oi,x,b,u,A,s,p,xi,D,r,Br,n,o,Oe,L,I,k,S);if(ga&&(Le=ga.placedGlyphBoxes,Le==null?void 0:Le.placeable))return B=!0,pe=ga.shift,Le}q?q=null:xi=g}return i&&!Le&&(Le={box:this.collisionIndex.placeCollisionBox(Nt,"always",u,A,s,b,x,n,p.predicate,L,void 0,I,k,S).box,offscreen:!1,placeable:!1,occluded:!1}),Le};ye(()=>ve(Nt,P.iconBox,1),()=>{let ne=P.verticalTextBox,Ze=fe==null?void 0:fe.placeable;return r.allowVerticalPlacement&&!Ze&&D.numVerticalGlyphVertices>0&&ne?ve(ne,P.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),fe&&(B=fe.placeable,oe=fe.offscreen);let be=V(fe==null?void 0:fe.placeable);if(!B&&this.prevPlacement){let ne=this.prevPlacement.variableOffsets[D.crossTileID];ne&&(this.variableOffsets[D.crossTileID]=ne,this.markUsedJustification(r,ne.anchor,D,be))}}}if(Te=fe,B=Te==null?void 0:Te.placeable,oe=Te==null?void 0:Te.offscreen,D.useRuntimeCollisionCircles&&D.centerJustifiedTextSymbolIndex>=0){let V=r.text.placedSymbolArray.get(D.centerJustifiedTextSymbolIndex),ye=Jd(r.textSizeData,d,V),te=a.get("text-padding"),ae=D.collisionCircleDiameter;Ge=this.collisionIndex.placeCollisionCircles(g,V,r.lineVertexArray,r.glyphOffsetArray,ye,s,l,i,b,p.predicate,ae,te,n,L),Ge.circles.length&&Ge.collisionDetected&&!i&&_e("Collisions detected, but collision boxes are not shown"),B=_||Ge.circles.length>0&&!Ge.collisionDetected,oe&&(oe=Ge.offscreen)}if(P.iconFeatureIndex&&(Yt=P.iconFeatureIndex),P.iconBox){let V=ye=>this.collisionIndex.placeCollisionBox(ye,y,u,A,s,b,x,o,p.predicate,L,w&&pe?pe:void 0,I,k,S);Ee&&Ee.placeable&&P.verticalIconBox?(Ce=V(P.verticalIconBox),Z=Ce.placeable):(Ce=V(P.iconBox),Z=Ce.placeable),oe&&(oe=Ce.offscreen)}let zt=f||D.numHorizontalGlyphVertices===0&&D.numVerticalGlyphVertices===0,Xe=m||D.numIconVertices===0;!zt&&!Xe?Z=B=Z&&B:Xe?zt||Z&&(Z=B):B=Z&&B;let Kt=B&&Te.placeable,vi=Z&&Ce.placeable;if(Kt&&(Ee&&Ee.placeable&&yt?this.collisionIndex.insertCollisionBox(Te.box,g,a.get("text-ignore-placement"),r.bucketInstanceId,yt,p.ID):this.collisionIndex.insertCollisionBox(Te.box,g,a.get("text-ignore-placement"),r.bucketInstanceId,mt,p.ID)),vi&&this.collisionIndex.insertCollisionBox(Ce.box,y,a.get("icon-ignore-placement"),r.bucketInstanceId,Yt,p.ID),Ge&&B&&this.collisionIndex.insertCollisionCircles(Ge.circles,g,a.get("text-ignore-placement"),r.bucketInstanceId,mt,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,R,P,Te,Ce,Ge),D.crossTileID===0)throw Error("symbolInstance.crossTileID can't be 0");if(r.bucketInstanceId===0)throw Error("bucket.bucketInstanceId can't be 0");let Li=(B||C)&&!(Te!=null&&Te.occluded),H=(Z||F)&&!(Ce!=null&&Ce.occluded);this.placements[D.crossTileID]=new zg(Li,H,oe||r.justReloaded),t[D.crossTileID]=!0};if(T){if(e.symbolInstanceStart!==0)throw Error("bucket.bucketInstanceId should be 0");let D=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let P=D.length-1;P>=0;--P){let R=D[P];E(r.symbolInstances.get(R),r.collisionArrays[R],R)}}else for(let D=e.symbolInstanceStart;D<e.symbolInstanceEnd;D++)E(r.symbolInstances.get(D),r.collisionArrays[D],D);r.justReloaded=!1}storeCollisionData(e,t,i,r,a,n){if(i.textBox||i.iconBox){let o;this.collisionBoxArrays.has(e)?o=this.collisionBoxArrays.get(e):(o=new Map,this.collisionBoxArrays.set(e,o));let s;o.has(t)?s=o.get(t):(s={text:null,icon:null},o.set(t,s)),i.textBox&&(s.text=r.box),i.iconBox&&(s.icon=a.box)}if(n){let o=this.collisionCircleArrays[e];o===void 0&&(o=this.collisionCircleArrays[e]=[]);for(let s=0;s<n.circles.length;s+=4)o.push(n.circles[s+0]-100),o.push(n.circles[s+1]-100),o.push(n.circles[s+2]),o.push(+!!n.collisionDetected)}}markUsedJustification(e,t,i,r){let a={left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex},n;n=r===2?i.verticalPlacedTextSymbolIndex:a[Uc(t)];let o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(let s of o)s>=0&&(n>=0&&s!==n?e.text.placedSymbolArray.get(s).crossTileID=0:e.text.placedSymbolArray.get(s).crossTileID=i.crossTileID)}markUsedOrientation(e,t,i){let r=t===1||t===3?t:0,a=t===2?t:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(let o of n)e.text.placedSymbolArray.get(o).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let r=t?t.symbolFadeChange(e):1,a=t?t.opacities:{},n=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(let s in this.placements){let l=this.placements[s],u=a[s];u?(this.opacities[s]=new Fn(u,r,l.text,l.icon),i||(i=l.text!==u.text.placed),i||(i=l.icon!==u.icon.placed)):(this.opacities[s]=new Fn(null,r,l.text,l.icon,l.skipFade),i||(i=l.text||l.icon))}for(let s in a){let l=a[s];if(!this.opacities[s]){let u=new Fn(l,r,!1,!1);u.isHidden()||(this.opacities[s]=u,i||(i=l.text.placed),i||(i=l.icon.placed))}}for(let s in n)!this.variableOffsets[s]&&this.opacities[s]&&!this.opacities[s].isHidden()&&(this.variableOffsets[s]=n[s]);for(let s in o)!this.placedOrientations[s]&&this.opacities[s]&&!this.opacities[s].isHidden()&&(this.placedOrientations[s]=o[s]);if(t&&t.lastPlacementChangeTime===void 0)throw Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let i={};for(let r of t){let a=r.getBucket(e);if(!a||!r.latestFeatureIndex||e.id!==a.layerIds[0])continue;let{duplicates:n,changed:o}=this._markDuplicates(a,i),s=!!a.hasDebugData()||a.bucketInstanceId in this.collisionCircleArrays;(o||s)&&this.updateBucketOpacities(a,r.tileID,n,r.collisionBoxArray),a.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[a.bucketInstanceId]&&(this.retainedQueryData[a.bucketInstanceId].featureSortOrder=a.featureSortOrder)}}_markDuplicates(e,t){let i=e.symbolInstances.length,r=this.lastOpacityInputs.get(e),a=!1;r||(r={crossTileIDs:Array(i).fill(0),duplicates:Array(i).fill(!1)},this.lastOpacityInputs.set(e,r),a=!0);let{crossTileIDs:n,duplicates:o}=r,s=e.symbolInstances.uint32,l=e.symbolInstances.bytesPerElement/4;for(let u=0;u<i;u++){let h=s[u*l+gI],c=!!t[h];t[h]=!0,(n[u]!==h||o[u]!==c)&&(n[u]=h,o[u]=c,a=!0)}return{duplicates:o,changed:a}}updateBucketOpacities(e,t,i,r){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,o=new Fn(null,0,!1,!1,!0),s=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 Fn(null,0,s&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(s||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);let f=(g,_,y)=>{for(let v=0;v<_/4;v++)g.opacityVertexArray.emplaceBack(y);g.hasVisibleVertices||(g.hasVisibleVertices=y!==0)},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}=_,b=i[g],w=this.opacities[x];b?w=o:w||(w=p,this.opacities[x]=w);let T=y>0||v>0,S=_.numIconVertices>0,C=this.placedOrientations[_.crossTileID],F=C===2,A=C===1||C===3;if(T){let I=Lg(w.text),E=F?0:I;f(e.text,y,E);let D=A?0:I;f(e.text,v,D);let P=w.text.isHidden(),R=[_.rightJustifiedTextSymbolIndex,_.centerJustifiedTextSymbolIndex,_.leftJustifiedTextSymbolIndex];for(let Z of R)Z>=0&&(e.text.placedSymbolArray.get(Z).hidden=P||F?1:0);_.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(_.verticalPlacedTextSymbolIndex).hidden=P||A?1:0);let k=this.variableOffsets[_.crossTileID];k&&this.markUsedJustification(e,k.anchor,_,C);let B=this.placedOrientations[_.crossTileID];B&&(this.markUsedJustification(e,"left",_,B),this.markUsedOrientation(e,B,_))}if(S){let I=Lg(w.icon),E=!(d&&_.verticalPlacedIconSymbolIndex&&F);if(_.placedIconSymbolIndex>=0){let D=E?I:0;f(e.icon,_.numIconVertices,D),e.icon.placedSymbolArray.get(_.placedIconSymbolIndex).hidden=w.icon.isHidden()}if(_.verticalPlacedIconSymbolIndex>=0){let D=E?0:I;f(e.icon,_.numVerticalIconVertices,D),e.icon.placedSymbolArray.get(_.verticalPlacedIconSymbolIndex).hidden=w.icon.isHidden()}}let L=m!=null&&m.has(g)?m.get(g):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let I=e.collisionArrays[g];if(I){let E=new M(0,0);if(I.textBox||I.verticalTextBox){let D=!0;if(u){let P=this.variableOffsets[x];P?(E=kg(P.anchor,P.width,P.height,P.textOffset,P.textBoxScale),h&&E._rotate(c?-this.transform.bearingInRadians:this.transform.bearingInRadians)):D=!1}if(I.textBox||I.verticalTextBox){let P;I.textBox&&(P=F),I.verticalTextBox&&(P=A),Rg(e.textCollisionBox.collisionVertexArray,w.text.placed,!D||P,L.text,E.x,E.y)}}if(I.iconBox||I.verticalIconBox){let D=!(A||!I.verticalIconBox),P;I.iconBox&&(P=D),I.verticalIconBox&&(P=!D),Rg(e.iconCollisionBox.collisionVertexArray,w.icon.placed,P,L.icon,d?E.x:0,d?E.y:0)}}}}if(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 i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}};function Rg(e,t,i,r,a,n){(!r||r.length===0)&&(r=[0,0,0,0]);let o=r[0]-100,s=r[1]-100,l=r[2]-100,u=r[3]-100;e.emplaceBack(+!!t,+!!i,a||0,n||0,o,s),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,s),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,u),e.emplaceBack(+!!t,+!!i,a||0,n||0,o,u)}const yI=2**25,vI=2**24,xI=2**17,bI=2**16;function Lg(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return wI;let t=+!!e.placed,i=Math.floor(e.opacity*127);return i*yI+t*vI+i*xI+t*bI+i*512+t*256+i*2+t}const wI=4294967295;var TI=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,i,r,a){let n=this._bucketParts;for(;this._currentTileIndex<e.length;){let o=e[this._currentTileIndex];if(t.getBucketParts(n,r,o,this._sortAcrossTiles),this._currentTileIndex++,a())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((o,s)=>o.sortKey-s.sortKey));this._currentPartIndex<n.length;){let o=n[this._currentPartIndex];if(t.placeLayerBucketPart(o,this._seenCrossTileIDs,i),this._currentPartIndex++,a())return!0}return!1}},DI=class{constructor(e,t,i,r,a,n,o,s){this.placement=new _I(e,t,n,o,s),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){let r=ke(),a=()=>!this._forceFullPlacement&&ke()-r>2;for(;this._currentPlacementIndex>=0;){let n=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(q1(n)&&n.layout&&(!n.minzoom||n.minzoom<=o)&&(!n.maxzoom||n.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new TI(n)),this._inProgressLayer.continuePlacement(i[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 Bg=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Ye=new Uint32Array(96);var SI=class Vv{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(t,0,2);if(i!==219)throw Error("Data does not appear to be in a KDBush format.");let a=r>>4;if(a!==1)throw Error(`Got v${a} data when expected v1.`);let n=Bg[r&15];if(!n)throw Error("Unrecognized array type.");let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Vv(s,o,n,void 0,t)}constructor(t,i=64,r=Float64Array,a=ArrayBuffer,n){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let o=Bg.indexOf(this.ArrayType),s=t*2*this.ArrayType.BYTES_PER_ELEMENT,l=t*this.IndexArrayType.BYTES_PER_ELEMENT,u=(8-l%8)%8;if(o<0)throw Error(`Unexpected typed array class: ${r}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(n,8+l+u,t*2),this._pos=t*2,this._finished=!0;else{let h=this.data=new a(8+s+l+u);this.ids=new this.IndexArrayType(h,8,t),this.coords=new r(h,8+l+u,t*2),this._pos=0,this._finished=!1,new Uint8Array(h,0,2).set([219,16+o]),new Uint16Array(h,2,1)[0]=i,new Uint32Array(h,4,1)[0]=t}}add(t,i){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=i,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return nd(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:o,nodeSize:s}=this;Ye[0]=0,Ye[1]=n.length-1,Ye[2]=0;let l=3,u=[];for(;l>0;){let h=Ye[--l],c=Ye[--l],d=Ye[--l];if(c-d<=s){for(let g=d;g<=c;g++){let _=o[2*g],y=o[2*g+1];_>=t&&_<=r&&y>=i&&y<=a&&u.push(n[g])}continue}let p=d+c>>1,f=o[2*p],m=o[2*p+1];f>=t&&f<=r&&m>=i&&m<=a&&u.push(n[p]),(h===0?t<=f:i<=m)&&(Ye[l++]=d,Ye[l++]=p-1,Ye[l++]=1-h),(h===0?r>=f:a>=m)&&(Ye[l++]=p+1,Ye[l++]=c,Ye[l++]=1-h)}return u}within(t,i,r){let a=[];return this.withinInto(t,i,r,a),a}withinInto(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:o,nodeSize:s}=this;Ye[0]=0,Ye[1]=n.length-1,Ye[2]=0;let l=3,u=0,h=r*r;for(;l>0;){let c=Ye[--l],d=Ye[--l],p=Ye[--l];if(d-p<=s){for(let _=p;_<=d;_++)Og(o[2*_],o[2*_+1],t,i)<=h&&(a[u++]=n[_]);continue}let f=p+d>>1,m=o[2*f],g=o[2*f+1];Og(m,g,t,i)<=h&&(a[u++]=n[f]),(c===0?t-r<=m:i-r<=g)&&(Ye[l++]=p,Ye[l++]=f-1,Ye[l++]=1-c),(c===0?t+r>=m:i+r>=g)&&(Ye[l++]=f+1,Ye[l++]=d,Ye[l++]=1-c)}return u}};function nd(e,t,i,r,a,n){if(a-r<=i)return;let o=r+a>>1;Nv(e,t,o,r,a,n),nd(e,t,i,r,o-1,1-n),nd(e,t,i,o+1,a,1-n)}function Nv(e,t,i,r,a,n){for(;a>r;){if(a-r>600){let u=a-r+1,h=i-r+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);Nv(e,t,i,Math.max(r,Math.floor(i-h*d/u+p)),Math.min(a,Math.floor(i+(u-h)*d/u+p)),n)}let o=t[2*i+n],s=r,l=a;for(zn(e,t,r,i),t[2*a+n]>o&&zn(e,t,r,a);s<l;){for(zn(e,t,s,l),s++,l--;t[2*s+n]<o;)s++;for(;t[2*l+n]>o;)l--}t[2*r+n]===o?zn(e,t,r,l):(l++,zn(e,t,l,a)),l<=i&&(r=l+1),i<=l&&(a=l-1)}}function zn(e,t,i,r){fh(e,i,r),fh(t,2*i,2*r),fh(t,2*i+1,2*r+1)}function fh(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function Og(e,t,i,r){let a=e-i,n=t-r;return a*a+n*n}const kn=512/O/2;var EI=class{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this._symbolsByKey={};let r=new Map;for(let a=0;a<t.length;a++){let n=t.get(a),o=n.key,s=r.get(o);s?s.push(n):r.set(o,[n])}for(let[a,n]of r){let o={positions:n.map(s=>({x:Math.floor(s.anchorX*kn),y:Math.floor(s.anchorY*kn)})),crossTileIDs:n.map(s=>s.crossTileID)};if(o.positions.length>128){let s=new SI(o.positions.length,16,Uint16Array);for(let{x:l,y:u}of o.positions)s.add(l,u);s.finish(),delete o.positions,o.index=s}this._symbolsByKey[a]=o}}getScaledCoordinates(e,t){let{x:i,y:r,z:a}=this.tileID.canonical,{x:n,y:o,z:s}=t.canonical,l=s-a,u=kn/2**l,h=(n*O+e.anchorX)*u,c=(o*O+e.anchorY)*u,d=i*O*kn,p=r*O*kn;return{x:Math.floor(h-d),y:Math.floor(c-p)}}findMatches(e,t,i){let r=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 o=this._symbolsByKey[n.key];if(!o)continue;let s=this.getScaledCoordinates(n,t);o.index?this.findMatchesForIndexedEntry(o,n,s,r,i):o.positions&&this.findMatchesForNonIndexedEntry(o,n,s,r,i)}}findMatchesForIndexedEntry(e,t,i,r,a){let n=e.index.range(i.x-r,i.y-r,i.x+r,i.y+r),o=1/0;for(let s of n)s<o&&!a[e.crossTileIDs[s]]&&(o=s);if(o!==1/0){let s=e.crossTileIDs[o];a[s]=!0,t.crossTileID=s}}findMatchesForNonIndexedEntry(e,t,i,r,a){for(let n=0;n<e.positions.length;n++){let o=e.positions[n],s=e.crossTileIDs[n];if(Math.abs(o.x-i.x)<=r&&Math.abs(o.y-i.y)<=r&&!a[s]){a[s]=!0,t.crossTileID=s;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},CI=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},PI=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let i in this.indexes){let r=this.indexes[i],a={};for(let n in r){let o=r[n];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),a[o.tileID.key]=o}this.indexes[i]=a}this.lng=e}addBucket(e,t,i){var a,n,o;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 s=0;s<t.symbolInstances.length;s++){let l=t.symbolInstances.get(s);l.crossTileID=0}(n=this.usedCrossTileIDs)[o=e.overscaledZ]||(n[o]={});let r=this.usedCrossTileIDs[e.overscaledZ];for(let s in this.indexes){let l=this.indexes[s];if(Number(s)>e.overscaledZ)for(let u in l){let h=l[u];h.tileID.isChildOf(e)&&h.findMatches(t.symbolInstances,e,r)}else{let u=l[e.scaledTo(Number(s)).key];u&&u.findMatches(t.symbolInstances,e,r)}}for(let s=0;s<t.symbolInstances.length;s++){let l=t.symbolInstances.get(s);l.crossTileID||(l.crossTileID=i.generate(),r[l.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new EI(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let i of t.getCrossTileIDsLists())for(let r of i)delete this.usedCrossTileIDs[e][r]}removeStaleBuckets(e){let t=!1;for(let i in this.indexes){let r=this.indexes[i];for(let a in r)e[r[a].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[a]),delete r[a],t=!0)}return t}},AI=class{constructor(){this.layerIndexes={},this.crossTileIDs=new CI,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let r=this.layerIndexes[e.id];r===void 0&&(r=this.layerIndexes[e.id]=new PI);let a=!1,n={};r.handleWrapJump(i);for(let o of t){let s=o.getBucket(e);e.id===(s==null?void 0:s.layerIds[0])&&(s.bucketInstanceId||(s.bucketInstanceId=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId)),r.addBucket(o.tileID,s,this.crossTileIDs)&&(a=!0),n[s.bucketInstanceId]=!0)}return r.removeStaleBuckets(n)&&(a=!0),a}pruneUnusedLayers(e){let t={};for(let i of e)t[i]=!0;for(let i in this.layerIndexes)t[i]||delete this.layerIndexes[i]}},MI=`#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;};`,II=`#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;};`,FI=`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
fragColor=vec4(1.0);
#endif
}`,zI="layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}",kI=`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
}`,RI="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,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);}",LI=`in vec3 v_data;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
}`,BI=`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;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);}`,jg="void main() {fragColor=vec4(1.0);}";const Wi={prelude:we(MI,II),projectionMercator:we(`
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:we("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:we(FI,zI),backgroundPattern:we(kI,RI),circle:we(LI,BI),clippingMask:we(jg,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}"),heatmap:we(`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:we(`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:we("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:we("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:we(`#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:we("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:we(jg,`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:we(`#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:we(`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:we(`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:we(`#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:we(`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.z==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:we(`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.z==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:we(`#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;uniform float u_log2_world_width;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+(3.0+u_log2_world_width-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:we(`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:we(`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;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;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);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:we(`uniform sampler2D u_image;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 vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;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);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:we(`#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;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;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;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;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_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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:we(`uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
#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;layout(location=2) in vec2 a_offset_normal;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;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_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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:we(`uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;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 vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) 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;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_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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:we(`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:we(`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:we(`uniform sampler2D u_texture;in vec2 v_tex;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;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:we(`#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:we(`#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;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;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:we("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:we("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;}"),terrainHeight:we("in highp float v_elevation;void main() {fragColor=vec4(v_elevation,0.0,0.0,1.0);}","layout(location=0) in vec3 a_pos3d;uniform vec4 u_tile_bounds;out highp float v_elevation;void main() {v_elevation=get_elevation(a_pos3d.xy);vec2 position=u_tile_bounds.xy+a_pos3d.xy/8192.0*u_tile_bounds.zw;gl_Position=vec4(position.x*2.0-1.0,1.0-position.y*2.0,0.0,1.0);}"),atmosphere:we(`#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:we("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 we(e,t){let i=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=n?n.concat(a):a,s=r?r.length:0,l={};return e=e.replace(i,(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(i,(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 = ${s++}) 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 = ${s++}) 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:r,staticUniforms:o}}const Uv="#define PROJECTION_MERCATOR",$v="mercator";var Ws=class{constructor(e=ln){this._cachedMesh=null,this._worldCoordinateHelper=e}get name(){return this._worldCoordinateHelper.name}get worldCoordinateHelper(){return this._worldCoordinateHelper}get useSubdivision(){return!1}get shaderVariantName(){return $v}get shaderDefine(){return Uv}get shaderPreludeCode(){return Wi.projectionMercator}get vertexShaderPreludeCode(){return Wi.projectionMercator.vertexSource}get subdivisionGranularity(){return Wd.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,i,r,a){if(this._cachedMesh)return this._cachedMesh;let n=new qr;n.emplaceBack(0,0),n.emplaceBack(O,0),n.emplaceBack(0,O),n.emplaceBack(O,O);let o=e.createVertexBuffer(n,Ba.members),s=Ke.simpleSegment(0,0,4,2),l=new Ki;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new wo(o,u,s),this._cachedMesh}recalculate(){}hasTransition(){return!1}},Vg=class Gv{constructor(t=0,i=0,r=0,a=0){if(isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0||isNaN(a)||a<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=i,this.left=r,this.right=a}interpolate(t,i,r){return i.top!=null&&t.top!=null&&(this.top=We.number(t.top,i.top,r)),i.bottom!=null&&t.bottom!=null&&(this.bottom=We.number(t.bottom,i.bottom,r)),i.left!=null&&t.left!=null&&(this.left=We.number(t.left,i.left,r)),i.right!=null&&t.right!=null&&(this.right=We.number(t.right,i.right,r)),this}getCenter(t,i){return new M(Y((this.left+t-this.right)/2,0,t),Y((this.top+i-this.bottom)/2,0,i))}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Gv(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function Ml(e,t){if(!e.renderWorldCopies||!e.worldCoordinateHelper.wraps||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function Ng(e){return Math.max(0,Math.floor(e))}var Dp=class{constructor(e,t){var i;this.applyConstrain=(r,a)=>this._constrainOverride===null?this._callbacks.defaultConstrain(r,a):this._constrainOverride(r,a),this._callbacks=e,this._tileSize=512,this._worldCoordinateHelper=ln,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=(i=t==null?void 0:t.constrainOverride)!=null?i:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new W(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ng(this._zoom),this._scale=pt(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Vg,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=Ng(this._zoom),this._scale=pt(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 Vg(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){e!==this._minElevationForCurrentTile&&(this._minElevationForCurrentTile=e,this._calcMatrices())}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 worldCoordinateHelper(){return this._worldCoordinateHelper}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),e&&!this._worldCoordinateHelper.wraps&&_e("renderWorldCopies has no effect in a projection whose world does not wrap."),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 M(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let t=fi(e,-180,180)*Math.PI/180;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=B_(),Kx(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=Y(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 Ei(this._fovInRadians)}setFov(e){e=Y(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=Ve(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=pt(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.constrainInternal(),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,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&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 mr([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setWorldCoordinateHelper(e){this._worldCoordinateHelper=e}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-85.051129,Fi])}getCameraQueryGeometry(e,t){if(t.length===1)return[t[0],e];{let{minX:i,minY:r,maxX:a,maxY:n}=Mi.fromPoints(t).extend(e);return[new M(i,r),new M(a,r),new M(a,n),new M(i,n),new M(i,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._pixelPerMeter=this.worldCoordinateHelper.worldZFromAltitude(1,this.center)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=Ii(new Float64Array(16));Rt(e,e,[this._width/2,-this._height/2,1]),st(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=Ii(new Float64Array(16)),Rt(e,e,[1,-1,1]),st(e,e,[-1,-1,0]),Rt(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,i,r){let a=i===void 0?this.bearing:i,n=r=r===void 0?this.pitch:r,{distanceToCenter:o,clampedElevation:s}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,n),{x:l,y:u}=Lc(n,a),h=this.worldCoordinateHelper,c=W.convert(e),d=h.worldFromLngLat(c.lng,c.lat,t),{centerMercator:p,dMercator:f}=this._centerAlongView(d,l,u,o,h.metersPerWorldUnit(d.x,d.y));return{center:h.lngLatFromWorld(p.x,p.y),elevation:s,zoom:_t(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=this.pitch,i=this.bearing,{x:r,y:a,z:n}=Lc(t,i),o=this.worldCoordinateHelper,s=o.worldFromLngLat(this.center.lng,this.center.lat,this.elevation),l=1/o.worldZFromAltitude(1,this.center),u=this.cameraToCenterDistance/this.worldSize,h=new It(s.x-r*u,s.y-a*u,s.z+n*u),{distanceToCenter:c,clampedElevation:d}=this._distanceToCenterFromAltElevationPitch(h.z*l,e,t),{centerMercator:p,dMercator:f}=this._centerAlongView(h,r,a,c,l),m=o.lngLatFromWorld(p.x,p.y),g=_t(this.cameraToCenterDistance/f/this.tileSize);this._elevation=d,this._center=m;let _=this._zoom;this.setZoom(g),this._zoom===_&&(this._unmodified=!1,this.constrainInternal(),this._calcMatrices())}_centerAlongView(e,t,i,r,a){let n=r/a,o=new It(e.x+t*n,e.y+i*n),s=1/0;for(let l=1;l<10;l++){let u=this.worldCoordinateHelper.metersPerWorldUnit(o.x,o.y),h=Math.abs(u-a);if(h<=1e-12*a||h>=s)break;s=h,a=u,n=r/a,o=new It(e.x+t*n,e.y+i*n)}return{centerMercator:o,dMercator:n}}_distanceToCenterFromAltElevationPitch(e,t,i){let r=-Math.cos(Ve(i)),a=e-t,n,o=t;return r*a>=0||Math.abs(r)<Math.cos(Ve(89.25))?(n=1e4,o=e+n*r):n=-a/r,{distanceToCenter:n,clampedElevation:o}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new M(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/O,1/t/O]}},OI=class{getCenter(e){return e.center}distanceToTile2d(e,t,i,r){let a=r,n=a.distanceX([e,t]),o=a.distanceY([e,t]);return Math.hypot(n,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,t,i,r){var s,l;let a=Math.min(0,i),n=Math.max(0,i);if(r!=null&&r.terrain){let u=new Ct(e.z,t,e.z,e.x,e.y),h=r.terrain.getMinMaxElevation(u);a=(s=h.minElevation)!=null?s:a,n=(l=h.maxElevation)!=null?l:n}let o=1<<e.z;return new _p([t+e.x/o,e.y/o,a],[t+(e.x+1)/o,(e.y+1)/o,n])}allowVariableZoom(e,t){let i=Y(78.5-e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height/2,0,60);return!!t.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}};const Ug=O*(1-1e-12),$g=-.5,Gg={covered:!1,demLoaded:!1,elevation:0};var jI=class{constructor(e,t,i=()=>ln){this.tileManager=e,this.exaggeration=t,this.getWorldCoordinateHelper=i,this._samplerCache=new Map}reset(){this._samplerCache.clear(),this._index=void 0,this._ownDemIndex=void 0}getIndex(e=!1){return e?(this._ownDemIndex===void 0&&(this._ownDemIndex=this._build(!0)),this._ownDemIndex):(this._index===void 0&&(this._index=this._build(!1)),this._index)}sample(e,t=!1){let i=this.getIndex(t);if(!i)return;let r=this.getWorldCoordinateHelper(),{x:a,y:n}=r.worldFromLngLat(e.lng,e.lat),o=nn(i,this.exaggeration,a,n,r.wraps);return o.demLoaded?o.elevation:void 0}getSampler(e){let t=e.key,i=this._samplerCache.get(t);if(i)return i;let r=this._createElevationSampler(e);return r&&this._samplerCache.set(t,r),r}_createElevationSampler(e){let t=this.tileManager.getSourceTile(e,!0),i=t==null?void 0:t.dem;if(!t||!i)return null;let r=e.canonical.z-t.tileID.canonical.z,a=1<<r,n=i.dim/(O*a),o=(e.canonical.x-(e.canonical.x>>r<<r))/a*i.dim+$g,s=(e.canonical.y-(e.canonical.y>>r<<r))/a*i.dim+$g;return(l,u,h)=>{let c=h===8192?1:O/h;return i.sampleBilinear(l*c*n+o,u*c*n+s)}}_build(e){var o,s,l,u;let{tileManager:t}=this,i=[],r=new Map,a=0,n=0;for(let h of t.getRenderableTiles()){if(!h)continue;let{canonical:c,wrap:d}=h.tileID;i.includes(c.z)||i.push(c.z);let p=e&&!((o=t.getSourceTile(h.tileID))!=null&&o.dem)?null:this.getSampler(h.tileID);r.set(`${d}/${c.z}/${c.x}/${c.y}`,p);let f=(s=t.getSourceTile(h.tileID,!0))==null?void 0:s.dem;a=Math.min(a,((l=f==null?void 0:f.min)!=null?l:0)*this.exaggeration),n=Math.max(n,((u=f==null?void 0:f.max)!=null?u:0)*this.exaggeration)}return r.size===0?null:(i.sort((h,c)=>c-h),{zooms:i,samplerPerTile:r,minElevation:a-10,maxElevation:n+10})}};function nn(e,t,i,r,a){if(r<0||r>=1||!a&&(i<0||i>=1))return Gg;let n=a?Math.floor(i):0,o=i-n;for(let s of e.zooms){let l=1<<s,u=o*l,h=r*l,c=Math.floor(u),d=Math.floor(h),p=`${n}/${s}/${c}/${d}`;if(!e.samplerPerTile.has(p))continue;let f=e.samplerPerTile.get(p);return f?{covered:!0,demLoaded:!0,elevation:f(Math.min((u-c)*O,Ug),Math.min((h-d)*O,Ug),O)*t}:{covered:!0,demLoaded:!1,elevation:0}}return Gg}function Sp(e,t){return e.covered&&t<=e.elevation+1e-6}function Zv(e,t,i,r,a){for(let n=0;n<40&&r-i>a;n++){let o=(i+r)/2;t(e,o)?r=o:i=o}return{lo:i,hi:r}}var qv=class Wv{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,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}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,i){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._maxBoundsWorldBox=null,this.defaultConstrain=(r,a)=>{if(a=Y(+a,this.minZoom,this.maxZoom),!this.worldCoordinateHelper.wraps)return this._constrainToWorldSquare(r,a);let n={center:new W(r.lng,r.lat),zoom:a},o=this._helper._lngRange;!this._helper._renderWorldCopies&&o===null&&(o=[-179.9999999999,180-1e-10]);let s=this.tileSize*pt(n.zoom),l=0,u=s,h=0,c=s,d=0,p=0,{top:f=0,bottom:m=0,left:g=0,right:_=0}=this.padding,y=this.width-g-_,v=this.height-f-m;if(this._helper._latRange){let C=this._helper._latRange;l=xl(C[1])*s,u=xl(C[0])*s,u-l<v&&(d=v/(u-l))}o&&(h=fi(vl(o[0])*s,0,s),c=fi(vl(o[1])*s,0,s),c<h&&(c+=s),c-h<y&&(p=y/(c-h)));let{x,y:b}=gi(s,r,this.worldCoordinateHelper),w,T,S=Math.max(p||0,d||0);if(S)return n.center=wr(s,new M(p?(c+h)/2:x,d?(u+l)/2:b),this.worldCoordinateHelper).wrap(),n.zoom+=_t(S),n;if(this._helper._latRange){let C=v/2;b-C<l&&(T=l+C),b+C>u&&(T=u-C)}if(o){let C=(h+c)/2,F=x;this._helper._renderWorldCopies&&(F=fi(x,C-s/2,C+s/2));let A=y/2;F-A<h&&(w=h+A),F+A>c&&(w=c-A)}return(w!==void 0||T!==void 0)&&(n.center=wr(s,new M(w!=null?w:x,T!=null?T:b),this.worldCoordinateHelper).wrap()),n},this.applyConstrain=(r,a)=>this._helper.applyConstrain(r,a),this._helper=i!=null?i:new Dp({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(r,a)=>this.defaultConstrain(r,a)},t),this._coveringTilesDetailsProvider=new OI}clone(){let t=new Wv;return t.setWorldCoordinateHelper(this.worldCoordinateHelper),t.apply(this,!1),t}get worldCoordinateHelper(){return this._helper.worldCoordinateHelper}setWorldCoordinateHelper(t){this._helper.setWorldCoordinateHelper(t),this._maxBoundsWorldBox=null}apply(t,i){this._helper.apply(t,i)}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 i=[new El(0,t)];if(this._helper.renderWorldCopies&&this.worldCoordinateHelper.wraps){let r=this.screenPointToMercatorCoordinate(new M(0,0)),a=this.screenPointToMercatorCoordinate(new M(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new M(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new M(0,this._helper._height)),s=Math.floor(Math.min(r.x,a.x,n.x,o.x)),l=Math.floor(Math.max(r.x,a.x,n.x,o.x));for(let u=s-1;u<=l+1;u++)u!==0&&i.push(new El(u,t))}return i}getCameraFrustum(){return yp.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){for(let i=0;i<3;i++){let r=t&&this._terrainPointPastMaxZoom(t)||this.screenPointToLocation(this.centerPoint,t),a=t?t.getElevationForLngLat(r,this):0;if(this.pitch<90&&a>=this.getCameraAltitude()||(this._helper.recalculateZoomAndCenter(a),!t||Math.abs(t.getElevationForLngLat(this.center,this)-this.elevation)<=1e-4))return}}setLocationAtPoint(t,i,r=this.elevation){let a=r-this.elevation,n=this.screenPointToMercatorCoordinateAtZ(i,a),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),s=this.worldCoordinateHelper,l=s.worldFromLngLat(t.lng,t.lat);this.setCenter(s.lngLatFromWorld(l.x-(n.x-o.x),l.y-(n.y-o.y))),this._helper.renderWorldCopies&&this.worldCoordinateHelper.wraps&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,i){let r=this.worldCoordinateHelper.worldFromLngLat(t.lng,t.lat);return i?this.coordinatePoint(r,i.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(r)}screenPointToLocation(t,i){return this._worldToLngLat(this.screenPointToMercatorCoordinate(t,i))}screenPointToLocationAtElevation(t,i){return this._worldToLngLat(this.screenPointToMercatorCoordinateAtZ(t,i-this.elevation))}_worldToLngLat(t){return t?this.worldCoordinateHelper.lngLatFromWorld(t.x,t.y):void 0}screenPointToMercatorCoordinate(t,i){if(i){let r=this.screenTerrainPointToMercatorCoordinate(t,i);if(r!=null)return r}return this.screenPointToMercatorCoordinateAtZ(t)}_terrainPointPastMaxZoom(t){var s;let i=t.getCoverageIndex();if(!i)return null;let{near:r,far:a}=this.getRaySegmentFromPixel(this.centerPoint,-1),n=this.cameraToCenterDistance*pt(this.zoom-this.maxZoom),o=lb([],r,a,Math.max(0,(n-this.nearZ)/(this.farZ-this.nearZ)));return Sp(nn(i,t.exaggeration,o[0]/this.worldSize,o[1]/this.worldSize,this.worldCoordinateHelper.wraps),o[2])?null:(s=this._worldToLngLat(this._raycastTerrain(o,a,t)))!=null?s:null}screenTerrainPointToMercatorCoordinate(t,i){let{near:r,far:a}=this.getRaySegmentFromPixel(t,-1);return this._raycastTerrain(r,a,i)}_raycastTerrain(t,i,r){let a=r.getCoverageIndex();if(!a)return null;let n=this.worldSize,o=i[0]-t[0],s=i[1]-t[1],l=i[2]-t[2],u={index:a,exaggeration:r.exaggeration,near:t,dx:o,dy:s,dz:l,worldSize:n,wraps:this.worldCoordinateHelper.wraps},h=0,c=1;if(l===0){if(t[2]>a.maxElevation||t[2]<a.minElevation)return null}else{let g=(a.maxElevation-t[2])/l,_=(a.minElevation-t[2])/l;if(h=Math.max(h,Math.min(g,_)),c=Math.min(c,Math.max(g,_)),h>c)return null}let d=Math.hypot(o,s),p=Y(Math.ceil(d*(c-h)/4),1,512),f=0,m=!Ps(u,0);for(let g=0;g<=p;g++){let _=h+(c-h)*g/p;if(!m)m=!Ps(u,_);else if(Ps(u,_)){let{lo:y,hi:v}=Zv(u,Ps,f,_,.001/d),x=Xs(u,y),b=Xs(u,v),w=t[2]+y*l-x.elevation,T=t[2]+v*l-b.elevation,S=x.covered&&w>T?Y(y+w*(v-y)/(w-T),y,v):v;return new It((t[0]+S*o)/n,(t[1]+S*s)/n,Xs(u,S).elevation)}f=_}return null}getRaySegmentFromPixel(t,i=0){let r=[t.x,t.y,i,1],a=[t.x,t.y,1,1];Pt(r,r,this._pixelMatrixInverse),Pt(a,a,this._pixelMatrixInverse);let n=r[3],o=a[3],s=this.elevation;return{near:[r[0]/n,r[1]/n,r[2]/n+s],far:[a[0]/o,a[1]/o,a[2]/o+s]}}screenPointToMercatorCoordinateAtZ(t,i){let r=i||0,{near:a,far:n}=this.getRaySegmentFromPixel(t),o=a[2]===n[2]?0:(r+this.elevation-a[2])/(n[2]-a[2]);return new It(We.number(a[0],n[0],o)/this.worldSize,We.number(a[1],n[1],o)/this.worldSize,r)}coordinatePoint(t,i=0,r=this._pixelMatrix){let a=this._coordinateClipPoint(t,i,r),n=a[3];return n>0?new M(a[0]/n,a[1]/n):this._offScreenPointBehindCamera(a[0],a[1],n)}_coordinateClipPoint(t,i,r){let a=[t.x*this.worldSize,t.y*this.worldSize,i,1];return Pt(a,a,r)}_offScreenPointBehindCamera(t,i,r){let a=this.width/2,n=this.height/2,o=t-a*r,s=i-n*r;o===0&&s===0&&(s=1);let l=a+this.width,u=n+this.height,h=Math.min(o===0?1/0:l/Math.abs(o),s===0?1/0:u/Math.abs(s));return new M(a+o*h,n+s*h)}getBounds(){let t=Math.max(0,this._helper._height/2-Qn(this));return new mr().extend(this.screenPointToLocation(new M(0,t))).extend(this.screenPointToLocation(new M(this._helper._width,t))).extend(this.screenPointToLocation(new M(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new M(0,this._helper._height)))}isPointOnMapSurface(t,i){if(i)return this.screenTerrainPointToMercatorCoordinate(t,i)!=null;let r=t.y>this.centerPoint.y-Qn(this);if(!r||this.worldCoordinateHelper.wraps)return r;let a=this.screenPointToMercatorCoordinate(t);return this.worldCoordinateHelper.hasLngLat(a.x,a.y)}calculatePosMatrix(t,i=!1,r=!1){var l;let a=(l=t.key)!=null?l:$a(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),n=i?this._alignedPosMatrixCache:this._posMatrixCache;if(n.has(a)){let u=n.get(a);return r?u.f32:u.f64}let o=rh(t,this.worldSize);Pa(o,i?this._alignedProjMatrix:this._viewProjMatrix,o);let s={f64:o,f32:new Float32Array(o)};return n.set(a,s),r?s.f32:s.f64}calculateFogMatrix(t){let i=t.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);let a=rh(t,this.worldSize);return Pa(a,this._fogMatrix,a),r.set(i,new Float32Array(a)),r.get(i)}_constrainToWorldSquare(t,i){let r=this.worldCoordinateHelper,a=this._helper._lngRange,n=this.tileSize*pt(i);if(!a){let{x,y:b}=gi(n,t,r),w=Y(x,0,n),T=Y(b,0,n);return w!==x||T!==b?{center:wr(n,new M(w,T),r),zoom:i}:{center:new W(t.lng,t.lat),zoom:i}}let o=this._projectMaxBounds(a,this._helper._latRange),s=Math.max(o.minX,0)*n,l=Math.min(o.maxX,1)*n,u=Math.max(o.minY,0)*n,h=Math.min(o.maxY,1)*n,{x:c,y:d}=this.size,p=l-s<c?c/(l-s):0,f=h-u<d?d/(h-u):0,{x:m,y:g}=gi(n,t,r),_=Math.max(p,f);if(_)return{center:wr(n,new M(p?(l+s)/2:m,f?(h+u)/2:g),r),zoom:i+_t(_)};let y=Y(m,s+c/2,l-c/2),v=Y(g,u+d/2,h-d/2);return y!==m||v!==g?{center:wr(n,new M(y,v),r),zoom:i}:{center:new W(t.lng,t.lat),zoom:i}}_projectMaxBounds(t,i){let r=this._maxBoundsWorldBox;if((r==null?void 0:r.lngRange)===t&&r.latRange===i)return r.box;let a=p1(this.worldCoordinateHelper,t[0],i[0],t[1],i[1]);return this._maxBoundsWorldBox={lngRange:t,latRange:i,box:a},a}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){let n=this.worldCoordinateHelper,o=W.convert(t),s=W.convert(r),l=n.worldFromLngLat(o.lng,o.lat,i),u=n.worldFromLngLat(s.lng,s.lat,a),h=u.x-l.x,c=u.y-l.y,d=u.z-l.z,p=Math.hypot(h,c,d);if(p===0)throw Error("Can't calculate camera options with same From and To");let f=Math.hypot(h,c),m=_t(this.cameraToCenterDistance/p/this.tileSize),g=Ei(Math.atan2(h,-c)),_=Ei(Math.acos(f/p));return _=d<0?90-_:90+_,{center:n.lngLatFromWorld(u.x,u.y),elevation:a,zoom:m,pitch:_,bearing:g}}_calculateNearFarZ(t,i,r){let a=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),n=t-a*this._helper._pixelPerMeter/Math.cos(i),o=a<0?n:t,s=Math.PI/2+this.pitchInRadians,l=Ve(this.fov)*(Math.abs(Math.cos(Ve(this.roll)))*this.height+Math.abs(Math.sin(Ve(this.roll)))*this.width)/this.height*(.5+r.y/this.height),u=Math.sin(l)*o/Math.sin(Y(Math.PI-s-l,.01,Math.PI-.01)),h=Qn(this),c=Math.atan(h/this._helper.cameraToCenterDistance),d=Ve(.75),p=c>d?2*c*(.5+r.y/(h*2)):d,f=Math.sin(p)*o/Math.sin(Y(Math.PI-s-p,.01,Math.PI-.01)),m=Math.min(u,f);this._helper._farZ=(Math.cos(Math.PI/2-i)*m+o)*1.01,this._helper._nearZ=this._helper._height/50}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let i=this.centerOffset,r=this.worldCoordinateHelper,a=gi(this.worldSize,this.center,r),n=a.x,o=a.y,s=Ve(Math.min(this.pitch,Na)),l=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(s));t&&this._calculateNearFarZ(l,s,i);let u;u=new Float64Array(16),kh(u,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),rI(this._invProjMatrix,u),u[8]=-i.x*2/this._helper._width,u[9]=i.y*2/this._helper._height,this._projectionMatrix=zh(u),Rt(u,u,[1,-1,1]),st(u,u,[0,0,-this._helper.cameraToCenterDistance]),Dr(u,u,-this.rollInRadians),Wa(u,u,this.pitchInRadians),Dr(u,u,-this.bearingInRadians),st(u,u,[-n,-o,0]),this._mercatorMatrix=Rt([],u,[this.worldSize,this.worldSize,this.worldSize]),Rt(u,u,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=Pa(new Float64Array(16),this.clipSpaceToPixelsMatrix,u),st(u,u,[0,0,-this.elevation]),this._viewProjMatrix=u,this._invViewProjMatrix=Js([],u);let h=[0,0,-1,1];Pt(h,h,this._invViewProjMatrix),this._cameraPosition=[h[0]/h[3],h[1]/h[3],h[2]/h[3]],this._fogMatrix=new Float64Array(16),kh(this._fogMatrix,this.fovInRadians,this.width/this.height,l,this._helper._farZ),this._fogMatrix[8]=-i.x*2/this.width,this._fogMatrix[9]=i.y*2/this.height,Rt(this._fogMatrix,this._fogMatrix,[1,-1,1]),st(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),Dr(this._fogMatrix,this._fogMatrix,-this.rollInRadians),Wa(this._fogMatrix,this._fogMatrix,this.pitchInRadians),Dr(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),st(this._fogMatrix,this._fogMatrix,[-n,-o,0]),Rt(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),st(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=Pa(new Float64Array(16),this.clipSpaceToPixelsMatrix,u);let c=this._helper._width%2/2,d=this._helper._height%2/2,p=Math.cos(this.bearingInRadians),f=Math.sin(-this.bearingInRadians),m=n-Math.round(n)+p*c+f*d,g=o-Math.round(o)+p*d+f*c,_=new Float64Array(u);if(st(_,_,[m>.5?m-1:m,g>.5?g-1:g,0]),this._alignedProjMatrix=_,u=Js(new Float64Array(16),this._pixelMatrix),!u)throw Error("failed to invert matrix");this._pixelMatrixInverse=u,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new M(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return Pt(i,i,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=this.worldCoordinateHelper,i=this.center,r=t.worldZFromAltitude(1,i),a=r*this.worldSize,n=this._helper.cameraToCenterDistance/a,o=c1(t.worldFromLngLat(i.lng,i.lat,this.elevation),this.pitch,this.bearing,n*r);return t.lngLatFromWorld(o.x,o.y)}getProjectionData(t){let{overscaledTileID:i,aligned:r,applyTerrainMatrix:a}=t,n=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,r,!0):null,s;return s=i!=null&&i.terrainRttPosMatrix32f&&a?i.terrainRttPosMatrix32f:o||N_(),{mainMatrix:s,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s,clipAntimeridian:!1}}isLocationOccluded(t,i,r){if(!(i!=null&&i.getCoverageIndex()))return!1;let a=this.worldCoordinateHelper.worldFromLngLat(t.lng,t.lat);r!=null||(r=i.getElevationForLngLat(t,this));let n=this._coordinateClipPoint(a,r,this._pixelMatrix3D),o=n[3];if(o<=0||n[2]>o)return!0;let s=new M(n[0]/o,n[1]/o),l=this.screenTerrainPointToMercatorCoordinate(s,i);if(l==null)return!1;let u=this.getRaySegmentFromPixel(s,-1),h=Zg(u,a.x*this.worldSize,a.y*this.worldSize,r);return Zg(u,l.x*this.worldSize,l.y*this.worldSize,l.z)<h*.99}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,i,r){return 1}transformLightDirection(t){return Rh(t)}getRayDirectionFromPixel(t){throw Error("Not implemented.")}projectTileCoordinates(t,i,r,a){let n=this.calculatePosMatrix(r),o;a==null?(o=[t,i,0,1],Tp(o,o,n)):(o=[t,i,a,1],Pt(o,o,n));let s=o[3];return{point:new M(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}populateCache(t){for(let i of t)this.calculatePosMatrix(i)}getProjectionDataForCustomLayer(t=!0){let i=new Ct(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:t}),a=rh(i,this.worldSize);Pa(a,this._viewProjMatrix,a);let n=[O,O,this.worldSize/this._helper.pixelsPerMeter],o=Gr();return Rt(o,a,n),{...r,tileMercatorCoords:[0,0,1,1],fallbackMatrix:o,mainMatrix:o}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function Hs(e){return new qv(e)}function Xs(e,t){return nn(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize,e.wraps)}function Ps(e,t){return Sp(Xs(e,t),e.near[2]+t*e.dz)}function Zg({near:e,far:t},i,r,a){let n=t[0]-e[0],o=t[1]-e[1],s=t[2]-e[2];return((i-e[0])*n+(r-e[1])*o+(a-e[2])*s)/(n*n+o*o+s*s)}function Hv(){_e("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Xv(e){if(e.useSlerp)if(e.k<1){let t=_f(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),i=_f(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);Ls(r,t,i,e.k);let a=Vb(r);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 Yv(e,t,i,r,a,n){let o=n.worldCoordinateHelper,s=gi(n.worldSize,r.getNorthWest(),o),l=gi(n.worldSize,r.getNorthEast(),o),u=gi(n.worldSize,r.getSouthEast(),o),h=gi(n.worldSize,r.getSouthWest(),o),[c,d]=o.wraps?[Y(r.getSouth(),-85.051129,Fi),Y(r.getNorth(),-85.051129,Fi)]:[r.getSouth(),r.getNorth()],{points:p,bulge:f}=d1(o,r.getWest(),c,r.getEast(),d),m=Ve(-a),g=1/0,_=1/0,y=-1/0,v=-1/0;for(let R of p){let{x:k,y:B}=R.mult(n.worldSize).rotate(m);k<g&&(g=k),B<_&&(_=B),k>y&&(y=k),B>v&&(v=B)}let x=f*n.worldSize,b=new M(y+x,v+x),w=new M(g-x,_-x),T=b.sub(w),S=n.width-(i.left+i.right+t.left+t.right),C=n.height-(i.top+i.bottom+t.top+t.bottom),F=S/T.x,A=C/T.y;if(A<0||F<0||!Number.isFinite(T.x)||!Number.isFinite(T.y)){Hv();return}let L=Math.min(_t(n.scale*Math.min(F,A)),e.maxZoom),I=M.convert(e.offset),E=new M((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(Ve(a)),D=I.add(E).mult(n.scale/pt(L)),P=f===0&&s.add(u).equals(l.add(h))?s.add(u).div(2):b.add(w).div(2).rotate(-m);return{center:wr(n.worldSize,P.sub(D),o),zoom:L,bearing:a}}var eo=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let i=e.mag(),r=Math.abs(Qn(t));return{easingOffset:e.mult(Math.min(r*.75/i,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,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around,e.aroundElevation)}cameraForBoxAndBearing(e,t,i,r,a,n){return Yv(e,t,i,r,a,n)}handleJumpToCenterZoom(e,t){let i=t.zoom===void 0?e.zoom:+t.zoom;e.zoom!==i&&e.setZoom(+t.zoom),t.center!==void 0&&e.setCenter(W.convert(t.center))}handleEaseTo(e,t){let i=e.zoom,r=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},o=t.zoom!==void 0,s=!e.isPaddingEqual(t.padding),l=!1,u=o?+t.zoom:e.zoom,h=e.centerPoint.add(t.offsetAsPoint),c=e.screenPointToLocation(h),{center:d,zoom:p}=e.applyConstrain(W.convert(t.center||c),u!=null?u:i);Ml(e,d);let f=e.worldCoordinateHelper,m=gi(e.worldSize,c,f),g=gi(e.worldSize,d,f).sub(m),_=pt(p-i);l=p!==i;let y=x=>{if(l&&e.setZoom(We.number(i,p,x)),Z_(a,n)||Xv({startEulerAngles:a,endEulerAngles:n,tr:e,k:x,useSlerp:a.roll!=n.roll}),s&&(e.interpolatePadding(r,t.padding,x),h=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let b=pt(e.zoom-i),w=(p>i?Math.min(2,_):Math.max(.5,_))**(1-x),T=m.add(g.mult(x*w)).mult(b),S=wr(e.worldSize,T,f);e.setLocationAtPoint(e.renderWorldCopies&&f.wraps?S.wrap():S,h)}},v=this._transformAtAnimationEnd(e,p,n,t.padding);return t.around?v.setLocationAtPoint(t.around,t.aroundPoint):v.setLocationAtPoint(d,v.centerPoint.add(t.offsetAsPoint)),{easeFunc:y,isZooming:l,elevationCenter:v.center}}handleFlyTo(e,t){let i=t.zoom!==void 0,r=e.zoom,a=e.applyConstrain(W.convert(t.center||t.locationAtOffset),i?+t.zoom:r),n=a.center,o=a.zoom;Ml(e,n);let s=e.worldCoordinateHelper,l=e.worldSize,u=gi(l,t.locationAtOffset,s),h=gi(l,n,s).sub(u),c=h.mag(),d=pt(o-r),p=t.minZoom===void 0?e.minZoom:+t.minZoom,f=Math.max(p,e.minZoom),m=Math.min(f,r,o),g=e.applyConstrain(n,m).zoom,_=pt(g-r),y=(x,b,w,T)=>{e.setZoom(x===1?o:r+_t(b));let S=x===1?n:wr(l,u.add(h.mult(w)),s);e.setLocationAtPoint(e.renderWorldCopies&&s.wraps?S.wrap():S,T)},v=this._transformAtAnimationEnd(e,o,{roll:t.roll,pitch:t.pitch,bearing:t.bearing},t.padding);return v.setLocationAtPoint(n,v.centerPoint.add(t.offsetAsPoint)),{easeFunc:y,scaleOfZoom:d,targetCenter:v.center,scaleOfMinZoom:_,pixelPathLength:c}}_transformAtAnimationEnd(e,t,i,r){let a=e.clone();return a.setZoom(t),a.setRoll(i.roll),a.setPitch(i.pitch),a.setBearing(i.bearing),a.setPadding(r),a}};let qg;const VI=()=>qg||(qg=new St({type:new U(z.projection.type,"type")})),mh=new Wd({fill:new ur(128,2),line:new ur(512,0),tile:new ur(128,32),stencil:new ur(128,1),circle:3});var Kv=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get worldCoordinateHelper(){return ln}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Wi.projectionGlobe}get vertexShaderPreludeCode(){return Wi.projectionMercator.vertexSource}get subdivisionGranularity(){return mh}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,r,a){let n=(a==="stencil"?mh.stencil:mh.tile).getGranularityForZoomLevel(t.z),o=t.y===0&&r,s=t.y===(1<<t.z)-1&&r;return this._getMesh(e,{granularity:n,generateBorders:i,extendToNorthPole:o,extendToSouthPole:s})}_getMesh(e,t){let i=this._getMeshKey(t);if(i in this._tileMeshCache)return this._tileMeshCache[i];let r=iv(e,t);return this._tileMeshCache[i]=r,r}recalculate(e){}hasTransition(){return!1}},Wg=class extends Ft{constructor(e,t){super(),this._transitionable=new Yl(VI(),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ie(0)),this._mercatorProjection=new Ws,this._verticalPerspectiveProjection=new Kv}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 Lr){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 worldCoordinateHelper(){return this.currentProjection.worldCoordinateHelper}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,i,r,a){return this.currentProjection.getMeshFromTileID(e,t,i,r,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 Jv(e){let t=Kr(e.worldSize,e.center.lat);return 2*Math.PI*t}function NI(e,t,i){let r=Y(lt(ht(t),ht(i)),-1,1),a=Math.acos(r),n=Jv(e);return a/(2*Math.PI)*n}function UI(e,t){return[ea(e*Math.PI*2+Math.PI,Math.PI*2),2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-Math.PI*.5]}function $I(e,t){let i=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*i,r[1]=Math.sin(t),r[2]=Math.cos(e)*i,r}function xr(e,t,i,r,a){let n=1/(1<<a),o=e/O*n+i*n,s=t/O*n+r*n,l=ea(o*Math.PI*2+Math.PI,Math.PI*2),u=2*Math.atan(Math.exp(Math.PI-s*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 ht(e){return $I(e.lng*Math.PI/180,e.lat*Math.PI/180)}function Kr(e,t){return e/(2*Math.PI)/sa(t)}function Qv(e){let t=Pt(sr(),[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 to(e){let t=Math.asin(e[1])/Math.PI*180,i=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(i>1e-6){let r=e[0]/i,a=e[2]/i,n=Math.acos(a);return new W(fi((r>0?n:-n)/Math.PI*180,-180,180),t)}return new W(0,t)}function GI(e,t){return fd(sr(),-e.lng,-e.lat,t)}function ZI(e){let t=e[0],i=e[1],r=e[2],a=e[3];return{lng:-Math.atan2(2*(a*t+i*r),1-2*(t*t+i*i))*180/Math.PI,lat:-Math.asin(Y(2*(a*i-r*t),-1,1))*180/Math.PI,bearing:Math.atan2(2*(a*r+t*i),1-2*(i*i+r*r))*180/Math.PI}}const gh=Math.PI*.98;function Hg(e,t){let i=e.cameraPosition,r=Pi(i);if(r<=1)return e.screenPointToLocation(t);let a=Me();jt(a,i);let n=e.getRayDirectionFromPixel(t),o=-lt(n,a),s=Me();Qs(s,n,a,o);let l=Pi(s);if(l<1e-9)return e.screenPointToLocation(t);let u=Math.atan2(l,o),h=Math.asin(1/r)*.9;if(u<h)return e.screenPointToLocation(t);let c=r*Math.sin(h),d=Math.asin(Y(c,-1,1))-h,p=r*Math.cos(h)/Math.sqrt(Math.max(1-c*c,1e-12))-1,f=gh-d,m=u-h,g=d+p*m*f/(f+p*m),_=Me();Ue(_,s,1/l);let y=Me();return Ue(y,a,Math.cos(Y(g,0,gh))),Qs(y,y,_,Math.sin(Y(g,0,gh))),jt(y,y),to(y)}function qI(e,t,i,r,a=!0){let n=Hg(e,i),o=t;if(r)o=Hg(e,i.sub(r));else if(!e.isPointOnMapSurface(i))return;let s=ht(n),l=ht(o),u=GI(e.center,e.bearing),h=Ht(Me(),l,s),c=Math.sqrt(lt(h,h)),d=Math.acos(Y(lt(l,s),-1,1))/2,p=Math.sin(d),f=c?wb(sr(),h[1]/c*p,-h[0]/c*p,h[2]/c*p,Math.cos(d)):yb(sr()),{lng:m,lat:g,bearing:_}=ZI(xb(sr(),u,f)),y=e.center.lat,v=e.zoom,x=a?WI(e,g,_):g,b=a?HI(e,i,r,m):m;e.setCenter(new W(fi(b,-180,180),x)),a||e.setBearing(_),e.setZoom(v+vt(y,e.center.lat))}function WI(e,t,i){return Math.abs(Zt(e.bearing,i))<=90?t:t>0?90:-90}function HI(e,t,i,r){let a=e.center.lng,n=e.center.lat,o=n>=0?90:-90,s=e.locationToScreenPoint(new W(0,o)),l=t.x-s.x,u=t.y-s.y,h=l*l+u*u,c=Y(1-(Fi-Math.abs(n))/12,0,1),d=c*c*(3-2*c),p=ea(r-a+180,360)-180,f=0;if(d>0&&i){let m=(l*i.y-u*i.x)/Math.max(h,400);f=(o>0?1:-1)*m*180/Math.PI}return a+(1-d)*p+d*f}function XI(e){let t=Me();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 YI(e,t,i){let r=Me();dr(r,i,e);let a=Me();return Qs(a,e,r,t/el(r)),a}function sa(e){return Math.cos(Math.min(Math.abs(e),Fi)*Math.PI/180)}function vt(e,t){let i=sa(e);return _t(sa(t)/i)}function KI(e,t){return 360/Jv({worldSize:e,center:{lat:t}})}function JI(e,t){let i=e.rotate(t.bearingInRadians),r=t.zoom+vt(t.center.lat,0),a=Cr(1/sa(t.center.lat),1/sa(Math.min(Math.abs(t.center.lat),60)),Zn(r,7,3,0,1)),n=KI(t.worldSize,t.center.lat);return new W(t.center.lng-i.x*n*a,Y(t.center.lat+i.y*n,-90,90))}function _h(e){let t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function Xg(e,t,i,r){let a=Y(e.lat+i*r,-90,90),n=Y(e.lat,-85.051129,Fi),o=Y(e.lat+i,-85.051129,Fi);if(Math.abs(o-n)>1){let s=(Math.sign(o)===Math.sign(n)?Math.abs(n):-Math.abs(n))*Math.PI/180,l=Math.abs(o)*Math.PI/180,u=_h(s+r*(l-s)),h=_h(s),c=_h(l),d=(u-h)/(c-h);return new W(e.lng+t*d,a)}return new W(e.lng+t*r,a)}function As(e,t,i=1){let r=lt(e,t),a=i*i,n=Me(),o=Me();Ue(o,t,r),dr(n,e,o);let s=a-lt(n,n);if(s<0)return null;let l=lt(e,e)-a,u=-r+(r<0?1:-1)*Math.sqrt(s),h=l/u,c=u,d=Math.max(h,c);return d<0?null:{tMin:Math.min(h,c),tMax:d}}function ex(e,t){let i=t*.01569612305760477,r=Y((e-i)/(9*i),0,1);return r*r*(3-2*r)}var QI=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,i,r){let a=`${e.z}_${e.x}_${e.y}_${r!=null&&r.terrain?"t":""}_${Math.round(i)}`,n=this._cache.get(a);if(n)return n;let o=this._cachePrevious.get(a);if(o)return this._cache.set(a,o),o;let s=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(a,s),this._hadAnyChanges=!0,s}},yh=class od{constructor(t,i,r,a){this.min=r,this.max=a,this.points=t,this.planes=i}static fromAabb(t,i){let r=[];for(let a=0;a<8;a++)r.push([((a|0)&1)==1?i[0]:t[0],(a>>1&1)==1?i[1]:t[1],(a>>2&1)==1?i[2]:t[2]]);return new od(r,[[-1,0,0,i[0]],[1,0,0,-t[0]],[0,-1,0,i[1]],[0,1,0,-t[1]],[0,0,-1,i[2]],[0,0,1,-t[2]]],t,i)}static fromCenterSizeAngles(t,i,r){let a=fd([],r[0],r[1],r[2]),n=Ou([],[i[0],0,0],a),o=Ou([],[0,i[1],0],a),s=Ou([],[0,0,i[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)+o[d]*((c>>1&1)==1?1:-1)+s[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];pi(d,d,Ue([],n,((c|0)&1)==1?1:-1)),pi(d,d,Ue([],o,(c>>1&1)==1?1:-1)),pi(d,d,Ue([],s,(c>>2&1)==1?1:-1)),h.push(d)}return new od(h,[[...n,-lt(n,h[0])],[...o,-lt(o,h[0])],[...s,-lt(s,h[0])],[-n[0],-n[1],-n[2],-lt(n,h[7])],[-o[0],-o[1],-o[2],-lt(o,h[7])],[-s[0],-s[1],-s[2],-lt(s,h[7])]],l,u)}intersectsFrustum(t){let i=!0,r=this.points.length,a=this.planes.length,n=t.planes.length,o=t.points.length;for(let s=0;s<n;s++){let l=t.planes[s],u=0;for(let h=0;h<r;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<r&&(i=!1)}if(i)return 2;for(let s=0;s<a;s++){let l=this.planes[s],u=0;for(let h=0;h<o;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 i=this.points.length,r=0;for(let a=0;a<i;a++){let n=this.points[a];t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]>=0&&r++}return r===i?2:r===0?0:1}};function Ys(e,t,i){let r=e-t;return r<0?-r:Math.max(0,r-i)}function vh(e,t,i,r,a){let n=e-i,o;return o=n<0?Math.min(-n,1+n-a):n>a?Math.min(Math.max(n-a,0),1-n):0,Math.max(o,Ys(t,r,a))}var e5=class{constructor(){this._boundingVolumeCache=new QI(this._computeTileBoundingVolume)}getCenter(e){return new W(e.center.lng,Y(e.center.lat,-85.051129,Fi))}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){let a=1<<i.z,n=1/a,o=i.x/a,s=i.y/a,l=.5,u=2;return u=Math.min(u,vh(e,t,o,s,n)),u=Math.min(u,vh(e,t,o+l,-s-n,n)),u=Math.min(u,vh(e,t,o+l,2-s-n,n)),u}getWrap(e,t,i){let r=1<<t.z,a=1/r,n=t.x/r,o=Ys(e.x,n,a),s=Ys(e.x,n-1,a),l=Ys(e.x,n+1,a),u=Math.min(o,s,l);return u===l?1:u===s?-1:0}allowVariableZoom(e,t){return vp(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,r)}_computeTileBoundingVolume(e,t,i,r){var o,s;let a=Math.min(0,i),n=Math.max(0,i);if(r!=null&&r.terrain){let l=new Ct(e.z,t,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(l);a=(o=u.minElevation)!=null?o:a,n=Math.max((s=u.maxElevation)!=null?s:n,n)}if(a/=Ot,n/=Ot,a+=1,n+=1,e.z<=0)return yh.fromAabb([-n,-n,-n],[n,n,n]);if(e.z===1)return yh.fromAabb([e.x===0?-n:0,e.y===0?0:-n,-n],[e.x===0?0:n,e.y===0?n:0,n]);{let l=[xr(0,0,e.x,e.y,e.z),xr(O,0,e.x,e.y,e.z),xr(O,O,e.x,e.y,e.z),xr(0,O,e.x,e.y,e.z)],u=[];for(let F of l)u.push(Ue([],F,n));if(n!==a)for(let F of l)u.push(Ue([],F,a));e.y===0&&u.push([0,1,0]),e.y===(1<<e.z)-1&&u.push([0,-1,0]);let h=[1,1,1],c=[-1,-1,-1];for(let F of u)for(let A=0;A<3;A++)h[A]=Math.min(h[A],F[A]),c[A]=Math.max(c[A],F[A]);let d=xr(O/2,O/2,e.x,e.y,e.z),p=Ht([],[0,1,0],d);jt(p,p);let f=Ht([],d,p);jt(f,f);let m=Ht([],l[2],l[1]);jt(m,m);let g=Ht([],l[0],l[3]);jt(g,g),u.push(Ue([],d,n)),e.y>=(1<<e.z)/2&&u.push(Ue([],xr(O/2,0,e.x,e.y,e.z),n)),e.y<(1<<e.z)/2&&u.push(Ue([],xr(O/2,O,e.x,e.y,e.z),n));let _=Yg(d,u),y=Yg(f,u),v=[-d[0],-d[1],-d[2],_.max],x=[d[0],d[1],d[2],-_.min],b=[-f[0],-f[1],-f[2],y.max],w=[f[0],f[1],f[2],-y.min],T=[...m,0],S=[...g,0],C=[];return e.y===0?C.push(li(S,T,v),li(S,T,x)):C.push(li(b,T,v),li(b,T,x),li(b,S,v),li(b,S,x)),e.y===(1<<e.z)-1?C.push(li(S,T,v),li(S,T,x)):C.push(li(w,T,v),li(w,T,x),li(w,S,v),li(w,S,x)),new yh(C,[v,x,b,w,T,S],h,c)}}};function Yg(e,t){let i=1/0,r=-1/0;for(let a of t){let n=lt(e,a);i=Math.min(i,n),r=Math.max(r,n)}return{min:i,max:r}}const Kg=1e-12;var tx=class ix{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,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}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,i){this._cachedClippingPlane=sr(),this._projectionMatrix=as(),this._globeViewProjMatrix32f=N_(),this._globeViewProjMatrixF64=as(),this._globeViewProjMatrixF64Inverted=as(),this._globeProjMatrixInverted=as(),this._cameraPosition=Me(),this.defaultConstrain=(r,a)=>{let n=Y(+a,this.minZoom+vt(0,r.lat),this.maxZoom),o=this._getMaxLatitude(n);return{center:new W(r.lng,Y(r.lat,-o,o)),zoom:n}},this.applyConstrain=(r,a)=>this._helper.applyConstrain(r,a),this._helper=i!=null?i:new Dp({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(r,a)=>this.defaultConstrain(r,a)},t),this._coveringTilesDetailsProvider=new e5}clone(){let t=new ix;return t.apply(this,!1),t}apply(t,i){this._helper.apply(t,i)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=Me();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:i,applyGlobeMatrix:r}=t,a=this._helper.getMercatorTileCoordinates(i);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:a,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!r,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:(i==null?void 0:i.canonical.z)===0}}_computeClippingPlane(t){let i=this.pitchInRadians,r=this.cameraToCenterDistance/t,a=Math.sin(i)*r,n=Math.cos(i)*r+1,o=1/Math.sqrt(a*a+n*n)*1,s=-a,l=n,u=Math.sqrt(s*s+l*l);s/=u,l/=u;let h=[0,s,l];ju(h,h,[0,0,0],-this.bearingInRadians),wn(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),Ta(h,h,[0,0,0],this.center.lng*Math.PI/180);let c=1/Pi(h);return Ue(h,h,c),[...h,-o*c]}isLocationOccluded(t,i,r){let a=i==null?void 0:i.getCoverageIndex();r!=null||(r=a?i.getElevationForLngLat(t,this):0);let n=Qg(t,r);if(!this.isSurfacePointVisible(n))return!0;if(!a)return!1;let o=this._projectSurfacePointToScreen(n),s=this.cameraPosition,l=this.getRayDirectionFromPixel(o),u=e_(s,l,n);if(u<=0)return!0;let h=this.screenTerrainPointToMercatorCoordinate(o,i);return h!=null&&e_(s,l,Qg(h.toLngLat(),h.z))<u*.99}transformLightDirection(t){let i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,a=Math.cos(r),n=[Math.sin(i)*a,Math.sin(r),Math.cos(i)*a],o=[n[2],0,-n[0]],s=[0,0,0];Ht(s,o,n),jt(o,o),jt(s,s);let l=[o[0]*t[0]+s[0]*t[1]+n[0]*t[2],o[1]*t[0]+s[1]*t[1]+n[1]*t[2],o[2]*t[0]+s[2]*t[1]+n[2]*t[2]],u=[0,0,0];return jt(u,l),u}getPixelScale(){return 1/sa(this._helper._center.lat)}getCircleRadiusCorrection(){return sa(this._helper._center.lat)}getPitchedTextCorrection(t,i,r){let a=h1(t,i,r.canonical),n=UI(a.x,a.y);return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(t,i,r,a){let n=r.canonical,o=xr(t,i,n.x,n.y,n.z),s=1+(a!=null?a:0)/Ot,l=o[0]*s,u=o[1]*s,h=o[2]*s,c=[l,u,h,1];Pt(c,c,this._globeViewProjMatrixF64);let d;if(s<=1){let p=this._cachedClippingPlane;d=p[0]*o[0]+p[1]*o[1]+p[2]*o[2]+p[3]<0}else d=this._isLineOfSightBlocked(l,u,h);return{point:new M(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:d}}_isLineOfSightBlocked(t,i,r){let a=this._cameraPosition,n=t-a[0],o=i-a[1],s=r-a[2],l=n*n+o*o+s*s;if(l===0)return!1;let u=Y(-(a[0]*n+a[1]*o+a[2]*s)/l,0,1),h=a[0]+u*n,c=a[1]+u*o,d=a[2]+u*s;return h*h+c*c+d*d<1}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let i=Kr(this.worldSize,this.center.lat),r=Gr();t&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+i*2),kh(r,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let a=this.centerOffset;r[8]=-a.x*2/this._helper._width,r[9]=a.y*2/this._helper._height,this._projectionMatrix=zh(r),this._globeProjMatrixInverted=Gr(),Js(this._globeProjMatrixInverted,r),st(r,r,[0,0,-this.cameraToCenterDistance]),Dr(r,r,this.rollInRadians),Wa(r,r,-this.pitchInRadians),Dr(r,r,this.bearingInRadians),st(r,r,[0,0,-i]);let n=Me();n[0]=i,n[1]=i,n[2]=i,Wa(r,r,this.center.lat*Math.PI/180),j_(r,r,-this.center.lng*Math.PI/180),Rt(r,r,n),this._globeViewProjMatrixF64=r,this._globeViewProjMatrix32f=new Float32Array(r),this._globeViewProjMatrixF64Inverted=Gr(),Js(this._globeViewProjMatrixF64Inverted,r);let o=Me();this._cameraPosition=Me(),this._cameraPosition[2]=this.cameraToCenterDistance/i,ju(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),wn(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),ju(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),pi(this._cameraPosition,this._cameraPosition,[0,0,1]),wn(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),Ta(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(i);let s=zh(this._globeViewProjMatrixF64Inverted);Rt(s,s,[1,1,-1]),this._cachedFrustum=yp.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){_e("calculateFogMatrix is not supported on globe projection.");let i=Gr();return Ii(i),i}getVisibleUnwrappedCoordinates(t){return[new El(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t?_e("terrain is not fully supported on vertical perspective projection."):this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(Pi(this._cameraPosition)-1)*Ot}getCameraLngLat(){let t=Me();return jt(t,this._cameraPosition),to(t)}get worldCoordinateHelper(){return this._helper.worldCoordinateHelper}populateCache(t){}getBounds(){let t=this.width*.5,i=this.height*.5,r=[new M(0,0),new M(t,0),new M(this.width,0),new M(this.width,i),new M(this.width,this.height),new M(t,this.height),new M(0,this.height),new M(0,i)],a=[];for(let c of r)a.push(this.unprojectScreenPoint(c));let n=0,o=0,s=0,l=0,u=this.center;for(let c of a){let d=Zt(u.lng,c.lng),p=Zt(u.lat,c.lat);d<o&&(o=d),d>n&&(n=d),p<l&&(l=p),p>s&&(s=p)}let h=[u.lng+o,u.lat+l,u.lng+n,u.lat+s];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 mr(h)}_getMaxLatitude(t){let i=Ve(4.948870999999997),r=Kr(this.tileSize*pt(t),Fi)*i,a=Math.min(this.width,this.height)/2,n=Math.min(r,a)*Zn(r,a,a*4,1,0);return Fi+Ei(i*n/r)}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){let n=W.convert(r),o=ht(W.convert(t));Ue(o,o,1+i/Ot);let s=ht(n),l=Ue(Me(),s,1+a/Ot),u=dd(Me(),o,s),h=Pi(u);if(h<Kg||pd(o,l)<Kg)throw Error("Can't calculate camera options with same From and To");let c=Me();Ta(u,u,c,-Ve(n.lng)),wn(u,u,c,Ve(n.lat));let d=Ei(Math.acos(Y(u[2]/h,-1,1))),p=Math.hypot(u[0],u[1])<h*1e-9?this.bearing:Ei(Math.atan2(-u[0],-u[1]));return{center:n,elevation:a,zoom:_t(this.cameraToCenterDistance/h/Kr(this.tileSize,n.lat)),pitch:d,bearing:p}}setLocationAtPoint(t,i,r){let a=ht(this.unprojectScreenPoint(i)),n=ht(t),o=Me();cb(o);let s=Me();Ta(s,a,o,-this.center.lng*Math.PI/180),wn(s,s,o,this.center.lat*Math.PI/180);let l=n[0]*n[0]+n[2]*n[2],u=s[0]*s[0];if(l<u)return;let h=Math.sqrt(l-u),c=-h,d=ns(n[0],n[2],s[0],h),p=ns(n[0],n[2],s[0],c),f=Me();Ta(f,n,o,-d);let m=ns(f[1],f[2],s[1],s[2]),g=Me();Ta(g,n,o,-p);let _=ns(g[1],g[2],s[1],s[2]),y=Math.PI*.5,v=m>=-y&&m<=y,x=_>=-y&&_<=y,b,w;if(v&&x){let F=this.center.lng*Math.PI/180,A=this.center.lat*Math.PI/180,L=os(d,F),I=os(m,A),E=os(p,F),D=os(_,A);L+I<E+D?(b=d,w=m):(b=p,w=_)}else if(v)b=d,w=m;else if(x)b=p,w=_;else return;let T=b/Math.PI*180,S=w/Math.PI*180,C=this.center.lat;this.setCenter(new W(T,Y(S,-90,90))),this.setZoom(this.zoom+vt(C,this.center.lat))}locationToScreenPoint(t,i){let r=ht(t);return i&&Ue(r,r,1+i.getElevationForLngLat(t,this)/Ot),this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(t){let i=sr();return Pt(i,[...t,1],this._globeViewProjMatrixF64),i[0]/=i[3],i[1]/=i[3],new M((i[0]*.5+.5)*this.width,(-i[1]*.5+.5)*this.height)}screenPointToMercatorCoordinate(t,i){if(i){let r=this.screenTerrainPointToMercatorCoordinate(t,i);if(r)return r}return It.fromLngLat(this.unprojectScreenPoint(t))}screenTerrainPointToMercatorCoordinate(t,i){let r=i.getCoverageIndex();if(!r)return null;let a=this.cameraPosition,n=this.getRayDirectionFromPixel(t),o=As(a,n,1+r.maxElevation/Ot);if(!o)return null;let s=As(a,n,1+r.minElevation/Ot),l=Math.max(o.tMin,0),u=s?s.tMin:o.tMax;if(u<=l)return null;let h={index:r,exaggeration:i.exaggeration,origin:a,direction:n},c=0;for(let d=0;d<=256;d++){let p=l+(u-l)*d/256;if(Jg(h,p)){let{hi:f}=Zv(h,Jg,c,p,1e-12),{sample:m,mercator:g}=rx(h,f);return new It(g.x,g.y,m.elevation)}c=p}return null}screenPointToLocation(t,i){var r;return(r=this.screenPointToMercatorCoordinate(t,i))==null?void 0:r.toLngLat()}screenPointToLocationAtElevation(t,i){return this.screenPointToLocation(t)}isPointOnMapSurface(t,i){let r=this._cameraPosition;return!!As(r,this.getRayDirectionFromPixel(t))}getRayDirectionFromPixel(t){let i=sr();i[0]=t.x/this.width*2-1,i[1]=(t.y/this.height*2-1)*-1,i[2]=1,i[3]=1,Pt(i,i,this._globeViewProjMatrixF64Inverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];let r=Me();r[0]=i[0]-this._cameraPosition[0],r[1]=i[1]-this._cameraPosition[1],r[2]=i[2]-this._cameraPosition[2];let a=Me();return jt(a,r),a}isSurfacePointVisible(t){let i=this._cachedClippingPlane;return i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let i=sr();return Pt(i,[...t,1],this._globeViewProjMatrixF64),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}unprojectScreenPoint(t){let i=this._cameraPosition,r=this.getRayDirectionFromPixel(t),a=As(i,r);if(a){let h=Me();pi(h,i,[r[0]*a.tMin,r[1]*a.tMin,r[2]*a.tMin]);let c=Me();return jt(c,h),to(c)}let n=this._cachedClippingPlane,o=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],s=-Bh(n,i)/o,l=Me();if(s>0)pi(l,i,[r[0]*s,r[1]*s,r[2]*s]);else{let h=Me();pi(h,i,[r[0]*2,r[1]*2,r[2]*2]);let c=Bh(this._cachedClippingPlane,h);dr(l,h,[this._cachedClippingPlane[0]*c,this._cachedClippingPlane[1]*c,this._cachedClippingPlane[2]*c])}let u=XI(n);return to(YI(u.center,u.radius,l))}getProjectionDataForCustomLayer(t=!0){let i=this.getProjectionData({overscaledTileID:new Ct(0,0,0,0,0),applyGlobeMatrix:t});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(t){}};function t5(e){return new tx(e)}function rx(e,t){let i=Me();Qs(i,e.origin,e.direction,t);let r=Pi(i),a=Me();Ue(a,i,1/r);let n=to(a),o=It.fromLngLat(n),s=new It(o.x,Y(o.y,0,.999999999)),l=nn(e.index,e.exaggeration,s.x,s.y,!1),u=Math.abs(n.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:u},radius:r,mercator:s}}function Jg(e,t){let{sample:i,radius:r}=rx(e,t);return Sp(i,(r-1)*Ot)}function Qg(e,t){let i=ht(e);return Ue(i,i,1+t/Ot)}function e_(e,t,i){return lt(dd(Me(),i,e),t)}var i5=class ax{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,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}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=(i,r)=>this.currentTransform.defaultConstrain(i,r),this.applyConstrain=(i,r)=>this._helper.applyConstrain(i,r),this._helper=new Dp({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(i,r)=>this.defaultConstrain(i,r)},t),this._globeness=1,this._mercatorTransform=new qv(void 0,this._helper),this._verticalPerspectiveTransform=new tx(void 0,this._helper)}clone(){let t=new ax;return t._globeness=this._globeness,t.apply(this,!1),t}apply(t,i){this._helper.apply(t,i)}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 i=this._mercatorTransform.getProjectionData(t),r=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?r.mainMatrix:i.mainMatrix,clippingPlane:r.clippingPlane,tileMercatorCoords:r.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:i.fallbackMatrix,clipAntimeridian:r.clipAntimeridian}}isLocationOccluded(t,i,r){return this.currentTransform.isLocationOccluded(t,i,r)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return Cr(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return this.currentTransform.getCircleRadiusCorrection()}getPitchedTextCorrection(t,i,r){return Cr(this._mercatorTransform.getPitchedTextCorrection(t,i,r),this._verticalPerspectiveTransform.getPitchedTextCorrection(t,i,r),this._globeness)}projectTileCoordinates(t,i,r,a){return this.currentTransform.projectTileCoordinates(t,i,r,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()}get worldCoordinateHelper(){return this._helper.worldCoordinateHelper}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){return this.currentTransform.calculateCameraOptionsFromTo(t,i,r,a)}setLocationAtPoint(t,i,r){this.currentTransform.setLocationAtPoint(t,i,r)}locationToScreenPoint(t,i){return this.currentTransform.locationToScreenPoint(t,i)}screenPointToMercatorCoordinate(t,i){return this.currentTransform.screenPointToMercatorCoordinate(t,i)}screenTerrainPointToMercatorCoordinate(t,i){return this.currentTransform.screenTerrainPointToMercatorCoordinate(t,i)}screenPointToLocation(t,i){return this.currentTransform.screenPointToLocation(t,i)}screenPointToLocationAtElevation(t,i){return this.currentTransform.screenPointToLocationAtElevation(t,i)}isPointOnMapSurface(t,i){return this.currentTransform.isPointOnMapSurface(t,i)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let i=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return i;let r=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return r.fallbackMatrix=i.mainMatrix,r.projectionTransition=this._globeness,r}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}};function t_(e){return new i5(e)}var nx=class ar{get useGlobeControls(){return!0}handlePanInertia(t,i){let r=JI(t,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new M(0,0)}}handleMapControlsRollPitchBearingZoom(t,i){let r=t.around,a=i.screenPointToLocation(r);t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta);let n=i.zoom;t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta);let o=i.zoom-n;if(o===0)return;let s=Zt(i.center.lng,a.lng),l=s/(Math.abs(s/180)+1),u=Zt(i.center.lat,a.lat),h=i.getRayDirectionFromPixel(r),c=i.cameraPosition,d=lt(c,h)*-1,p=Me();pi(p,c,[h[0]*d,h[1]*d,h[2]*d]);let f=Pi(p),m=f-1,g=Math.exp(-Math.max(m-.3,0)*.5),_=Zn(f,.95,.999,0,1),y=Zn(Kr(i.worldSize,i.center.lat)/Math.min(i.width,i.height),.9,.5,1,.25),v=Math.min(g,Cr(1,y,_)),x=(1-pt(-o))*v,b=i.center.lat,w=i.zoom,T=new W(i.center.lng+l*x,Y(i.center.lat+u*x,-90,90));i.setLocationAtPoint(a,r);let S=i.center,C=Zn(Math.abs(s),45,85,0,1),F=Math.max(C,_)**.25,A=Zt(S.lng,T.lng),L=Zt(S.lat,T.lat);i.setCenter(new W(S.lng+A*F,Y(S.lat+L*F,-90,90)).wrap()),i.setZoom(w+vt(b,i.center.lat))}handleMapControlsPan(t,i,r){t.panDelta&&qI(i,r,i.isPointOnMapSurface(t.around)?t.around:i.centerPoint,t.panDelta)}cameraForBoxAndBearing(t,i,r,a,n,o){let s=Yv(t,i,r,a,n,o);if(!s)return;let l=i.left/o.width*2-1,u=(o.width-i.right)/o.width*2-1,h=i.top/o.height*-2+1,c=(o.height-i.bottom)/o.height*-2+1,d=Zt(a.getWest(),a.getEast())<0,p=d?a.getEast():a.getWest(),f=d?a.getWest():a.getEast(),m=Math.max(a.getNorth(),a.getSouth()),g=Math.min(a.getNorth(),a.getSouth()),_=p+Zt(p,f)*.5,y=m+Zt(m,g)*.5,v=o.clone();v.setCenter(s.center),v.setPadding(r),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);let x=v.modelViewProjectionMatrix,b=[ht(a.getNorthWest()),ht(a.getNorthEast()),ht(a.getSouthWest()),ht(a.getSouthEast()),ht(new W(f,y)),ht(new W(p,y)),ht(new W(_,m)),ht(new W(_,g))],w=ht(s.center),T=1/0;for(let S of b)l<0&&(T=ar.getLesserNonNegativeNonNull(T,ar.solveVectorScale(S,w,x,"x",l))),u>0&&(T=ar.getLesserNonNegativeNonNull(T,ar.solveVectorScale(S,w,x,"x",u))),h>0&&(T=ar.getLesserNonNegativeNonNull(T,ar.solveVectorScale(S,w,x,"y",h))),c<0&&(T=ar.getLesserNonNegativeNonNull(T,ar.solveVectorScale(S,w,x,"y",c)));if(!Number.isFinite(T)||T===0)Hv();else return s.zoom=Math.min(v.zoom+_t(T),t.maxZoom),s}handleJumpToCenterZoom(t,i){let r=t.center.lat,a=i.center?W.convert(i.center):t.center;t.setCenter(t.applyConstrain(a,t.zoom).center.wrap());let n=i.zoom===void 0?t.zoom+vt(r,t.center.lat):+i.zoom;t.zoom!==n&&(t.setZoom(n),t.setCenter(t.applyConstrain(a,t.zoom).center.wrap()))}handleEaseTo(t,i){let r=t.zoom,a=t.center,n=t.padding,o={roll:t.roll,pitch:t.pitch,bearing:t.bearing},s={roll:i.roll===void 0?t.roll:i.roll,pitch:i.pitch===void 0?t.pitch:i.pitch,bearing:i.bearing===void 0?t.bearing:i.bearing},l=i.zoom!==void 0,u=!t.isPaddingEqual(i.padding),h=!1,c=i.center?W.convert(i.center):a,d=t.applyConstrain(c,l?+i.zoom:r).center;Ml(t,d);let p=t.clone();p.setCenter(d),p.setZoom(l?+i.zoom:r+vt(a.lat,c.lat)),p.setBearing(i.bearing);let f=new M(Y(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),Y(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(d,f);let m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:r+vt(a.lat,m.lat),_=r+vt(a.lat,0),y=g+vt(m.lat,0),v=Zt(a.lng,m.lng),x=Zt(a.lat,m.lat),b=pt(y-_);return h=g!==r,{easeFunc:w=>{if(Z_(o,s)||Xv({startEulerAngles:o,endEulerAngles:s,tr:t,k:w,useSlerp:o.roll!=s.roll}),u&&t.interpolatePadding(n,i.padding,w),i.around)_e("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(i.around,i.aroundPoint);else{let T=w*(y>_?Math.min(2,b):Math.max(.5,b))**(1-w),S=Xg(a,v,x,T);t.setCenter(S.wrap())}if(h){let T=We.number(_,y,w)+vt(0,t.center.lat);t.setZoom(T)}w===1&&!i.around&&t.setCenter(m.wrap())},isZooming:h,elevationCenter:m}}handleFlyTo(t,i){let r=i.zoom!==void 0,a=t.center,n=t.zoom,o=t.padding,s=!t.isPaddingEqual(i.padding),l=t.applyConstrain(W.convert(i.center||i.locationAtOffset),r?+i.zoom:n).center,u=r?+i.zoom:t.zoom+vt(t.center.lat,l.lat),h=t.clone();h.setCenter(l),h.setZoom(u),h.setBearing(i.bearing);let c=new M(Y(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),Y(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(l,c);let d=h.center;Ml(t,d);let p=NI(t,a,d),f=n+vt(a.lat,0),m=u+vt(d.lat,0),g=pt(m-f),_=typeof i.minZoom=="number"?+i.minZoom:t.minZoom,y=Math.max(_,t.minZoom)+vt(d.lat,0),v=Math.min(y,f,m)+vt(0,d.lat),x=pt(t.applyConstrain(d,v).zoom+vt(d.lat,0)-f),b=Zt(a.lng,d.lng),w=Zt(a.lat,d.lat);return{easeFunc:(T,S,C,F)=>{let A=Xg(a,b,w,C);s&&t.interpolatePadding(o,i.padding,T);let L=T===1?d:A;t.setCenter(L.wrap());let I=f+_t(S);t.setZoom(T===1?u:I+vt(0,L.lat)),T===1&&t.setCenter(d.wrap())},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:x,pixelPathLength:p}}static solveVectorScale(t,i,r,a,n){let o=n,s=a==="x"?[r[0],r[4],r[8],r[12]]:[r[1],r[5],r[9],r[13]],l=[r[3],r[7],r[11],r[15]],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],h=t[0]*l[0]+t[1]*l[1]+t[2]*l[2],c=i[0]*s[0]+i[1]*s[1]+i[2]*s[2],d=i[0]*l[0]+i[1]*l[1]+i[2]*l[2],p=(c+s[3]-o*d-o*l[3])/(c-u-o*d+o*h);return c+o*h===u+o*d||l[3]*(u-c)+s[3]*(d-h)+u*d===c*h?null:p}static getLesserNonNegativeNonNull(t,i){return i!==null&&i>=0&&i<t?i:t}},i_=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new eo,this._verticalPerspectiveCameraHelper=new nx}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,i){this.currentHelper.handleMapControlsPan(e,t,i)}cameraForBoxAndBearing(e,t,i,r,a,n){return this.currentHelper.cameraForBoxAndBearing(e,t,i,r,a,n)}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 r_(e,t,i){let r={constrainOverride:t};if(Array.isArray(e)){let n=r5(e);n&&_e(`Projection expressions cannot use the registered projection "${n}", which only works as a plain name. Falling back to the globe projection.`);let o=new Wg({type:e},i);return{projection:o,transform:t_(r),cameraHelper:new i_(o)}}let a=su(e);if(a){let n=new kP(a),o=Hs(r);return o.setWorldCoordinateHelper(n),{projection:new Ws(n),transform:o,cameraHelper:new eo}}switch(e){case"mercator":return{projection:new Ws,transform:Hs(r),cameraHelper:new eo};case"globe":{let n=new Wg({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:n,transform:t_(r),cameraHelper:new i_(n)}}case"vertical-perspective":return{projection:new Kv,transform:t5(r),cameraHelper:new nx};default:return _e(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Ws,transform:Hs(r),cameraHelper:new eo}}}function r5(e){return e.flat(1/0).find(t=>typeof t=="string"&&su(t)!==void 0)}const a5=$w();var a_=class extends Ft{constructor(e,t={}){var r,a,n;super(),this._rtlPluginLoaded=()=>{for(let o in this.tileManagers){let s=this.tileManagers[o].getSource().type;(s==="vector"||s==="geojson")&&this.tileManagers[o].reload()}},this.map=e,this.dispatcher=new X1(H1(),e._getMapId()).setEventedParent(this),this.dispatcher.registerMessageHandler("GG",(o,s)=>this.getGlyphs(o,s)),this.dispatcher.registerMessageHandler("GI",(o,s)=>this.getImages(o,s)),this.dispatcher.registerMessageHandler("GDA",(o,s)=>this.getDashes(o,s)),this.imageManager=new OC,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new jC(this.imageManager);let i=((r=e._container)==null?void 0:r.lang)||typeof document<"u"&&((a=document.documentElement)==null?void 0:a.lang)||void 0;this.glyphManager=new XC(e._requestManager,t.localIdeographFontFamily,i),this.lineAtlas=new tP(256,512),this.crossTileSymbolIndex=new AI,this._setInitialValues(),this._initialGlobalState=(n=t.globalState)!=null?n:{},this._resetUpdates(),this.dispatcher.broadcast("SR",yd()),ed().on(Qc,this._rtlPluginLoaded),this.on("data",o=>{if(o.dataType!=="source"||o.sourceDataType!=="metadata")return;let s=this.tileManagers[o.sourceId];if(!s)return;let l=s.getSource();if(l!=null&&l.vectorLayerIds)for(let u in this._layers){let h=this._layers[u];h.source===l.id&&this._validateLayer(h)}})}_setInitialValues(){var e;this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new Qh,this._imagesListDirty=!1,this._initialGlobalState={},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 r,a,n;this._checkLoaded();let i=t===null?(n=(a=(r=this.stylesheet.state)==null?void 0:r[e])==null?void 0:a.default)!=null?n:null:t;return this._setGlobalStateValues({[e]:i}),this}getGlobalState(){return this._globalState}setGlobalState(e){var r,a,n;this._checkLoaded();let t={},i=new Set([...Object.keys(e!=null?e:{}),...Object.keys(this._initialGlobalState)]);for(let o of i)t[o]=(n=(a=this._initialGlobalState[o])!=null?a:(r=e[o])==null?void 0:r.default)!=null?n:null;this._setGlobalStateValues(t)}_setGlobalStateValues(e){let t=[];for(let r in e)$i(e[r],this._globalState[r])||t.push(r);if(t.length===0)return;let i={...this._globalState};for(let r of t)this._globalState[r]=e[r];this._applyGlobalStateChanges(t,i)}_applyGlobalStateChanges(e,t){var n,o;let i=new Set,r={};for(let s of e)r[s]=this._globalState[s];for(let s in this._layers){let l=this._layers[s];l.retainPriorGlobalState(e,t);let u=l.getLayoutAffectingGlobalStateRefs(),h=l.getPaintAffectingGlobalStateRefs(),c=l.getVisibilityAffectingGlobalStateRefs();for(let d of e){if(u.has(d)&&i.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:ke(),transition:this.getTransition()};(n=this.light)==null||n.applyGlobalStateChange(e,t,a),(o=this.sky)==null||o.applyGlobalStateChange(e,t,a),this.dispatcher.broadcast("UGS",r);for(let s in this.tileManagers)i.has(s)&&(this._reloadSource(s),this._changed=!0)}async loadURL(e,t={},i){this.fire(new Di("dataloading")),t.validate=typeof t.validate!="boolean"||t.validate,this._loadStyleRequest=new AbortController;let r=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(e,"Style");_d(r.signal);let n=await Rl(a,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(n.data,t,i)}catch(a){this._loadStyleRequest===r&&(this._loadStyleRequest=null),a&&!r.signal.aborted&&this.fire(new K(Dt(a)))}}loadJSON(e,t={},i){this.fire(new Di("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,i)}).catch(()=>{})}loadEmpty(){this.fire(new Di("dataloading")),this._load(a5,{validate:!1})}_load(e,t,i){var n,o,s,l,u;let r=t.transformStyle?t.transformStyle(i,e):e;if(t.validate&&Zf(this,r))return;r={...r},this._loaded=!0,this.stylesheet=r,this.setGlobalState((n=this.stylesheet.state)!=null?n:null);let a=r_(((o=this.stylesheet.projection)==null?void 0:o.type)||"mercator",(s=this.map._camera)==null?void 0:s.transform.constrainOverride,this._globalState);this.projection=a.projection;for(let h in r.sources)this.addSource(h,r.sources[h],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this.glyphManager.setFontFaces(r["font-faces"]),this._createLayers(),this.light=new KC((l=this.stylesheet.light)!=null?l:{},this._globalState),this._applyProjection(a),this.sky=new QC(this.stylesheet.sky,this._globalState),this.sky.setEventedParent(this),this.map.setTerrain((u=this.stylesheet.terrain)!=null?u:null,{validate:!1}),this.fire(new Di("data")),this.fire(new xf)}_createLayers(){var t,i;let e=wf(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map(r=>r.id),this._layers={},this._serializedLayers=null;for(let r of e){let a=lh(r,this._globalState);if(a.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=a,tc(a)&&this.tileManagers[a.source]){let n=(i=(t=r.paint)==null?void 0:t["raster-fade-duration"])!=null?i:a.paint.get("raster-fade-duration");this.tileManagers[a.source].setRasterFadeDuration(n)}}}async _loadSprite(e,t=!1,i=void 0){this.imageManager.setLoaded(!1);let r=new AbortController;this._spriteRequest=r;let a;try{let n=await LC(e,this.map._requestManager,this.map.getPixelRatio(),r);if(!n)return;for(let o in n){let{loaded:s,removed:l}=this.imageManager.setSpriteImages(o,n[o]);this._markImagesChanged(l),t&&this._markImagesChanged(s)}}catch(n){a=n,r.signal.aborted||this.fire(new K(a))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new Di("data")),i==null||i(a)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new Di("data"))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let i=e.sourceLayer;if(!i)return;let r=t.getSource();(r.type==="geojson"||r.vectorLayerIds&&!r.vectorLayerIds.includes(i))&&this.fire(new K(Error(`Source layer "${i}" does not exist on source "${r.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 i=this._serializedAllLayers();if(!e||e.length===0)return Object.values(t?Wt(i):i);let r=[];for(let a of e)if(i[a]){let n=t?Wt(i[a]):i[a];r.push(n)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let i of t){let r=this._layers[i];r.type!=="custom"&&(e[i]=r.serialize())}return e}hasTransitions(){var e,t,i;if((e=this.light)!=null&&e.hasTransition()||(t=this.sky)!=null&&t.hasTransition()||(i=this.projection)!=null&&i.hasTransition())return!0;for(let r in this.tileManagers)if(this.tileManagers[r].hasTransition())return!0;for(let r in this._layers)if(this._layers[r].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 o in this._updatedSources){let s=this._updatedSources[o];if(s==="reload")this._reloadSource(o);else if(s==="clear")this._clearSource(o);else throw Error(`Invalid action ${s}`)}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let o in this._updatedPaintProps)this._layers[o].updateTransitions(e);this._resetUpdates()}let i={};for(let a in this.tileManagers){let n=this.tileManagers[a];i[a]=n.used,n.used=!1}let r=this.imageManager.listImages();for(let a of this._order){let n=this._layers[a];n.recalculate(e,r),!n.isHidden(e.zoom)&&n.source&&(this.tileManagers[n.source].used=!0)}for(let a in i){let n=this.tileManagers[a];!!i[a]!=!!n.used&&n.fire(new $e("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 Di("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})}resize(){for(let e of this._order)this._layers[e].resize()}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){var n,o;this._checkLoaded();let i=this.serialize();if(e=t.transformStyle?t.transformStyle(i,e):e,((n=t.validate)!=null?n:!0)&&Zf(this,e))return!1;e=Wt(e),e.layers=wf(e.layers);let r=h2(i,e),a=this._getOperationsToPerform(r);if(a.unimplemented.length>0)throw Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(a.operations.length===0)return!1;this._initialGlobalState=(o=t.globalState)!=null?o:{};for(let s of a.operations)s();return this.stylesheet=e,this._serializedLayers=null,this.fire(new xf({style:this})),!0}_getOperationsToPerform(e){let t=[],i=[];for(let r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":{let[a,n]=r.args;t.push(()=>this.addLayer(a,n));break}case"removeLayer":{let[a]=r.args;t.push(()=>this.removeLayer(a));break}case"setPaintProperty":{let[a,n,o]=r.args;t.push(()=>this.setPaintProperty(a,n,o));break}case"setLayoutProperty":{let[a,n,o]=r.args;t.push(()=>this.setLayoutProperty(a,n,o));break}case"setFilter":{let[a,n]=r.args;t.push(()=>this.setFilter(a,n));break}case"addSource":{let[a,n]=r.args;t.push(()=>this.addSource(a,n));break}case"removeSource":{let[a]=r.args;t.push(()=>this.removeSource(a));break}case"setLayerZoomRange":{let[a,n,o]=r.args;t.push(()=>this.setLayerZoomRange(a,n,o));break}case"setLight":{let[a]=r.args;t.push(()=>this.setLight(a));break}case"setGeoJSONSourceData":{let[a,n]=r.args;t.push(()=>this.setGeoJSONSourceData(a,n));break}case"setGlyphs":{let[a]=r.args;t.push(()=>this.setGlyphs(a));break}case"setFontFaces":{let[a]=r.args;t.push(()=>this.setFontFaces(a));break}case"setSprite":{let[a]=r.args;t.push(()=>this.setSprite(a));break}case"setTerrain":{let[a]=r.args;t.push(()=>this.map.setTerrain(a));break}case"setSky":{let[a]=r.args;t.push(()=>this.setSky(a));break}case"setProjection":{let[a]=r.args;t.push(()=>this.setProjection(a));break}case"setGlobalState":{let[a]=r.args;t.push(()=>this.setGlobalState(a));break}case"setTransition":t.push(()=>{});break;default:i.push(r.command)}return{operations:t,unimplemented:i}}addImage(e,t){this.getImage(e)?this.fire(new K(Error(`An image named "${e}" already exists.`))):(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){this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e)):this.fire(new K(Error(`An image named "${e}" does not exist.`)))}_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 Di("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,i={}){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(y0.has(t.type)&&this._validate(qt.source,`sources.${e}`,t,null,i))return;(a=this.map)!=null&&a._collectResourceTiming&&(t.collectResourceTiming=!0);let r=this.tileManagers[e]=new id(e,t,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.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 i in this._layers)if(this._layers[i].source===e)return this.fire(new K(Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new $e("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 i=this.tileManagers[e].getSource();if(i.type!=="geojson")throw Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){var t;return(t=this.tileManagers[e])==null?void 0:t.getSource()}addLayer(e,t,i={}){this._checkLoaded();let r=e.id;if(this.getLayer(r)){this.fire(new K(Error(`Layer "${r}" already exists on this map.`)));return}let a;if(e.type==="custom"){if(Bd(this,kC(e)))return;a=lh(e,this._globalState)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(r,e.source),e=Wt(e),e=X(e,{source:r})),this._validate(qt.layer,`layers.${r}`,e,{arrayIndex:-1},i))return;a=lh(e,this._globalState),this._validateLayer(a),a.setEventedParent(this,{layer:{id:r}})}let n=t?this._order.indexOf(t):this._order.length;if(t&&n===-1)this.fire(new K(Error(`Cannot add layer "${r}" before non-existing layer "${t}".`)));else{if(this._order.splice(n,0,r),this._layerOrderChanged=!0,this._layers[r]=a,this._removedLayers[r]&&a.source&&a.type!=="custom"){let o=this._removedLayers[r];delete this._removedLayers[r],o.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 K(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 K(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));return}let i=this._order.indexOf(e);this._order.splice(i,1);let r=t?this._order.indexOf(t):this._order.length;this._order.splice(r,0,e),this._layerOrderChanged=!0}removeLayer(e){var r;this._checkLoaded();let t=this._layers[e];if(!t){this.fire(new K(Error(`Cannot remove non-existing layer "${e}".`)));return}t.setEventedParent(null);let i=this._order.indexOf(e);this._order.splice(i,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&&((r=this.tileManagers[t.source])==null||r.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,i){this._checkLoaded();let r=this.getLayer(e);r?(r.minzoom!==t||r.maxzoom!==i)&&(t!=null&&(r.minzoom=t),i!=null&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new K(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,t,i={}){this._checkLoaded();let r=this.getLayer(e);r?$i(r.filter,t)||(t==null?(r.setFilter(void 0),this._updateLayer(r)):this._validate(qt.filter,`layers.${r.id}.filter`,t,null,i)||(r.setFilter(Wt(t)),this._updateLayer(r))):this.fire(new K(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return Wt(this.getLayer(e).filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);a?$i(a.getLayoutProperty(t),i)||(a.setLayoutProperty(t,i,r),this._updateLayer(a)):this.fire(new K(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,t){let i=this.getLayer(e);if(!i)this.fire(new K(Error(`Cannot get style of non-existing layer "${e}".`)));else return i.getLayoutProperty(t)}setPaintProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);a?$i(a.getPaintProperty(t),i)||this._updatePaintProperty(a,t,i,r):this.fire(new K(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,i,r={}){e.setPaintProperty(t,i,r)&&this._updateLayer(e),tc(e)&&t==="raster-fade-duration"&&this.tileManagers[e.source].setRasterFadeDuration(i),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 i=e.source,r=e.sourceLayer,a=this.tileManagers[i];if(a===void 0){this.fire(new K(Error(`The source '${i}' does not exist in the map's style.`)));return}let n=a.getSource().type;if(n==="geojson"&&r){this.fire(new K(Error("GeoJSON sources cannot have a sourceLayer parameter.")));return}if(n==="vector"&&!r){this.fire(new K(Error("The sourceLayer parameter must be provided for vector source types.")));return}if(e.id===void 0){this.fire(new K(Error("The feature id parameter must be provided.")));return}let o=["__proto__","constructor","prototype"];t&&Object.keys(t).some(s=>o.includes(s))?this.fire(new K(Error(`The feature state should not include one of the following keys: ${o}`))):a.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let i=e.source,r=this.tileManagers[i];if(r===void 0){this.fire(new K(Error(`The source '${i}' does not exist in the map's style.`)));return}let a=r.getSource().type,n=a==="vector"?e.sourceLayer:void 0;a==="vector"&&!n?this.fire(new K(Error("The sourceLayer parameter must be provided for vector source types."))):t&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new K(Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,e.id,t)}getFeatureState(e){this._checkLoaded();let t=e.source,i=e.sourceLayer,r=this.tileManagers[t];if(r===void 0)this.fire(new K(Error(`The source '${t}' does not exist in the map's style.`)));else if(r.getSource().type==="vector"&&!i)this.fire(new K(Error("The sourceLayer parameter must be provided for vector source types.")));else return e.id===void 0&&this.fire(new K(Error("The feature id parameter must be provided."))),r.getFeatureState(i,e.id)}getTransition(){var e;return X({duration:300,delay:0},(e=this.stylesheet)==null?void 0:e.transition)}serialize(){if(!this._loaded)return;let e=gd(this.tileManagers,a=>a.serialize()),t=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return $_({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,"font-faces":r["font-faces"],transition:r.transition,projection:r.projection,state:r.state,sources:e,layers:t,terrain:i},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",i={},r=[];for(let n=this._order.length-1;n>=0;n--){let o=this._order[n];if(t(o)){i[o]=n;for(let s of e){let l=s[o];if(l)for(let u of l)r.push(u)}}}r.sort((n,o)=>o.intersectionZ-n.intersectionZ);let a=[];for(let n=this._order.length-1;n>=0;n--){let o=this._order[n];if(t(o))for(let s=r.length-1;s>=0;s--){let l=r[s].feature;if(i[l.layer.id]<n)break;a.push(l),r.pop()}else for(let s of e){let l=s[o];if(l)for(let u of l)a.push(u.feature)}}return a}queryRenderedFeatures(e,t,i){t!=null&&t.filter&&this._validate(qt.filter,"queryRenderedFeatures.filter",t.filter,null,t);let r={};if(t!=null&&t.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new K(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 K(Error(`The layer '${l}' does not exist in the map's style and cannot be queried for features.`))),[];r[u.source]=!0}}let a=[];t.availableImages=this.imageManager.listImages();let n=this._serializedAllLayers(),o=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,s={...t,layers:o,globalState:this._globalState};for(let l in this.tileManagers)(!t.layers||r[l])&&a.push(gP(this.tileManagers[l],this._layers,n,e,s,i,this.map.terrain?(u,h,c)=>this.map.terrain.getElevation(u,h,c):void 0));return this.placement&&a.push(_P(this._layers,n,this.tileManagers,e,s,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t!=null&&t.filter&&this._validate(qt.filter,"querySourceFeatures.filter",t.filter,null,t);let i=this.tileManagers[e];return i?yP(i,{...t,globalState:this._globalState,worldCoordinateHelper:this.projection.worldCoordinateHelper}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let i=this.light.getLight(),r=!1;for(let n in e)if(!$i(e[n],i[n])){r=!0;break}if(!r)return;let a={now:ke(),transition:X({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!=null?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 i=this.getSky(),r=!1;if(!e&&!i)return;if(e&&!i)r=!0;else if(!e&&i)r=!0;else for(let n in e)if(!$i(e[n],i[n])){r=!0;break}if(!r)return;let a={now:ke(),transition:X({duration:300,delay:0},this.stylesheet.transition)};this.sky.setSky(e,t)&&(this.stylesheet.sky=e,this.sky.updateTransitions(a))}_setProjectionInternal(e){var t;this._applyProjection(r_(e,(t=this.map._camera)==null?void 0:t.transform.constrainOverride,this._globalState))}_applyProjection(e){this.projection=e.projection,this.map.migrateProjection(e.transform,e.cameraHelper);for(let t in this.tileManagers)this.tileManagers[t].reload()}_validate(e,t,i,r,a={}){return a.validate!==!1&&Mo(this,e,{key:t,style:this.serialize(),value:i,...r},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)),ed().off(Qc,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let i=this.tileManagers[t];i.setEventedParent(null),i.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,i){var a;let r=this.pauseablePlacement;return!r||this._symbolPlacementTriggered||this._placedProjectionTransition!==((a=this.projection)==null?void 0:a.transitionState)||r._showCollisionBoxes!==t||r.placement.collisionGroups.crossSourceCollisions!==i||r.placement.transform.renderWorldCopies!==e.renderWorldCopies||!nb(r.placement.transform.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,i,r,a=!1){var h,c;let n=!1,o=!1,s={};for(let d of this._order){let p=this._layers[d];if(p.type!=="symbol")continue;if(!s[p.source]){let m=this.tileManagers[p.source];s[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,s[p.source],e.worldCoordinateHelper.wraps?e.center.lng:0);n||(n=f)}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||(a=this._layerOrderChanged||i===0);let l=n||this._placementInputsChanged(e,t,r),u=((h=this.pauseablePlacement)==null?void 0:h.isDone())&&!this.placement.stillRecent(ke(),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 DI(e,this.map.terrain,this._order,a,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,s),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ke()),o=!0),n&&this.pauseablePlacement.placement.setStale()),o||n)for(let d of this._order){let p=this._layers[d];p.type==="symbol"&&this.placement.updateLayerOpacities(p,s[p.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ke())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let i=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,t.icons),i}async getGlyphs(e,t){let i=await this.glyphManager.getGlyphs(t.stacks),r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,[""]),i}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),!(e&&this._validate(qt.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 i={};for(let[r,a]of Object.entries(t.dashes))i[r]=this.lineAtlas.getDash(a.dasharray,a.round);return i}addSprite(e,t,i={},r){this._checkLoaded();let a=[{id:e,url:t}],n=[...$s(this.stylesheet.sprite),...a];this._validate(qt.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(a,!0,r))}removeSprite(e){this._checkLoaded();let t=$s(this.stylesheet.sprite);if(!t.find(r=>r.id===e)){this.fire(new K(Error(`Sprite "${e}" doesn't exists on this map.`)));return}let i=this.imageManager.removeSpriteImages(e);this._markImagesChanged(i),t.splice(t.findIndex(r=>r.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new Di("data"))}getSprite(){return $s(this.stylesheet.sprite)}setSprite(e,t={},i){this._checkLoaded(),!(e&&this._validate(qt.sprite,"sprite",e,null,t))&&(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,i):(this._unloadSprite(),i&&i(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 n5=Qe([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var o5=class{constructor(e,t,i){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.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 n_={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var s5=class{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,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 i of this.attributes){let r=t.attributes[i.name];r!==void 0&&e.enableVertexAttribArray(r.location)}}setVertexAttribPointers(e,t,i){for(let r of this.attributes){let a=t.attributes[r.name];if(a!==void 0){let n=r.offset+this.itemSize*(i||0);a.isInteger?e.vertexAttribIPointer(a.location,r.components,e[n_[r.type]],this.itemSize,n):e.vertexAttribPointer(a.location,r.components,e[n_[r.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)}},l5=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)}},u5=class extends Re{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},h5=class extends Re{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},c5=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)}},d5=class extends Re{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},p5=class extends Re{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},f5=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)}},m5=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)}},g5=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}},_5=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)}},y5=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}},v5=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)}},x5=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}},b5=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)}},w5=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)}},T5=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)}},D5=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}},S5=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)}},E5=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)}},C5=class extends Re{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},P5=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)}},A5=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)}},M5=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}},I5=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}},F5=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}},z5=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}},k5=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}},R5=class extends Re{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},L5=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}},B5=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}},O5=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}},Ep=class extends Re{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},j5=class extends Ep{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}},V5=class extends Ep{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}},N5=class extends Ep{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}},U5=class{constructor(e,t,i,r,a){this.context=e,this.width=t,this.height=i;let n=e.gl,o=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new j5(e,o),r)this.depthAttachment=a?new N5(e,o):new V5(e,o);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 i=this.depthAttachment.get();i&&e.deleteRenderbuffer(i)}e.deleteFramebuffer(this.framebuffer)}};const hu={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2};function $5(e,t){for(let[i,r]of Object.entries(hu)){let a=e.getUniformBlockIndex(t,i);a!==e.INVALID_INDEX&&e.uniformBlockBinding(t,a,r)}}const G5={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function Cp(e){let t={},i=0;for(let{name:r,type:a}of e){let[n,o]=G5[a];i=Math.ceil(i/o)*o,t[r]=i,i+=n}return{offsets:t,contentWords:i,sizeWords:Math.ceil(i/4)*4}}var Pp=class{constructor(e,t,i){this.context=e,this.binding=t,this.contentWords=i.contentWords;let r=e.gl;this.buffer=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,this.buffer),r.bufferData(r.UNIFORM_BUFFER,i.sizeWords*4,r.DYNAMIC_DRAW),this.uploaded=new Float32Array(i.sizeWords),this.pending=new Float32Array(i.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 i=this.pendingWords,r=this.uploadedWords;for(let a=0;a<this.contentWords;a++)if(i[a]!==r[a]){t=!0;break}}t?(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):this.bind()}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 ox=Cp([{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"}]),Ea=ox.offsets;function sx(e){return new Pp(e,hu.ProjectionUBO,ox)}function o_(e,t){let i=e.pending;i.set(t.mainMatrix,Ea.u_projection_matrix),i.set(t.fallbackMatrix,Ea.u_projection_fallback_matrix),i.set(t.tileMercatorCoords,Ea.u_projection_tile_mercator_coords),i.set(t.clippingPlane,Ea.u_projection_clipping_plane),i[Ea.u_projection_transition]=t.projectionTransition,e.pendingWords[Ea.u_projection_clip_antimeridian]=+!!t.clipAntimeridian,e.upload()}function Z5(e,t){var n;if(!t){e.projectionUniformBuffer.bind();return}let i=t.uniformBufferKey;if(i===void 0){o_(e.projectionUniformBuffer,t);return}let r=e.keyedProjectionUniformBuffers.get(i);if(r){r.bind();return}let a=(n=e.freeProjectionUniformBuffers.pop())!=null?n:sx(e);e.keyedProjectionUniformBuffers.set(i,a),o_(a,t)}function q5(e){e.freeProjectionUniformBuffers.push(...e.keyedProjectionUniformBuffers.values()),e.keyedProjectionUniformBuffers.clear()}function W5(e){e.projectionUniformBuffer.destroy();for(let t of e.keyedProjectionUniformBuffers.values())t.destroy();for(let t of e.freeProjectionUniformBuffers)t.destroy()}const lx=Cp([{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"}]),Bt=lx.offsets;function H5(e){return new Pp(e,hu.FrameUBO,lx)}function X5(e,t,i){let r=e.pending,a=e.context.gl;r[Bt.u_units_to_pixels]=1/t.pixelsToGLUnits[0],r[Bt.u_units_to_pixels+1]=1/t.pixelsToGLUnits[1],r[Bt.u_world_size]=a.drawingBufferWidth,r[Bt.u_world_size+1]=a.drawingBufferHeight,r[Bt.u_camera_to_center_distance]=t.cameraToCenterDistance,r[Bt.u_symbol_fade_change]=i.fadeDuration?i.symbolFadeChange:1,r[Bt.u_aspect_ratio]=t.width/t.height,r[Bt.u_device_pixel_ratio]=i.pixelRatio,r[Bt.u_viewport_size]=t.width,r[Bt.u_viewport_size+1]=t.height,r[Bt.u_pixel_extrude_scale]=1/t.width,r[Bt.u_pixel_extrude_scale+1]=1/t.height,r[Bt.u_pitch]=t.pitch/360*2*Math.PI,e.upload()}function s_(e,t,i){let r=e.pending;r[Bt.u_world_size]=t,r[Bt.u_world_size+1]=i,e.upload()}const ux=Cp([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),Ms=ux.offsets;function Y5(e){return new Pp(e,hu.TerrainUBO,ux)}function K5(e,t){let i=e.pending;i.set(t.u_terrain_matrix,Ms.u_terrain_matrix),i.set(t.u_terrain_unpack,Ms.u_terrain_unpack),i[Ms.u_terrain_dim]=t.u_terrain_dim,i[Ms.u_terrain_exaggeration]=t.u_terrain_exaggeration,e.upload()}var tt=class{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}};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 l5(this),this.clearDepth=new u5(this),this.clearStencil=new h5(this),this.colorMask=new c5(this),this.depthMask=new d5(this),this.stencilMask=new p5(this),this.stencilFunc=new f5(this),this.stencilOp=new m5(this),this.stencilTest=new g5(this),this.depthRange=new _5(this),this.depthTest=new y5(this),this.depthFunc=new v5(this),this.blend=new x5(this),this.blendFunc=new b5(this),this.blendColor=new w5(this),this.blendEquation=new T5(this),this.cullFace=new D5(this),this.cullFaceSide=new S5(this),this.frontFace=new E5(this),this.program=new C5(this),this.activeTexture=new P5(this),this.viewport=new A5(this),this.bindFramebuffer=new M5(this),this.bindRenderbuffer=new I5(this),this.bindTexture=new F5(this),this.bindVertexBuffer=new z5(this),this.bindElementBuffer=new k5(this),this.bindVertexArray=new R5(this),this.pixelStoreUnpack=new L5(this),this.pixelStoreUnpackPremultiplyAlpha=new B5(this),this.pixelStoreUnpackFlipY=new O5(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=sx(this),this.keyedProjectionUniformBuffers=new Map,this.freeProjectionUniformBuffers=[],this.terrainUniformBuffer=Y5(this),this.frameUniformBuffer=H5(this)}destroy(){W5(this),this.terrainUniformBuffer.destroy(),this.frameUniformBuffer.destroy()}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 o5(this,e,t)}createVertexBuffer(e,t,i){return new s5(this,e,t,i)}createRenderbuffer(e,t,i){let r=this.gl,a=r.createRenderbuffer();return this.bindRenderbuffer.set(a),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),a}createFramebuffer(e,t,i,r){return new U5(this,e,t,i,r)}clear({color:e,depth:t,stencil:i}){let r=this.gl,a=0;e&&(a|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(a|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),i!==void 0&&(a|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.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){$i(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)}},Q5=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,i,r,a,n,o,s,l){this.context=e;let u=this.boundPaintVertexBuffers.length!==r.length;for(let h=0;!u&&h<r.length;h++)this.boundPaintVertexBuffers[h]!==r[h]&&(u=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||u||this.boundIndexBuffer!==a||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,r,a,n,o,s,l):e.bindVertexArray.set(this.vao)}freshBind(e,t,i,r,a,n,o,s){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=i,this.boundIndexBuffer=r,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,t.enableAttributes(h,e);for(let c of i)c.enableAttributes(h,e);n&&n.enableAttributes(h,e),o&&o.enableAttributes(h,e),s&&s.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,a);for(let c of i)c.bind(),c.setVertexAttribPointers(h,e,a);n&&(n.bind(),n.setVertexAttribPointers(h,e,a)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(h,e,a)),s&&(s.bind(),s.setVertexAttribPointers(h,e,a)),u.currentNumAttributes=l}destroy(){this.vao&&(this.vao=(this.context.deleteVertexArray(this.vao),null))}};const eF=(e,t)=>({u_depth:new J(e,t.u_depth),u_terrain:new J(e,t.u_terrain)}),tF=(e,t)=>({u_texture:new J(e,t.u_texture),u_ele_delta:new $(e,t.u_ele_delta),u_fog_matrix:new zi(e,t.u_fog_matrix),u_fog_color:new kr(e,t.u_fog_color),u_fog_ground_blend:new $(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new $(e,t.u_fog_ground_blend_opacity),u_horizon_color:new kr(e,t.u_horizon_color),u_horizon_fog_blend:new $(e,t.u_horizon_fog_blend),u_is_globe_mode:new $(e,t.u_is_globe_mode)}),iF=(e,t)=>({u_ele_delta:new $(e,t.u_ele_delta)}),rF=(e,t)=>({u_tile_bounds:new tn(e,t.u_tile_bounds)}),aF=(e,t,i,r,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:i?i["fog-color"]:se.white,u_fog_ground_blend:i?i["fog-ground-blend"]:1,u_fog_ground_blend_opacity:a?0:i?eP(r):0,u_horizon_color:i?i["horizon-color"]:se.white,u_horizon_fog_blend:i?i["horizon-fog-blend"]:1,u_is_globe_mode:+!!a}),nF=e=>({u_ele_delta:e}),oF=e=>({u_tile_bounds:e});function xh(e){let t=[];for(let i of e){if(i===null)continue;let r=i.split(" ");t.push(r.pop())}return t}function sF(e,t){let i=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]),r=new Set,a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let n=0;n<a;n++){let o=e.getActiveAttrib(t,n);o&&i.has(o.type)&&r.add(o.name)}return r}var lF=class{constructor(e,t,i,r,a,n,o,s,l=[]){let u=e.gl;this.program=u.createProgram();let h=xh(t.staticAttributes),c=i?i.getBinderAttributes():[],d=h.concat(c),p=Wi.prelude.staticUniforms?xh(Wi.prelude.staticUniforms):[],f=t.staticUniforms?xh(t.staticUniforms):[],m=i?i.getBinderUniforms():[],g=p.concat(f).concat(m),_=[];for(let C of g)_.includes(C)||_.push(C);let y=i?i.defines():[];y.unshift("#version 300 es"),a&&y.push("#define OVERDRAW_INSPECTOR;"),n&&y.push("#define TERRAIN3D;"),s&&y.push(s),l&&y.push(...l);let v=y.concat(Wi.prelude.fragmentSource,o.fragmentSource,t.fragmentSource).join(`
`),x=y.concat(Wi.prelude.vertexSource,o.vertexSource,t.vertexSource).join(`
`),b=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(b,v),u.compileShader(b),u.attachShader(this.program,b);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}u.shaderSource(w,x),u.compileShader(w),u.attachShader(this.program,w),this.attributes={};let T={};if(this.numAttributes=d.length,u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS)){if(u.isContextLost()||u.getProgramParameter(this.program,u.ATTACHED_SHADERS)===0){this.failedToCreate=!0;return}throw u.getShaderParameter(b,u.COMPILE_STATUS)?u.getShaderParameter(w,u.COMPILE_STATUS)?Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`):Error(`Could not compile fragment shader: ${u.getShaderInfoLog(b)}`)}$5(u,this.program);let S=sF(u,this.program);for(let C of d){if(!C)continue;let F=u.getAttribLocation(this.program,C);F>=0&&(this.attributes[C]={location:F,isInteger:S.has(C)})}u.deleteShader(w),u.deleteShader(b);for(let C of _)if(C&&!T[C]){let F=u.getUniformLocation(this.program,C);F&&(T[C]=F)}this.fixedUniforms=r(e,T),this.terrainUniforms=eF(e,T),this.binderUniforms=i?i.getUniforms(e,T):[]}draw(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y){var b;let v=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.terrainUniformBuffer.bind(),e.frameUniformBuffer.bind(),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(a),e.setCullFace(n),s){e.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,s.depthTexture),e.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,s.texture);for(let w in this.terrainUniforms)this.terrainUniforms[w].set(s[w]);K5(e.terrainUniformBuffer,s)}if(Z5(e,l),o)for(let w in this.fixedUniforms)this.fixedUniforms[w].set(o[w]);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 w of d.get())w.vaos||(w.vaos={}),(b=w.vaos)[u]||(b[u]=new Q5),w.vaos[u].bind(e,this,h,m?m.getPaintVertexBuffers():[],c,w.vertexOffset,g,_,y),v.drawElements(t,w.primitiveLength*x,v.UNSIGNED_SHORT,w.primitiveOffset*x*2)}};function hx(e,t,i){let r=1/oi(i,1,t.tileZoom),a=2**i.tileID.overscaledZ,n=i.tileSize*2**t.tileZoom/a,o=n*(i.tileID.canonical.x+i.tileID.wrap*a),s=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[o&65535,s&65535]}}function uF(e,t,i,r,a){let n=i.getPattern(e.from.toString()),o=i.getPattern(e.to.toString()),{width:s,height:l}=i.getPixelSize(),u=2**a.tileID.overscaledZ,h=a.tileSize*2**r.tileZoom/u,c=h*(a.tileID.canonical.x+a.tileID.wrap*u),d=h*a.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,l],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/oi(a,1,r.tileZoom),u_pixel_coord_upper:[c>>16,d>>16],u_pixel_coord_lower:[c&65535,d&65535]}}const hF=(e,t)=>({u_lightpos:new Vt(e,t.u_lightpos),u_lightpos_globe:new Vt(e,t.u_lightpos_globe),u_lightintensity:new $(e,t.u_lightintensity),u_lightcolor:new Vt(e,t.u_lightcolor),u_vertical_gradient:new $(e,t.u_vertical_gradient),u_opacity:new $(e,t.u_opacity),u_fill_translate:new ce(e,t.u_fill_translate)}),cF=(e,t)=>({u_lightpos:new Vt(e,t.u_lightpos),u_lightpos_globe:new Vt(e,t.u_lightpos_globe),u_lightintensity:new $(e,t.u_lightintensity),u_lightcolor:new Vt(e,t.u_lightcolor),u_vertical_gradient:new $(e,t.u_vertical_gradient),u_height_factor:new $(e,t.u_height_factor),u_opacity:new $(e,t.u_opacity),u_fill_translate:new ce(e,t.u_fill_translate),u_image:new J(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 Vt(e,t.u_scale),u_fade:new $(e,t.u_fade)}),cx=(e,t,i,r,a)=>{let n=G_(t.position),o=O_();t.anchor==="viewport"&&Qx(o,e.bearingInRadians),hb(n,n,o);let s=e.transformLightDirection(n),l=t.color;return{u_lightpos:n,u_lightpos_globe:s,u_lightintensity:t.intensity,u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:a}},dF=(e,t,i,r,a,n,o,s)=>X(cx(e,t,i,r,a),hx(o,e,s),{u_height_factor:-(2**n.overscaledZ)/s.tileSize/8}),pF=(e,t)=>({u_fill_translate:new ce(e,t.u_fill_translate)}),fF=(e,t)=>({u_image:new J(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 Vt(e,t.u_scale),u_fade:new $(e,t.u_fade),u_sdf_pattern:new J(e,t.u_sdf_pattern),u_fill_translate:new ce(e,t.u_fill_translate)}),mF=(e,t)=>({u_fill_translate:new ce(e,t.u_fill_translate)}),gF=(e,t)=>({u_image:new J(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 Vt(e,t.u_scale),u_fade:new $(e,t.u_fade),u_sdf_pattern:new J(e,t.u_sdf_pattern),u_fill_translate:new ce(e,t.u_fill_translate)}),dx=(e,t,i,r,a)=>X(hx(t,e,i),{u_fill_translate:r,u_sdf_pattern:+!!a}),_F=e=>({u_fill_translate:e}),yF=e=>({u_fill_translate:e}),vF=(e,t,i,r,a)=>dx(e,t,i,r,a),xF=(e,t)=>({u_scale_with_map:new J(e,t.u_scale_with_map),u_pitch_with_map:new J(e,t.u_pitch_with_map),u_extrude_scale:new ce(e,t.u_extrude_scale),u_globe_extrude_scale:new $(e,t.u_globe_extrude_scale),u_translate:new ce(e,t.u_translate)}),bF=(e,t,i,r,a)=>{let n,o,s=0;if(i.paint.get("circle-pitch-alignment")==="map"){let l=oi(t,1,e.zoom);n=!0,o=[l,l],s=l/(O*2**t.tileID.overscaledZ)*2*Math.PI*a}else n=!1,o=e.pixelsToGLUnits;return{u_scale_with_map:+(i.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+n,u_extrude_scale:o,u_globe_extrude_scale:s,u_translate:r}},wF=(e,t)=>({u_color:new kr(e,t.u_color),u_overlay:new J(e,t.u_overlay),u_overlay_scale:new $(e,t.u_overlay_scale)}),l_=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),TF=(e,t)=>({u_extrude_scale:new $(e,t.u_extrude_scale),u_intensity:new $(e,t.u_intensity),u_globe_extrude_scale:new $(e,t.u_globe_extrude_scale)}),DF=(e,t)=>({u_matrix:new zi(e,t.u_matrix),u_image:new J(e,t.u_image),u_color_ramp:new J(e,t.u_color_ramp),u_opacity:new $(e,t.u_opacity)}),px=(e,t,i,r)=>{let a=oi(e,1,t)/(O*2**e.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:oi(e,1,t),u_intensity:i,u_globe_extrude_scale:a}},fx=(e,t,i,r)=>{let a=la();return nr(a,0,e.width,e.height,0,0,1),{u_matrix:a,u_image:i,u_color_ramp:r,u_opacity:t.paint.get("heatmap-opacity")}},SF=(e,t)=>({u_image:new J(e,t.u_image),u_latrange:new ce(e,t.u_latrange),u_exaggeration:new $(e,t.u_exaggeration),u_altitudes:new rm(e,t.u_altitudes),u_azimuths:new rm(e,t.u_azimuths),u_accent:new kr(e,t.u_accent),u_method:new J(e,t.u_method),u_shadows:new im(e,t.u_shadows),u_highlights:new im(e,t.u_highlights)}),EF=(e,t)=>({u_matrix:new zi(e,t.u_matrix),u_image:new J(e,t.u_image),u_dimension:new ce(e,t.u_dimension),u_zoom:new $(e,t.u_zoom),u_unpack:new tn(e,t.u_unpack),u_log2_world_width:new $(e,t.u_log2_world_width)}),CF=(e,t,i)=>{let r=i.paint.get("hillshade-accent-color"),a;switch(i.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=i.getIlluminationProperties();for(let o=0;o<n.directionRadians.length;o++)i.paint.get("hillshade-illumination-anchor")==="viewport"&&(n.directionRadians[o]+=e.bearingInRadians);return{u_image:0,u_latrange:MF(e,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:n.altitudeRadians,u_azimuths:n.directionRadians,u_accent:r,u_method:a,u_highlights:n.highlightColor,u_shadows:n.shadowColor}},PF=(e,t,i)=>{let r=i.stride,a=la();return nr(a,0,O,-8192,0,0,1),st(a,a,[0,-8192,0]),{u_matrix:a,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector(),u_log2_world_width:AF(e)}};function AF(e){let t=e.worldCoordinateHelper;return t.wraps?25.2562:Math.log2(t.metersPerWorldUnit(.5,.5))}function MF(e,t){let i=e.worldCoordinateHelper;if(!i.wraps)return[0,0];let r=2**t.canonical.z,a=t.canonical.y;return[i.lngLatFromWorld(0,a/r).lat,i.lngLatFromWorld(0,(a+1)/r).lat]}const IF=(e,t)=>({u_image:new J(e,t.u_image),u_unpack:new tn(e,t.u_unpack),u_dimension:new ce(e,t.u_dimension),u_elevation_stops:new J(e,t.u_elevation_stops),u_color_stops:new J(e,t.u_color_stops),u_color_ramp_size:new J(e,t.u_color_ramp_size),u_opacity:new $(e,t.u_opacity)}),FF=(e,t,i=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:i,u_opacity:e.paint.get("color-relief-opacity")}),zF=(e,t)=>({u_translation:new ce(e,t.u_translation),u_ratio:new $(e,t.u_ratio)}),kF=(e,t)=>({u_translation:new ce(e,t.u_translation),u_ratio:new $(e,t.u_ratio),u_image:new J(e,t.u_image),u_image_height:new $(e,t.u_image_height)}),RF=(e,t)=>({u_translation:new ce(e,t.u_translation),u_texsize:new ce(e,t.u_texsize),u_ratio:new $(e,t.u_ratio),u_image:new J(e,t.u_image),u_scale:new Vt(e,t.u_scale),u_fade:new $(e,t.u_fade)}),LF=(e,t)=>({u_translation:new ce(e,t.u_translation),u_ratio:new $(e,t.u_ratio),u_image:new J(e,t.u_image),u_mix:new $(e,t.u_mix),u_tileratio:new $(e,t.u_tileratio),u_crossfade_from:new $(e,t.u_crossfade_from),u_crossfade_to:new $(e,t.u_crossfade_to),u_lineatlas_width:new $(e,t.u_lineatlas_width),u_lineatlas_height:new $(e,t.u_lineatlas_height)}),BF=(e,t)=>({u_translation:new ce(e,t.u_translation),u_ratio:new $(e,t.u_ratio),u_image:new J(e,t.u_image),u_image_height:new $(e,t.u_image_height),u_tileratio:new $(e,t.u_tileratio),u_crossfade_from:new $(e,t.u_crossfade_from),u_crossfade_to:new $(e,t.u_crossfade_to),u_image_dash:new J(e,t.u_image_dash),u_mix:new $(e,t.u_mix),u_lineatlas_width:new $(e,t.u_lineatlas_width),u_lineatlas_height:new $(e,t.u_lineatlas_height)}),cu=(e,t,i,r)=>({u_translation:mx(e,t,i),u_ratio:r/oi(t,1,e.zoom)}),OF=(e,t,i,r,a)=>X(cu(e,t,i,r),{u_image:0,u_image_height:a}),jF=(e,t,i,r,a)=>{let n=Ap(t,e);return{u_translation:mx(e,t,i),u_texsize:t.imageAtlasTexture.size,u_ratio:r/oi(t,1,e.zoom),u_image:0,u_scale:[n,a.fromScale,a.toScale],u_fade:a.t}},VF=(e,t,i,r,a,n)=>{let o=Ap(i,e);return X(cu(e,i,r,a),{u_tileratio:o,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image:0,u_mix:n.t,u_lineatlas_width:t.width,u_lineatlas_height:t.height})},NF=(e,t,i,r,a,n,o)=>{let s=Ap(i,e);return X(cu(e,i,r,a),{u_image:0,u_image_height:o,u_tileratio:s,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image_dash:1,u_mix:n.t,u_lineatlas_width:t.width,u_lineatlas_height:t.height})};function Ap(e,t){return 1/oi(e,1,t.tileZoom)}function mx(e,t,i){return Ir(e,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const UF=(e,t)=>({u_image:new J(e,t.u_image),u_opacity:new $(e,t.u_opacity)}),$F=(e,t)=>({u_image:t,u_opacity:e}),GF=(e,t)=>({u_is_size_zoom_constant:new J(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new J(e,t.u_is_size_feature_constant),u_size_t:new $(e,t.u_size_t),u_size:new $(e,t.u_size),u_rotate_symbol:new J(e,t.u_rotate_symbol),u_label_plane_matrix:new zi(e,t.u_label_plane_matrix),u_coord_matrix:new zi(e,t.u_coord_matrix),u_is_text:new J(e,t.u_is_text),u_pitch_with_map:new J(e,t.u_pitch_with_map),u_is_along_line:new J(e,t.u_is_along_line),u_is_variable_anchor:new J(e,t.u_is_variable_anchor),u_texsize:new ce(e,t.u_texsize),u_texture:new J(e,t.u_texture),u_translation:new ce(e,t.u_translation),u_pitched_scale:new $(e,t.u_pitched_scale),u_is_offset:new J(e,t.u_is_offset),u_height_anchor_ground:new J(e,t.u_height_anchor_ground)}),ZF=(e,t)=>({u_is_size_zoom_constant:new J(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new J(e,t.u_is_size_feature_constant),u_size_t:new $(e,t.u_size_t),u_size:new $(e,t.u_size),u_rotate_symbol:new J(e,t.u_rotate_symbol),u_label_plane_matrix:new zi(e,t.u_label_plane_matrix),u_coord_matrix:new zi(e,t.u_coord_matrix),u_is_text:new J(e,t.u_is_text),u_pitch_with_map:new J(e,t.u_pitch_with_map),u_is_along_line:new J(e,t.u_is_along_line),u_is_variable_anchor:new J(e,t.u_is_variable_anchor),u_texsize:new ce(e,t.u_texsize),u_texture:new J(e,t.u_texture),u_gamma_scale:new $(e,t.u_gamma_scale),u_is_halo:new J(e,t.u_is_halo),u_is_plain:new J(e,t.u_is_plain),u_translation:new ce(e,t.u_translation),u_pitched_scale:new $(e,t.u_pitched_scale),u_is_offset:new J(e,t.u_is_offset),u_height_anchor_ground:new J(e,t.u_height_anchor_ground)}),qF=(e,t)=>({u_is_size_zoom_constant:new J(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new J(e,t.u_is_size_feature_constant),u_size_t:new $(e,t.u_size_t),u_size:new $(e,t.u_size),u_rotate_symbol:new J(e,t.u_rotate_symbol),u_label_plane_matrix:new zi(e,t.u_label_plane_matrix),u_coord_matrix:new zi(e,t.u_coord_matrix),u_is_text:new J(e,t.u_is_text),u_pitch_with_map:new J(e,t.u_pitch_with_map),u_is_along_line:new J(e,t.u_is_along_line),u_is_variable_anchor:new J(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 J(e,t.u_texture),u_texture_icon:new J(e,t.u_texture_icon),u_gamma_scale:new $(e,t.u_gamma_scale),u_is_halo:new J(e,t.u_is_halo),u_translation:new ce(e,t.u_translation),u_pitched_scale:new $(e,t.u_pitched_scale),u_is_offset:new J(e,t.u_is_offset),u_height_anchor_ground:new J(e,t.u_height_anchor_ground)}),gx=(e,t,i,r,a,n,o,s,l,u,h,c,d,p)=>({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:+i,u_label_plane_matrix:o,u_coord_matrix:s,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:a,u_is_variable_anchor:n,u_texsize:h,u_texture:0,u_translation:l,u_pitched_scale:c,u_is_offset:d,u_height_anchor_ground:+p}),_x=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m)=>X(gx(e,t,i,r,a,n,s,l,u,h,c,p,f,m),{u_gamma_scale:r?Math.cos(o.pitch*Math.PI/180)*o.cameraToCenterDistance:1,u_is_halo:+!!d,u_is_plain:1}),WF=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f)=>X(_x(e,t,i,r,a,n,o,s,l,u,!0,h,!0,d,p,f),{u_texsize_icon:c,u_texture_icon:1}),HF=(e,t)=>({u_opacity:new $(e,t.u_opacity),u_color:new kr(e,t.u_color)}),XF=(e,t)=>({u_opacity:new $(e,t.u_opacity),u_image:new J(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 $(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 $(e,t.u_scale_a),u_scale_b:new $(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 $(e,t.u_tile_units_to_pixels)}),YF=(e,t)=>({u_opacity:e,u_color:t}),KF=(e,t,i,r,a,n)=>X(uF(r,n,t,i,a),{u_opacity:e}),JF=(e,t)=>({u_sun_pos:new Vt(e,t.u_sun_pos),u_atmosphere_blend:new $(e,t.u_atmosphere_blend),u_globe_position:new Vt(e,t.u_globe_position),u_globe_radius:new $(e,t.u_globe_radius),u_inv_proj_matrix:new zi(e,t.u_inv_proj_matrix)}),QF=(e,t,i,r,a)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:a}),ez=(e,t)=>({u_sky_color:new kr(e,t.u_sky_color),u_horizon_color:new kr(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 $(e,t.u_sky_horizon_blend),u_sky_blend:new $(e,t.u_sky_blend),u_inv_proj_matrix:new zi(e,t.u_inv_proj_matrix),u_globe_position:new Vt(e,t.u_globe_position),u_globe_radius:new $(e,t.u_globe_radius),u_atmosphere_blend:new $(e,t.u_atmosphere_blend)}),tz=(e,t,i)=>{let r=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),n=Qn(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition,s=Qv(t),l=Kr(t.worldSize,t.center.lat);return{u_sky_color:e["sky-color"],u_horizon_color:e["horizon-color"],u_horizon:[(t.width/2-n*a)*i,(t.height/2+n*r)*i],u_horizon_normal:[-a,r],u_sky_horizon_blend:e["sky-horizon-blend"]*t.height/2*i,u_sky_blend:o,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:s,u_globe_radius:l,u_atmosphere_blend:e["atmosphere-blend"]*ex(Pi(s)-l,l)}},Is=(e,t)=>({}),iz={fillExtrusion:hF,fillExtrusionPattern:cF,fill:pF,fillPattern:fF,fillOutline:mF,fillOutlinePattern:gF,circle:xF,collisionBox:Is,collisionCircle:Is,debug:wF,depth:Is,clippingMask:Is,heatmap:TF,heatmapTexture:DF,hillshade:SF,hillshadePrepare:EF,colorRelief:IF,line:zF,lineGradient:kF,linePattern:RF,lineSDF:LF,lineGradientSDF:BF,layerOpacity:UF,raster:OP,symbolIcon:GF,symbolSDF:ZF,symbolTextAndIcon:qF,background:HF,backgroundPattern:XF,terrain:tF,terrainDepth:iF,terrainHeight:rF,atmosphere:JF,sky:ez};var rz=class{constructor(e){this.programs={},this.context=e}getProgram(e){var s;let t=e.programConfiguration?e.programConfiguration.cacheKey:"",i=`/${e.projectionShaderVariant.name}`,r=e.showOverdrawInspector?"/overdraw":"",a=e.useTerrain?"/terrain":"",n=e.defines?`/${e.defines.join("/")}`:"",o=e.name+t+i+r+a+n;return(s=this.programs)[o]||(s[o]=new lF(this.context,Wi[e.name],e.programConfiguration,iz[e.name],e.showOverdrawInspector,e.useTerrain,e.projectionShaderVariant.prelude,e.projectionShaderVariant.define,e.defines)),this.programs[o]}destroy(){for(let e of Object.values(this.programs))e.program&&this.context.gl.deleteProgram(e.program);this.programs={}}};const bh=7680;var Pe=class{constructor(e,t,i,r,a,n){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=a,this.pass=n}};Pe.disabled=new Pe({func:519,mask:0},0,0,bh,bh,bh);const u_=1029,wh=2305;var Ae=class{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}};Ae.disabled=new Ae(!1,u_,wh),Ae.backCCW=new Ae(!0,u_,wh),Ae.frontCCW=new Ae(!0,1028,wh);var ge=class{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}};ge.ReadOnly=!1,ge.ReadWrite=!0,ge.disabled=new ge(519,ge.ReadOnly,[0,1]);let Fs;function h_(e,t,i,r,a){let n=a.context,o=n.gl,s=a.useProgram("collisionBox"),l=[],u=0,h=0;for(let g of i){let _=e.getTile(g).getBucket(t);if(!_)continue;let y=r?_.textCollisionBox:_.iconCollisionBox,v=_.collisionCircleArray;v.length>0&&(l.push({circleArray:v,circleOffset:h,coord:g}),u+=v.length/4,h=u),y&&s.draw(n,o.LINES,ge.disabled,Pe.disabled,a.colorModeForRenderPass(),Ae.disabled,null,a.getTerrainDataForTile(g),a.getProjectionDataForTile(g),t.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,a.transform.zoom,null,null,y.collisionVertexBuffer)}if(!r||!l.length)return;let c=a.useProgram("collisionCircle"),d=new PT;d.resize(u*4),d._trim();let p=0;for(let g of l)for(let _=0;_<g.circleArray.length/4;_++){let y=_*4,v=g.circleArray[y+0],x=g.circleArray[y+1],b=g.circleArray[y+2],w=g.circleArray[y+3];d.emplace(p++,v,x,b,w,0),d.emplace(p++,v,x,b,w,1),d.emplace(p++,v,x,b,w,2),d.emplace(p++,v,x,b,w,3)}(!Fs||Fs.length<u*2)&&(Fs=az(u));let f=n.createIndexBuffer(Fs,!0),m=n.createVertexBuffer(d,jS.members,!0);for(let g of l)c.draw(n,o.TRIANGLES,ge.disabled,Pe.disabled,a.colorModeForRenderPass(),Ae.disabled,null,a.getTerrainDataForTile(g.coord),null,t.id,m,f,Ke.simpleSegment(0,g.circleOffset*2,g.circleArray.length,g.circleArray.length/2),null,a.transform.zoom,null,null,null);m.destroy(),f.destroy()}function az(e){let t=e*2,i=new MT;i.resize(t),i._trim();for(let r=0;r<t;r++){let a=r*6;i.uint16[a+0]=r*4+0,i.uint16[a+1]=r*4+1,i.uint16[a+2]=r*4+2,i.uint16[a+3]=r*4+2,i.uint16[a+4]=r*4+3,i.uint16[a+5]=r*4+0}return i}const nz=Ii(new Float32Array(16));function oz(e,t,i,r,a){if(a.currentPass!=="translucent")return;let n=Pe.disabled,o=a.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&lz(r,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),a),i.paint.get("icon-opacity").constantOr(1)!==0&&c_(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment").constantOr("viewport"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),n,o,a),i.paint.get("text-opacity").constantOr(1)!==0&&c_(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),n,o,a),t.map.showCollisionBoxes&&(h_(t,i,r,!0,a),h_(t,i,r,!1,a))}function sz(e,t,i,r,a,n){let{horizontalAlign:o,verticalAlign:s}=ru(e),l=-(o-.5)*t,u=-(s-.5)*i;return new M((l/a+r[0])*n,(u/a+r[1])*n)}function lz(e,t,i,r,a,n,o,s){var p;let l=s.transform,u=s.terrain,h=s.data.variableOffsets,c=r==="map",d=a==="map";for(let f of e){let m=i.getTile(f),g=m.getBucket(t);if(!((p=g==null?void 0:g.text)!=null&&p.segments.get().length))continue;let _=g.textSizeData,y=au(_,l.zoom),v=xp(c,l,oi(m,1,l.zoom)),x=t.layout.get("icon-text-fit")!=="none"&&g.hasIconData();if(y){let b=2**(l.zoom-m.tileID.overscaledZ),w=u?(T,S)=>u.getElevation(f,T,S):void 0;hz(g,c,d,h,l,v,b,y,x,Ir(l,m,n,o),f.toUnwrapped(),w,t.layout.get("symbol-height-anchor")==="ground")}}}function uz(e,t,i,r,a,n){let o=t.tileAnchorPoint.add(new M(t.translation[0],t.translation[1]));if(t.pitchWithMap){let s=r.mult(n);i||(s=s.rotate(-a));let l=o.add(s);return wp(l.x,l.y,t.pitchedLabelPlaneMatrix,na(t,l.x,l.y)).point}if(i){let s=oa(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),l=Math.atan(s.y/s.x)+(s.x<0?Math.PI:0);return e.add(r.rotate(l))}return e.add(r)}function hz(e,t,i,r,a,n,o,s,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?r[y.crossTileID]:null;if(!x)qa(y.numGlyphs,f);else{let b=new M(y.anchorX,y.anchorY),w={getElevation:c,heightOffset:y.heightOffset,heightAnchorGround:d,width:a.width,height:a.height,pitchedLabelPlaneMatrix:n,pitchWithMap:i,transform:a,tileAnchorPoint:b,translation:u,unwrappedTileID:h},T=i?jv(b.x,b.y,w):oa(b.x,b.y,w),S=Lv(a.cameraToCenterDistance,T.signedDistanceFromCamera),C=Jd(e.textSizeData,s,y)*S/24;i&&(C*=e.tilePixelRatio/o);let{width:F,height:A,anchor:L,textOffset:I,textBoxScale:E}=x,D=sz(L,F,A,I,E,C),P=a.getPitchedTextCorrection(b.x+u[0],b.y+u[1],h),R=uz(T.point,w,t,D,-a.bearingInRadians,P),k=e.allowVerticalPlacement&&y.placedOrientation===2?Math.PI/2:0;for(let B=0;B<y.numGlyphs;B++)Dl(f,R,k);l&&y.associatedIconIndex>=0&&(g[y.associatedIconIndex]={shiftedAnchor:R,angle:k})}}if(l){m.clear();let _=e.icon.placedSymbolArray;for(let y=0;y<_.length;y++){let v=_.get(y);if(v.hidden)qa(v.numGlyphs,m);else{let x=g[y];if(!x)qa(v.numGlyphs,m);else for(let b=0;b<v.numGlyphs;b++)Dl(m,x.shiftedAnchor,x.angle)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function cz(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function c_(e,t,i,r,a,n,o,s,l,u,h,c,d){var L;let p=d.context,f=p.gl,m=d.transform,g=s==="map",_=l==="map",y=s!=="viewport"&&i.layout.get("symbol-placement")!=="point",v=g&&!_&&!y,x=!i.layout.get("symbol-sort-key").isConstant(),b=!1,w=d.getDepthModeForSublayer(0,ge.ReadOnly),T=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S=[],C=m.getCircleRadiusCorrection();for(let I of r){let E=t.getTile(I),D=E.getBucket(i);if(!D)continue;let P=a?D.text:D.icon;if(!(P!=null&&P.segments.get().length)||!P.hasVisibleVertices)continue;let R=P.programConfigurations.get(i.id),k=a||D.sdfIcons,B=a?D.textSizeData:D.iconSizeData,Z=_||m.pitch!==0,oe=d.useProgram(cz(k,a,D),R),pe=au(B,m.zoom),fe=d.getTerrainDataForTile(I),Ee,Te=[0,0],Ge,Ce,mt=null,yt;if(a){if(Ge=E.glyphAtlasTexture,Ce=f.LINEAR,Ee=E.glyphAtlasTexture.size,D.iconsInText){Te=E.imageAtlasTexture.size,mt=E.imageAtlasTexture;let ve=B.kind==="composite"||B.kind==="camera";yt=Z||d.data.rotating||d.data.zooming||ve?f.LINEAR:f.NEAREST}}else{let ve=i.layout.get("icon-size").constantOr(0)!==1||D.iconsNeedLinear;Ge=E.imageAtlasTexture,Ce=k||d.data.rotating||d.data.zooming||ve||Z?f.LINEAR:f.NEAREST,Ee=E.imageAtlasTexture.size}let Yt=oi(E,1,d.transform.zoom),Nt=xp(g,d.transform,Yt),zt=oI(_,g,d.transform,Yt),Xe=Ir(m,E,n,o),Kt=d.getProjectionDataForTile(I),vi=T&&D.hasTextData(),Li=i.layout.get("icon-text-fit")!=="none"&&vi&&D.hasIconData(),H=i._unevaluatedLayout.hasValue("icon-offset"),xe=i.layout.get("symbol-height-anchor")==="ground";if(y){let ve=la();iI(ve,Nt);let be=d.terrain?(ne,Ze)=>d.terrain.getElevation(I,ne,Ze):void 0;lI(D,e,m,a,Nt,ve,_,u,i.layout.get("text-rotation-alignment")==="map",I.toUnwrapped(),Xe,be)}let ie=a&&T||Li,V=_?Nt:d.transform.clipSpaceToPixelsMatrix,ye=y||ie?nz:V,te=k&&i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1)!==0,ae;ae=k?D.iconsInText?WF(B.kind,pe,v,_,y,ie,m,ye,zt,Xe,Ee,Te,C,H,xe):_x(B.kind,pe,v,_,y,ie,m,ye,zt,Xe,a,Ee,te,C,H,xe):gx(B.kind,pe,v,_,y,ie,ye,zt,Xe,a,Ee,C,H,xe);let q={program:oe,buffers:P,uniformValues:ae,projectionData:Kt,atlasTexture:Ge,atlasTextureIcon:mt,atlasInterpolation:Ce,atlasInterpolationIcon:yt,isSDF:k,hasHalo:te};if(x&&D.canOverlap){b=!0;let ve=P.segments.get();for(let be of ve)S.push({segments:new Ke([be]),sortKey:be.sortKey,state:q,terrainData:fe})}else S.push({segments:P.segments,sortKey:0,state:q,terrainData:fe})}b&&S.sort((I,E)=>I.sortKey-E.sortKey);let F=(L=i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(null))!=null?L:1/0,A=i.layout.get("text-letter-spacing").constantOr(0)*24<0||F>1;for(let I of S){let E=I.state;p.activeTexture.set(f.TEXTURE0),E.atlasTexture.bind(E.atlasInterpolation,f.CLAMP_TO_EDGE),E.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),E.atlasTextureIcon&&E.atlasTextureIcon.bind(E.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let D=E.isSDF&&E.hasHalo;if(D){let P=E.uniformValues;P.u_is_halo=1,A&&(P.u_is_plain=0,d_(E.buffers,I.segments,i,d,E.program,w,h,c,P,E.projectionData,I.terrainData),P.u_is_halo=0,P.u_is_plain=1)}d_(E.buffers,I.segments,i,d,E.program,w,h,c,E.uniformValues,E.projectionData,I.terrainData),D&&!A&&(E.uniformValues.u_is_halo=0)}}function d_(e,t,i,r,a,n,o,s,l,u,h){let c=r.context,d=c.gl;a.draw(c,d.TRIANGLES,n,o,s,Ae.backCCW,l,h,u,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function dz(e,t,i,r){if(r.currentPass!=="translucent")return;let a=t.paint.get("circle-opacity"),n=t.paint.get("circle-stroke-width"),o=t.paint.get("circle-stroke-opacity"),s=!t.layout.get("circle-sort-key").isConstant();if(a.constantOr(1)===0&&(n.constantOr(1)===0||o.constantOr(1)===0))return;let l=r.context,u=l.gl,h=r.transform,c=r.getDepthModeForSublayer(0,ge.ReadOnly),d=Pe.disabled,p=r.colorModeForRenderPass(),f=[],m=h.getCircleRadiusCorrection();for(let g of i){let _=e.getTile(g),y=_.getBucket(t);if(!y)continue;let v=Ir(h,_,t.paint.get("circle-translate"),t.paint.get("circle-translate-anchor")),x=y.programConfigurations.get(t.id),b=r.useProgram("circle",x),w=y.layoutVertexBuffer,T=y.indexBuffer,S=r.getTerrainDataForTile(g),C={programConfiguration:x,program:b,layoutVertexBuffer:w,indexBuffer:T,uniformValues:bF(h,_,t,v,m),terrainData:S,projectionData:r.getProjectionDataForTile(g)};if(s){let F=y.segments.get();for(let A of F)f.push({segments:new Ke([A]),sortKey:A.sortKey,state:C})}else f.push({segments:y.segments,sortKey:0,state:C})}s&&f.sort((g,_)=>g.sortKey-_.sortKey);for(let g of f){let{programConfiguration:_,program:y,layoutVertexBuffer:v,indexBuffer:x,uniformValues:b,terrainData:w,projectionData:T}=g.state,S=g.segments;y.draw(l,u.TRIANGLES,c,d,p,Ae.backCCW,b,w,T,t.id,v,x,S,t.paint,r.transform.zoom,_)}}function pz(e,t,i,r,a){if(i.paint.get("heatmap-opacity")===0)return;let n=a.context;if(a.terrain){for(let o of r){let s=t.getTile(o);t.hasRenderableParent(o)||(a.currentPass==="offscreen"?gz(s,i,o,a):a.currentPass==="translucent"&&_z(e,i,o,a))}n.viewport.set([0,0,e.width,e.height])}else a.currentPass==="offscreen"?fz(e,t,i,r,a):a.currentPass==="translucent"&&mz(e,i,a)}function fz(e,t,i,r,a){let n=a.context,o=n.gl,s=a.transform,l=Pe.disabled,u=new tt([o.ONE,o.ONE],se.transparent,[!0,!0,!0,!0]);yz(n,e,i),n.clear({color:se.transparent});for(let h of r){if(t.hasRenderableParent(h))continue;let c=t.getTile(h),d=c.getBucket(i);if(!d)continue;let p=d.programConfigurations.get(i.id),f=a.useProgram("heatmap",p),m=a.getProjectionDataForTile(h,{applyTerrainMatrix:!1}),g=s.getCircleRadiusCorrection();f.draw(n,o.TRIANGLES,ge.disabled,l,u,Ae.backCCW,px(c,s.zoom,i.paint.get("heatmap-intensity"),g),null,m,i.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,i.paint,s.zoom,p)}n.viewport.set([0,0,e.width,e.height])}function mz(e,t,i){let r=i.context,a=r.gl;r.setColorMode(i.colorModeForRenderPass());let n=t.heatmapFbos.get(ml);n&&(r.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,n.colorAttachment.get()),r.activeTexture.set(a.TEXTURE1),vx(r,t).bind(a.LINEAR,a.CLAMP_TO_EDGE),i.useProgram("heatmapTexture").draw(r,a.TRIANGLES,ge.disabled,Pe.disabled,i.colorModeForRenderPass(),Ae.disabled,fx(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,i.transform.zoom))}function gz(e,t,i,r){let a=r.context,n=a.gl,o=Pe.disabled,s=new tt([n.ONE,n.ONE],se.transparent,[!0,!0,!0,!0]),l=e.getBucket(t);if(!l)return;let u=i.key,h=t.heatmapFbos.get(u);h||(h=yx(a,e.tileSize,e.tileSize),t.heatmapFbos.set(u,h)),a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,e.tileSize,e.tileSize]),a.clear({color:se.transparent});let c=l.programConfigurations.get(t.id),d=r.useProgram("heatmap",c,!r.data.isRenderingGlobe),p=r.getProjectionDataForTile(e.tileID),f=r.getTerrainDataForTile(i);d.draw(a,n.TRIANGLES,ge.disabled,o,s,Ae.disabled,px(e,r.transform.zoom,t.paint.get("heatmap-intensity"),1),f,p,t.id,l.layoutVertexBuffer,l.indexBuffer,l.segments,t.paint,r.transform.zoom,c)}function _z(e,t,i,r){let a=r.context,n=a.gl,o=r.transform;a.setColorMode(r.colorModeForRenderPass());let s=vx(a,t),l=i.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),s.bind(n.LINEAR,n.CLAMP_TO_EDGE);let h=r.getProjectionDataForTile(i,{applyTerrainMatrix:r.data.isRenderingGlobe});r.useProgram("heatmapTexture").draw(a,n.TRIANGLES,ge.disabled,Pe.disabled,r.colorModeForRenderPass(),Ae.disabled,fx(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,o.zoom),u.destroy(),t.heatmapFbos.delete(l)}function yz(e,t,i){let r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let a=i.heatmapFbos.get(ml);a?(r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=yx(e,t.width/4,t.height/4),i.heatmapFbos.set(ml,a))}function yx(e,t,i){let r=e.gl,a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA16F,t,i);let n=e.createFramebuffer(t,i,!1,!1);return n.colorAttachment.set(a),n}function vx(e,t){return t.colorRampTexture||(t.colorRampTexture=new ft(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function xx(e,t,i,r){let a=r.context,n=a.bindFramebuffer.get(),o=a.viewport.get(),[,,s,l]=o;return vz(e,s,l),a.viewport.set([0,0,s,l]),a.clear({color:se.transparent,depth:1,stencil:0}),r.invalidateTileClippingMasks(),r.renderTileClippingMasks(t,i),{compositeTarget:n,compositeViewport:o}}function vz(e,t,i){let r=e.context.gl;if(!e.layerOpacityFbo){let n=e.context.createFramebuffer(t,i,!0,!0),o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),n.colorAttachment.set(o),n.depthAttachment.set(e.context.createRenderbuffer(r.DEPTH_STENCIL,t,i)),e.layerOpacityFbo=n,e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}if(e.layerOpacityFbo.width===t&&e.layerOpacityFbo.height===i){e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);return}let a=e.layerOpacityFbo;r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(a.depthAttachment.get()),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,i),e.context.bindRenderbuffer.set(null),a.width=t,a.height=i,e.context.bindFramebuffer.set(a.framebuffer)}function bx(e,t,i,r,a){let n=a.context,o=n.gl;n.bindFramebuffer.set(i.compositeTarget),n.viewport.set(i.compositeViewport),n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),a.useProgram("layerOpacity").draw(n,o.TRIANGLES,ge.disabled,Pe.disabled,a.colorModeForRenderPass(),Ae.disabled,$F(t,0),null,null,r.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,r.paint,a.transform.zoom),a.invalidateTileClippingMasks()}function wx(e,t,i,r,a,n,o,s){let l=256;if(r.stepInterpolant){let u=e.getSource().maxzoom,h=n.canonical.z===u?Math.ceil(1<<s.transform.maxZoom-n.canonical.z):1;l=Y(Fb(a.maxLineLength/O*1024*h),256,t.maxTextureSize)}return o.gradient=X0({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:o.gradient||void 0,clips:a.lineClipsArray}),o.texture?o.texture.update(o.gradient):o.texture=new ft(t,o.gradient,i.RGBA),o.version=r.gradientVersion,o.texture}function xz(e,t,i,r,a){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(a)}function bz(e,t,i,r,a,n){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(n)}function wz(e,t,i,r,a,n,o){let s=a.gradients[r.id],l=s.texture;r.gradientVersion!==s.version&&(l=wx(e,t,i,r,a,n,s,o)),t.activeTexture.set(i.TEXTURE0),l.bind(r.stepInterpolant?i.NEAREST:i.LINEAR,i.CLAMP_TO_EDGE)}function Tz(e,t,i,r,a,n,o,s,l,u){let h=n.gradients[a.id],c=h.texture;a.gradientVersion!==h.version&&(c=wx(t,i,r,a,n,o,h,u)),i.activeTexture.set(r.TEXTURE0),c.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(i),s.updatePaintBuffers(l)}function Dz(e,t,i,r,a){if(a.currentPass!=="translucent")return;let n=i.paint.get("line-opacity"),o=i.paint.get("line-width"),s=i.paint.get("line-layer-opacity");if(n.constantOr(1)!==0&&o.constantOr(1)!==0&&s!==0)if(s<1){let l=xx(e,i,r,a);p_(e,t,i,r,a),bx(e,s,l,i,a)}else p_(e,t,i,r,a)}function p_(e,t,i,r,a){let n=a.getDepthModeForSublayer(0,ge.ReadOnly),o=a.colorModeForRenderPass(),s=i.paint.get("line-dasharray"),l=s.constantOr(1),u=i.paint.get("line-pattern"),h=u.constantOr(1),c=i.paint.get("line-gradient"),d=i.getCrossfadeParameters(),p;p=h?"linePattern":l&&c?"lineGradientSDF":l?"lineSDF":c?"lineGradient":"line";let f=a.context,m=f.gl,g=a.transform,_=!0;for(let y of r){let v=t.getTile(y);if(h&&!v.patternsLoaded())continue;let x=v.getBucket(i);if(!x)continue;let b=x.programConfigurations.get(i.id),w=f.program.get(),T=a.useProgram(p,b),S=_||T.program!==w,C=a.getTerrainDataForTile(y),F=u.constantOr(null),A=s==null?void 0:s.constantOr(null);if(F&&v.imageAtlas){let P=v.imageAtlas,R=P.patternPositions[F.to.toString()],k=P.patternPositions[F.from.toString()];R&&k&&b.setConstantPatternPositions(R,k)}else if(A){let P=i.layout.get("line-cap").constantOr(null)==="round",R=e.lineAtlas.getDash(A.to,P),k=e.lineAtlas.getDash(A.from,P);b.setConstantDashPositions(R,k)}let L=a.getProjectionDataForTile(y),I=g.getPixelScale(),E;h?(E=jF(g,v,i,I,d),xz(f,m,v,b,d)):l&&c?(E=NF(g,e.lineAtlas,v,i,I,d,x.lineClipsArray.length),Tz(e,t,f,m,i,x,y,b,d,a)):l?(E=VF(g,e.lineAtlas,v,i,I,d),bz(e,f,m,b,S,d)):c?(E=OF(g,v,i,I,x.lineClipsArray.length),wz(t,f,m,i,x,y,a)):E=cu(g,v,i,I);let D=a.stencilModeForClipping(y);T.draw(f,m.TRIANGLES,n,D,o,Ae.disabled,E,C,L,i.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,i.paint,a.transform.zoom,b,x.layoutVertexBuffer2),_=!1}}function Tx(e,t,i,r,a){if(!i||!(r!=null&&r.imageAtlas))return;let n=r.imageAtlas.patternPositions,o=n[i.to.toString()],s=n[i.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let l=a.getPaintProperty(t);o=n[l],s=n[l]}o&&s&&e.setConstantPatternPositions(o,s)}function Sz(e,t,i,r,a){let n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity"),s=i.paint.get("fill-layer-opacity");if(o.constantOr(1)===0||s===0)return;if(s<1){if(a.currentPass!=="translucent")return;let h=xx(e,i,r,a);f_(t,i,r,a),bx(e,s,h,i,a);return}let l=i.paint.get("fill-pattern"),u=a.opaquePassEnabledForLayer()&&!l.constantOr(1)&&n.constantOr(se.transparent).a===1&&o.constantOr(0)===1;if(u&&a.currentPass==="opaque"){let h=a.colorModeForRenderPass();Mp(t,i,r,a.getDepthModeForSublayer(1,ge.ReadWrite),h,!1,a)}else u&&a.currentPass==="translucent"?Dx(t,i,r,a):a.currentPass==="translucent"&&f_(t,i,r,a)}function f_(e,t,i,r){let a=r.colorModeForRenderPass();Mp(e,t,i,r.getDepthModeForSublayer(1,ge.ReadOnly),a,!1,r),Dx(e,t,i,r)}function Dx(e,t,i,r){if(!t.paint.get("fill-antialias"))return;let a=r.colorModeForRenderPass();Mp(e,t,i,r.getDepthModeForSublayer(t.getPaintProperty("fill-outline-color")?2:0,ge.ReadOnly),a,!0,r)}function Mp(e,t,i,r,a,n,o){var w;let s=o.context,l=s.gl,u="fill-pattern",h=t.paint.get(u),c=h==null?void 0:h.constantOr(1),d=t.getCrossfadeParameters(),p,f,m,g,_,y=o.transform,v=t.paint.get("fill-translate"),x=t.paint.get("fill-translate-anchor");n?(f=c&&!t.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(f=c?"fillPattern":"fill",p=l.TRIANGLES);let b=h.constantOr(null);for(let T of i){let S=e.getTile(T);if(c&&!S.patternsLoaded())continue;let C=S.getBucket(t);if(!C)continue;let F=(w=C.sdfPatterns[t.id])!=null?w:!1,A=C.programConfigurations.get(t.id),L=o.useProgram(f,A),I=o.getTerrainDataForTile(T);c&&(s.activeTexture.set(l.TEXTURE0),S.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),A.updatePaintBuffers(d)),Tx(A,u,b,S,t);let E=o.getProjectionDataForTile(T),D=Ir(y,S,v,x);n?(g=C.indexBuffer2,_=C.segments2,m=f==="fillOutlinePattern"&&c?vF(y,d,S,D,F):yF(D)):(g=C.indexBuffer,_=C.segments,m=c?dx(y,d,S,D,F):_F(D));let P=o.stencilModeForClipping(T);L.draw(s,p,r,P,a,Ae.backCCW,m,I,E,t.id,C.layoutVertexBuffer,g,_,t.paint,o.transform.zoom,A)}}function Ez(e,t,i,r){let a=t.paint.get("fill-extrusion-opacity");if(a!==0&&r.currentPass==="translucent"){let n=new ge(r.context.gl.LEQUAL,ge.ReadWrite,r.depthRangeFor3D);if(a===1&&!t.paint.get("fill-extrusion-pattern").constantOr(1)){let o=r.colorModeForRenderPass();Th(e,t,i,n,Pe.disabled,o,r)}else Th(e,t,i,n,Pe.disabled,tt.disabled,r),Th(e,t,i,n,r.stencilModeFor3D(),r.colorModeForRenderPass(),r)}}function Th(e,t,i,r,a,n,o){let s=o.context,l=s.gl,u="fill-extrusion-pattern",h=t.paint.get(u),c=h.constantOr(1),d=t.getCrossfadeParameters(),p=t.paint.get("fill-extrusion-opacity"),f=h.constantOr(null),m=o.transform;for(let g of i){let _=e.getTile(g),y=_.getBucket(t);if(!y)continue;let v=o.getTerrainDataForTile(g),x=y.programConfigurations.get(t.id),b=o.useProgram(c?"fillExtrusionPattern":"fillExtrusion",x);c&&(s.activeTexture.set(l.TEXTURE0),_.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),x.updatePaintBuffers(d));let w=o.getProjectionDataForTile(g);Tx(x,u,f,_,t);let T=Ir(m,_,t.paint.get("fill-extrusion-translate"),t.paint.get("fill-extrusion-translate-anchor")),S=t.paint.get("fill-extrusion-vertical-gradient"),C=c?dF(m,o.data.light,S,p,T,g,d,_):cx(m,o.data.light,S,p,T);b.draw(s,s.gl.TRIANGLES,r,a,n,Ae.backCCW,C,v,w,t.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,t.paint,o.transform.zoom,x,o.terrain&&y.centroidVertexBuffer)}}function Cz(e,t,i,r,a){if(a.currentPass!=="offscreen"&&a.currentPass!=="translucent")return;let n=a.context,{useSubdivision:o}=a.data,s=a.getDepthModeForSublayer(0,ge.ReadOnly),l=a.colorModeForRenderPass();if(a.currentPass==="offscreen")Pz(e,t,r,i,s,Pe.disabled,l,a),n.viewport.set([0,0,e.width,e.height]);else if(a.currentPass==="translucent")if(o){let[u,h,c]=a.stencilConfigForOverlapTwoPass(r);Dh(t,i,c,u,s,l,!1,a),Dh(t,i,c,h,s,l,!0,a)}else{let[u,h]=a.getStencilConfigForOverlapAndUpdateStencilID(r);Dh(t,i,h,u,s,l,!1,a)}}function Dh(e,t,i,r,a,n,o,s){let l=s.context,u=l.gl,h=[`#define NUM_ILLUMINATION_SOURCES ${t.paint.get("hillshade-highlight-color").values.length}`],c=s.useProgram("hillshade",null,!1,h),d=!s.data.moving;for(let p of i){let f=e.getTile(p),m=f.fbo;if(!m)continue;let g=s.getMeshFromTileID(p.canonical,o,!0,"raster"),_=s.getTerrainDataForTile(p);l.activeTexture.set(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,m.colorAttachment.get());let y=s.getProjectionDataForTile(p,{aligned:d});c.draw(l,u.TRIANGLES,a,r[p.overscaledZ],n,Ae.backCCW,CF(s.transform,f,t),_,y,t.id,g.vertexBuffer,g.indexBuffer,g.segments)}}function Pz(e,t,i,r,a,n,o,s){let l=s.context,u=l.gl,h=r.paint.get("resampling")==="nearest"?u.NEAREST:u.LINEAR;for(let c of i){let d=t.getTile(c),p=d.dem;if(!(p!=null&&p.data)||!d.needsHillshadePrepare)continue;let f=p.dim+2,m=p.stride,g=p.getPixels();if(l.activeTexture.set(u.TEXTURE1),l.pixelStoreUnpackPremultiplyAlpha.set(!1),d.demTexture||(d.demTexture=e.getTileTexture(m)),d.demTexture){let y=d.demTexture;y.update(g,{premultiply:!1}),y.bind(u.NEAREST,u.CLAMP_TO_EDGE)}else d.demTexture=new ft(l,g,u.RGBA,{premultiply:!1}),d.demTexture.bind(u.NEAREST,u.CLAMP_TO_EDGE);l.activeTexture.set(u.TEXTURE0);let _=d.fbo;if(!_){let y=new ft(l,{width:f,height:f,data:null},u.RGBA);y.bind(h,u.CLAMP_TO_EDGE),_=d.fbo=l.createFramebuffer(f,f,!0,!1),_.colorAttachment.set(y.texture)}l.bindFramebuffer.set(_.framebuffer),l.viewport.set([0,0,f,f]),s.useProgram("hillshadePrepare").draw(l,u.TRIANGLES,a,n,o,Ae.disabled,PF(s.transform,d.tileID,p),null,null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),d.needsHillshadePrepare=!1}}function Az(e,t,i,r,a){if(a.currentPass!=="translucent"||!r.length)return;let{useSubdivision:n}=a.data,o=a.getDepthModeForSublayer(0,ge.ReadOnly),s=a.colorModeForRenderPass();if(n){let[l,u,h]=a.stencilConfigForOverlapTwoPass(r);Eh(e,t,i,h,l,o,s,!1,a),Eh(e,t,i,h,u,o,s,!0,a)}else{let[l,u]=a.getStencilConfigForOverlapAndUpdateStencilID(r);Eh(e,t,i,u,l,o,s,!1,a)}}let Sh=0;function Eh(e,t,i,r,a,n,o,s,l){var g;let u=l.context,h=u.gl,c=l.useProgram("colorRelief"),d=!l.data.moving,p=i.paint.get("resampling")==="nearest"?h.NEAREST:h.LINEAR,f=!0,m=0;for(let _ of r){let y=t.getTile(_),v=y.dem;if(!(v!=null&&v.data))continue;if(f){Sh||(Sh=h.getParameter(h.MAX_TEXTURE_SIZE));let S=Sh,{elevationTexture:C,colorTexture:F}=i.getColorRampTextures(u,S,v.getUnpackVector());u.activeTexture.set(h.TEXTURE1),C.bind(h.NEAREST,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE4),F.bind(h.LINEAR,h.CLAMP_TO_EDGE),f=!1,m=C.size[0]}let x=v.stride;u.activeTexture.set(h.TEXTURE0),(!y.demTexture||y.needsColorReliefPrepare)&&(u.pixelStoreUnpackPremultiplyAlpha.set(!1),y.demTexture||(y.demTexture=(g=e.getTileTexture(x))!=null?g:new ft(u,{width:x,height:x,data:null},h.RGBA)),y.demTexture.update(v.getPixels(),{premultiply:!1}),y.needsColorReliefPrepare=!1),y.demTexture.bind(p,h.CLAMP_TO_EDGE);let b=l.getMeshFromTileID(_.canonical,s,!0,"raster"),w=l.getTerrainDataForTile(_),T=l.getProjectionDataForTile(_,{aligned:d});c.draw(u,h.TRIANGLES,n,a[_.overscaledZ],o,Ae.backCCW,FF(i,y.dem,m),w,T,i.id,b.vertexBuffer,b.indexBuffer,b.segments)}}const Ch=[new M(0,0),new M(O,0),new M(O,O),new M(0,O)];function Mz(e,t,i,r){if(r.currentPass!=="translucent"||t.paint.get("raster-opacity")===0||!i.length)return;let a=e.getSource(),{useSubdivision:n}=r.data;if(a instanceof ko)zs(e,t,i,null,!1,!1,a.tileCoords,a.imageWarp,a.flippedWindingOrder,r,a.getMesh(r.context,n));else if(n){let[o,s,l]=r.stencilConfigForOverlapTwoPass(i);zs(e,t,l,o,!1,!0,Ch,Ga,!1,r),zs(e,t,l,s,!0,!0,Ch,Ga,!1,r)}else{let[o,s]=r.getStencilConfigForOverlapAndUpdateStencilID(i);zs(e,t,s,o,!1,!0,Ch,Ga,!1,r)}}function zs(e,t,i,r,a,n,o,s,l=!1,u,h=null){let c=i[i.length-1].overscaledZ,d=u.context,p=d.gl,f=u.useProgram("raster"),m=u.colorModeForRenderPass(),g=!u.data.moving,_=t.paint.get("raster-opacity"),y=t.paint.get("resampling")==="nearest"||t.paint.get("raster-resampling")==="nearest"?p.NEAREST:p.LINEAR,v=t.paint.get("raster-fade-duration"),x=!!u.terrain;for(let b of i){let w=u.getDepthModeForSublayer(b.overscaledZ-c,_===1?ge.ReadWrite:ge.ReadOnly,p.LESS),T=e.getTile(b);d.activeTexture.set(p.TEXTURE0),T.texture.bind(y,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(p.TEXTURE1);let{parentTile:S,parentScaleBy:C,parentTopLeft:F,fadeValues:A}=Iz(T,e,v,x);T.fadeOpacity=A.tileOpacity,S?(S.fadeOpacity=A.parentTileOpacity,S.texture.bind(y,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST)):T.texture.bind(y,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),T.texture.useMipmap&&d.extTextureFilterAnisotropic&&u.transform.pitch>u.data.anisotropicFilterPitch&&p.texParameterf(p.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);let L=u.getTerrainDataForTile(b),I=u.getProjectionDataForTile(b,{aligned:g}),E=jP(F,C,A.fadeMix,t,o,s),D=h!=null?h:u.getMeshFromTileID(b.canonical,a,n,"raster"),P=r?r[b.overscaledZ]:Pe.disabled;f.draw(d,p.TRIANGLES,w,P,m,l?Ae.frontCCW:Ae.backCCW,E,L,I,t.id,D.vertexBuffer,D.indexBuffer,D.segments)}}function Iz(e,t,i,r){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(i===0||r)return a;if(e.fadingParentID){let n=t.getLoadedTile(e.fadingParentID);if(!n)return a;let o=2**(n.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:n,parentScaleBy:o,parentTopLeft:[e.tileID.canonical.x*o%1,e.tileID.canonical.y*o%1],fadeValues:Fz(e,n,i)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:zz(e,i)}:a}function Fz(e,t,i){let r=ke(),a=(r-e.timeAdded)/i,n=(r-t.timeAdded)/i,o=e.fadingDirection===1,s=Y(a,0,1),l=Y(1-n,0,1),u=o?s:l;return{tileOpacity:u,parentTileOpacity:o?l:s,fadeMix:{opacity:1,mix:1-u}}}function zz(e,t){let i=Y((ke()-e.timeAdded)/t,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}function kz(e,t,i,r,a){let n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(o===0)return;let s=a.context,l=s.gl,u=a.transform,h=u.tileSize,c=i.paint.get("background-pattern");if(e.patternAtlas.isPatternMissing(c))return;let d=!c&&n.a===1&&o===1&&a.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.currentPass!==d)return;let p=Pe.disabled,f=a.getDepthModeForSublayer(0,d==="opaque"?ge.ReadWrite:ge.ReadOnly),m=a.colorModeForRenderPass(),g=a.useProgram(c?"backgroundPattern":"background"),_=r||Bo(u,{tileSize:h,terrain:a.terrain});c&&(s.activeTexture.set(l.TEXTURE0),e.patternAtlas.bind(s));let y=i.getCrossfadeParameters();for(let v of _){let x=a.getProjectionDataForTile(v),b=c?KF(o,e.patternAtlas,u,c,{tileID:v,tileSize:h},y):YF(o,n),w=a.getTerrainDataForTile(v),T=a.getMeshFromTileID(v.canonical,!1,!0,"raster");g.draw(s,l.TRIANGLES,f,p,m,Ae.backCCW,b,w,x,i.id,T.vertexBuffer,T.indexBuffer,T.segments)}}const Rz=new se(1,0,0,1),Lz=new se(0,1,0,1),Bz=new se(0,0,1,1),Oz=new se(1,0,1,1),jz=new se(0,1,1,1);function Vz(e){let t=e.transform.padding;m_(e,e.transform.height-(t.top||0),3,Rz),m_(e,t.bottom||0,3,Lz),g_(e,t.left||0,3,Bz),g_(e,e.transform.width-(t.right||0),3,Oz);let i=e.transform.centerPoint;Nz(e,i.x,e.transform.height-i.y,jz)}function Nz(e,t,i,r){Il(e,t-1,i-10,2,20,r),Il(e,t-10,i-1,20,2,r)}function m_(e,t,i,r){Il(e,0,t+i/2,e.transform.width,i,r)}function g_(e,t,i,r){Il(e,t-i/2,0,i,e.transform.height,r)}function Il(e,t,i,r,a,n){let o=e.context,s=o.gl,l=e.data.pixelRatio;s.enable(s.SCISSOR_TEST),s.scissor(t*l,i*l,r*l,a*l),o.clear({color:n}),s.disable(s.SCISSOR_TEST)}function Uz(e,t,i,r){for(let a of i)$z(e,t,a,r)}function $z(e,t,i,r){var y;let a=r.context,n=a.gl,o=r.useProgram("debug"),s=ge.disabled,l=Pe.disabled,u=r.colorModeForRenderPass(),h="$debug",c=r.getTerrainDataForTile(i);a.activeTexture.set(n.TEXTURE0);let d=((y=t.getTileByID(i.key).latestRawTileData)==null?void 0:y.byteLength)||0,p=Math.floor(d/1024),f=t.getTile(i).tileSize,m=512/Math.min(f,512)*(i.overscaledZ/r.transform.zoom)*.5,g=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(g+=` => ${i.overscaledZ}`),Gz(e,`${g} ${p}kB`);let _=r.getProjectionDataForTile(i);o.draw(a,n.TRIANGLES,s,l,tt.alphaBlended,Ae.disabled,l_(se.transparent,m),null,_,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(a,n.LINE_STRIP,s,l,u,Ae.disabled,l_(se.red),c,_,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Gz(e,t){e.initDebugOverlayCanvas();let i=e.debugOverlayCanvas,r=e.context.gl,a=e.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,i.width,i.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(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}function Zz(e,t){let i=null,r=Object.values(e._layers).flatMap(s=>s.source&&!s.isHidden(t)?[e.tileManagers[s.source]]:[]),a=r.filter(s=>s.getSource().type==="vector"),n=r.filter(s=>s.getSource().type!=="vector"),o=s=>{(!i||i.getSource().maxzoom<s.getSource().maxzoom)&&(i=s)};for(let s of a)o(s);if(!i)for(let s of n)o(s);return i}function qz(e,t,i){let r=i.context,a=r.gl,n=i.transform,o=tt.unblended,s=new ge(a.LEQUAL,ge.ReadWrite,[0,1]),l=t.tileManager.getRenderableTiles(),u=i.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 h of l){let c=t.getTerrainMesh(h.tileID,i.data.isRenderingGlobe),d=t.getTerrainData(h.tileID),p=n.getProjectionData({overscaledTileID:h.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),f=nF(t.getSkirtLength(n.zoom));u.draw(r,a.TRIANGLES,s,Pe.disabled,o,Ae.backCCW,f,d,p,"terrain",c.vertexBuffer,c.indexBuffer,c.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}function Wz(e,t,i,r){let{isRenderingGlobe:a}=r.data,n=r.context,o=n.gl,s=r.transform,l=r.colorModeForRenderPass(),u=r.getDepthModeFor3D(),h=r.useProgram("terrain");n.bindFramebuffer.set(null),n.viewport.set([0,0,e.width,e.height]);for(let c of i){let d=t.getTerrainMesh(c.tileID,a),p=e.renderToTexture.getTexture(c),f=t.getTerrainData(c.tileID);n.activeTexture.set(o.TEXTURE0),p.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_LINEAR);let m=t.getSkirtLength(s.zoom),g=s.calculateFogMatrix(c.tileID.toUnwrapped()),_=aF(m,g,r.data.sky,s.pitch,a),y=r.getProjectionDataForTile(c.tileID,{applyTerrainMatrix:!1});h.draw(n,o.TRIANGLES,u,Pe.disabled,l,Ae.backCCW,_,f,y,"terrain",d.vertexBuffer,d.indexBuffer,d.segments)}}function Hz(e,t,i){var c;let r=e.context,a=r.gl,[n,o,s,l]=i.bounds;r.setDirty();let u=t.getHeightMapFramebuffer(i.texture);r.viewport.set([0,0,i.width,i.height]),r.clear({color:se.transparent});let h=e.useProgram("terrainHeight",null,!0);for(let d of t.tileManager.getRenderableTiles()){let p=t.getTerrainData(d.tileID);if(!((c=p.tile)!=null&&c.dem))continue;let{canonical:f,wrap:m}=d.tileID,g=1/(1<<f.z),_=oF([(f.x*g+m-n)/(s-n),(f.y*g-o)/(l-o),g/(s-n),g/(l-o)]),y=t.getTerrainMesh(d.tileID,e.data.isRenderingGlobe);h.draw(r,a.TRIANGLES,ge.disabled,Pe.disabled,tt.unblended,Ae.disabled,_,p,null,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}u.colorAttachment.set(null)}function Xz(e,t,i,r,a){if(a.isRenderingToTexture){Yz(e,i,r[0],a);return}let{isRenderingGlobe:n,projectionShaderVariant:o}=a.data,{terrain:s}=a,l=a.context,u=i.implementation,h=a.transform,c=h.getProjectionDataForCustomLayer(n),d={farZ:h.farZ,nearZ:h.nearZ,fov:h.fov*Math.PI/180,modelViewProjectionMatrix:h.modelViewProjectionMatrix,projectionMatrix:h.projectionMatrix,shaderData:{variantName:o.name,vertexShaderPrelude:`const float PI = 3.141592653589793;
uniform mat4 u_projection_matrix;
${o.prelude.vertexSource}`,define:o.define},defaultProjectionData:c,getProjectionData:f=>{var m;return h.getProjectionData({overscaledTileID:new Ct(f.tileID.canonical.z,(m=f.tileID.wrap)!=null?m:0,f.tileID.canonical.z,f.tileID.canonical.x,f.tileID.canonical.y),aligned:f.aligned,applyGlobeMatrix:f.applyGlobeMatrix,applyTerrainMatrix:f.applyTerrainMatrix})},renderTerrainHeightMap:s&&a.currentPass==="offscreen"?f=>Hz(a,s,f):void 0},p=u.renderingMode?u.renderingMode:"2d";if(a.currentPass==="offscreen"){let f=u.prerender;f&&(l.setCustomLayerDefaults(),l.setColorMode(a.colorModeForRenderPass()),f.call(u,l.gl,d),l.setDirty(),e.setBaseState())}else if(a.currentPass==="translucent"){l.setCustomLayerDefaults(),l.setColorMode(a.colorModeForRenderPass()),l.setStencilMode(Pe.disabled);let f=p==="3d"?a.getDepthModeFor3D():a.getDepthModeForSublayer(0,ge.ReadOnly);l.setDepthMode(f),u.render(l.gl,d),l.setDirty(),e.setBaseState(),l.bindFramebuffer.set(null)}}function Yz(e,t,i,r){let a=r.context,n=a.bindFramebuffer.get(),o=a.viewport.get();a.setCustomLayerDefaults(),a.setColorMode(r.colorModeForRenderPass()),a.setDepthMode(ge.disabled),a.setStencilMode(Pe.disabled),t.implementation.renderToTerrainTile(a.gl,{tileID:{canonical:i.canonical,wrap:i.wrap},width:o[2],height:o[3]}),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(n),a.viewport.set(o)}function Kz(e,t){let i=t.context,r=i.gl,{sky:a,pixelRatio:n}=t.data,o=tz(a,t.transform,n),s=new ge(r.LEQUAL,ge.ReadWrite,[0,1]),l=Pe.disabled,u=t.colorModeForRenderPass();t.useProgram("sky").draw(i,r.TRIANGLES,s,l,u,Ae.disabled,o,null,void 0,"sky",e.vertexBuffer,e.indexBuffer,e.segments)}function Jz(e,t){let i=G_(e.position);sb(i,i);let r=Ii(new Float64Array(16));return e.anchor==="map"&&(Dr(r,r,t.rollInRadians),Wa(r,r,-t.pitchInRadians),Dr(r,r,t.bearingInRadians),Wa(r,r,t.center.lat*Math.PI/180),j_(r,r,-t.center.lng*Math.PI/180)),ub(i,i,r),i}function Qz(e,t){let i=t.context,r=i.gl,{sky:a,light:n}=t.data,o=t.useProgram("atmosphere"),s=new ge(r.LEQUAL,ge.ReadOnly,[0,1]),l=t.transform,u=Jz(n,l),h=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),c=Kr(l.worldSize,l.center.lat),d=Qv(l),p=ex(Pi(d)-c,c),f=a["atmosphere-blend"]*h.projectionTransition*p;if(f===0)return;let m=QF(u,f,d,c,l.inverseProjectionMatrix);o.draw(i,r.TRIANGLES,s,Pe.disabled,tt.alphaBlended,Ae.disabled,m,null,null,"atmosphere",e.vertexBuffer,e.indexBuffer,e.segments)}const ek={symbol:oz,circle:dz,heatmap:pz,line:Dz,fill:Sz,fillExtrusion:Ez,hillshade:Cz,colorRelief:Az,raster:Mz,background:kz,sky:Kz,atmosphere:Qz,custom:Xz,debug:Uz,debugPadding:Vz,terrainDepth:qz},__=id.maxOverzooming+id.maxUnderzooming+1,y_=1/2**16,tk={name:$v,define:Uv,prelude:Wi.projectionMercator};var ik=class{constructor(e){this.currentLayer=0,this.opaquePassCutoff=1/0,this.depthRangeFor3D=[0,1],this.isRenderingToTexture=!1,this.nextStencilID=1,this.tileClippingMaskIDs={},this.transform=e.transform,this.terrain=e.terrain,this.data=e.data,this.context=e.context,this.programCache=e.programCache,this.currentPass=e.currentPass,this.projection=e.projection}getProjectionDataForTile(e,t={}){var r;let i=this.transform.getProjectionData({overscaledTileID:e,aligned:t.aligned,applyGlobeMatrix:!this.isRenderingToTexture,applyTerrainMatrix:(r=t.applyTerrainMatrix)!=null?r:!0});return this.isRenderingToTexture||(i.uniformBufferKey=t.aligned?`${e.key}/aligned`:e.key),i}getTerrainDataForTile(e){var t,i;return this.isRenderingToTexture?null:(i=(t=this.terrain)==null?void 0:t.getTerrainData(e))!=null?i:null}getMeshFromTileID(e,t,i,r){return this.projection.getMeshFromTileID(this.context,e,t,i,r)}useProgram(e,t,i=!1,r=[]){return this.programCache.getProgram({name:e,programConfiguration:t,projectionShaderVariant:i?tk:this.data.projectionShaderVariant,showOverdrawInspector:this.data.showOverdrawInspector,useTerrain:this.terrain!==null,defines:r})}colorModeForRenderPass(){let e=this.context.gl;if(this.data.showOverdrawInspector){let t=.125;return new tt([e.CONSTANT_COLOR,e.ONE],new se(t,t,t,0),[!0,!0,!0,!0])}return this.currentPass==="opaque"?tt.unblended:tt.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return ge.disabled;let r=1-((1+this.currentLayer)*__+e)*y_;return new ge(i||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new ge(this.context.gl.LEQUAL,ge.ReadWrite,this.depthRangeFor3D)}setDepthRangeFor3D(e){this.depthRangeFor3D=[0,1-(e+2)*__*y_]}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}clearStencil(){this.nextStencilID=1,this.currentStencilSource=void 0,this.context.clear({stencil:0})}invalidateTileClippingMasks(){this.currentStencilSource=void 0}renderTileClippingMasks(e,t){if(this.currentStencilSource===e.source||!e.isTileClipped()||!(t!=null&&t.length))return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let i=this.context;i.setColorMode(tt.disabled),i.setDepthMode(ge.disabled);let r={};for(let a of t)r[a.key]=this.nextStencilID++;this.data.useSubdivision&&this.renderTileMasks(r,t,!0),this.renderTileMasks(r,t,!1),this.tileClippingMaskIDs=r}renderTileMasks(e,t,i){let r=this.context,a=r.gl,n=this.useProgram("clippingMask");for(let o of t){let s=e[o.key],l=this.getTerrainDataForTile(o),u=this.getMeshFromTileID(o.canonical,i,!0,"stencil"),h=this.getProjectionDataForTile(o);n.draw(r,a.TRIANGLES,ge.disabled,new Pe({func:a.ALWAYS,mask:0},s,255,a.KEEP,a.KEEP,a.REPLACE),tt.disabled,this.isRenderingToTexture?Ae.disabled:Ae.backCCW,null,l,h,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new Pe({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new Pe({func:t.EQUAL,mask:255},this.tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,i=e.sort((n,o)=>o.overscaledZ-n.overscaledZ),r=i[i.length-1].overscaledZ,a=i[0].overscaledZ-r+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();let n={};for(let o=0;o<a;o++)n[o+r]=new Pe({func:t.GEQUAL,mask:255},o+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=a,[n,i]}return[{[r]:Pe.disabled},i]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,i=e.sort((n,o)=>o.overscaledZ-n.overscaledZ),r=i[i.length-1].overscaledZ,a=i[0].overscaledZ-r+1;if(this.clearStencil(),a>1){let n={},o={};for(let s=0;s<a;s++)n[s+r]=new Pe({func:t.GREATER,mask:255},a+1+s,255,t.KEEP,t.KEEP,t.REPLACE),o[s+r]=new Pe({func:t.GREATER,mask:255},1+s,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=a*2+1,[n,o,i]}return this.nextStencilID=3,[{[r]:new Pe({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new Pe({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}},Qr,rk=(Qr=class{constructor(t){this.drawFunctions=ek,this.context=new J5(t),this.programCache=new rz(this.context),this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:Ii(new Float64Array(16)),renderTime:0},this.setup()}resize(t,i,r){this.width=Math.round(t*r),this.height=Math.round(i*r),this.context.viewport.set([0,0,this.width,this.height])}setup(){let t=this.context,i=new qr;i.emplaceBack(0,0),i.emplaceBack(O,0),i.emplaceBack(0,O),i.emplaceBack(O,O),this.tileExtentBuffer=t.createVertexBuffer(i,Ba.members),this.tileExtentSegments=Ke.simpleSegment(0,0,4,2);let r=new qr;r.emplaceBack(0,0),r.emplaceBack(O,0),r.emplaceBack(0,O),r.emplaceBack(O,O),this.debugBuffer=t.createVertexBuffer(r,Ba.members),this.debugSegments=Ke.simpleSegment(0,0,4,5);let a=new vT;a.emplaceBack(0,0,0,0),a.emplaceBack(O,0,O,0),a.emplaceBack(0,O,0,O),a.emplaceBack(O,O,O,O),this.rasterBoundsBuffer=t.createVertexBuffer(a,n5.members),this.rasterBoundsSegments=Ke.simpleSegment(0,0,4,2);let n=new qr;n.emplaceBack(0,0),n.emplaceBack(1,0),n.emplaceBack(0,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,Ba.members),this.viewportSegments=Ke.simpleSegment(0,0,4,2);let o=new IT;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let s=new Ki;s.emplaceBack(1,0,2),s.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s),this.tileExtentMesh=new wo(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);let l=new qr;l.emplaceBack(-1,-1),l.emplaceBack(1,-1),l.emplaceBack(1,1),l.emplaceBack(-1,1);let u=new Ki;u.emplaceBack(0,1,2),u.emplaceBack(0,2,3),this.skyMesh=new wo(t.createVertexBuffer(l,Ba.members),t.createIndexBuffer(u),Ke.simpleSegment(0,0,l.length,u.length))}_renderTilesDepthBuffer(t){let i=this.context,r=i.gl,a=t.transform,n=t.useProgram("depth"),o=t.getDepthModeFor3D(),s=Bo(a,{tileSize:a.tileSize});for(let l of s){let u=t.getTerrainDataForTile(l),h=t.getMeshFromTileID(l.canonical,!0,!0,"raster"),c=t.getProjectionDataForTile(l);n.draw(i,r.TRIANGLES,o,Pe.disabled,tt.disabled,Ae.backCCW,null,u,c,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}render(t,i,r){var c,d;if(this.context.gl.isContextLost())return;let a=new ik({transform:i,terrain:(c=t.map.terrain)!=null?c:null,data:r,context:this.context,programCache:this.programCache,currentPass:"offscreen",projection:t.projection});this.lineAtlas=t.lineAtlas,this.patternAtlas=t.patternAtlas,X5(this.context.frameUniformBuffer,i,r),t.imageManager.beginFrame(),q5(this.context);let n=t._order,o=t.tileManagers,s={},l={},u={};for(let p in o){let f=o[p];f.used&&f.prepare(this.context),s[p]=f.getVisibleCoordinates(!1),l[p]=s[p].slice().reverse(),u[p]=f.getVisibleCoordinates(!0).reverse()}a.opaquePassCutoff=1/0;for(let p=0;p<n.length;p++){let f=n[p];if(t._layers[f].is3D()){a.opaquePassCutoff=p;break}}this.maybeDrawDepth(a),this.renderToTexture&&(this.renderToTexture.prepareForRender(t,i.zoom,r.moving),a.opaquePassCutoff=0),a.currentPass="offscreen";for(let p of n){let f=t._layers[p];if(!f.hasOffscreenPass()||f.isHidden(i.zoom))continue;let m=l[f.source];(f.type==="custom"||m.length)&&this.renderLayer(this,o[f.source],f,m,a)}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}),a.clearStencil(),r.sky&&this.drawFunctions.sky(this.skyMesh,a),a.setDepthRangeFor3D(t._order.length),!this.renderToTexture)for(a.currentPass="opaque",a.currentLayer=n.length-1;a.currentLayer>=0;a.currentLayer--){let p=t._layers[n[a.currentLayer]];if(p.isHidden(i.zoom))continue;let f=o[p.source],m=s[p.source];a.renderTileClippingMasks(p,m),this.renderLayer(this,f,p,m,a)}a.currentPass="translucent";let h=!1;for(a.currentLayer=0;a.currentLayer<n.length;a.currentLayer++){let p=t._layers[n[a.currentLayer]];if(p.isHidden(i.zoom))continue;let f=o[p.source];if((d=this.renderToTexture)!=null&&d.renderLayer(p,t,a))continue;!a.opaquePassEnabledForLayer()&&!h&&(h=!0,r.isRenderingGlobe&&!a.terrain&&this._renderTilesDepthBuffer(a));let m=(p.type==="symbol"?u:l)[p.source];a.renderTileClippingMasks(p,s[p.source]),this.renderLayer(this,f,p,m,a)}if(r.isRenderingGlobe&&this.drawFunctions.atmosphere(this.skyMesh,a),r.showTileBoundaries){let p=Zz(t,i.zoom);p&&this.drawFunctions.debug(this,p,p.getVisibleCoordinates(),a)}r.showPadding&&this.drawFunctions.debugPadding(a),this.renderToTexture&&!r.moving&&this.clearRTTPool(),this.context.setDefault()}markTerrainDepthDirty(){this.terrainFacilitator.depthDirty=!0}maybeDrawDepth(t){if(!t.data.projectionShaderVariant||!t.terrain)return;let i=this.terrainFacilitator.matrix,r=t.transform.modelViewProjectionMatrix,a=this.terrainFacilitator.depthDirty;a||(a=!ob(i,r)),a||(a=t.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),a&&(tb(i,r),this.terrainFacilitator.renderTime=ke(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,t.terrain,t))}renderLayer(t,i,r,a,n){if(r.isHidden(n.transform.zoom)||r.type!=="background"&&r.type!=="custom"&&!(a||[]).length)return;let o=this.drawFunctions;q1(r)?o.symbol(t,i,r,a,n):aD(r)?o.circle(i,r,a,n):lD(r)?o.heatmap(t,i,r,a,n):kS(r)?o.line(t,i,r,a,n):YD(r)?o.fill(t,i,r,a,n):bS(r)?o.fillExtrusion(i,r,a,n):dD(r)?o.hillshade(t,i,r,a,n):_D(r)?o.colorRelief(t,i,r,a,n):tc(r)?o.raster(i,r,a,n):FC(r)?o.background(t,i,r,a,n):nu(r)&&o.custom(t,i,r,a,n)}saveTileTexture(t){let i=this._tileTextures[t.size[0]];i?i.length<Qr.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?i.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let i=this._tileTextures[t];return i&&i.length>0?i.pop():null}acquireRTT(t){let i=this.context.gl,r=this._rttObjectRecyclePool.pop();if(r)return r.size!==t&&(r.texture.update({width:t,height:t,data:null},{premultiply:!1,useMipmap:!0}),r.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),r.size=t),r;let a=new ft(this.context,{width:t,height:t,data:null},i.RGBA,{premultiply:!1,useMipmap:!0});return a.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:a,size:t}}bindRTT(t){let i=this.context.gl,r=t.size;if(!this._rttSharedFbo){let a=this.context.createFramebuffer(r,r,!0,!0),n=this.context.createRenderbuffer(i.DEPTH_STENCIL,r,r);a.depthAttachment.set(n),this._rttSharedFbo={fbo:a,depthRenderbuffer:n,size:r}}this._rttSharedFbo.size!==r&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,r,r),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=r,this._rttSharedFbo.fbo.height=r,this._rttSharedFbo.size=r),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}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 ft(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){var t,i,r,a;if(this._tileTextures){for(let n in this._tileTextures){let o=this._tileTextures[n];if(o)for(let s of o)s.destroy()}this._tileTextures={}}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.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&((i=this.tileExtentMesh.vertexBuffer)==null||i.destroy()),this.tileExtentMesh&&((r=this.tileExtentMesh.indexBuffer)==null||r.destroy()),(a=this.skyMesh)==null||a.destroy(),this.skyMesh=null,this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.destroy(),this.programCache.destroy(),this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:i}=this.context.gl;return this.width!==t||this.height!==i}},Qr.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50,Qr),ak=class extends Error{constructor(e,t){var i;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=(i=t==null?void 0:t.statusMessage)!=null?i:null}};function Ip(e,t){let i=!1,r=null,a,n=()=>{r=null,i&&(i=(e(...a),r=setTimeout(n,t),!1))};return(...o)=>(i=!0,a=o,r||n(),r)}var nk=class{constructor(e){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{var i;let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||"").split("/"):((i=[...t.keys()][0])!=null?i:"").split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let i=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:i,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 i=decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,""),r=i?`#${i}`:"",a=window.location.href.replace(/(#.+)?$/,r);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(),i=Math.round(this._map.getZoom()*100)/100,r=uS(this._map._camera.transform.worldCoordinateHelper,t),a=10**Math.ceil((i*Math.LN2+Math.log(512/r/.5))/Math.LN10),n=Math.round(t.lng*a)/a,o=Math.round(t.lat*a)/a,s=this._map.getBearing(),l=this._map.getPitch(),u="";if(u+=e?`/${n}/${o}/${i}`:`${i}/${o}/${n}`,(s||l)&&(u+=`/${Math.round(s*10)/10}`),l&&(u+=`/${Math.round(l)}`),this._hashName){let h=this._getHashParams();return h.set(this._hashName,u),`#${decodeURIComponent(h.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${u}`}_isValidHash(e){if(e.length<3||e.some(a=>isNaN(+a)))return!1;try{new W(+e[2],+e[1])}catch(a){return!1}let t=+e[0],i=+(e[3]||0),r=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&i>=-180&&i<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}};const Oo={linearity:.3,easing:md(0,0,.3,1)},ok=X({deceleration:2500,maxSpeed:1400},Oo),sk=X({deceleration:20,maxSpeed:1400},Oo),lk=X({deceleration:1e3,maxSpeed:360},Oo),uk=X({deceleration:1e3,maxSpeed:90},Oo),hk=X({deceleration:1e3,maxSpeed:360},Oo);var ck=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ke(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=ke();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=ke()-60,i=Math.max(0,e.length-2);for(;i>0&&e[i-1].time>=t;)i--;return e.slice(i)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2){this.clear();return}let i={zoom:0,bearing:0,pitch:0,roll:0,pan:new M(0,0),pinchAround:void 0,around:void 0};for(let{settings:n}of t)n.around&&(i.around=n.around),n.pinchAround&&(i.pinchAround=n.pinchAround);for(let{settings:n}of t.slice(1))i.zoom+=n.zoomDelta||0,i.bearing+=n.bearingDelta||0,i.pitch+=n.pitchDelta||0,i.roll+=n.rollDelta||0,n.panDelta&&i.pan._add(n.panDelta);if(!i.pan.mag()&&!i.zoom&&!i.bearing&&!i.pitch&&!i.roll){this.clear();return}let r=ke()-t[0].time,a={};if(i.pan.mag()){let n=Ln(i.pan.mag(),r,X({},ok,e||{})),o=i.pan.mult(n.amount/i.pan.mag()),s=this._map._camera.cameraHelper.handlePanInertia(o,this._map._camera.transform);a.center=s.easingCenter,a.offset=s.easingOffset,Rn(a,n)}if(i.zoom){let n=Ln(i.zoom,r,sk);a.zoom=ii(this._map.getZoom()+n.amount,this._map.getZoomSnap(),n.amount),Rn(a,n)}if(i.bearing){let n=Ln(i.bearing,r,lk);a.bearing=this._map.getBearing()+Y(n.amount,-179,179),Rn(a,n)}if(i.pitch){let n=Ln(i.pitch,r,uk);a.pitch=this._map.getPitch()+n.amount,Rn(a,n)}if(i.roll){let n=Ln(i.roll,r,hk);a.roll=this._map.getRoll()+Y(n.amount,-179,179),Rn(a,n)}if(a.zoom||a.bearing){let n=i.pinchAround===void 0?i.around:i.pinchAround;a.around=n?this._map.unproject(n):this._map.getCenter()}return this.clear(),X(a,{noMoveStart:!0})}};function Rn(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Ln(e,t,i){let{maxSpeed:r,linearity:a,deceleration:n}=i,o=Y(e*a/(t/1e3),-r,r),s=Math.abs(o)/(n*a);return{easing:i.easing,duration:s*1e3,amount:s/2*o}}var dk=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new e2(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ri(e.type,this._map,e))}mouseup(e){this._map.fire(new ri(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ri(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ri(e.type,this._map,e))}mouseover(e){this._map.fire(new ri(e.type,this._map,e))}mouseout(e){this._map.fire(new ri(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ls(e.type,this._map,e))}touchmove(e){this._map.fire(new ls(e.type,this._map,e))}touchend(e){this._map.fire(new ls(e.type,this._map,e))}touchcancel(e){this._map.fire(new ls(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},pk=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 ri(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ri("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}touchstart(e,t,i){if(this._clearLongPress(),this._touchActive=i.length>0,i.length!==1)return;this._longPressStart=t[0];let r=i[0];this._longPressTimer=setTimeout(()=>{this._longPressTimer=void 0;let a=new MouseEvent("contextmenu",{clientX:r.clientX,clientY:r.clientY,button:2,bubbles:!0,cancelable:!0});this._map.fire(new ri("contextmenu",this._map,a))},500)}touchmove(e,t,i){this._longPressTimer&&(i.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){this._touchActive?e.preventDefault():(this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ri(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault())}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},fk=class{constructor(e,t,i){this._map=e,this._tr=i,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&&(De.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=i,this._box||(this._box=De.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let a=Math.min(r.x,i.x),n=Math.max(r.x,i.x),o=Math.min(r.y,i.y),s=Math.max(r.y,i.y);this._box.style.transform=`translate(${a}px,${o}px)`,this._box.style.width=`${n-a}px`,this._box.style.height=`${s-o}px`}mouseupWindow(e,t){if(!this._active||e.button!==0)return;let i=this._startPos,r=t;if(this.reset(),De.suppressClick(),i.x===r.x&&i.y===r.y)this._fireEvent("boxzoomcancel",e);else{if(this._map.fire(new bf("boxzoomend",{originalEvent:e})),this._boxZoomEnd){this._boxZoomEnd(this._map,i,r,e);return}return{cameraAnimation:a=>a.fitScreenCoordinates(i,r,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)),De.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new bf(e,{originalEvent:t}))}};function sd(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 i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}function mk(e){let t=new M(0,0);for(let i of e)t._add(i);return t.div(e.length)}var gk=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,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(this.startTime===void 0&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=mk(t),this.touches=sd(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;let r=sd(i,t);for(let a in this.touches){let n=this.touches[a],o=r[a];(!o||o.dist(n)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),i.length===0){let r=!this.aborted&&this.centroid;if(this.reset(),r)return r}}},ld=class{constructor(e){this.singleTap=new gk(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){let r=this.singleTap.touchend(e,t,i);if(r){let a=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if((!a||!n)&&this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}},_k=class{constructor(e,t){this._tr=t,this._zoomIn=new ld({numTouches:1,numTaps:2}),this._zoomOut=new ld({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){let r=this._zoomIn.touchend(e,t,i),a=this._zoomOut.touchend(e,t,i),n=this._tr;if(r)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:o=>o.easeTo({duration:300,zoom:ii(n.zoom+1,o.getZoomSnap()),around:n.transform.isPointOnMapSurface(r)?n.unproject(r):void 0},{originalEvent:e})};if(a)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:o=>o.easeTo({duration:300,zoom:ii(n.zoom-1,o.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}},jo=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,delete this._startPoint,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._startPoint=Array.isArray(t)?t[0]:t,this._lastPoint=this._startPoint,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e)){this.reset(e);return}let r=Array.isArray(t)?t[0]:t;if(!(!this._moved&&r.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=r,this._move(i,r,this._startPoint)}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&De.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 yk={0:1,2:2};function vk(e,t){let i=yk[t];return e.buttons===void 0||(e.buttons&i)!==i}var Vo=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!vk(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}},xk=class{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}},bk=class{constructor(e=new Vo({checkCorrectEvent:()=>!0}),t=new xk){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){if(e instanceof MouseEvent)return t(e);if(typeof TouchEvent<"u"&&e instanceof TouchEvent)return i(e)}startMove(e){this._executeRelevantHandler(e,t=>{this.mouseMoveStateManager.startMove(t)},t=>{this.oneFingerTouchMoveStateManager.startMove(t)})}endMove(e){this._executeRelevantHandler(e,t=>{this.mouseMoveStateManager.endMove(t)},t=>{this.oneFingerTouchMoveStateManager.endMove(t)})}isValidStartEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidStartEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t))}isValidMoveEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidMoveEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t))}isValidEndEvent(e){return!!this._executeRelevantHandler(e,t=>this.mouseMoveStateManager.isValidEndEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t))}};function Fp(e,t,i){return t==="center"||!(e.bearingDelta||e.pitchDelta||e.rollDelta)?e:{...e,around:i}}const du=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=t=>{t.preventDefault()}};function wk({enable:e,clickTolerance:t}){return new jo({clickTolerance:t,move:(i,r)=>({around:r,panDelta:r.sub(i)}),activateOnStart:!0,moveStateManager:new Vo({checkCorrectEvent:i=>i.button===0&&!i.ctrlKey}),enable:e,assignEvents:du})}function Tk({enable:e,clickTolerance:t,minPixelCenterThreshold:i=100,rotateSpeed:r=.8},a,n,o){return new jo({clickTolerance:t,move:(s,l,u)=>{var p;if((n==null?void 0:n())==="pointer")return Fp({bearingDelta:(l.x-s.x)*r},"pointer",u);let h=a(),c=((p=o==null?void 0:o())!=null?p:"circular")==="circular";if(c&&Math.abs(h.y-s.y)>i)return{bearingDelta:q_(new M(s.x,l.y),l,h)};let d=(l.x-s.x)*r;return c&&l.y<h.y&&(d=-d),{bearingDelta:d}},moveStateManager:new Vo({checkCorrectEvent:s=>s.button===0&&s.ctrlKey||s.button===2&&!s.ctrlKey}),enable:e,assignEvents:du})}function Dk({enable:e,clickTolerance:t,pitchSpeed:i=-.5},r){return new jo({clickTolerance:t,move:(a,n,o)=>{var s;return Fp({pitchDelta:(n.y-a.y)*i},(s=r==null?void 0:r())!=null?s:"center",o)},moveStateManager:new Vo({checkCorrectEvent:a=>a.button===0&&a.ctrlKey||a.button===2}),enable:e,assignEvents:du})}function Sk({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r,a){return new jo({clickTolerance:t,move:(n,o,s)=>{var h;let l=r(),u=(o.x-n.x)*i;return o.y<l.y&&(u=-u),Fp({rollDelta:u},(h=a==null?void 0:a())!=null?h:"center",s)},moveStateManager:new Vo({checkCorrectEvent:n=>n.button===2&&n.ctrlKey}),enable:e,assignEvents:du})}var Ek=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new M(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active)if(this._shouldBePrevented(i.length))this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);else return e.preventDefault(),this._calculateTransform(e,t,i)}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);let r=sd(i,t),a=new M(0,0),n=new M(0,0),o=0;for(let l in r){let u=r[l],h=this._touches[l];h&&(a._add(u),n._add(u.sub(h)),o++,r[l]=u)}if(this._touches=r,this._shouldBePrevented(o)||!n.mag())return;let s=n.div(o);if(this._sum._add(s),!(this._sum.mag()<this._clickTolerance))return{around:a.div(o),panDelta:s}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},zp=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){if(!this._firstTwoTouches)return;e.preventDefault();let[r,a]=this._firstTwoTouches,n=ks(i,t,r),o=ks(i,t,a);if(!n||!o)return;let s=this._aroundCenter?null:n.add(o).div(2);return this._move([n,o],s,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;let[r,a]=this._firstTwoTouches,n=ks(i,t,r),o=ks(i,t,a);n&&o||(this._active&&De.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 ks(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}const v_=.1;function x_(e,t){return Math.log(e/t)/Math.LN2}var Ck=class extends zp{constructor(){super(),this._zoomRate=1,this._zoomThreshold=v_}setZoomRate(e){this._zoomRate=e!=null?e:1}setZoomThreshold(e){this._zoomThreshold=e!=null?e:v_}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let i=this._distance;if(this._distance=e[0].dist(e[1]),!(!this._active&&Math.abs(x_(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:x_(this._distance,i)*this._zoomRate,pinchAround:t}}};function b_(e,t){return e.angleWith(t)*180/Math.PI}var Pk=class extends zp{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,i){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:b_(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,i=b_(e,this._startVector);return Math.abs(i)<t}};function Ph(e){return Math.abs(e.y)>Math.abs(e.x)}var Ak=class extends zp{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,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Ph(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),a=e[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,a,i.timeStamp),this._valid)return this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+a.y)/2*-.5}}gestureBeginsVertically(e,t,i){if(this._valid!==void 0)return this._valid;let r=e.mag()>=2,a=t.mag()>=2;if(!r&&!a)return;if(!r||!a)return this._firstMove===void 0&&(this._firstMove=i),i-this._firstMove<100&&void 0;let n=e.y>0==t.y>0;return Ph(e)&&Ph(t)&&n}};const Mk={panStep:100,bearingStep:15,pitchStep:10};var Ik=class{constructor(e,t){this._tr=t;let i=Mk;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=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?i=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:o=>{let s=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:Fk,zoom:t?ii(s.zoom+t*(e.shiftKey?2:1),o.getZoomSnap()):s.zoom,bearing:s.bearing+i*this._bearingStep,pitch:s.pitch+r*this._pitchStep,offset:[-a*this._panStep,-n*this._panStep],center:s.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 Fk(e){return e*(2-e)}const w_=4.000244140625;var zk=class{constructor(e,t,i){this._onTimeout=r=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)},this._map=e,this._tr=i,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,i=ke(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,t!==0&&t%w_==0?this._type="wheel":t!==0&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*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=De.mousePos(this._map.getCanvas(),e),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(W.convert(i.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 o=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=o),typeof this._targetZoom=="number"&&(this._targetZoom+=o)}if(this._delta!==0){let o=this._type==="wheel"&&Math.abs(this._delta)>w_?this._wheelZoomRate:this._defaultZoomRate,s=2/(1+Math.exp(-Math.abs(this._delta*o)));this._delta<0&&s!==0&&(s=1/s);let l=typeof this._targetZoom=="number"?pt(this._targetZoom):e.scale,u=e.applyConstrain(e.getCameraLngLat(),_t(l*s)).zoom,h=this._map.getZoomSnap();if(this._type==="wheel"&&h>0){let c=ii(e.zoom,h);this._targetZoom=ii(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,i=this._startZoom,r=this._easing,a=!1,n;if(this._type==="wheel"&&i&&r){let o=ke()-this._lastWheelEventTime,s=Math.min((o+5)/200,1),l=r(s);n=We.number(i,t,l),s<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=Oh;if(this._prevEase){let i=this._prevEase,r=(ke()-i.start)/i.duration,a=i.easing(r+.01)-i.easing(r),n=.27/Math.sqrt(a*a+1e-4)*.01;t=md(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:ke(),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)}},kk=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()}},Rk=class{constructor(e,t){this._tr=t,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:ii(this._tr.zoom+(e.shiftKey?-1:1),i.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}},Lk=class{constructor(){this._tap=new ld({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e!=null?e:1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(!this._tapTime)this._tap.touchstart(e,t,i);else{let r=t[0],a=e.timeStamp-this._tapTime<500,n=this._tapPoint.dist(r)<30;!a||!n?this.reset():i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier)}}touchmove(e,t,i){if(!this._tapTime)this._tap.touchmove(e,t,i);else if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;let r=t[0],a=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}touchend(e,t,i){if(this._tapTime)this._swipePoint&&i.length===0&&this.reset();else{let r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Bk=class{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}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()}},Ok=class{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;let{aroundCenter:a=!0}=e;this._defaultMovement=a?"circular":"linear",this.around="center",this.movement=this._defaultMovement}enable(e){var i,r;let t=typeof e=="object"?e:{};this.around=(i=t.around)!=null?i:"center",this.movement=t.around==="pointer"?"linear":(r=t.movement)!=null?r:this._defaultMovement,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()}},jk=class{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,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()}},Vk=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=De.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);let a=document.createElement("div");a.className="maplibregl-mobile-message",a.textContent=i,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 wt("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},Nk=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(M.convert(e),this._camera.terrain)}};const Rs=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;var Uk=class extends ua{};function Ah(e){var t;return((t=e.panDelta)==null?void 0:t.mag())||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var $k=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,i){this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this._rotationPivot=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 o=a.type==="renderFrame"?void 0:a,s={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(Ub(a,n||a.type)){let g=De.mousePos(this._map.getCanvas(),a);m=p[n||a.type](a,g)}else if(Nb(a,n||a.type)){let g=a.touches,_=this._getMapTouches(g),y=De.touchPos(this._map.getCanvas(),_);m=p[n||a.type](a,y,_)}else $b(n||a.type)||(m=p[n||a.type](a));this.mergeHandlerResult(s,l,m,d,o),m!=null&&m.needsRenderFrame&&this._triggerRenderFrame()}(m||p.isActive())&&(u[d]=p)}let h={};for(let d in this._previousActiveHandlers)u[d]||(h[d]=o);this._previousActiveHandlers=u,(Object.keys(h).length||Ah(s))&&(this._changes.push([s,l,h]),this._triggerRenderFrame()),(Object.keys(u).length||Ah(s))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=s;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=e,this._camera=t,this._transformProvider=new Nk(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ck(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);let r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[a,n,o]of this._listeners)a.addEventListener(n,a===this._ownerDocument?this.handleWindowEvent:this.handleEvent,o)}destroy(){for(let[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){let t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new dk(t,e));let r=t.boxZoom=new fk(t,e,this._transformProvider);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();let a=t.cooperativeGestures=new Vk(t,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();let n=new _k(t,this._transformProvider),o=new Rk(t,this._transformProvider);t.doubleClickZoom=new kk(o,n),this._add("tapZoom",n),this._add("clickZoom",o),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let s=new Lk;this._add("tapDragZoom",s);let l=t.touchPitch=new Ak(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let u=()=>this._camera.transform.centerPoint,h=()=>t.dragRotate.around,c=Tk(e,u,h,()=>t.dragRotate.movement),d=Dk(e,h),p=Sk(e,u,h);t.dragRotate=new Ok(e,c,d,p),this._add("mouseRotate",c,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",p,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable(e.dragRotate);let f=wk(e),m=new Ek(e,t);t.dragPan=new Bk(i,f,m),this._add("mousePan",f),this._add("touchPan",m,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let g=new Pk,_=new Ck;t.touchZoomRotate=new jk(i,_,g,s),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new pk(t,e),["touchPan"]);let y=t.scrollZoom=new zk(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let v=t.keyboard=new Ik(t,this._transformProvider);this._add("keyboard",v),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),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!!Rs(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(let r in e)if(r!==i&&!(t!=null&&t.includes(r)))return!0;return!1}_getMapTouches(e){let t=[];for(let i of e){let r=i.target;this._el.contains(r)&&t.push(i)}return t}mergeHandlerResult(e,t,i,r,a){if(!i)return;X(e,i);let n={handlerName:r,originalEvent:i.originalEvent||a};i.zoomDelta!==void 0&&(t.zoom=n),i.panDelta!==void 0&&(t.drag=n),i.rollDelta!==void 0&&(t.roll=n),i.pitchDelta!==void 0&&(t.pitch=n),i.bearingDelta!==void 0&&(t.rotate=n)}_applyChanges(){let e={},t={},i={};for(let[r,a,n]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new M(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),r.around!==void 0&&(e.around=r.around),r.pinchAround!==void 0&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),X(t,a),X(i,n);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){let r=this._map.terrain;if(!Ah(e)){this._fireEvents(t,i,!0);return}let a=this._camera.getTransformForUpdate();if(this._camera.stop(!0),this._turnsAroundPivot(e,t)){this._orbitRotationPivot(a,e,r),this._commitFrame(a,e,t,i);return}let{panDelta:n,zoomDelta:o,bearingDelta:s,pitchDelta:l,rollDelta:u}=e;o>0&&this._terrainGesture.inFlight&&this._camera.moveCenterOntoTerrain(a,o);let{around:h,aroundOnSurface:c}=this._resolveAround(e,r,a),d=r?this._terrainGestureElevation(r,h,c,a,t):void 0,p={panDelta:n,zoomDelta:o,rollDelta:u,pitchDelta:l,bearingDelta:s,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:r,tr:a,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:n}),this._commitFrame(a,e,t,i)}_commitFrame(e,t,i,r){this._camera.applyUpdatedTransform(e),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,r,!0)}_turnsAroundPivot(e,t){return e.around?!t.drag&&!t.zoom:!1}_orbitRotationPivot(e,t,i){var u;i&&!this._terrainGesture.inFlight&&(this._terrainGesture.inFlight=!0,this._camera.holdElevation(e,"gesture"));let{panDelta:r,zoomDelta:a,bearingDelta:n,pitchDelta:o,rollDelta:s,around:l}=t;(u=this._rotationPivot)!=null||(this._rotationPivot=this._camera.captureRotationPivot(e,l)),this._camera.orbitRotationPivot(e,this._rotationPivot,{panDelta:r,zoomDelta:a,bearingDelta:n,pitchDelta:o,rollDelta:s,around:l})||(this._rotationPivot=null)}_resolveAround(e,t,i){let r=e.pinchAround===void 0?e.around:e.pinchAround;return r||(r=this._camera.transform.centerPoint),t&&!i.isPointOnMapSurface(r)?{around:i.centerPoint,aroundOnSurface:!1}:{around:r,aroundOnSurface:!0}}_terrainGestureElevation(e,t,i,r,a){if(!i)return;if(this._terrainGesture.anchorCenterElevation!==r.elevation&&(a.drag||a.zoom)){let o=r.screenTerrainPointToMercatorCoordinate(t,e);this._terrainGesture.anchorElevation=o?o.z:void 0,this._terrainGesture.anchorCenterElevation=r.elevation}let n=this._terrainGesture.anchorElevation;if(n!=null&&!(t.distSqr(r.centerPoint)<.01)&&!(n-r.elevation>=.9*(r.getCameraAltitude()-r.elevation)))return n}_computePreZoomAroundLoc(e,t,i,r){if(t.distSqr(e.centerPoint)<.01)return e.center;let a=i?t.sub(i):t;return r===void 0?e.screenPointToLocation(a):e.screenPointToLocationAtElevation(a,r)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:a,panDelta:n}){let o=this._camera.cameraHelper;o.handleMapControlsRollPitchBearingZoom(i,t),!e&&!o.useGlobeControls&&!t.isPointOnMapSurface(i.around)?n&&t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n))):e?this._terrainGesture.inFlight?!o.useGlobeControls&&i.aroundElevation===void 0&&a.drag&&n?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n))):o.handleMapControlsPan(i,t,r):(this._terrainGesture.inFlight=!0,this._camera.holdElevation(t,"gesture"),o.handleMapControlsPan(i,t,r)):o.handleMapControlsPan(i,t,r)}_fireEvents(e,t,i){let r=Rs(this._eventsInProgress),a=Rs(e),n={};for(let h in e){let{originalEvent:c}=e[h];this._eventsInProgress[h]||(n[`${h}start`]=c),this._eventsInProgress[h]=e[h]}!r&&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 o={},s;for(let h in this._eventsInProgress){let{handlerName:c,originalEvent:d}=this._eventsInProgress[h];this._handlersById[c].isActive()||(delete this._eventsInProgress[h],s=t[c]||d,o[`${h}end`]=s)}for(let h in o)this._fireEvent(h,o[h]);let l=Rs(this._eventsInProgress),u=(r||a)&&!l;if(u&&this._terrainGesture.inFlight){let h=this._camera.releaseElevation();this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this._camera.applyTransformChange(c=>{this._map.getCenterClampedToGround()&&(this._map.terrain?this._camera.putCenterBackOnTerrain(c,this._map.terrain,h):c.setElevation(0))})}if(i&&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:s})):(this._fireEvent("moveend",s),c(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}u&&(this._rotationPivot=null)}_fireEvent(e,t){this._camera.fire(new ee(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new Uk("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}},Gk=class{constructor(e,t,i){this.holder=e,this.lift=null,this._terrainChanged=!1,this._dem=t?"awaiting":"loaded",this.keepsTerrainBelowMaxZoomForCenter=i}get tookDem(){return this._dem==="taken"}noteTerrainChange(){this._terrainChanged=!0}take(e,t){let i=!1;if(this._terrainChanged&&(this._terrainChanged=!1,t.getElevationAndDEMStateForLngLat(e.center,e).demState!=="loaded"&&(e.setElevation(0),this._dem="awaiting",i=!0)),this._dem!=="awaiting")return i;let r=t.getDrawnElevationForLngLat(e.center,!0);if(r!==void 0)return e.setElevation(r),this._dem="taken",!0;let a=t.getDrawnElevationForLngLat(e.center);return a===void 0||a===e.elevation?i:(e.setElevation(a),!0)}};const T_=.01;var Zk=class extends Ft{constructor(e){var t,i,r;super(),this._elevationHold=null,this._renderFrameCallback=()=>{let a=Math.min((ke()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=Hs(),this.cameraHelper=new eo,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=(t=e.centerClampedToGround)!=null?t:!0,this.transformCameraUpdate=(i=e.transformCameraUpdate)!=null?i:null,this._stopHandlers=(r=e.stopHandlers)!=null?r:(()=>{}),this.on("moveend",()=>{delete this._requestedCameraState})}setTerrain(e){var t;this.terrain=e,e&&((t=this._elevationHold)==null||t.noteTerrainChange()),this.applyTerrainChange()}migrateProjection(e,t){if(e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t,this._requestedCameraState){let i=e.clone();i.apply(this._requestedCameraState,!0),this._requestedCameraState=i}}getCenter(){return new W(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,i){return e=M.convert(e).mult(-1),this.panTo(this.transform.center,X({offset:e},t),i)}panTo(e,t,i){return this.easeTo(X({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(X({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(ii(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(ii(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.applyTransformChange(i=>i.setFov(e)),this.fire(new ee("movestart",t)).fire(new ee("move",t)).fire(new ee("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,i){return this.easeTo(X({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,X({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(X({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=mr.convert(e).adjustAntiMeridian();let i=(t==null?void 0:t.bearing)||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,t,i,r){let a={top:0,bottom:0,right:0,left:0};if(r=X({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},r),typeof r.padding=="number"){let d=r.padding;r.padding={top:d,bottom:d,right:d,left:d}}let n=X(a,r.padding);r.padding=n;let o=this.transform,s=new mr(e,t),l={top:0,bottom:0,right:0,left:0},u=r.absolutePadding?l:n,h=r.absolutePadding?n:X(l,o.padding),c=this.cameraHelper.cameraForBoxAndBearing(r,u,h,s,i,o);if(c)return this._zoomSnap&&(c.zoom=ii(c.zoom,this._zoomSnap,-1)),r.absolutePadding?{...c,padding:n}:c}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,t,i,r,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(M.convert(e)),this.transform.screenPointToLocation(M.convert(t)),i,r),r,a)}_fitInternal(e,t,i){return e?(t=X(e,t),t.absolutePadding?(t.padding=e.padding,delete t.absolutePadding):delete t.padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop(),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=ii(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,a=!1,n=!1,o=i.zoom;if(this.terrain&&this.getCenterClampedToGround()){let{elevation:l,demState:u}=this.terrain.getElevationAndDEMStateForLngLat(e.center?W.convert(e.center):i.center,i);u!=="loading"&&i.setElevation(l)}this.cameraHelper.handleJumpToCenterZoom(i,e);let s=i.zoom!==o;return e.elevation!==void 0&&i.elevation!==+e.elevation&&i.setElevation(+e.elevation),e.bearing!==void 0&&i.bearing!==+e.bearing&&(r=!0,i.setBearing(+e.bearing)),e.pitch!==void 0&&i.pitch!==+e.pitch&&(a=!0,i.setPitch(+e.pitch)),e.roll!==void 0&&i.roll!==+e.roll&&(n=!0,i.setRoll(+e.roll)),e.padding!=null&&!i.isPaddingEqual(e.padding)&&i.setPadding(e.padding),this.applyUpdatedTransform(i),this.fire(new ee("movestart",t)).fire(new ee("move",t)),s&&this.fire(new ee("zoomstart",t)).fire(new ee("zoom",t)).fire(new ee("zoomend",t)),r&&this.fire(new ee("rotatestart",t)).fire(new ee("rotate",t)).fire(new ee("rotateend",t)),a&&this.fire(new ee("pitchstart",t)).fire(new ee("pitch",t)).fire(new ee("pitchend",t)),n&&this.fire(new ee("rollstart",t)).fire(new ee("roll",t)).fire(new ee("rollend",t)),this.fire(new ee("moveend",t))}calculateAnchoredCameraOptions(e){var n;let t=this.transform.clone(),i=W.convert(e.anchorLocation),r=M.convert(e.anchorScreenPoint),a={panDelta:r.sub(this.transform.locationToScreenPoint(i,this.terrain)),zoomDelta:e.zoom===void 0?0:e.zoom-t.zoom,bearingDelta:0,pitchDelta:0,rollDelta:0,around:r,aroundElevation:(n=this.terrain)==null?void 0:n.getElevationForLngLat(i,t)};return this.cameraHelper.handleMapControlsRollPitchBearingZoom(a,t),this.cameraHelper.handleMapControlsPan(a,t,i),{center:t.center,zoom:t.zoom}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){let n=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,r);return{center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:i,pitch:r,roll:a}}easeTo(e,t){this._stop(!1,e.easeId),e=X({offset:[0,0],duration:500,easing:Oh},e),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=ii(e.zoom,this._zoomSnap)),(e.animate===!1||!e.essential&&Xt.prefersReducedMotion)&&(e.duration=0);let i=this.getTransformForUpdate(),r=this.getBearing(),a=i.pitch,n=i.roll,o=e.bearing===void 0?r:this._normalizeBearing(e.bearing,r),s=e.pitch===void 0?a:+e.pitch,l=e.roll===void 0?n:this._normalizeBearing(e.roll,n),u=e.padding===void 0?i.padding:e.padding,h=M.convert(e.offset),c,d;e.around&&(c=W.convert(e.around),d=i.locationToScreenPoint(c));let p={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},f=this.cameraHelper.handleEaseTo(i,{bearing:o,pitch:s,roll:l,padding:u,around:c,aroundPoint:d,offsetAsPoint:h,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||(this._rotating=r!==o),this._pitching||(this._pitching=s!==a),this._rolling||(this._rolling=l!==n),this._padding=!i.isPaddingEqual(u),this._zooming||(this._zooming=f.isZooming),this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,p,{tr:i,center:f.elevationCenter,freeze:e.freezeElevation}),this._ease(m=>{f.easeFunc(m),this.terrain&&!e.freezeElevation&&this._updateElevation(m,i),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},m=>{this._afterEase(t,m,e.freezeElevation)},e),this}_prepareEase(e,t,i={},r){this._moving=!0,this.terrain&&r&&(this._prepareElevation(r.center,r.tr),r.freeze&&this.holdElevation(r.tr,"animation")),!t&&!i.moving&&this.fire(new ee("movestart",e)),this._zooming&&!i.zooming&&this.fire(new ee("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new ee("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new ee("pitchstart",e)),this._rolling&&!i.rolling&&this.fire(new ee("rollstart",e))}_prepareElevation(e,t){this._elevationCenter=e,this._elevationStart=t.elevation;let{elevation:i,demState:r}=this.terrain.getElevationAndDEMStateForLngLat(e,t);this._elevationTarget=r==="loading"?t.elevation:i,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{elevation:i,demState:r}=this.terrain.getElevationAndDEMStateForLngLat(this._elevationCenter,t),a=r==="loading"?this._elevationTarget:i;if(e<1&&a!==this._elevationTarget){let n=this._elevationTarget-this._elevationStart,o=(a-(n*e+this._elevationStart))/(1-e);this._elevationStart+=e*(n-o),this._elevationTarget=a}this.getCenterClampedToGround()&&t.setElevation(We.number(this._elevationStart,this._elevationTarget,e))}holdElevation(e,t){this.elevationFreeze=!0;let i=!!this.terrain&&this.getCenterClampedToGround()&&this.terrain.getElevationAndDEMStateForLngLat(e.center,e).demState!=="loaded",r=this.terrain?this._terrainHeightAboveMaxZoomForCenter(e):void 0;this._elevationHold=new Gk(t,i,r!==void 0&&r<=T_)}releaseElevation(){var t,i;let e=(i=(t=this._elevationHold)==null?void 0:t.tookDem)!=null?i:!1;return this.elevationFreeze=!1,this._elevationHold=null,e}putCenterBackOnTerrain(e,t,i){if(i&&t.getDrawnElevationForLngLat(e.center,!0)===void 0){e.setElevation(t.getElevationForLngLat(e.center,e));let r=this._raiseCameraByPitchAndZoom(e);r!==e&&e.apply(r,!1)}else e.recalculateZoomAndCenter(t)}_takeLandedElevation(e){return!this._elevationHold||!this.terrain||!this.getCenterClampedToGround()?!1:this._elevationHold.take(e,this.terrain)}applyTerrainChange(){var r;if(this.elevationFreeze){let a=this._requestedCameraState;((r=this._elevationHold)==null?void 0:r.holder)==="gesture"&&a&&this._takeLandedElevation(a)&&this.applyUpdatedTransform(a);return}let e=this.transform;if(e.setMinElevationForCurrentTile(this.terrain?this.terrain.getMinTileElevationForLngLatZoom(e.center,e.tileZoom):0),!this.getCenterClampedToGround())return;if(!this.terrain){e.setElevation(0);return}let{elevation:t,demState:i}=this.terrain.getElevationAndDEMStateForLngLat(e.center,e);i!=="loading"&&e.setElevation(t)}getTransformForUpdate(){return!this.transformCameraUpdate&&!this.terrain?this.transform:(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState)}_keepCameraAboveTerrain(e){let t=this._elevationHold;if(!this.terrain||!t||e.pitch>=90||!this.getCenterClampedToGround()||e.getClippingPlane())return this._raiseCameraByPitchAndZoom(e);let i=t.holder==="gesture",r=t.lift&&t.lift.heldElevation+t.lift.height===e.elevation?t.lift:{heldElevation:e.elevation,height:0},a=this._terrainHeightAboveMaxZoomForCenter(e);a!==void 0&&a<=T_&&(t.keepsTerrainBelowMaxZoomForCenter=!0);let n=t.keepsTerrainBelowMaxZoomForCenter&&a!==void 0?a:-1/0,o=i?this._terrainHeightAboveCamera(e):-1/0,s=Math.max(0,Math.max(o,n)+r.height);return s!==r.height&&e.setElevation(r.heldElevation+s),t.lift=s>0?{heldElevation:r.heldElevation,height:s}:null,i?e:this._raiseCameraByPitchAndZoom(e)}_raiseCameraByPitchAndZoom(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90||e.getClippingPlane())return e;let t=e.getCameraLngLat(),i=this.terrain?this._terrainHeightAboveCamera(e):-e.getCameraAltitude();if(i<=0)return e;let r=e.clone();for(let a=0;a<3&&i>0;a++){let{zoom:n,pitch:o}=r.calculateCameraOptionsFromTo(t,r.getCameraAltitude()+i,r.center,r.elevation);r.setZoom(n),r.setPitch(o),i=this.terrain?this._terrainHeightAboveCamera(r):-r.getCameraAltitude()}return r}_terrainHeightAboveCamera(e){let t=this.terrain.getElevationForLngLat(e.getCameraLngLat(),e)-e.getCameraAltitude(),i=e.getClippingPlane()?null:this.terrain.getCoverageIndex();if(!i)return t;let[r,a,n,o]=e.getCameraFrustum().points;for(let s=0;s<=2;s++){let l=s/2;for(let u=0;u<=2;u++){let h=u/2,c=(1-h)*(1-l),d=h*(1-l),p=h*l,f=(1-h)*l,m=c*r[0]+d*a[0]+p*n[0]+f*o[0],g=c*r[1]+d*a[1]+p*n[1]+f*o[1],_=c*r[2]+d*a[2]+p*n[2]+f*o[2],y=nn(i,this.terrain.exaggeration,m,g,e.worldCoordinateHelper.wraps);y.covered&&(t=Math.max(t,y.elevation-_))}}return t}_terrainHeightAboveMaxZoomForCenter(e){let t=this.terrain.getCoverageIndex();if(!t)return;let i=e.worldCoordinateHelper,r=e.getCameraLngLat(),a=i.worldFromLngLat(r.lng,r.lat),n=i.worldFromLngLat(e.center.lng,e.center.lat),o=pt(e.zoom-e.maxZoom),s=nn(t,this.terrain.exaggeration,Cr(a.x,n.x,o),Cr(a.y,n.y,o),i.wraps);return s.covered?s.elevation-Cr(e.getCameraAltitude(),e.elevation,o):void 0}moveCenterOntoTerrain(e,t){if(!this.terrain||!this.getCenterClampedToGround()||e.getClippingPlane())return;let{center:i,elevation:r,zoom:a}=e;e.recalculateZoomAndCenter(this.terrain),(!(e.zoom>a-t&&e.zoom<e.maxZoom)||Math.abs(this.terrain.getElevationForLngLat(e.center,e)-e.elevation)>=1)&&(e.setZoom(a),e.setCenter(i),e.setElevation(r))}captureRotationPivot(e,t){if(!E_(e,t))return{point:e.centerPoint,location:e.center,distance:Ks(e,e.center)};let i=this.terrain?e.screenTerrainPointToMercatorCoordinate(t,this.terrain):null,r=i?i.toLngLat():e.screenPointToLocation(t);return i&&this.cameraHelper.useGlobeControls?{point:e.locationToScreenPoint(r),location:r,distance:Ks(e,r)}:{point:t,location:r,elevation:i==null?void 0:i.z,distance:Ks(e,r,i==null?void 0:i.z)}}orbitRotationPivot(e,t,i){var a;if(t.point.equals(e.centerPoint))return this.cameraHelper.handleMapControlsRollPitchBearingZoom(i,e),!0;let r=(a=this._turnAroundPivot(e,t,i))!=null?a:this._turnAroundPivot(e,t,{...i,pitchDelta:0,rollDelta:0});return r?(e.apply(r,!1),!0):(this.cameraHelper.handleMapControlsRollPitchBearingZoom(i,e),!1)}_turnAroundPivot(e,t,i){let r=e.clone();return this.cameraHelper.handleMapControlsRollPitchBearingZoom(i,r),r.pitch>=90||!E_(r,t.point)?null:qk(r,t)&&Wk(r,t)?r:null}applyUpdatedTransform(e){this._takeLandedElevation(e);let t=this._keepCameraAboveTerrain(e);if(!this.transformCameraUpdate){t!==this.transform&&this.transform.apply(t,!1);return}let i=t.clone(),{center:r,zoom:a,roll:n,pitch:o,bearing:s,elevation:l}=this.transformCameraUpdate(i);r&&i.setCenter(r),l!==void 0&&i.setElevation(l),a!==void 0&&i.setZoom(a),n!==void 0&&i.setRoll(n),o!==void 0&&i.setPitch(o),s!==void 0&&i.setBearing(s),this.transform.apply(l===void 0?i:this._raiseCameraByPitchAndZoom(i),!1)}applyTransformChange(e){let t=this._requestedCameraState!==void 0,i=this.getTransformForUpdate();e(i),this.applyUpdatedTransform(i),t||delete this._requestedCameraState}_fireMoveEvents(e){this.fire(new ee("move",e)),this._zooming&&this.fire(new ee("zoom",e)),this._rotating&&this.fire(new ee("rotate",e)),this._pitching&&this.fire(new ee("pitch",e)),this._rolling&&this.fire(new ee("roll",e))}_afterEase(e,t,i=!1){this._takeLandedElevation(this.transform);let r=this.releaseElevation();if(this.terrain&&i&&this.getCenterClampedToGround()&&this.putCenterBackOnTerrain(this.transform,this.terrain,r),this._easeId&&t&&this._easeId===t)return;delete this._easeId;let a=this._zooming,n=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,a&&this.fire(new ee("zoomend",e)),n&&this.fire(new ee("rotateend",e)),o&&this.fire(new ee("pitchend",e)),s&&this.fire(new ee("rollend",e)),this.fire(new ee("moveend",e))}flyTo(e,t){if(!e.essential&&Xt.prefersReducedMotion)return this.easeTo(e,t);this.stop(),e=X({offset:[0,0],speed:1.2,curve:1.42,easing:Oh},e),e.zoom!==void 0&&this._zoomSnap&&(e.zoom=ii(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=i.bearing,a=i.pitch,n=i.roll,o=i.padding,s=e.bearing===void 0?r:this._normalizeBearing(e.bearing,r),l=e.pitch===void 0?a:+e.pitch,u=e.roll===void 0?n:this._normalizeBearing(e.roll,n),h=e.padding===void 0?i.padding:e.padding,c=M.convert(e.offset),d=i.centerPoint.add(c),p=i.screenPointToLocation(d),f=this.cameraHelper.handleFlyTo(i,{bearing:s,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(i.width,i.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 b(I){let E=(_*_-g*g+(I?-1:1)*x*x*y*y)/(2*(I?_:g)*x*y);return Math.log(Math.sqrt(E*E+1)-E)}function w(I){return(Math.exp(I)-Math.exp(-I))/2}function T(I){return(Math.exp(I)+Math.exp(-I))/2}function S(I){return w(I)/T(I)}let C=b(!1),F=function(I){return T(C)/T(C+m*I)},A=function(I){return g*((T(C)*S(C+m*I)-w(C))/x)/y},L=(b(!0)-C)/m;if(Math.abs(y)<2e-6||!isFinite(L)){if(Math.abs(g-_)<1e-6)return this.easeTo(e,t);let I=_<g?-1:1;L=Math.abs(Math.log(_/g))/m,A=()=>0,F=E=>Math.exp(I*m*E)}if(e.duration!==void 0)e.duration=+e.duration;else{let I=e.screenSpeed===void 0?+e.speed:+e.screenSpeed/m;e.duration=1e3*L/I}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==s,this._pitching=l!==a,this._rolling=u!==n,this._padding=!i.isPaddingEqual(h),this._prepareEase(t,!1,{},{tr:i,center:f.targetCenter,freeze:e.freezeElevation}),this._ease(I=>{let E=I*L,D=1/F(E),P=A(E);this._rotating&&i.setBearing(We.number(r,s,I)),this._pitching&&i.setPitch(We.number(a,l,I)),this._rolling&&i.setRoll(We.number(n,u,I)),this._padding&&(i.interpolatePadding(o,h,I),d=i.centerPoint.add(c)),f.easeFunc(I,D,P,d),this.terrain&&!e.freezeElevation&&this._updateElevation(I,i),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},()=>{this._afterEase(t,void 0,e.freezeElevation)},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 i=this._onEaseEnd;delete this._onEaseEnd,i.call(this,t)}return e||this._stopHandlers(),this}_ease(e,t,i){i.animate===!1||i.duration===0?(e(1),t()):(this._easeStart=ke(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=fi(e,-180,180);let i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};function qk(e,t){let i=1,r=D_(e,t),a=t.distance/r;for(let n=0;n<5&&!S_(r,t);n++){if(!Number.isFinite(a)||a<=0)return!1;let o=e.zoom;e.setZoom(o+_t(i/a));let s=i*pt(o-e.zoom);if(s===i)return!0;let l=D_(e,t);a=s+(t.distance-l)*(s-i)/(l-r),i=s,r=l}return S_(r,t)}function D_(e,t){return e.setLocationAtPoint(t.location,t.point,t.elevation),Ks(e,t.location,t.elevation)}function S_(e,t){return Math.abs(e/t.distance-1)<1e-7}function Wk(e,t){return t.elevation!==void 0||pd(Fl(e.screenPointToLocation(t.point),0),Fl(t.location,0))<t.distance*1e-4}function E_(e,t){return e.isPointOnMapSurface(new M(t.x,t.y-16))}function Ks(e,t,i=e.elevation){return pd(Fl(e.getCameraLngLat(),e.getCameraAltitude()),Fl(t,i))}function Fl(e,t){let i=ht(e);return Ue(i,i,Ot+t)}const Sx={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var Ex=class{constructor(e=Sx){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=De.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=De.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=De.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 i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(r=>typeof r=="string"?r:"")):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let r=this._map.style.stylesheet;this.styleOwner=r.owner,this.styleId=r.id}let t=this._map.style.tileManagers;for(let r in t){let a=t[r];if(a.used||a.usedForTerrain){let n=a.getSource();n.attribution&&!e.includes(n.attribution)&&e.push(n.attribution)}}e=e.filter(r=>String(r).trim()),e.sort((r,a)=>r.length-a.length),e=e.filter((r,a)=>{for(let n=a+1;n<e.length;n++)if(e[n].includes(r))return!1;return!0});let i=e.join(" | ");if(i!==this._attribHTML){if(this._attribHTML=i,e.length){let r=document.createDocumentFragment(),a=!0;for(let n of e){let o=De.sanitize(n);o.hasChildNodes()&&(a||r.append(" | "),r.append(o),a=!1)}this._innerContainer.replaceChildren(r),this._container.classList.remove("maplibregl-attrib-empty")}else this._container.classList.add("maplibregl-attrib-empty");this._updateCompact(),this._editLink=null}}},Hk=class{constructor(e={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let i=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&i.classList.add("maplibregl-compact"):i.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){var i;this._map=e,this._compact=(i=this.options)==null?void 0:i.compact,this._container=De.create("div","maplibregl-ctrl");let t=De.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}},Xk=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,i=t?this._queue.concat(t):this._queue;for(let r of i)if(r.id===e){r.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 i=!1,r;for(let a of t)if(!a.cancelled){try{a.callback(e)}catch(n){i||(i=!0,r=n)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,i)throw r}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const Yk=Qe([{name:"a_pos3d",type:"Int16",components:3}]);var Kk=class extends Ft{constructor(e){super(),this._lastTilesetChange=ke(),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 i={},r=!1;for(let a of Bo(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t}))i[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=new Float32Array(16),nr(a.terrainRttPosMatrix32f,0,O,O,0,0,1),this._tiles[a.key]=new zv(a,this.tileSize),this._lastTilesetChange=ke(),r=!0);for(let a in this._tiles)i[a]||(this._tiles[a].releaseRTT(this.tileManager.map.painter),delete this._tiles[a],r=!0);return r}releaseRTT(e){for(let t in this._tiles){let i=this._tiles[t];(i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&i.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 i of this._renderableTilesKeys){let r=this._tiles[i].tileID,a=e.clone(),n=Gr();if(r.canonical.equals(e.canonical))nr(n,0,O,O,0,0,1);else if(r.canonical.isChildOf(e.canonical)){let o=r.canonical.z-e.canonical.z,s=r.canonical.x-(r.canonical.x>>o<<o),l=r.canonical.y-(r.canonical.y>>o<<o),u=O>>o;nr(n,0,u,u,0,0,1),st(n,n,[-s*u,-l*u,0])}else if(e.canonical.isChildOf(r.canonical)){let o=e.canonical.z-r.canonical.z,s=e.canonical.x-(e.canonical.x>>o<<o),l=e.canonical.y-(e.canonical.y>>o<<o),u=O>>o;nr(n,0,O,O,0,0,1),st(n,n,[s*u,l*u,0]),Rt(n,n,[1/2**o,1/2**o,0])}else continue;a.terrainRttPosMatrix32f=new Float32Array(n),t[i]=a}return t}_getTerrainCoordsForTileRanges(e,t){let i={};for(let r of this._renderableTilesKeys){let a=this._tiles[r].tileID;if(!this._isWithinTileRanges(a,t))continue;let n=e.clone(),o=Gr();if(a.canonical.z===e.canonical.z){let s=e.canonical.x-a.canonical.x+e.wrap*(1<<e.canonical.z),l=e.canonical.y-a.canonical.y;nr(o,0,O,O,0,0,1),st(o,o,[s*O,l*O,0])}else if(a.canonical.z>e.canonical.z){let s=a.canonical.z-e.canonical.z,l=a.canonical.x-(a.canonical.x>>s<<s)+e.wrap*(1<<a.canonical.z),u=a.canonical.y-(a.canonical.y>>s<<s),h=e.canonical.x-(a.canonical.x>>s),c=e.canonical.y-(a.canonical.y>>s),d=O>>s;nr(o,0,d,d,0,0,1),st(o,o,[-l*d+h*O,-u*d+c*O,0])}else{let s=e.canonical.z-a.canonical.z,l=e.canonical.x-(e.canonical.x>>s<<s)+e.wrap*(1<<e.canonical.z),u=e.canonical.y-(e.canonical.y>>s<<s),h=(e.canonical.x>>s)-a.canonical.x,c=(e.canonical.y>>s)-a.canonical.y,d=O<<s;nr(o,0,d,d,0,0,1),st(o,o,[l*O+h*d,u*O+c*d,0])}n.terrainRttPosMatrix32f=new Float32Array(o),i[r]=n}return i}getSourceTile(e,t){var n;let i=this.tileManager._source,r=e.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;((n=this._sourceTileCache[e.key])==null?void 0:n.zoom)!==r&&(this._sourceTileCache[e.key]={zoom:r,key:e.scaledTo(r).key});let a=this.findTileInCaches(this._sourceTileCache[e.key].key);if(!(a!=null&&a.dem)&&t)for(;r>=i.minzoom&&!(a!=null&&a.dem);)a=this.findTileInCaches(e.scaledTo(r--).key);return a}isStillWaitingForDEM(e){var a;let t=this.tileManager._source,i=Math.min(e.overscaledZ-this.deltaZoom,t.maxzoom);if(i<t.minzoom)return!1;let r=e.scaledTo(i);return t.hasTile&&!t.hasTile(r)?!1:((a=this.findTileInCaches(r.key))==null?void 0:a.state)!=="errored"}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=ke()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let i=t[e.canonical.z];return!!i&&(e.wrap>i.minWrap||e.wrap<i.maxWrap||e.canonical.x>=i.minTileXWrapped&&e.canonical.x<=i.maxTileXWrapped&&e.canonical.y>=i.minTileY&&e.canonical.y<=i.maxTileY)}},Jk=class{constructor(e,t,i,r="auto",a=()=>ln){this._meshCache={},this.painter=e,this._getWorldCoordinateHelper=a,this.tileManager=new Kk(t),this.options=i,this.exaggeration=typeof i.exaggeration=="number"?i.exaggeration:1,this._terrainSkirtLength=r,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this.coverage=new jI(this.tileManager,this.exaggeration,()=>this._worldCoordinateHelper)}destroy(){this._fbo&&(this._fbo=(this._fbo.destroy(),null)),this._heightMapFbo&&(this._heightMapFbo=(this._heightMapFbo.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,i,r=O){let a=e.normalizeCoordinates(t,i,r);if(!a)return 0;let n=this.coverage.getSampler(a.tileID);return n?n(a.x,a.y,r):0}getElevationForLngLatZoom(e,t){let i=this._worldCoordinateHelper;if(!ch(t,i.wraps?e.wrap():e,i))return 0;let{tileID:r,worldX:a,worldY:n}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(r,a%O,n%O,O)}getElevationForLngLat(e,t){let i=this.getDrawnElevationForLngLat(e);return i===void 0?this.getElevationForLngLatZoom(e,this._getFallbackZoom(t)):i}getDrawnElevationForLngLat(e,t=!1){return this.coverage.sample(e,t)}getElevationAndDEMStateForLngLat(e,t){var o;let i=this.getElevationForLngLat(e,t);if(i!==0||this.getDrawnElevationForLngLat(e)!==void 0)return{elevation:i,demState:"loaded"};let r=this._getFallbackZoom(t),a=this._worldCoordinateHelper;if(!ch(r,a.wraps?e.wrap():e,a))return{elevation:i,demState:"none"};let{tileID:n}=this._getOverscaledTileIDFromLngLatZoom(e,r);return(o=this.tileManager.getSourceTile(n,!0))!=null&&o.dem?{elevation:i,demState:"loaded"}:{elevation:i,demState:this.tileManager.isStillWaitingForDEM(n)?"loading":"none"}}_getFallbackZoom(e){return Math.min(e.tileZoom,this.tileManager.maxzoom)}getElevation(e,t,i,r=O){return this.getDEMElevation(e,t,i,r)*this.exaggeration}resetElevationCache(){this.coverage.reset()}getCoverageIndex(){return this.coverage.getIndex()}_getDEMTileMatrix(e,t){let i=`${t.tileID.key}/${e.key}`,r=this._demMatrixCache.get(i);if(r)return r;let a=e.canonical.z-t.tileID.canonical.z,n=e.canonical.x-(e.canonical.x>>a<<a),o=e.canonical.y-(e.canonical.y>>a<<a),s=ib(new Float64Array(16),[1/(O<<a),1/(O<<a),0]);return st(s,s,[n*O,o*O,0]),this._demMatrixCache.set(i,s),s}getTerrainData(e){var r,a;if(!this._emptyDemTexture){let n=this.painter.context,o=new Ne({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new ft(n,o,n.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new ft(n,new Ne({width:1,height:1}),n.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=Ii([])}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 ft(n,t.dem.getPixels(),n.gl.RGBA,{premultiply:!1}),t.demTexture.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),t.needsTerrainPrepare=!1}let i=t?this._getDEMTileMatrix(e,t):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:((r=t==null?void 0:t.dem)==null?void 0:r.dim)||1,u_terrain_matrix:i,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,i=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==t||this._fbo.height!==i)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new ft(e.context,{width:t,height:i,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,i,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,t,i))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}getHeightMapFramebuffer(e){return this._heightMapFbo||(this._heightMapFbo=this.painter.context.createFramebuffer(1,1,!1,!1)),this._heightMapFbo.colorAttachment.set(e),this._heightMapFbo}getTerrainMesh(e,t){let i=t&&e.canonical.y===0,r=t&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${i?"n":""}_${r?"s":""}`;if(this._meshCache[a])return this._meshCache[a];let n=this.painter.context,o=new yT,s=new Ki,l=this.meshSize,u=O/l,h=l*l;for(let d=0;d<=l;d++)for(let p=0;p<=l;p++)o.emplaceBack(p*u,d*u,0);for(let d=0;d<h;d+=l+1)for(let p=0;p<l;p++)s.emplaceBack(p+d,l+p+d+1,l+p+d+2),s.emplaceBack(p+d,l+p+d+2,p+d+1);this._terrainSkirtLength!=="none"&&this._buildSkirts(o,s,l,u,i,r);let c=new wo(n.createVertexBuffer(o,Yk.members),n.createIndexBuffer(s),Ke.simpleSegment(0,0,o.length,s.length));return this._meshCache[a]=c,c}getSkirtLength(e){return this._worldCoordinateHelper.metersPerWorldUnit(.5,.5)/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){var a;let i=this._worldCoordinateHelper;if(!ch(t,i.wraps?e.wrap():e,i))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,t);return(a=this.getMinMaxElevation(r).minElevation)!=null?a:0}getMinMaxElevation(e){let t=this.tileManager.getSourceTile(e,!0),i={minElevation:null,maxElevation:null};return t!=null&&t.dem&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}get _worldCoordinateHelper(){return this._getWorldCoordinateHelper()}_getOverscaledTileIDFromLngLatZoom(e,t){let i=this._worldCoordinateHelper,r=i.wraps?e.wrap():e,a=i.worldFromLngLat(r.lng,r.lat),n=(1<<t)*O,o=a.x*n,s=a.y*n;return{tileID:new Ct(t,0,t,Math.floor(o/O),Math.floor(s/O)),worldX:o,worldY:s}}_buildSkirts(e,t,i,r,a,n){let o=e.length,s=o+(i+1),l=(i+1)*i,u=a?Yn:0,h=+!a,c=n?Kn:O,d=+!n;for(let m=0;m<=i;m++)e.emplaceBack(m*r,u,h);for(let m=0;m<=i;m++)e.emplaceBack(m*r,c,d);for(let m=0;m<i;m++)t.emplaceBack(l+m,s+m,s+m+1),t.emplaceBack(l+m,s+m+1,l+m+1),t.emplaceBack(0+m,o+m+1,o+m),t.emplaceBack(0+m,0+m+1,o+m+1);let p=e.length,f=p+(i+1)*2;for(let m of[0,1])for(let g=0;g<=i;g++)for(let _ of[0,1])e.emplaceBack(m*O,g*r,_);for(let m=0;m<i*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 C_=["none","zoom","sourceTiles","visibleLayers","revision"];var P_=class{constructor(e,t,i,r){this._tileKeys=e.map(a=>a.key).sort().join(),this._revision=t,this._zoom=i,this._visibleLayerIds=r}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 Cx={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};function Mh(e){return nu(e)?`custom-layer:${e.id}`:e.source}function ud(e){return nu(e)?e.implementation.renderToTerrainTile!==void 0:Cx[e.type]===!0}function Qk(e,t){let i=[],r=!1;for(let a of t){let n=ud(e._layers[a]);n&&!r&&i.push([]),n&&i[i.length-1].push(a),r=n}return i}var e6=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,i){var u;let r=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevRenderedToTexture=!1,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(h=>!e._layers[h].isHidden(t));let a=Qk(e,this._renderableLayerIds),n=this._renderableLayerIds.join(),o=new Set;for(let h of this._renderableLayerIds){let c=e._layers[h],d=c.source;d&&Cx[c.type]&&o.add(d)}this._coordsAscending={},this._rttFingerprints={};for(let h of o){let c=e.tileManagers[h];if(!c)continue;this._coordsAscending[h]={};let d=this._coordsAscending[h],p=c.getSource(),f=p instanceof ko?p.terrainTileRanges:null;for(let _ of c.getVisibleCoordinates()){let y=this.terrain.tileManager.getTerrainCoords(_,f);for(let v in y)d[v]||(d[v]=[]),d[v].push(y[v])}this._rttFingerprints[h]={};let m=this._rttFingerprints[h],g=c.getState().revision;for(let _ in d)m[_]=new P_(d[_],g,t,n)}for(let h of this._renderableLayerIds){let c=e._layers[h];if(!nu(c)||!ud(c))continue;let d=(u=c.implementation.terrainTileRevision)!=null?u:0,p={};for(let f of this._renderableTiles)p[f.tileID.key]=new P_([f.tileID],d,t,n);this._rttFingerprints[Mh(c)]=p}this.needsFollowUpFrame=!1;let s=r||i,l=!1;for(let h of this._renderableTiles){let c=this._textureDifference(h);c!=="none"&&(c==="zoom"&&s||c==="visibleLayers"&&r?this.needsFollowUpFrame=!0:c==="zoom"||c==="sourceTiles"?(l?this.needsFollowUpFrame=!0:this._releaseChangedTextures(h,e,a),l=!0):this._releaseChangedTextures(h,e,a))}}_releaseChangedTextures(e,t,i){let r=i.map(a=>this._hasStackChanged(e,t,a));if(!r.includes(!1))e.releaseRTT(this.painter);else for(let[a,n]of r.entries())n&&e.releaseRTTStack(this.painter,a)}_hasStackChanged(e,t,i){var a;let r=!1;for(let n of i){let o=Mh(t._layers[n]),s=(a=this._rttFingerprints[o])==null?void 0:a[e.tileID.key],l=e.rttFingerprint[o];if(s||l){if((s==null?void 0:s.difference(l))!=="none")return!0;r=!0}}return!r}_textureDifference(e){let t="none";for(let i in this._rttFingerprints){let r=this._rttFingerprints[i][e.tileID.key];if(!r)continue;let a=r.difference(e.rttFingerprint[i]);C_.indexOf(a)>C_.indexOf(t)&&(t=a)}return t}renderLayer(e,t,i){if(e.isHidden(i.transform.zoom))return!1;let r=ud(e),a=this.painter,n=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(r&&(this._prevRenderedToTexture||this._stacks.push([]),this._prevRenderedToTexture=!0,this._stacks[this._stacks.length-1].push(e.id),!n))return!0;if(this._prevRenderedToTexture||r&&n){this._prevRenderedToTexture=r;let o=this._stacks.length-1,s=this._stacks[o]||[];i.isRenderingToTexture=!0,s_(a.context.frameUniformBuffer,this.rttSize,this.rttSize);for(let l of this._renderableTiles){if(this._rttTiles.push(l),l.getRTT(o))continue;let u=l.acquireRTT(a,o,this.rttSize);a.bindRTT(u),a.context.clear({color:se.transparent,stencil:0}),i.invalidateTileClippingMasks();for(let h of s){let c=t._layers[h],d=c.source?this._coordsAscending[c.source][l.tileID.key]:[l.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),i.renderTileClippingMasks(c,d),a.renderLayer(a,t.tileManagers[c.source],c,d,i);let p=Mh(c);p&&(l.rttFingerprint[p]=this._rttFingerprints[p][l.tileID.key])}u.texture.generateMipmap()}return i.isRenderingToTexture=!1,s_(a.context.frameUniformBuffer,a.context.gl.drawingBufferWidth,a.context.gl.drawingBufferHeight),Wz(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],r}return!1}};const t6={"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"},i6=R_,A_={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Sx,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:ta.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,globalState:void 0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var r6=class extends Ft{get _ownerWindow(){var e,t;return((t=(e=this._container)==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)||window}constructor(e){var n,o,s;super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Xk,this._controls=[],this._mapId=U_(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=l=>{if(l.preventDefault(),this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),!this.style)this.fire(new Gu("webglcontextlost",{originalEvent:l}));else{for(let u of Object.values(this.style._layers))if(u.type==="custom"&&console.warn(`Custom layer with id '${u.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),u._listeners)for(let[h]of Object.entries(u._listeners))console.warn(`Custom layer with id '${u.id}' had event listeners for event '${h}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.off("error",this._onStyleError),this.style.destroy(),this.style=null,this.fire(new Gu("webglcontextlost",{originalEvent:l}))}},this._contextRestored=l=>{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 u in this._lostContextStyle.images){let h=this._lostContextStyle.images[u];h.isWebGLImage&&this.style.imageManager.updateImage(u,h,!1)}}this._lostContextStyle={style:null,images:null};try{this._setupPainter()}catch(u){this.fire(new K(u));return}this.resize(),this._update(),this._resizeInternal(),this.fire(new Gu("webglcontextrestored",{originalEvent:l}))},this._onMapScroll=l=>{if(l.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onStyleError=l=>{l.tile&&this.triggerRepaint()},this._onWindowOnline=()=>{this._update()};let t={...A_,...e,canvasContextAttributes:{...A_.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 Zk({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:l=>this._requestRenderFrame(l),cancelRenderFrame:l=>this._cancelRenderFrame(l),transformCameraUpdate:t.transformCameraUpdate,stopHandlers:()=>{var l;return(l=this._handlers)==null?void 0:l.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={...t6,...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 Qb(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer();try{this._setupPainter()}catch(l){throw this._cleanupContainer(),l}this._imageQueueHandle=Ci.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 $k(this,this._camera,t),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let i=typeof t.hash=="string"&&t.hash||void 0;this._hash=t.hash?new nk(i).addTo(this):void 0,(n=this._hash)!=null&&n._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,X({},t.fitBoundsOptions,{duration:0}))));let r=typeof t.style=="string"||(s=(o=t.style)==null?void 0:o.projection)==null?void 0:s.type,a=r!=="globe"&&!su(r);this.resize(null,a),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,this._initialGlobalState=t.globalState,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new Ex(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new Hk,t.logoPosition),this.on("style.load",()=>{if(a||this._resizeTransform(),this._camera.transform.unmodified){let l=zl(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(l)}}),this.on("data",l=>{this._update(l.dataType==="style"),this.fire(l.dataType==="style"?new Di("styledata",l):new $e("sourcedata",l))}),this.on("dataloading",l=>{this.fire(l.dataType==="style"?new Di("styledataloading",l):new $e("sourcedataloading",l))}),this.on("dataabort",l=>{this.fire(new $e("sourcedataabort",l))})}_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 K(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let i=e.onAdd(this);this._controls.push(e);let r=this._controlPositions[t];return t.includes("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!(e!=null&&e.onRemove))return this.fire(new K(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 Bo(this._camera.transform,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return new W(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,i){return this._camera.panBy(e,t,i),this}panTo(e,t,i){return this._camera.panTo(e,t,i),this}getZoom(){return this._camera.transform.zoom}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,i){return this._camera.zoomTo(e,t,i),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,i){return this._camera.rotateTo(e,t,i),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,i){return this._camera.fitBounds(e,t,i),this}fitScreenCoordinates(e,t,i,r,a){return this._camera.fitScreenCoordinates(e,t,i,r,a),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateAnchoredCameraOptions(e){return this._camera.calculateAnchoredCameraOptions(e)}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,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(W.convert(e),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,i,r){return r==null&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(e,t,i,r!=null?r:0)}resize(e,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);let i=!this._camera._moving;return i&&(this.stop(),this.fire(new ee("movestart",e)).fire(new ee("move",e))),this.fire(new wt("resize",e)),i&&this.fire(new ee("moveend",e)),this}_resizeInternal(e=!0){var r;let[t,i]=this._containerDimensions();if(this._clampedPixelRatio=this._getClampedPixelRatio(t,i),this._resizeCanvas(t,i,this._clampedPixelRatio),this.painter.resize(t,i,this._clampedPixelRatio),this.painter.overLimit()){let a=this.painter.context.gl;this._maxCanvasSize=[a.drawingBufferWidth,a.drawingBufferHeight],this._clampedPixelRatio=this._getClampedPixelRatio(t,i),this._resizeCanvas(t,i,this._clampedPixelRatio),this.painter.resize(t,i,this._clampedPixelRatio)}(r=this.style)==null||r.resize(),this._resizeTransform(e)}_resizeTransform(e=!0){var r;let[t,i]=this._containerDimensions();this._camera.transform.resize(t,i,e),(r=this._camera._requestedCameraState)==null||r.resize(t,i,e)}_getClampedPixelRatio(e,t){let{0:i,1:r}=this._maxCanvasSize,a=this.getPixelRatio(),n=e*a,o=t*a,s=n>i?i/n:1,l=o>r?r/o:1,u=Math.min(s,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(){var e;return(e=this._overridePixelRatio)!=null?e: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(mr.convert(e))),this._update()}setMinZoom(e){if(e!=null||(e=-2),e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(i=>i.setMinZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new ee("zoomstart")).fire(new ee("zoom")).fire(new ee("zoomend")).fire(new ee("movestart")).fire(new ee("move")).fire(new ee("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!=null||(e=22),e>=this._camera.transform.minZoom){let t=this._camera.transform.zoom;return this._camera.applyTransformChange(i=>i.setMaxZoom(e)),this._update(),t!==this._camera.transform.zoom&&this.fire(new ee("zoomstart")).fire(new ee("zoom")).fire(new ee("zoomend")).fire(new ee("movestart")).fire(new ee("move")).fire(new ee("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(e){if(e!=null||(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(i=>i.setMinPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new ee("pitchstart")).fire(new ee("pitch")).fire(new ee("pitchend")).fire(new ee("movestart")).fire(new ee("move")).fire(new ee("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(e){if(e!=null||(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(i=>i.setMaxPitch(e)),this._update(),t!==this._camera.transform.pitch&&this.fire(new ee("pitchstart")).fire(new ee("pitch")).fire(new ee("pitchend")).fire(new ee("movestart")).fire(new ee("move")).fire(new ee("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!=null||(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(W.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(M.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,i){if(e==="mouseenter"||e==="mouseover"){let r=!1;return{mousemove:a=>{let n=t.filter(s=>this.getLayer(s)),o=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});o.length?r||(r=!0,i.call(this,new ri(e,this,a.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}if(e==="mouseleave"||e==="mouseout"){let r=!1;return{mousemove:a=>{let n=t.filter(o=>this.getLayer(o));(n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n})).length?r=!0:r&&(r=!1,i.call(this,new ri(e,this,a.originalEvent)))},mouseout:a=>{r&&(r=!1,i.call(this,new ri(e,this,a.originalEvent)))}}}{let r=a=>{let n=t.filter(s=>this.getLayer(s)),o=n.length===0?[]:this.queryRenderedFeatures(a.point,{layers:n});o.length&&(a.features=o,i.call(this,a),delete a.features)};return{[e]:r}}}_addDelegatedListener(e,t){var i;this._delegatedListeners||(this._delegatedListeners={}),(i=this._delegatedListeners)[e]||(i[e]=[]),this._delegatedListeners[e].push(t);for(let r in t.delegates)this.on(r,t.delegates[r])}_removeDelegatedListener(e,t,i){var a;if(!((a=this._delegatedListeners)!=null&&a[e]))return;let r=this._delegatedListeners[e];for(let n=0;n<r.length;n++){let o=r[n];if(o.listener===i&&o.layers.length===t.length&&o.layers.every(s=>t.includes(s))){for(let s in o.delegates)this.off(s,o.delegates[s]);r.splice(n,1);return}}}on(e,t,i){if(i===void 0)return super.on(e,t);let r=typeof t=="string"?[t]:t,a={layers:r,listener:i,delegates:this._createDelegates(e,r,i)};return this._addDelegatedListener(e,a),{unsubscribe:()=>{this._removeDelegatedListener(e,r,i)}}}once(e,t,i){if(i===void 0)return super.once(e,t);let r=typeof t=="string"?[t]:t,a={layers:r,listener:i,delegates:this._createDelegates(e,r,n=>{this._removeDelegatedListener(e,r,i),i.call(this,n)})};return this._addDelegatedListener(e,a),this}off(e,t,i){if(i===void 0)return super.off(e,t);let r=typeof t=="string"?[t]:t;return this._removeDelegatedListener(e,r,i),this}queryRenderedFeatures(e,t){if(!this.style)return[];let i,r=e instanceof M||Array.isArray(e),a=r?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||(t=(r?{}:e)||{}),a instanceof M||typeof a[0]=="number")i=[M.convert(a)];else{let n=M.convert(a[0]),o=M.convert(a[1]);i=[n,new M(o.x,n.y),o,new M(n.x,o.y),n]}return this.style.queryRenderedFeatures(i,t,this._camera.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return t=X({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle,globalState:this._initialGlobalState},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 r,a,n;if((r=this._diffStyleRequest)==null||r.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded){this.style.once("style.load",()=>this._updateStyle(e,t));return}let i=this.style&&t.transformStyle?this.style.serialize():void 0;if(this.style&&(this.style.off("error",this._onStyleError),this.style.setEventedParent(null),this.style._remove(!e)),e)this.style=new a_(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}),this.style.on("error",this._onStyleError),typeof e=="string"?this.style.loadURL(e,t,i):this.style.loadJSON(e,t,i),this}_lazyInitEmptyStyle(){this.style||(this.style=new a_(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.on("error",this._onStyleError),this.style.loadEmpty())}async _diffStyle(e,t){var i;if((i=this._diffStyleRequest)==null||i.abort(),typeof e=="string"){let r=e;this._diffStyleRequest=new AbortController;let a=this._diffStyleRequest;try{let n=await this._requestManager.transformRequest(r,"Style");if(a.signal.aborted){this._diffStyleRequest=null;return}let o=await Rl(n,a);this._diffStyleRequest=null,this._updateDiff(o.data,t)}catch(n){this._diffStyleRequest=null,Fr(n)||this.fire(new K(Dt(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(i){_e(`Unable to perform style diff: ${Dt(i).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.");else return this.style.loaded()}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){var i;let t=(i=this.style)==null?void 0:i.tileManagers[e];if(t===void 0)this.fire(new K(Error(`There is no tile manager with ID '${e}'`)));else return t.loaded()}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&Mo(this,qt.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 i=this.style.tileManagers[e.source];if(!i)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&i.reload();for(let r in this.style._layers){let a=this.style._layers[r];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 Jk(this.painter,i,e,this._terrainSkirtLength,()=>this._camera.transform.worldCoordinateHelper),this.painter.renderToTexture=new e6(this.painter,this.terrain),this._camera.setTerrain(this.terrain),this._terrainDataCallback=r=>this._handleTerrainDataEvent(r,e.source),this.style.on("data",this._terrainDataCallback)}return this.style.triggerSymbolPlacement(),this.fire(new t2({terrain:e})),this}_handleTerrainDataEvent(e,t){var r;if(e.dataType==="style"){this.terrain.tileManager.releaseAllRTT();return}let i=e.sourceId===t;i&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),i&&e.tile&&(this.painter.markTerrainDepthDirty(),this._camera.applyTerrainChange()),e.tile&&(((r=e.source)==null?void 0:r.type)==="image"?this.terrain.tileManager.releaseAllRTT():this.terrain.tileManager.releaseRTT(e.tile.tileID))}getTerrain(){var e,t;return(t=(e=this.terrain)==null?void 0:e.options)!=null?t:null}areTilesLoaded(){var t;let e=(t=this.style)==null?void 0:t.tileManagers;for(let i of Object.values(e))if(!i.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,i){if(i){let r=this.getSource(i);if(!r)throw Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=td(Math.max(1,e),Math.max(1,t))}else for(let r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=td(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let i=this.style.tileManagers[e];if(!i)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);t===void 0?i.reload(!0):i.refreshTiles(t.map(r=>new ou(r.z,r.x,r.y)))}addImage(e,t,i={}){var a;this._lazyInitEmptyStyle();let r=this._createStyleImage(t,i);return r&&(this.style.addImage(e,r),(a=r.userImage)!=null&&a.onAdd&&r.userImage.onAdd(this,e)),this}setMissingStyleImageResolver(e){var t;return this._missingStyleImageResolver=e,(t=this.style)==null||t.setMissingImageResolver(e),this}_createStyleImage(e,t={}){let{pixelRatio:i=1,sdf:r=!1,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l}=t;if(e instanceof HTMLImageElement||Hr(e)){let{width:u,height:h,data:c}=Xt.getImageData(e);return{data:new Ne({width:u,height:h},c),pixelRatio:i,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l,sdf:r,version:0}}if(e.width===void 0||e.height===void 0)return this.fire(new K(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=wl(d.data);return{data:p?new Ne({width:u,height:h}):new Ne({width:u,height:h},new Uint8Array(c)),pixelRatio:i,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l,sdf:r,version:0,isWebGLImage:p,userImage:d}}}updateImage(e,t){let i=this.style.getImage(e);if(!i)return this.fire(new K(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:a,data:n}=t instanceof HTMLImageElement||Hr(t)?Xt.getImageData(t):t;if(r===void 0||a===void 0)return this.fire(new K(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(r!==i.data.width||a!==i.data.height)return this.fire(new K(Error("The width and height of the updated image must be that same as the previous version of the image")));if(i.isWebGLImage=wl(n),i.isWebGLImage)i.userImage=t;else{let o=!(t instanceof HTMLImageElement||Hr(t));i.data.replace(n,o)}return this.style.updateImage(e,i),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new K(Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await Ci.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,t;return(t=(e=this.style)==null?void 0:e.listImages())!=null?t:[]}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,t;return(t=(e=this.style)==null?void 0:e.getLayersOrder())!=null?t:[]}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){var r;return(r=this.style)==null||r.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){var a;return(a=this.style)==null||a.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),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,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,r=>{r||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,i=>{i||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 i;if(!((i=this._container)!=null&&i.clientWidth)||!this._container.clientHeight)return!1;let[e,t]=this._containerDimensions();return e!==this._camera.transform.width||t!==this._camera.transform.height}_setupResizeObserver(){var r;let e=!1,t=Ip(a=>{this._trackResize&&!this._removed&&(this.resize(a),this.redraw())},50),i=(r=this._ownerWindow.ResizeObserver)!=null?r:ResizeObserver;this._resizeObserver=new i(a=>{!e&&(e=!0,!this._shouldHandleInitialResize())||t(a)}),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]),i=this._container;i.classList.add("maplibregl-map");let r=this._canvasContainer=De.create("div","maplibregl-canvas-container",i);this._interactive&&r.classList.add("maplibregl-interactive"),this._canvas=De.create("canvas","maplibregl-canvas",r),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=De.create("div","maplibregl-control-container",i),n=this._controlPositions={};for(let o of["top-left","top-right","bottom-left","bottom-right"])n[o]=De.create("div",`maplibregl-ctrl-${o} `,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,i){let r=Math.round(i*e),a=Math.round(i*t);this._canvas.width=r,this._canvas.height=a,this._canvas.style.width=`${r/i}px`,this._canvas.style.height=`${a/i}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener("webglcontextcreationerror",r=>{t=r},{once:!0});let i=this._canvas.getContext("webgl2",e);if(!i)throw new ak(e,t);this.painter=new rk(i)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.fire(new i2({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}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var l,u,h,c,d,p,f,m,g;let t=this._idleTriggered?this._fadeDuration:0,i=((l=this.style.projection)==null?void 0:l.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let _=this._camera.transform.zoom,y=ke();this.style.zoomHistory.update(_,y);let v=new Ie(_,{now:y,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),x=v.crossFadingFactor();(x!==1||x!==this._crossFadingFactor)&&(r=!0,this._crossFadingFactor=x),this.style.update(v)}let a=((u=this.style.projection)==null?void 0:u.transitionState)>0!==i;if(this._camera.transform.setTransitionState((h=this.style.projection)==null?void 0:h.transitionState),this.style&&(this._sourcesDirty||a)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain){if(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()){let{elevation:_,demState:y}=this.terrain.getElevationAndDEMStateForLngLat(this._camera.transform.center,this._camera.transform);y!=="loading"&&this._camera.transform.setElevation(_)}}else this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0);this._placementDirty=(c=this.style)==null?void 0:c._updatePlacement(this._camera.transform,this.showCollisionBoxes,t,this._crossSourceCollisions,a);let n=this.style.projection,o=(d=n==null?void 0:n.transitionState)!=null?d:0;this.painter.render(this.style,this._camera.transform,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,symbolFadeChange:this.style.placement.symbolFadeChange(ke()),variableOffsets:this.style.placement.variableOffsets,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch(),projectionTransition:o,isRenderingGlobe:o>0,projectionShaderVariant:n?{name:n.shaderVariantName,define:n.shaderDefine,prelude:n.shaderPreludeCode}:void 0,useSubdivision:(p=n==null?void 0:n.useSubdivision)!=null?p:!1,pixelRatio:this._clampedPixelRatio,light:(f=this.style.light)==null?void 0:f.getEvaluated(),sky:(m=this.style.sky)==null?void 0:m.getEvaluated()}),this.fire(new wt("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new wt("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let s=this._sourcesDirty||this._styleDirty||this._placementDirty||((g=this.painter.renderToTexture)==null?void 0:g.needsFollowUpFrame);return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new wt("idle")),this._loaded&&!this._fullyLoaded&&!s&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest=(this._frameRequest.abort(),null)),this._render(0)),this}remove(){var t,i;this._hash&&this._hash.remove();for(let r of this._controls)r.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),Ci.removeThrottleControl(this._imageQueueHandle),(i=this._resizeObserver)==null||i.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 wt("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(!Fr(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 i6}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};const a6={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var n6=class{constructor(e){this._updateZoomButtons=()=>{let t=this._map.getZoom(),i=t===this._map.getMaxZoom(),r=t===this._map.getMinZoom(!0);this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())},this._rotateCompassArrow=()=>{let t=this._map.getPitch(),i=this._map.getRoll(),r=this._map.getBearing(),a=1/Math.cos(Ve(t))**.5;this.options.visualizePitch&&this.options.visualizeRoll?this._compassIcon.style.transform=`scale(${a}) rotateZ(${-i}deg) rotateX(${t}deg) rotateZ(${-r}deg)`:this.options.visualizePitch?this._compassIcon.style.transform=`scale(${a}) rotateX(${t}deg) rotateZ(${-r}deg)`:this.options.visualizeRoll?this._compassIcon.style.transform=`rotate(${-r-i}deg)`:this._compassIcon.style.transform=`rotate(${-r}deg)`},this._setButtonTitle=(t,i)=>{let r=this._map._getUIString(`NavigationControl.${i}`);t.title=r,t.setAttribute("aria-label",r)},this.options=X({},a6,e),this._container=De.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),De.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),De.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=De.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("move",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new o6(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("move",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let i=De.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},o6=class{constructor(e,t,i=!1){this.mousedown=a=>{this.startMove(a,De.mousePos(this.element,a)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=a=>{this.move(a,De.mousePos(this.element,a))},this.mouseup=a=>{this._rotatePitchHandler.dragEnd(a),this.offTemp()},this.touchstart=a=>{a.targetTouches.length===1?(this._startPos=this._lastPos=De.touchPos(this.element,a.targetTouches)[0],this.startMove(a,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend)):this.reset()},this.touchmove=a=>{a.targetTouches.length===1?(this._lastPos=De.touchPos(this.element,a.targetTouches)[0],this.move(a,this._lastPos)):this.reset()},this.touchend=a=>{a.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=t;let r=new bk;this._rotatePitchHandler=new jo({clickTolerance:3,move:(a,n)=>{let o=t.getBoundingClientRect(),s=new M((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:q_(new M(a.x,n.y),n,s),pitchDelta:i?(n.y-a.y)*-.5:void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),De.disableDrag()}move(e,t){let i=this.map,{bearingDelta:r,pitchDelta:a}=this._rotatePitchHandler.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),a&&i.setPitch(i.getPitch()+a)}off(){let e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){De.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};function s6(e,t,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return e==null?void 0:e.wrap();let a=new W(e.lng,e.lat);if(e=new W(e.lng,e.lat),t){let n=new W(e.lng-360,e.lat),o=new W(e.lng+360,e.lat),s=i.locationToScreenPoint(e).distSqr(t);i.locationToScreenPoint(n).distSqr(t)<s?e=n:i.locationToScreenPoint(o).distSqr(t)<s&&(e=o)}for(;Math.abs(e.lng-i.center.lng)>180;){let n=i.locationToScreenPoint(e);if(n.x>=0&&n.y>=0&&n.x<=i.width&&n.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&i.isPointOnMapSurface(i.locationToScreenPoint(e))?e:a}const Px={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 l6(e,t,i){let r=e.classList;for(let a in Px)r.remove(`maplibregl-${i}-anchor-${a}`);r.add(`maplibregl-${i}-anchor-${t}`)}const M_={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},Ax="#3FB1CE";function ci(e,t,i=[]){let r=De.createNS("http://www.w3.org/2000/svg",e);for(let a in t)r.setAttributeNS(null,a,t[a]);for(let a of i)r.appendChild(a);return r}let Ih;function u6(){return Ih||(Ih=ci("svg",{display:"block",height:"41px",width:"27px",viewBox:"0 0 27 41"},[ci("g",{"fill-rule":"nonzero"},[ci("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])=>ci("ellipse",{opacity:"0.04",cx:"10.5",cy:"5.80029008",rx:e,ry:t}))),ci("g",{fill:Ax},[ci("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"})]),ci("g",{opacity:"0.25",fill:"#000000"},[ci("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"})]),ci("g",{transform:"translate(6.0, 7.0)",fill:"#FFFFFF"}),ci("g",{transform:"translate(8.0, 8.0)"},[ci("circle",{fill:"#000000",opacity:"0.25",cx:"5.5",cy:"5.5",r:"5.4999962"}),ci("circle",{fill:"#FFFFFF",cx:"5.5",cy:"5.5",r:"5.4999962"})])])]),Ih)}function h6(e){return e.firstElementChild.children[1]}var Ca=class extends ua{},c6=class extends ua{},d6=class extends Ft{constructor(e){if(super(),this._onClick=t=>{this.fire(new c6("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 i=M_[t.key];if(!i)return;t.preventDefault(),t.stopPropagation();let r=t.shiftKey?10:1,a=this._map.project(this._lngLat);this.setLngLat(this._map.unproject(new M(a.x+i[0]*r,a.y+i[1]*r))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new Ca("dragstart"))),this.fire(new Ca("drag"))},this._onKeyUp=t=>{M_[t.key]&&this._endKeyboardDrag()},this._onBlur=()=>{this._endKeyboardDrag()},this._onMapClick=t=>{let i=t.originalEvent.target,r=this._element;this._popup&&(i===r||r.contains(i))&&this.togglePopup()},this._updateCoveredUnthrottled=()=>{var r,a;let t=(r=this._map)==null?void 0:r.terrain;if(!t||!this._isInViewport())return;let i=this._isCovered(t);i&&((a=this._popup)!=null&&a.isOpen())&&this._popup.remove(),this._element.style.opacity=i?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",i)},this._updateCovered=Ip(this._updateCoveredUnthrottled,100),this._update=t=>{if(!this._map)return;this._lngLat=s6(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 i="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?i=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?r="rotateX(0deg)":this._pitchAlignment==="map"&&(r=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(t==null?void 0:t.type)!=="move"&&(this._pos=this._pos.round()),this._element.style.transform=`${Px[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`,this._updateOpacity()},this._onMove=t=>{if(!this._isDragging){let i=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=i}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 Ca("dragstart"))),this.fire(new Ca("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 Ca("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)||Ax,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=M.convert((e==null?void 0:e.offset)||[0,0]);else{this._defaultMarker=!0,this._element=De.create("div");let t=u6().cloneNode(!0);t.setAttributeNS(null,"height",`${41*this._scale}px`),t.setAttributeNS(null,"width",`${27*this._scale}px`),h6(t).setAttributeNS(null,"fill",this._color),this._element.appendChild(t),this._offset=M.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()}),l6(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=W.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 Ca("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 i;if(!this._isInViewport())return;let e=(i=this._map)==null?void 0:i.terrain,t=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!e||t){let r=t?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==r&&(this._element.style.opacity=r,this._element.classList.toggle("maplibregl-marker-covered",t))}else 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,i=e.getElevationForLngLat(this._lngLat,t),r=Math.max(0,-this._offset.y)/t.pixelsPerMeter,a=Math.sin(this._map.getPitch()*Math.PI/180)*r;return t.isLocationOccluded(this._lngLat,e,i+a)}getOffset(){return this._offset}setOffset(e){return this._offset=M.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}};const p6={maxWidth:100,unit:"metric"};var f6=class{constructor(e){this._onMove=()=>{I_(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,this._map&&I_(this._map,this._container,this.options)},this.options={...p6,...e}}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=De.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._map.on("projectiontransition",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map.off("projectiontransition",this._onMove),this._map=void 0}};function I_(e,t,i){let r=(i==null?void 0:i.maxWidth)||100,{width:a,height:n}=e._camera.transform,o=n/2,s=a/2,l=e.unproject([s-r/2,o]),u=e.unproject([s+r/2,o]);if(!l||!u)return;let h=Math.round(e.project(u).x-e.project(l).x),c=Math.min(r,h,a),d=l.distanceTo(u);if((i==null?void 0:i.unit)==="imperial"){let p=3.2808*d;p>5280?Bn(t,c,p/5280,e._getUIString("ScaleControl.Miles")):Bn(t,c,p,e._getUIString("ScaleControl.Feet"))}else(i==null?void 0:i.unit)==="nautical"?Bn(t,c,d/1852,e._getUIString("ScaleControl.NauticalMiles")):d>=1e3?Bn(t,c,d/1e3,e._getUIString("ScaleControl.Kilometers")):Bn(t,c,d,e._getUIString("ScaleControl.Meters"))}function Bn(e,t,i,r){let a=g6(i),n=a/i;e.style.width=`${t*n}px`;let o=`${a} ${r}`;e.textContent!==o&&(e.textContent=o)}function m6(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}function g6(e){let t=10**(`${Math.floor(e)}`.length-1),i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:m6(i),t*i}function _6(e){tp.workerCount=e}function y6(e){ta.WORKER_URL=e}const v6="/ui/assets/maplibre-gl-worker-DIJJQdfC.js";var x6=Object.defineProperty,er=(e,t)=>x6(e,"name",{value:t,configurable:!0});function Gt(e,t){let i="script";return e==="name"?i="script":e==="name2"?i="script2":e==="name3"&&(i="script3"),[["coalesce",["get",`pgf:${e}`],["get",e]],{"text-font":["case",["==",["get",i],"Devanagari"],["literal",["Noto Sans Devanagari Regular v1"]],["literal",[t||"Noto Sans Regular"]]]}]}er(Gt,"get_name_block");function Ui(e,t,i){let r="name";return i==="name"?r="":i==="name2"?r="2":i==="name3"&&(r="3"),t==="Latin"?["has",`script${r}`]:e==="ja"?["all",["!=",["get",`script${r}`],"Han"],["!=",["get",`script${r}`],"Hiragana"],["!=",["get",`script${r}`],"Katakana"],["!=",["get",`script${r}`],"Mixed-Japanese"]]:["!=",["get",`script${r}`],t]}er(Ui,"is_not_in_target_script");function Si(e){return e==="Devanagari"?{"text-font":["literal",["Noto Sans Devanagari Regular v1"]]}:{}}er(Si,"get_font_formatting");function kp(e){let t=b6.find(i=>i.lang===e);return t===void 0?"Latin":t.script}er(kp,"get_default_script");function Mx(e,t){let i=t||kp(e),r;return i==="Devanagari"?r="pgf:":r="",["format",["coalesce",["get",`${r}name:${e}`],["get","name:en"]],Si(i)]}er(Mx,"get_country_name");function Ti(e,t,i){let r=t||kp(e),a;return r==="Devanagari"?a="pgf:":a="",["case",["all",["any",["has","name"],["has","pgf:name"]],["!",["any",["has","name2"],["has","pgf:name2"]]],["!",["any",["has","name3"],["has","pgf:name3"]]]],["case",Ui(e,r,"name"),["case",["any",["is-supported-script",["get","name"]],["has","pgf:name"]],["format",["coalesce",["get",`${a}name:${e}`],["get","name:en"]],Si(r),`
`,{},["case",["all",["!",["has",`${a}name:${e}`]],["has","name:en"],["!",["has","script"]]],"",["coalesce",["get","pgf:name"],["get","name"]]],{"text-font":["case",["==",["get","script"],"Devanagari"],["literal",["Noto Sans Devanagari Regular v1"]],["literal",[i||"Noto Sans Regular"]]]}],["get","name:en"]],["format",["coalesce",["get",`${a}name:${e}`],["get","pgf:name"],["get","name"]],Si(r)]],["all",["any",["has","name"],["has","pgf:name"]],["any",["has","name2"],["has","pgf:name2"]],["!",["any",["has","name3"],["has","pgf:name3"]]]],["case",["all",Ui(e,r,"name"),Ui(e,r,"name2")],["format",["get",`${a}name:${e}`],Si(r),`
`,{},...Gt("name",i),`
`,{},...Gt("name2",i)],["case",Ui(e,r,"name2"),["format",["coalesce",["get",`${a}name:${e}`],["get","pgf:name"],["get","name"]],Si(r),`
`,{},...Gt("name2",i)],["format",["coalesce",["get",`${a}name:${e}`],["get","pgf:name2"],["get","name2"]],Si(r),`
`,{},...Gt("name",i)]]],["case",["all",Ui(e,r,"name"),Ui(e,r,"name2"),Ui(e,r,"name3")],["format",["get",`${a}name:${e}`],Si(r),`
`,{},...Gt("name",i),`
`,{},...Gt("name2",i),`
`,{},...Gt("name3",i)],["case",["!",Ui(e,r,"name")],["format",["coalesce",["get",`${a}name:${e}`],["get","pgf:name"],["get","name"]],Si(r),`
`,{},...Gt("name2",i),`
`,{},...Gt("name3",i)],["!",Ui(e,r,"name2")],["format",["coalesce",["get",`${a}name:${e}`],["get","pgf:name2"],["get","name2"]],Si(r),`
`,{},...Gt("name",i),`
`,{},...Gt("name3",i)],["format",["coalesce",["get",`${a}name:${e}`],["get","pgf:name3"],["get","name3"]],Si(r),`
`,{},...Gt("name",i),`
`,{},...Gt("name2",i)]]]]}er(Ti,"get_multiline_name");var b6=[{lang:"ar",full_name:"Arabic",script:"Arabic"},{lang:"cs",full_name:"Czech",script:"Latin"},{lang:"bg",full_name:"Bulgarian",script:"Cyrillic"},{lang:"da",full_name:"Danish",script:"Latin"},{lang:"de",full_name:"German",script:"Latin"},{lang:"el",full_name:"Greek",script:"Greek"},{lang:"en",full_name:"English",script:"Latin"},{lang:"es",full_name:"Spanish",script:"Latin"},{lang:"et",full_name:"Estonian",script:"Latin"},{lang:"fa",full_name:"Persian",script:"Arabic"},{lang:"fi",full_name:"Finnish",script:"Latin"},{lang:"fr",full_name:"French",script:"Latin"},{lang:"ga",full_name:"Irish",script:"Latin"},{lang:"he",full_name:"Hebrew",script:"Hebrew"},{lang:"hi",full_name:"Hindi",script:"Devanagari"},{lang:"hr",full_name:"Croatian",script:"Latin"},{lang:"hu",full_name:"Hungarian",script:"Latin"},{lang:"id",full_name:"Indonesian",script:"Latin"},{lang:"it",full_name:"Italian",script:"Latin"},{lang:"ja",full_name:"Japanese",script:""},{lang:"ko",full_name:"Korean",script:"Hangul"},{lang:"lt",full_name:"Lithuanian",script:"Latin"},{lang:"lv",full_name:"Latvian",script:"Latin"},{lang:"ne",full_name:"Nepali",script:"Devanagari"},{lang:"nl",full_name:"Dutch",script:"Latin"},{lang:"no",full_name:"Norwegian",script:"Latin"},{lang:"mr",full_name:"Marathi",script:"Devanagari"},{lang:"mt",full_name:"Maltese",script:"Latin"},{lang:"pl",full_name:"Polish",script:"Latin"},{lang:"pt",full_name:"Portuguese",script:"Latin"},{lang:"ro",full_name:"Romanian",script:"Latin"},{lang:"ru",full_name:"Russian",script:"Cyrillic"},{lang:"sk",full_name:"Slovak",script:"Latin"},{lang:"sl",full_name:"Slovenian",script:"Latin"},{lang:"sv",full_name:"Swedish",script:"Latin"},{lang:"tr",full_name:"Turkish",script:"Latin"},{lang:"uk",full_name:"Ukrainian",script:"Cyrillic"},{lang:"ur",full_name:"Urdu",script:"Arabic"},{lang:"vi",full_name:"Vietnamese",script:"Latin"},{lang:"zh-Hans",full_name:"Chinese (Simplified)",script:"Han"},{lang:"zh-Hant",full_name:"Chinese (Traditional)",script:"Han"}];function Ix(e,t){return[{id:"background",type:"background",paint:{"background-color":t.background}},{id:"earth",type:"fill",filter:["==","$type","Polygon"],source:e,"source-layer":"earth",paint:{"fill-color":t.earth}},...t.landcover?[{id:"landcover",type:"fill",source:e,"source-layer":"landcover",paint:{"fill-color":["match",["get","kind"],"grassland",t.landcover.grassland,"barren",t.landcover.barren,"urban_area",t.landcover.urban_area,"farmland",t.landcover.farmland,"glacier",t.landcover.glacier,"scrub",t.landcover.scrub,t.landcover.forest],"fill-opacity":["interpolate",["linear"],["zoom"],5,1,7,0]}}]:[],{id:"landuse_park",type:"fill",source:e,"source-layer":"landuse",filter:["in","kind","national_park","park","cemetery","protected_area","nature_reserve","forest","golf_course","wood","scrub","grassland","grass","glacier","sand","military","naval_base","airfield"],paint:{"fill-opacity":["interpolate",["linear"],["zoom"],6,0,11,1],"fill-color":["case",["in",["get","kind"],["literal",["national_park","park","cemetery","protected_area","nature_reserve","forest","golf_course"]]],t.park_b,["==",["get","kind"],"wood"],t.wood_b,["in",["get","kind"],["literal",["scrub","grassland","grass"]]],t.scrub_b,["==",["get","kind"],"glacier"],t.glacier,["==",["get","kind"],"sand"],t.sand,["in",["get","kind"],["literal",["military","naval_base","airfield"]]],t.zoo,t.earth]}},{id:"landuse_urban_green",type:"fill",source:e,"source-layer":"landuse",filter:["in","kind","allotments","village_green","playground"],paint:{"fill-color":t.park_b,"fill-opacity":.7}},{id:"landuse_hospital",type:"fill",source:e,"source-layer":"landuse",filter:["==","kind","hospital"],paint:{"fill-color":t.hospital}},{id:"landuse_industrial",type:"fill",source:e,"source-layer":"landuse",filter:["==","kind","industrial"],paint:{"fill-color":t.industrial}},{id:"landuse_school",type:"fill",source:e,"source-layer":"landuse",filter:["in","kind","school","university","college"],paint:{"fill-color":t.school}},{id:"landuse_beach",type:"fill",source:e,"source-layer":"landuse",filter:["in","kind","beach"],paint:{"fill-color":t.beach}},{id:"landuse_zoo",type:"fill",source:e,"source-layer":"landuse",filter:["in","kind","zoo"],paint:{"fill-color":t.zoo}},{id:"landuse_aerodrome",type:"fill",source:e,"source-layer":"landuse",filter:["in","kind","aerodrome"],paint:{"fill-color":t.aerodrome}},{id:"roads_runway",type:"line",source:e,"source-layer":"roads",filter:["==","kind_detail","runway"],paint:{"line-color":t.runway,"line-width":["interpolate",["exponential",1.6],["zoom"],10,0,12,4,18,30]}},{id:"roads_taxiway",type:"line",source:e,"source-layer":"roads",minzoom:13,filter:["==","kind_detail","taxiway"],paint:{"line-color":t.runway,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,15,6]}},{id:"landuse_runway",type:"fill",source:e,"source-layer":"landuse",filter:["any",["in","kind","runway","taxiway"]],paint:{"fill-color":t.runway}},{id:"water",type:"fill",filter:["==","$type","Polygon"],source:e,"source-layer":"water",paint:{"fill-color":t.water}},{id:"water_stream",type:"line",source:e,"source-layer":"water",minzoom:14,filter:["in","kind","stream"],paint:{"line-color":t.water,"line-width":.5}},{id:"water_river",type:"line",source:e,"source-layer":"water",minzoom:9,filter:["in","kind","river"],paint:{"line-color":t.water,"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1,18,12]}},{id:"landuse_pedestrian",type:"fill",source:e,"source-layer":"landuse",filter:["in","kind","pedestrian","dam"],paint:{"fill-color":t.pedestrian}},{id:"landuse_pier",type:"fill",source:e,"source-layer":"landuse",filter:["==","kind","pier"],paint:{"fill-color":t.pier}},{id:"roads_tunnels_other_casing",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["in","kind","other","path"]],paint:{"line-color":t.tunnel_other_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_tunnels_minor_casing",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","minor_road"]],paint:{"line-color":t.tunnel_minor_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_tunnels_link_casing",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["has","is_link"]],paint:{"line-color":t.tunnel_link_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_tunnels_major_casing",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":t.tunnel_major_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_tunnels_highway_casing",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":t.tunnel_highway_casing,"line-dasharray":[6,.5],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_tunnels_other",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["in","kind","other","path"]],paint:{"line-color":t.tunnel_other,"line-dasharray":[4.5,.5],"line-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_tunnels_minor",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","minor_road"]],paint:{"line-color":t.tunnel_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_tunnels_link",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["has","is_link"]],paint:{"line-color":t.tunnel_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_tunnels_major",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","major_road"]],paint:{"line-color":t.tunnel_major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_tunnels_highway",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==",["get","kind"],"highway"],["!",["has","is_link"]]],paint:{"line-color":t.tunnel_highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}},{id:"buildings",type:"fill",source:e,"source-layer":"buildings",filter:["in","kind","building","building_part"],paint:{"fill-color":t.buildings,"fill-opacity":.5}},{id:"roads_pier",type:"line",source:e,"source-layer":"roads",filter:["==","kind_detail","pier"],paint:{"line-color":t.pier,"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,.5,20,16]}},{id:"roads_minor_service_casing",type:"line",source:e,"source-layer":"roads",minzoom:13,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["==","kind_detail","service"]],paint:{"line-color":t.minor_service_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,18,8],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,.8]}},{id:"roads_minor_casing",type:"line",source:e,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["!=","kind_detail","service"]],paint:{"line-color":t.minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_link_casing",type:"line",source:e,"source-layer":"roads",minzoom:13,filter:["has","is_link"],paint:{"line-color":t.minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1.5]}},{id:"roads_major_casing_late",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":t.major_casing_late,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_highway_casing_late",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":t.highway_casing_late,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_other",type:"line",source:e,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["in","kind","other","path"],["!=","kind_detail","pier"]],paint:{"line-color":t.other,"line-width":["interpolate",["exponential",1.6],["zoom"],14,.5,20,12]}},{id:"roads_link",type:"line",source:e,"source-layer":"roads",filter:["has","is_link"],paint:{"line-color":t.link,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_minor_service",type:"line",source:e,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["==","kind_detail","service"]],paint:{"line-color":t.minor_service,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,18,8]}},{id:"roads_minor",type:"line",source:e,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["!=","kind_detail","service"]],paint:{"line-color":["interpolate",["exponential",1.6],["zoom"],11,t.minor_a,16,t.minor_b],"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_major_casing_early",type:"line",source:e,"source-layer":"roads",maxzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":t.major_casing_early,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_major",type:"line",source:e,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":t.major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_highway_casing_early",type:"line",source:e,"source-layer":"roads",maxzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":t.highway_casing_early,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1]}},{id:"roads_highway",type:"line",source:e,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":t.highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}},{id:"roads_rail",type:"line",source:e,"source-layer":"roads",filter:["==","kind","rail"],paint:{"line-dasharray":[.3,.75],"line-opacity":.5,"line-color":t.railway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,.15,18,9]}},{id:"boundaries_country",type:"line",source:e,"source-layer":"boundaries",filter:["<=","kind_detail",2],paint:{"line-color":t.boundaries,"line-width":.7,"line-dasharray":["step",["zoom"],["literal",[2,0]],4,["literal",[2,1]]]}},{id:"boundaries",type:"line",source:e,"source-layer":"boundaries",filter:[">","kind_detail",2],paint:{"line-color":t.boundaries,"line-width":.4,"line-dasharray":["step",["zoom"],["literal",[2,0]],4,["literal",[2,1]]]}},{id:"roads_bridges_other_casing",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["in","kind","other","path"]],paint:{"line-color":t.bridges_other_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_bridges_link_casing",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["has","is_link"]],paint:{"line-color":t.bridges_minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1.5]}},{id:"roads_bridges_minor_casing",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","minor_road"]],paint:{"line-color":t.bridges_minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,.8]}},{id:"roads_bridges_major_casing",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":t.bridges_major_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,10],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1.5]}},{id:"roads_bridges_other",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["in","kind","other","path"]],paint:{"line-color":t.bridges_other,"line-dasharray":[2,1],"line-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_bridges_minor",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","minor_road"]],paint:{"line-color":t.bridges_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_bridges_link",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["has","is_link"]],paint:{"line-color":t.bridges_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_bridges_major",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":t.bridges_major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_bridges_highway_casing",type:"line",source:e,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":t.bridges_highway_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_bridges_highway",type:"line",source:e,"source-layer":"roads",filter:["all",["has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":t.bridges_highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}}]}er(Ix,"nolabels_layers");function Fx(e,t,i,r){return[{id:"address_label",type:"symbol",source:e,"source-layer":"buildings",minzoom:18,filter:["==","kind","address"],layout:{"symbol-placement":"point","text-font":[t.italic||"Noto Sans Italic"],"text-field":["get","addr_housenumber"],"text-size":12},paint:{"text-color":t.address_label,"text-halo-color":t.address_label_halo,"text-halo-width":1}},{id:"water_waterway_label",type:"symbol",source:e,"source-layer":"water",minzoom:13,filter:["in","kind","river","stream"],layout:{"symbol-placement":"line","text-font":[t.italic||"Noto Sans Italic"],"text-field":Ti(i,r,t.regular),"text-size":12,"text-letter-spacing":.2},paint:{"text-color":t.ocean_label,"text-halo-color":t.water,"text-halo-width":1}},{id:"roads_oneway",type:"symbol",source:e,"source-layer":"roads",minzoom:16,filter:["==",["get","oneway"],"yes"],layout:{"symbol-placement":"line","icon-image":"arrow","icon-rotate":90,"symbol-spacing":100}},{id:"roads_labels_minor",type:"symbol",source:e,"source-layer":"roads",minzoom:15,filter:["in","kind","minor_road","other","path"],layout:{"symbol-sort-key":["get","min_zoom"],"symbol-placement":"line","text-font":[t.regular||"Noto Sans Regular"],"text-field":Ti(i,r,t.regular),"text-size":12},paint:{"text-color":t.roads_label_minor,"text-halo-color":t.roads_label_minor_halo,"text-halo-width":1}},{id:"water_label_ocean",type:"symbol",source:e,"source-layer":"water",filter:["in","kind","sea","ocean","bay","strait","fjord"],layout:{"text-font":[t.italic||"Noto Sans Italic"],"text-field":Ti(i,r,t.regular),"text-size":["interpolate",["linear"],["zoom"],3,10,10,12],"text-letter-spacing":.1,"text-max-width":9,"text-transform":"uppercase"},paint:{"text-color":t.ocean_label,"text-halo-width":1,"text-halo-color":t.water}},{id:"earth_label_islands",type:"symbol",source:e,"source-layer":"earth",filter:["in","kind","island"],layout:{"text-font":[t.italic||"Noto Sans Italic"],"text-field":Ti(i,r,t.regular),"text-size":10,"text-letter-spacing":.1,"text-max-width":8},paint:{"text-color":t.subplace_label,"text-halo-color":t.subplace_label_halo,"text-halo-width":1}},{id:"water_label_lakes",type:"symbol",source:e,"source-layer":"water",filter:["in","kind","lake","water"],layout:{"text-font":[t.italic||"Noto Sans Italic"],"text-field":Ti(i,r,t.regular),"text-size":["interpolate",["linear"],["zoom"],3,10,6,12,10,12],"text-letter-spacing":.1,"text-max-width":9},paint:{"text-color":t.ocean_label,"text-halo-color":t.water,"text-halo-width":1}},{id:"roads_shields",type:"symbol",source:e,"source-layer":"roads",filter:["all",["in",["get","kind"],["literal",["highway","major_road"]]],["has","shield_text"],["<=",["length",["get","shield_text"]],5]],layout:{"icon-image":["match",["get","network"],"US:I",["concat","US:I-",["length",["get","shield_text"]],"char"],"NL:S-road",["concat","NL:S-road-",["length",["get","shield_text"]],"char"],["concat","generic_shield-",["length",["get","shield_text"]],"char"]],"text-field":["get","shield_text"],"text-font":[t.bold||"Noto Sans Medium"],"text-size":8,"icon-size":.8,"symbol-placement":"line","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport"},paint:{"text-color":t.roads_label_major}},{id:"roads_labels_major",type:"symbol",source:e,"source-layer":"roads",minzoom:11,filter:["in","kind","highway","major_road"],layout:{"symbol-sort-key":["get","min_zoom"],"symbol-placement":"line","text-font":[t.regular||"Noto Sans Regular"],"text-field":Ti(i,r,t.regular),"text-size":12},paint:{"text-color":t.roads_label_major,"text-halo-color":t.roads_label_major_halo,"text-halo-width":1}},...t.pois?[{id:"pois",type:"symbol",source:e,"source-layer":"pois",filter:["all",["in",["get","kind"],["literal",["beach","forest","marina","park","peak","zoo","garden","bench","aerodrome","station","bus_stop","ferry_terminal","stadium","university","library","school","animal","toilets","drinking_water","post_office","building","townhall","restaurant","fast_food","cafe","bar","supermarket","convenience","books","beauty","electronics","clothes","attraction","museum","theatre","artwork"]]],[">=",["zoom"],["+",["get","min_zoom"],0]]],layout:{"icon-image":["match",["get","kind"],"station","train_station",["get","kind"]],"text-font":[t.regular||"Noto Sans Regular"],"text-justify":"auto","text-field":Ti(i,r,t.regular),"text-size":["interpolate",["linear"],["zoom"],17,10,19,16],"text-max-width":8,"text-offset":[1.1,0],"text-variable-anchor":["left","right"]},paint:{"text-color":["case",["in",["get","kind"],["literal",["beach","forest","marina","park","peak","zoo","garden","bench"]]],t.pois.green,["in",["get","kind"],["literal",["aerodrome","station","bus_stop","ferry_terminal"]]],t.pois.lapis,["in",["get","kind"],["literal",["stadium","university","library","school","animal","toilets","drinking_water","post_office","building","townhall"]]],t.pois.slategray,["in",["get","kind"],["literal",["supermarket","convenience","books","beauty","electronics","clothes"]]],t.pois.blue,["in",["get","kind"],["literal",["restaurant","fast_food","cafe","bar"]]],t.pois.tangerine,["in",["get","kind"],["literal",["attraction","museum","theatre","artwork"]]],t.pois.pink,t.earth],"text-halo-color":t.earth,"text-halo-width":1}}]:[],{id:"places_subplace",type:"symbol",source:e,"source-layer":"places",filter:["in","kind","neighbourhood","macrohood"],layout:{"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-field":Ti(i,r,t.regular),"text-font":[t.regular||"Noto Sans Regular"],"text-max-width":7,"text-letter-spacing":.1,"text-padding":["interpolate",["linear"],["zoom"],5,2,8,4,12,18,15,20],"text-size":["interpolate",["exponential",1.2],["zoom"],11,8,14,14,18,24],"text-transform":"uppercase"},paint:{"text-color":t.subplace_label,"text-halo-color":t.subplace_label_halo,"text-halo-width":1}},{id:"places_region",type:"symbol",source:e,"source-layer":"places",filter:["==","kind","region"],layout:{"symbol-sort-key":["get","sort_key"],"text-field":["step",["zoom"],["coalesce",["get","ref:en"],["get","ref"]],6,Ti(i,r,t.regular)],"text-font":[t.regular||"Noto Sans Regular"],"text-size":["interpolate",["linear"],["zoom"],3,11,7,16],"text-radial-offset":.2,"text-anchor":"center","text-transform":"uppercase"},paint:{"text-color":t.state_label,"text-halo-color":t.state_label_halo,"text-halo-width":1}},{id:"places_locality",type:"symbol",source:e,"source-layer":"places",filter:["==","kind","locality"],layout:{"icon-image":["step",["zoom"],["case",["==",["get","capital"],"yes"],"capital","townspot"],8,""],"icon-size":.7,"text-field":Ti(i,r,t.regular),"text-font":["case",["<=",["get","min_zoom"],5],["literal",[t.bold||"Noto Sans Medium"]],["literal",[t.regular||"Noto Sans Regular"]]],"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-padding":["interpolate",["linear"],["zoom"],5,3,8,7,12,11],"text-size":["interpolate",["linear"],["zoom"],2,["case",["<",["get","population_rank"],13],8,[">=",["get","population_rank"],13],13,0],4,["case",["<",["get","population_rank"],13],10,[">=",["get","population_rank"],13],15,0],6,["case",["<",["get","population_rank"],12],11,[">=",["get","population_rank"],12],17,0],8,["case",["<",["get","population_rank"],11],11,[">=",["get","population_rank"],11],18,0],10,["case",["<",["get","population_rank"],9],12,[">=",["get","population_rank"],9],20,0],15,["case",["<",["get","population_rank"],8],12,[">=",["get","population_rank"],8],22,0]],"icon-padding":["interpolate",["linear"],["zoom"],0,0,8,4,10,8,12,6,22,2],"text-justify":"auto","text-variable-anchor":["step",["zoom"],["literal",["bottom","left","right","top"]],8,["literal",["center"]]],"text-radial-offset":.3},paint:{"text-color":t.city_label,"text-halo-color":t.city_label_halo,"text-halo-width":1}},{id:"places_country",type:"symbol",source:e,"source-layer":"places",filter:["==","kind","country"],layout:{"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-field":Mx(i,r),"text-font":[t.bold||"Noto Sans Medium"],"text-size":["interpolate",["linear"],["zoom"],2,["case",["<",["get","population_rank"],10],8,[">=",["get","population_rank"],10],12,0],6,["case",["<",["get","population_rank"],8],10,[">=",["get","population_rank"],8],18,0],8,["case",["<",["get","population_rank"],7],11,[">=",["get","population_rank"],7],20,0]],"icon-padding":["interpolate",["linear"],["zoom"],0,2,14,2,16,20,17,2,22,2],"text-transform":"uppercase"},paint:{"text-color":t.country_label,"text-halo-color":t.earth,"text-halo-width":1}}]}er(Fx,"labels_layers");var w6={background:"#cccccc",earth:"#e2dfda",park_a:"#cfddd5",park_b:"#9cd3b4",hospital:"#e4dad9",industrial:"#d1dde1",school:"#e4ded7",wood_a:"#d0ded0",wood_b:"#a0d9a0",pedestrian:"#e3e0d4",scrub_a:"#cedcd7",scrub_b:"#99d2bb",glacier:"#e7e7e7",sand:"#e2e0d7",beach:"#e8e4d0",aerodrome:"#dadbdf",runway:"#e9e9ed",water:"#80deea",zoo:"#c6dcdc",military:"#dcdcdc",tunnel_other_casing:"#e0e0e0",tunnel_minor_casing:"#e0e0e0",tunnel_link_casing:"#e0e0e0",tunnel_major_casing:"#e0e0e0",tunnel_highway_casing:"#e0e0e0",tunnel_other:"#d5d5d5",tunnel_minor:"#d5d5d5",tunnel_link:"#d5d5d5",tunnel_major:"#d5d5d5",tunnel_highway:"#d5d5d5",pier:"#e0e0e0",buildings:"#cccccc",minor_service_casing:"#e0e0e0",minor_casing:"#e0e0e0",link_casing:"#e0e0e0",major_casing_late:"#e0e0e0",highway_casing_late:"#e0e0e0",other:"#ebebeb",minor_service:"#ebebeb",minor_a:"#ebebeb",minor_b:"#ffffff",link:"#ffffff",major_casing_early:"#e0e0e0",major:"#ffffff",highway_casing_early:"#e0e0e0",highway:"#ffffff",railway:"#a7b1b3",boundaries:"#adadad",bridges_other_casing:"#e0e0e0",bridges_minor_casing:"#e0e0e0",bridges_link_casing:"#e0e0e0",bridges_major_casing:"#e0e0e0",bridges_highway_casing:"#e0e0e0",bridges_other:"#ebebeb",bridges_minor:"#ffffff",bridges_link:"#ffffff",bridges_major:"#f5f5f5",bridges_highway:"#ffffff",roads_label_minor:"#91888b",roads_label_minor_halo:"#ffffff",roads_label_major:"#938a8d",roads_label_major_halo:"#ffffff",ocean_label:"#728dd4",subplace_label:"#8f8f8f",subplace_label_halo:"#e0e0e0",city_label:"#5c5c5c",city_label_halo:"#e0e0e0",state_label:"#b3b3b3",state_label_halo:"#e0e0e0",country_label:"#a3a3a3",address_label:"#91888b",address_label_halo:"#ffffff",pois:{blue:"#1A8CBD",green:"#20834D",lapis:"#315BCF",pink:"#EF56BA",red:"#F2567A",slategray:"#6A5B8F",tangerine:"#CB6704",turquoise:"#00C3D4"},landcover:{grassland:"rgba(210, 239, 207, 1)",barren:"rgba(255, 243, 215, 1)",urban_area:"rgba(230, 230, 230, 1)",farmland:"rgba(216, 239, 210, 1)",glacier:"rgba(255, 255, 255, 1)",scrub:"rgba(234, 239, 210, 1)",forest:"rgba(196, 231, 210, 1)"}},T6={background:"#34373d",earth:"#1f1f1f",park_a:"#1c2421",park_b:"#192a24",hospital:"#252424",industrial:"#222222",school:"#262323",wood_a:"#202121",wood_b:"#202121",pedestrian:"#1e1e1e",scrub_a:"#222323",scrub_b:"#222323",glacier:"#1c1c1c",sand:"#212123",beach:"#28282a",aerodrome:"#1e1e1e",runway:"#333333",water:"#31353f",zoo:"#222323",military:"#242323",tunnel_other_casing:"#141414",tunnel_minor_casing:"#141414",tunnel_link_casing:"#141414",tunnel_major_casing:"#141414",tunnel_highway_casing:"#141414",tunnel_other:"#292929",tunnel_minor:"#292929",tunnel_link:"#292929",tunnel_major:"#292929",tunnel_highway:"#292929",pier:"#333333",buildings:"#111111",minor_service_casing:"#1f1f1f",minor_casing:"#1f1f1f",link_casing:"#1f1f1f",major_casing_late:"#1f1f1f",highway_casing_late:"#1f1f1f",other:"#333333",minor_service:"#333333",minor_a:"#3d3d3d",minor_b:"#333333",link:"#3d3d3d",major_casing_early:"#1f1f1f",major:"#3d3d3d",highway_casing_early:"#1f1f1f",highway:"#474747",railway:"#000000",boundaries:"#5b6374",bridges_other_casing:"#2b2b2b",bridges_minor_casing:"#1f1f1f",bridges_link_casing:"#1f1f1f",bridges_major_casing:"#1f1f1f",bridges_highway_casing:"#1f1f1f",bridges_other:"#333333",bridges_minor:"#333333",bridges_link:"#3d3d3d",bridges_major:"#3d3d3d",bridges_highway:"#474747",roads_label_minor:"#525252",roads_label_minor_halo:"#1f1f1f",roads_label_major:"#666666",roads_label_major_halo:"#1f1f1f",ocean_label:"#717784",subplace_label:"#525252",subplace_label_halo:"#1f1f1f",city_label:"#7a7a7a",city_label_halo:"#212121",state_label:"#3d3d3d",state_label_halo:"#1f1f1f",country_label:"#5c5c5c",address_label:"#525252",address_label_halo:"#1f1f1f",pois:{blue:"#4299BB",green:"#30C573",lapis:"#2B5CEA",pink:"#EF56BA",red:"#F2567A",slategray:"#93939F",tangerine:"#F19B6E",turquoise:"#00C3D4"},landcover:{grassland:"rgba(30, 41, 31, 1)",barren:"rgba(38, 38, 36, 1)",urban_area:"rgba(28, 28, 28, 1)",farmland:"rgba(31, 36, 32, 1)",glacier:"rgba(43, 43, 43, 1)",scrub:"rgba(34, 36, 30, 1)",forest:"rgba(28, 41, 37, 1)"}},D6={background:"#ffffff",earth:"#ffffff",park_a:"#fcfcfc",park_b:"#fcfcfc",hospital:"#f8f8f8",industrial:"#fcfcfc",school:"#f8f8f8",wood_a:"#fafafa",wood_b:"#fafafa",pedestrian:"#fdfdfd",scrub_a:"#fafafa",scrub_b:"#fafafa",glacier:"#fcfcfc",sand:"#fafafa",beach:"#f6f6f6",aerodrome:"#fdfdfd",runway:"#efefef",water:"#dcdcdc",zoo:"#f7f7f7",military:"#fcfcfc",tunnel_other_casing:"#d6d6d6",tunnel_minor_casing:"#fcfcfc",tunnel_link_casing:"#fcfcfc",tunnel_major_casing:"#fcfcfc",tunnel_highway_casing:"#fcfcfc",tunnel_other:"#d6d6d6",tunnel_minor:"#d6d6d6",tunnel_link:"#d6d6d6",tunnel_major:"#d6d6d6",tunnel_highway:"#d6d6d6",pier:"#efefef",buildings:"#efefef",minor_service_casing:"#ffffff",minor_casing:"#ffffff",link_casing:"#ffffff",major_casing_late:"#ffffff",highway_casing_late:"#ffffff",other:"#f5f5f5",minor_service:"#f5f5f5",minor_a:"#ebebeb",minor_b:"#f5f5f5",link:"#ebebeb",major_casing_early:"#ffffff",major:"#ebebeb",highway_casing_early:"#ffffff",highway:"#ebebeb",railway:"#d6d6d6",boundaries:"#adadad",bridges_other_casing:"#ffffff",bridges_minor_casing:"#ffffff",bridges_link_casing:"#ffffff",bridges_major_casing:"#ffffff",bridges_highway_casing:"#ffffff",bridges_other:"#f5f5f5",bridges_minor:"#f5f5f5",bridges_link:"#ebebeb",bridges_major:"#ebebeb",bridges_highway:"#ebebeb",roads_label_minor:"#adadad",roads_label_minor_halo:"#ffffff",roads_label_major:"#999999",roads_label_major_halo:"#ffffff",ocean_label:"#adadad",subplace_label:"#8f8f8f",subplace_label_halo:"#ffffff",city_label:"#5c5c5c",city_label_halo:"#ffffff",state_label:"#b3b3b3",state_label_halo:"#ffffff",country_label:"#b8b8b8",address_label:"#adadad",address_label_halo:"#ffffff"},S6={background:"#a3a3a3",earth:"#cccccc",park_a:"#c2c2c2",park_b:"#c2c2c2",hospital:"#d0d0d0",industrial:"#c6c6c6",school:"#d0d0d0",wood_a:"#c2c2c2",wood_b:"#c2c2c2",pedestrian:"#c4c4c4",scrub_a:"#c2c2c2",scrub_b:"#c2c2c2",glacier:"#d2d2d2",sand:"#d2d2d2",beach:"#d2d2d2",aerodrome:"#c9c9c9",runway:"#f5f5f5",water:"#a3a3a3",zoo:"#c7c7c7",military:"#bfbfbf",tunnel_other_casing:"#b8b8b8",tunnel_minor_casing:"#b8b8b8",tunnel_link_casing:"#b8b8b8",tunnel_major_casing:"#b8b8b8",tunnel_highway_casing:"#b8b8b8",tunnel_other:"#d6d6d6",tunnel_minor:"#d6d6d6",tunnel_link:"#d6d6d6",tunnel_major:"#d6d6d6",tunnel_highway:"#d6d6d6",pier:"#b8b8b8",buildings:"#e0e0e0",minor_service_casing:"#cccccc",minor_casing:"#cccccc",link_casing:"#cccccc",major_casing_late:"#cccccc",highway_casing_late:"#cccccc",other:"#e0e0e0",minor_service:"#e0e0e0",minor_a:"#ebebeb",minor_b:"#e0e0e0",link:"#ebebeb",major_casing_early:"#cccccc",major:"#ebebeb",highway_casing_early:"#cccccc",highway:"#ebebeb",railway:"#f5f5f5",boundaries:"#5c5c5c",bridges_other_casing:"#cccccc",bridges_minor_casing:"#cccccc",bridges_link_casing:"#cccccc",bridges_major_casing:"#cccccc",bridges_highway_casing:"#cccccc",bridges_other:"#e0e0e0",bridges_minor:"#e0e0e0",bridges_link:"#ebebeb",bridges_major:"#ebebeb",bridges_highway:"#ebebeb",roads_label_minor:"#999999",roads_label_minor_halo:"#e0e0e0",roads_label_major:"#8f8f8f",roads_label_major_halo:"#ebebeb",ocean_label:"#7a7a7a",subplace_label:"#7a7a7a",subplace_label_halo:"#cccccc",city_label:"#474747",city_label_halo:"#cccccc",state_label:"#999999",state_label_halo:"#cccccc",country_label:"#858585",address_label:"#999999",address_label_halo:"#e0e0e0"},E6={background:"#2b2b2b",earth:"#141414",park_a:"#181818",park_b:"#181818",hospital:"#1d1d1d",industrial:"#101010",school:"#111111",wood_a:"#1a1a1a",wood_b:"#1a1a1a",pedestrian:"#191919",scrub_a:"#1c1c1c",scrub_b:"#1c1c1c",glacier:"#191919",sand:"#161616",beach:"#1f1f1f",aerodrome:"#191919",runway:"#323232",water:"#333333",zoo:"#191919",military:"#121212",tunnel_other_casing:"#101010",tunnel_minor_casing:"#101010",tunnel_link_casing:"#101010",tunnel_major_casing:"#101010",tunnel_highway_casing:"#101010",tunnel_other:"#292929",tunnel_minor:"#292929",tunnel_link:"#292929",tunnel_major:"#292929",tunnel_highway:"#292929",pier:"#0a0a0a",buildings:"#0a0a0a",minor_service_casing:"#141414",minor_casing:"#141414",link_casing:"#141414",major_casing_late:"#141414",highway_casing_late:"#141414",other:"#1f1f1f",minor_service:"#1f1f1f",minor_a:"#292929",minor_b:"#1f1f1f",link:"#1f1f1f",major_casing_early:"#141414",major:"#292929",highway_casing_early:"#141414",highway:"#292929",railway:"#292929",boundaries:"#707070",bridges_other_casing:"#141414",bridges_minor_casing:"#141414",bridges_link_casing:"#141414",bridges_major_casing:"#141414",bridges_highway_casing:"#141414",bridges_other:"#1f1f1f",bridges_minor:"#1f1f1f",bridges_link:"#292929",bridges_major:"#292929",bridges_highway:"#292929",roads_label_minor:"#525252",roads_label_minor_halo:"#141414",roads_label_major:"#5c5c5c",roads_label_major_halo:"#141414",ocean_label:"#707070",subplace_label:"#5c5c5c",subplace_label_halo:"#141414",city_label:"#999999",city_label_halo:"#141414",state_label:"#3d3d3d",state_label_halo:"#141414",country_label:"#707070",address_label:"#525252",address_label_halo:"#141414"};function zx(e){switch(e){case"light":return w6;case"dark":return T6;case"white":return D6;case"grayscale":return S6;case"black":return E6}throw new Error("Flavor not found")}er(zx,"namedFlavor");function kx(e,t,i){let r=[];return i!=null&&i.labelsOnly||(r=Ix(e,t)),i!=null&&i.lang&&(r=r.concat(Fx(e,t,i.lang))),r}er(kx,"layers");const F_=(e,t,i)=>Array.isArray(e)&&t>=e[0]&&t<=e[2]&&i>=e[1]&&i<=e[3],C6=(e,t,i)=>e.find(r=>r.id.startsWith("cn-")&&F_(r.bounds,t,i))||e.find(r=>r.id==="china"&&F_(r.bounds,t,i))||e.find(r=>r.id==="world");function z_(e){const t=(e||[]).filter(a=>Number.isFinite(a.longitude)&&Number.isFinite(a.latitude)&&Number.isFinite(a.at)&&Math.abs(a.longitude)<=180&&Math.abs(a.latitude)<85).slice(0,1e4).sort((a,n)=>a.at-n.at),i=[];let r=[];for(let a=0;a<t.length;a++){const n=t[a];a&&n.at-t[a-1].at>1800&&(r.length>1&&i.push(r),r=[]),r.push([n.longitude,n.latitude])}return r.length>1&&i.push(r),{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"MultiLineString",coordinates:i}},...t.map((a,n)=>({type:"Feature",properties:{at:a.at,edge:n===0||n===t.length-1},geometry:{type:"Point",coordinates:[a.longitude,a.latitude]}}))]}}function Fh(e,t=Date.now()){return(Array.isArray(e)?e:[]).filter(i=>{const r=i==null?void 0:i.position;return i.status!=="stale"&&r&&Number.isFinite(r.longitude)&&Number.isFinite(r.latitude)&&Math.abs(r.longitude)<=180&&Math.abs(r.latitude)<=85.051129&&Number.isFinite(r.at)&&t/1e3-r.at<900&&r.at<=t/1e3+60}).slice(0,200)}function P6(e){const{longitude:t,latitude:i,accuracy:r}=e.position,a=Math.min(5e4,Math.max(0,Number(r)||0)),n=[];for(let o=0;o<=64;o++){const s=o*Math.PI/32;n.push([t+a*Math.cos(s)/(111320*Math.cos(i*Math.PI/180)),i+a*Math.sin(s)/111320])}return{type:"Feature",properties:{id:e.id},geometry:{type:"Polygon",coordinates:[n]}}}y6(v6);_6(2);function A6(e,{onSelect:t=()=>{},onStatus:i=()=>{},night:r=!1}={}){let a,n=!1,o=[],s=[],l="",u=new globalThis.Map,h=!1,c=!1,d=r,p={regions:[]},f,m,g,_="",y=!1;const v=new AbortController,x=location.origin,b=(D,P)=>C6(p.regions||[],D,P),w=()=>{const D={...zx(d?"dark":"light"),...d?{earth:"#192725",background:"#15211f",water:"#173747",minor_a:"#33483e",minor_b:"#33483e",major:"#496354",highway:"#6f7160",roads_label_minor:"#b1c3b9",roads_label_major:"#c8d8ce",subplace_label:"#adbbb3",city_label:"#d0ddcf",state_label:"#d0ddcf",country_label:"#d0ddcf",roads_label_minor_halo:"#192725",roads_label_major_halo:"#192725",subplace_label_halo:"#192725",city_label_halo:"#192725"}:{earth:"#f3f0e7",water:"#bad8e6",park_a:"#d7e4cf"}},P=(a==null?void 0:a.getCenter())||{lng:117.8,lat:36.6},R=(a==null?void 0:a.getZoom())||6;let k=b(P.lng,P.lat);return R<=6?k=p.regions.find(B=>B.id==="world")||k:R<9&&(k!=null&&k.id.startsWith("cn-"))&&(k=p.regions.find(B=>B.id==="china")||k),k=k||p.regions[0],_=k.id+d+k.revision,{version:8,glyphs:`${x}/maps/assets/fonts/{fontstack}/{range}.pbf`,sprite:`${x}/maps/assets/sprites/v4/${d?"dark":"light"}`,sources:{base:{type:"vector",tiles:[`${x}/maps/tiles/${k.id}/{z}/{x}/{y}.mvt`],minzoom:0,maxzoom:k.maxZoom,bounds:k.bounds}},layers:kx("base",D,{lang:"zh"})}},T=D=>D!=null&&D.id.startsWith("cn-")?18:(D==null?void 0:D.id)==="china"?11:6;function S(){if(!a||!c)return;const D=a.getCenter(),P=b(D.lng,D.lat);i(P!=null&&P.id.startsWith("cn-")?`${P.name}详细地图 · 道路与建筑`:`${(P==null?void 0:P.name)||"概览"} · 进入省份后后台准备详细地图,完成后自动可用`)}function C(){if(!a||!c||n)return;const D=_,P=w();D!==_&&(a.setStyle(P),a.once("style.load",A));const R=a.getCenter(),k=T(b(R.lng,R.lat));a.getMaxZoom()!==k&&a.setMaxZoom(k),S()}function F(){for(const D of u.values())D.remove();u.clear()}function A(){if(!a||n)return;const D=Fh(o),P=new Set(D.map(R=>R.id));for(const[R,k]of u)P.has(R)||(k.remove(),u.delete(R));for(const R of D){if(u.has(R.id)){const oe=u.get(R.id),pe=oe.getElement();oe.setLngLat([R.position.longitude,R.position.latitude]),pe.classList.toggle("selected",R.id===l),pe.firstChild.textContent=String(R.name||"家人").slice(0,1),pe.lastChild.textContent=String(R.name||"家人"),pe.setAttribute("aria-label",`查看${R.name||"家人"}的位置`);continue}const k=document.createElement("button");k.type="button",k.className="family-map-pin"+(R.id===l?" selected":""),k.setAttribute("aria-label",`查看${R.name||"家人"}的位置`);const B=document.createElement("span");B.textContent=String(R.name||"家人").slice(0,1);const Z=document.createElement("b");Z.textContent=String(R.name||"家人"),k.append(B,Z),k.onclick=()=>{l=R.id,t(R.id),I(R.id)},u.set(R.id,new d6({element:k,anchor:"bottom"}).setLngLat([R.position.longitude,R.position.latitude]).addTo(a))}if(a.isStyleLoaded()){const R={type:"FeatureCollection",features:D.filter(B=>!l||B.id===l).map(P6)};a.getSource("family-accuracy")?a.getSource("family-accuracy").setData(R):(a.addSource("family-accuracy",{type:"geojson",data:R}),a.addLayer({id:"family-accuracy-fill",type:"fill",source:"family-accuracy",paint:{"fill-color":"#238e79","fill-opacity":.12}}),a.addLayer({id:"family-accuracy-line",type:"line",source:"family-accuracy",paint:{"line-color":"#238e79","line-width":1,"line-opacity":.6}}));const k=z_(s);a.getSource("family-track")?a.getSource("family-track").setData(k):(a.addSource("family-track",{type:"geojson",data:k}),a.addLayer({id:"family-track-line",type:"line",source:"family-track",filter:["==",["geometry-type"],"LineString"],paint:{"line-color":"#e49a26","line-width":4,"line-opacity":.85}}),a.addLayer({id:"family-track-points",type:"circle",source:"family-track",filter:["==",["geometry-type"],"Point"],paint:{"circle-radius":["case",["get","edge"],6,3],"circle-color":"#217d6b","circle-stroke-color":"#fff","circle-stroke-width":1}}))}!h&&D.length&&(h=!0,L())}function L(){if(!a)return;if(s.length){const k=z_(s).features.filter(B=>B.geometry.type==="Point").map(B=>B.geometry.coordinates);if(k.length){a.setMaxZoom(18),a.fitBounds([[Math.min(...k.map(B=>B[0])),Math.min(...k.map(B=>B[1]))],[Math.max(...k.map(B=>B[0])),Math.max(...k.map(B=>B[1]))]],{padding:55,maxZoom:14,duration:400});return}}const D=Fh(o);if(D.length===1){I(D[0].id);return}if(!D.length){a.easeTo({center:[105,35],zoom:4,duration:400});return}const P=D.map(k=>k.position.longitude),R=D.map(k=>k.position.latitude);a.setMaxZoom(18),a.fitBounds([[Math.min(...P),Math.min(...R)],[Math.max(...P),Math.max(...R)]],{padding:65,maxZoom:13,duration:500})}function I(D){const P=Fh(o).find(B=>B.id===D);if(!a||!P)return;l=D;const R=P.position,k=T(b(R.longitude,R.latitude));a.setMaxZoom(k),a.easeTo({center:[R.longitude,R.latitude],zoom:Math.min(14,k),duration:450}),A()}const E={setItems(D){o=Array.isArray(D)?D:[],o.length||(h=!1,l=""),A()},setTrack(D){s=Array.isArray(D)?D:[],A(),s.length&&L()},focus:I,fit:L,setNight(D){d!==D&&(d=D,C())},resize(){a==null||a.resize()},destroy(){n=!0,v.abort(),clearInterval(f),clearInterval(m),g==null||g.disconnect(),F(),a==null||a.remove(),a=null,o=[],s=[]},ready:Promise.resolve()};return E.ready=(async()=>{var D;try{const P=setTimeout(()=>v.abort(),1e4);let R;try{R=await fetch("/maps/catalog.json",{signal:v.signal})}finally{clearTimeout(P)}if(!R.ok)throw Error();if(p=await R.json(),n)return;if(!((D=p.regions)!=null&&D.length)){i("地图数据尚未就绪,家人位置可查看列表");return}a=new r6({container:e,style:w(),center:[117.8,36.6],zoom:6,maxZoom:18,minZoom:1,attributionControl:!1,renderWorldCopies:!1,dragRotate:!1,touchPitch:!1,localIdeographFontFamily:"sans-serif"}),a.addControl(new n6({showCompass:!1}),"top-right"),a.addControl(new f6({unit:"metric"}),"bottom-left"),a.addControl(new Ex({compact:!0,customAttribution:'<a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">© OpenStreetMap</a> · <a href="https://protomaps.com" target="_blank" rel="noreferrer">Protomaps</a>'}),"bottom-right"),a.on("load",()=>{c=!0,A(),s.length&&L(),S()}),a.on("error",()=>i("部分地图未能加载,可重试;家人信息仍可查看列表")),a.on("moveend",C),g=new ResizeObserver(()=>a==null?void 0:a.resize()),g.observe(e),f=setInterval(A,15e3),m=setInterval(async()=>{var k;if(!(n||y)){y=!0;try{const B=await fetch("/maps/catalog.json",{signal:v.signal,cache:"no-store"});if(B.ok){const Z=await B.json();(k=Z.regions)!=null&&k.length&&Z.revision!==p.revision&&(p=Z,C())}}catch(B){}finally{y=!1}}},2e4)}catch(P){n||i("此设备暂时无法绘制地图,请查看家人列表或更新系统 WebView")}})(),E}export{A6 as createFamilyMap};