diff --git a/config/importmap.rb b/config/importmap.rb index 9b70f201..6160d09e 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -27,7 +27,10 @@ under: "mapbox-gl-draw-paint-mode", preload: false # https://github.com/maplibre/maplibre-gl-js -pin "maplibre-gl" # @6.0.0 — preloaded so the browser fetches during head parse +# From https://cdn.jsdelivr.net/npm/maplibre-gl@6.1.0/dist/ +# update all of maplibre-gl.js + maplibre-gl-shared.mjs + maplibre-gl-worker.mjs +# preloaded so the browser fetches during head parse +pin "maplibre-gl" # @6.1.0 # https://github.com/maplibre/maplibre-gl-geocoder pin "@maplibre/maplibre-gl-geocoder", preload: false, to: "@maplibre--maplibre-gl-geocoder.js" # @1.9.4 # https://github.com/GIScience/openrouteservice-js?tab=readme-ov-file diff --git a/vendor/javascript/maplibre-gl-shared.mjs b/vendor/javascript/maplibre-gl-shared.mjs index e4f73662..955af1b7 100644 --- a/vendor/javascript/maplibre-gl-shared.mjs +++ b/vendor/javascript/maplibre-gl-shared.mjs @@ -1,6 +1,6 @@ /** * MapLibre GL JS -* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.0.0/LICENSE.txt +* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.1.0/LICENSE.txt */ -var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(t,n)=>()=>(n||(t((n={exports:{}}).exports,n),t=null),n.exports),l=(t,o,c,l)=>{if(o&&typeof o==`object`||typeof o==`function`)for(var u=a(o),d=0,f=u.length,p;do[t]).bind(null,p),enumerable:!(l=r(o,p))||l.enumerable});return t},u=(r,a,s)=>(s=r==null?{}:t(o(r)),l(a||!r||!r.__esModule?n(s,`default`,{value:r,enumerable:!0}):s,r));function d(t,n){this.x=t,this.y=n}d.prototype={clone(){return new d(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,n){return this.clone()._rotateAround(t,n)},matMult(t){return this.clone()._matMult(t)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){let n=t.x-this.x,r=t.y-this.y;return n*n+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,n){return Math.atan2(this.x*n-this.y*t,this.x*t+this.y*n)},_matMult(t){let n=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=n,this.y=r,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){let t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){let n=Math.cos(t),r=Math.sin(t),a=n*this.x-r*this.y,o=r*this.x+n*this.y;return this.x=a,this.y=o,this},_rotateAround(t,n){let r=Math.cos(t),a=Math.sin(t),o=n.x+r*(this.x-n.x)-a*(this.y-n.y),s=n.y+a*(this.x-n.x)+r*(this.y-n.y);return this.x=o,this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:d},d.convert=function(t){if(t instanceof d)return t;if(Array.isArray(t))return new d(+t[0],+t[1]);if(t.x!==void 0&&t.y!==void 0)return new d(+t.x,+t.y);throw Error(`Expected [x, y] or {x, y} point format`)};function f(t,n,r,a){let o=3*t,s=3*(r-t)-o,c=1-o-s,l=3*n,u=3*(a-n)-l,d=1-l-u;return function(t,n=1e-6){if(t<=0)return 0;if(t>=1)return 1;let r=t;for(let a=0;a<8;a++){let a=((c*r+s)*r+o)*r-t;if(Math.abs(a)l?a=r:f=r,r=(a+f)*.5}return((d*r+u)*r+l)*r}}let p;function m(){return p??=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)&&typeof createImageBitmap==`function`,p}let h;function g(){if(h==null&&(h=!1,m())){let t=new OffscreenCanvas(5,5).getContext(`2d`,{willReadFrequently:!0});if(t){for(let n=0;n<25;n++){let r=n*4;t.fillStyle=`rgb(${r},${r+1},${r+2})`,t.fillRect(n%5,Math.floor(n/5),1,1)}let n=t.getImageData(0,0,5,5).data;for(let t=0;t<100;t++)if(t%4!=3&&n[t]!==t){h=!0;break}}}return h||!1}var _=typeof Float32Array<`u`?Float32Array:Array;Math.PI/180,180/Math.PI;function v(){var t=new _(9);return _!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function y(t){var n=t[0],r=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8];return n*(d*s-c*u)+r*(-d*o+c*l)+a*(u*o-s*l)}function b(t,n){var r=Math.sin(n),a=Math.cos(n);return t[0]=a,t[1]=r,t[2]=0,t[3]=-r,t[4]=a,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function x(t,n){var r=n[0],a=n[1],o=n[2],s=n[3],c=r+r,l=a+a,u=o+o,d=r*c,f=a*c,p=a*l,m=o*c,h=o*l,g=o*u,_=s*c,v=s*l,y=s*u;return t[0]=1-p-g,t[3]=f-y,t[6]=m+v,t[1]=f+y,t[4]=1-d-g,t[7]=h-_,t[2]=m-v,t[5]=h+_,t[8]=1-d-p,t}function S(){var t=new _(16);return _!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function C(t){var n=new _(16);return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function w(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],t}function T(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function E(t,n){var r=n[0],a=n[1],o=n[2],s=n[3],c=n[4],l=n[5],u=n[6],d=n[7],f=n[8],p=n[9],m=n[10],h=n[11],g=n[12],_=n[13],v=n[14],y=n[15],b=r*l-a*c,x=r*u-o*c,S=r*d-s*c,C=a*u-o*l,w=a*d-s*l,T=o*d-s*u,E=f*_-p*g,D=f*v-m*g,O=f*y-h*g,k=p*v-m*_,A=p*y-h*_,j=m*y-h*v,M=b*j-x*A+S*k+C*O-w*D+T*E;return M?(M=1/M,t[0]=(l*j-u*A+d*k)*M,t[1]=(o*A-a*j-s*k)*M,t[2]=(_*T-v*w+y*C)*M,t[3]=(m*w-p*T-h*C)*M,t[4]=(u*O-c*j-d*D)*M,t[5]=(r*j-o*O+s*D)*M,t[6]=(v*S-g*T-y*x)*M,t[7]=(f*T-m*S+h*x)*M,t[8]=(c*A-l*O+d*E)*M,t[9]=(a*O-r*A-s*E)*M,t[10]=(g*w-_*S+y*b)*M,t[11]=(p*S-f*w-h*b)*M,t[12]=(l*D-c*k-u*E)*M,t[13]=(r*k-a*D+o*E)*M,t[14]=(_*x-g*C-v*b)*M,t[15]=(f*C-p*x+m*b)*M,t):null}function D(t,n,r){var a=n[0],o=n[1],s=n[2],c=n[3],l=n[4],u=n[5],d=n[6],f=n[7],p=n[8],m=n[9],h=n[10],g=n[11],_=n[12],v=n[13],y=n[14],b=n[15],x=r[0],S=r[1],C=r[2],w=r[3];return t[0]=x*a+S*l+C*p+w*_,t[1]=x*o+S*u+C*m+w*v,t[2]=x*s+S*d+C*h+w*y,t[3]=x*c+S*f+C*g+w*b,x=r[4],S=r[5],C=r[6],w=r[7],t[4]=x*a+S*l+C*p+w*_,t[5]=x*o+S*u+C*m+w*v,t[6]=x*s+S*d+C*h+w*y,t[7]=x*c+S*f+C*g+w*b,x=r[8],S=r[9],C=r[10],w=r[11],t[8]=x*a+S*l+C*p+w*_,t[9]=x*o+S*u+C*m+w*v,t[10]=x*s+S*d+C*h+w*y,t[11]=x*c+S*f+C*g+w*b,x=r[12],S=r[13],C=r[14],w=r[15],t[12]=x*a+S*l+C*p+w*_,t[13]=x*o+S*u+C*m+w*v,t[14]=x*s+S*d+C*h+w*y,t[15]=x*c+S*f+C*g+w*b,t}function O(t,n,r){var a=r[0],o=r[1],s=r[2],c,l,u,d,f,p,m,h,g,_,v,y;return n===t?(t[12]=n[0]*a+n[4]*o+n[8]*s+n[12],t[13]=n[1]*a+n[5]*o+n[9]*s+n[13],t[14]=n[2]*a+n[6]*o+n[10]*s+n[14],t[15]=n[3]*a+n[7]*o+n[11]*s+n[15]):(c=n[0],l=n[1],u=n[2],d=n[3],f=n[4],p=n[5],m=n[6],h=n[7],g=n[8],_=n[9],v=n[10],y=n[11],t[0]=c,t[1]=l,t[2]=u,t[3]=d,t[4]=f,t[5]=p,t[6]=m,t[7]=h,t[8]=g,t[9]=_,t[10]=v,t[11]=y,t[12]=c*a+f*o+g*s+n[12],t[13]=l*a+p*o+_*s+n[13],t[14]=u*a+m*o+v*s+n[14],t[15]=d*a+h*o+y*s+n[15]),t}function k(t,n,r){var a=r[0],o=r[1],s=r[2];return t[0]=n[0]*a,t[1]=n[1]*a,t[2]=n[2]*a,t[3]=n[3]*a,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=n[7]*o,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=n[11]*s,t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],t}function A(t,n,r){var a=Math.sin(r),o=Math.cos(r),s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],f=n[9],p=n[10],m=n[11];return n!==t&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15]),t[4]=s*o+d*a,t[5]=c*o+f*a,t[6]=l*o+p*a,t[7]=u*o+m*a,t[8]=d*o-s*a,t[9]=f*o-c*a,t[10]=p*o-l*a,t[11]=m*o-u*a,t}function j(t,n,r){var a=Math.sin(r),o=Math.cos(r),s=n[0],c=n[1],l=n[2],u=n[3],d=n[8],f=n[9],p=n[10],m=n[11];return n!==t&&(t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15]),t[0]=s*o-d*a,t[1]=c*o-f*a,t[2]=l*o-p*a,t[3]=u*o-m*a,t[8]=s*a+d*o,t[9]=c*a+f*o,t[10]=l*a+p*o,t[11]=u*a+m*o,t}function M(t,n,r){var a=Math.sin(r),o=Math.cos(r),s=n[0],c=n[1],l=n[2],u=n[3],d=n[4],f=n[5],p=n[6],m=n[7];return n!==t&&(t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15]),t[0]=s*o+d*a,t[1]=c*o+f*a,t[2]=l*o+p*a,t[3]=u*o+m*a,t[4]=d*o-s*a,t[5]=f*o-c*a,t[6]=p*o-l*a,t[7]=m*o-u*a,t}function ee(t,n){return t[0]=n[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=n[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function te(t,n,r,a,o){var s=1/Math.tan(n/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){var c=1/(a-o);t[10]=(o+a)*c,t[14]=2*o*a*c}else t[10]=-1,t[14]=-2*a;return t}var ne=te;function re(t,n,r,a,o,s,c){var l=1/(n-r),u=1/(a-o),d=1/(s-c);return t[0]=-2*l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*d,t[11]=0,t[12]=(n+r)*l,t[13]=(o+a)*u,t[14]=(c+s)*d,t[15]=1,t}var ie=re;function ae(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&t[4]===n[4]&&t[5]===n[5]&&t[6]===n[6]&&t[7]===n[7]&&t[8]===n[8]&&t[9]===n[9]&&t[10]===n[10]&&t[11]===n[11]&&t[12]===n[12]&&t[13]===n[13]&&t[14]===n[14]&&t[15]===n[15]}function oe(t,n){var r=t[0],a=t[1],o=t[2],s=t[3],c=t[4],l=t[5],u=t[6],d=t[7],f=t[8],p=t[9],m=t[10],h=t[11],g=t[12],_=t[13],v=t[14],y=t[15],b=n[0],x=n[1],S=n[2],C=n[3],w=n[4],T=n[5],E=n[6],D=n[7],O=n[8],k=n[9],A=n[10],j=n[11],M=n[12],ee=n[13],te=n[14],ne=n[15];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(o-S)<=1e-6*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(s-C)<=1e-6*Math.max(1,Math.abs(s),Math.abs(C))&&Math.abs(c-w)<=1e-6*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(l-T)<=1e-6*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(u-E)<=1e-6*Math.max(1,Math.abs(u),Math.abs(E))&&Math.abs(d-D)<=1e-6*Math.max(1,Math.abs(d),Math.abs(D))&&Math.abs(f-O)<=1e-6*Math.max(1,Math.abs(f),Math.abs(O))&&Math.abs(p-k)<=1e-6*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(m-A)<=1e-6*Math.max(1,Math.abs(m),Math.abs(A))&&Math.abs(h-j)<=1e-6*Math.max(1,Math.abs(h),Math.abs(j))&&Math.abs(g-M)<=1e-6*Math.max(1,Math.abs(g),Math.abs(M))&&Math.abs(_-ee)<=1e-6*Math.max(1,Math.abs(_),Math.abs(ee))&&Math.abs(v-te)<=1e-6*Math.max(1,Math.abs(v),Math.abs(te))&&Math.abs(y-ne)<=1e-6*Math.max(1,Math.abs(y),Math.abs(ne))}function se(){var t=new _(3);return _!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function ce(t){var n=new _(3);return n[0]=t[0],n[1]=t[1],n[2]=t[2],n}function le(t){var n=t[0],r=t[1],a=t[2];return Math.sqrt(n*n+r*r+a*a)}function ue(t,n,r){var a=new _(3);return a[0]=t,a[1]=n,a[2]=r,a}function de(t,n,r){return t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function fe(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2],t}function pe(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t}function me(t,n,r,a){return t[0]=n[0]+r[0]*a,t[1]=n[1]+r[1]*a,t[2]=n[2]+r[2]*a,t}function he(t,n){return t[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t}function ge(t,n){var r=n[0],a=n[1],o=n[2],s=r*r+a*a+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t}function _e(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ve(t,n,r){var a=n[0],o=n[1],s=n[2],c=r[0],l=r[1],u=r[2];return t[0]=o*u-s*l,t[1]=s*c-a*u,t[2]=a*l-o*c,t}function ye(t,n,r){var a=n[0],o=n[1],s=n[2],c=r[3]*a+r[7]*o+r[11]*s+r[15];return c||=1,t[0]=(r[0]*a+r[4]*o+r[8]*s+r[12])/c,t[1]=(r[1]*a+r[5]*o+r[9]*s+r[13])/c,t[2]=(r[2]*a+r[6]*o+r[10]*s+r[14])/c,t}function be(t,n,r){var a=n[0],o=n[1],s=n[2];return t[0]=a*r[0]+o*r[3]+s*r[6],t[1]=a*r[1]+o*r[4]+s*r[7],t[2]=a*r[2]+o*r[5]+s*r[8],t}function xe(t,n,r){var a=r[0],o=r[1],s=r[2],c=r[3],l=n[0],u=n[1],d=n[2],f=o*d-s*u,p=s*l-a*d,m=a*u-o*l;return f+=f,p+=p,m+=m,t[0]=l+c*f+o*m-s*p,t[1]=u+c*p+s*f-a*m,t[2]=d+c*m+a*p-o*f,t}function Se(t,n,r,a){var o=[],s=[];return o[0]=n[0]-r[0],o[1]=n[1]-r[1],o[2]=n[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(a)-o[2]*Math.sin(a),s[2]=o[1]*Math.sin(a)+o[2]*Math.cos(a),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Ce(t,n,r,a){var o=[],s=[];return o[0]=n[0]-r[0],o[1]=n[1]-r[1],o[2]=n[2]-r[2],s[0]=o[2]*Math.sin(a)+o[0]*Math.cos(a),s[1]=o[1],s[2]=o[2]*Math.cos(a)-o[0]*Math.sin(a),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function we(t,n,r,a){var o=[],s=[];return o[0]=n[0]-r[0],o[1]=n[1]-r[1],o[2]=n[2]-r[2],s[0]=o[0]*Math.cos(a)-o[1]*Math.sin(a),s[1]=o[0]*Math.sin(a)+o[1]*Math.cos(a),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Te(t){return t[0]=0,t[1]=0,t[2]=0,t}var Ee=fe,De=le;(function(){var t=se();return function(n,r,a,o,s,c){var l,u;for(r||=3,a||=0,u=o?Math.min(o*r+a,n.length):n.length,l=a;l0&&(c=1/Math.sqrt(c)),t[0]=r*c,t[1]=a*c,t[2]=o*c,t[3]=s*c,t}function Me(t,n,r){var a=n[0],o=n[1],s=n[2],c=n[3];return t[0]=r[0]*a+r[4]*o+r[8]*s+r[12]*c,t[1]=r[1]*a+r[5]*o+r[9]*s+r[13]*c,t[2]=r[2]*a+r[6]*o+r[10]*s+r[14]*c,t[3]=r[3]*a+r[7]*o+r[11]*s+r[15]*c,t}var Ne=ke;(function(){var t=Oe();return function(n,r,a,o,s,c){var l,u;for(r||=4,a||=0,u=o?Math.min(o*r+a,n.length):n.length,l=a;l1e-6?(m=Math.acos(h),g=Math.sin(m),_=Math.sin((1-a)*m)/g,v=Math.sin(a*m)/g):(_=1-a,v=a),t[0]=_*o+v*u,t[1]=_*s+v*d,t[2]=_*c+v*f,t[3]=_*l+v*p,t}function Le(t,n){var r=n[0]+n[4]+n[8],a;if(r>0)a=Math.sqrt(r+1),t[3]=.5*a,a=.5/a,t[0]=(n[5]-n[7])*a,t[1]=(n[6]-n[2])*a,t[2]=(n[1]-n[3])*a;else{var o=0;n[4]>n[0]&&(o=1),n[8]>n[o*3+o]&&(o=2);var s=(o+1)%3,c=(o+2)%3;a=Math.sqrt(n[o*3+o]-n[s*3+s]-n[c*3+c]+1),t[o]=.5*a,a=.5/a,t[3]=(n[s*3+c]-n[c*3+s])*a,t[s]=(n[s*3+o]+n[o*3+s])*a,t[c]=(n[c*3+o]+n[o*3+c])*a}return t}function Re(t,n,r,a){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`zyx`,s=Math.PI/360;n*=s,a*=s,r*=s;var c=Math.sin(n),l=Math.cos(n),u=Math.sin(r),d=Math.cos(r),f=Math.sin(a),p=Math.cos(a);switch(o){case`xyz`:t[0]=c*d*p+l*u*f,t[1]=l*u*p-c*d*f,t[2]=l*d*f+c*u*p,t[3]=l*d*p-c*u*f;break;case`xzy`:t[0]=c*d*p-l*u*f,t[1]=l*u*p-c*d*f,t[2]=l*d*f+c*u*p,t[3]=l*d*p+c*u*f;break;case`yxz`:t[0]=c*d*p+l*u*f,t[1]=l*u*p-c*d*f,t[2]=l*d*f-c*u*p,t[3]=l*d*p+c*u*f;break;case`yzx`:t[0]=c*d*p+l*u*f,t[1]=l*u*p+c*d*f,t[2]=l*d*f-c*u*p,t[3]=l*d*p-c*u*f;break;case`zxy`:t[0]=c*d*p-l*u*f,t[1]=l*u*p+c*d*f,t[2]=l*d*f+c*u*p,t[3]=l*d*p-c*u*f;break;case`zyx`:t[0]=c*d*p-l*u*f,t[1]=l*u*p+c*d*f,t[2]=l*d*f-c*u*p,t[3]=l*d*p+c*u*f;break;default:throw Error(`Unknown angle order `+o)}return t}var ze=je;(function(){var t=se(),n=ue(1,0,0),r=ue(0,1,0);return function(a,o,s){var c=_e(o,s);return c<-.999999?(ve(t,n,o),De(t)<1e-6&&ve(t,r,o),ge(t,t),Fe(a,t,Math.PI),a):c>.999999?(a[0]=0,a[1]=0,a[2]=0,a[3]=1,a):(ve(t,o,s),a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=1+c,ze(a,a))}})(),function(){var t=Pe(),n=Pe();return function(r,a,o,s,c,l){return Ie(t,a,c,l),Ie(n,o,s,l),Ie(r,t,n,2*l*(1-l)),r}}(),function(){var t=v();return function(n,r,a,o){return t[0]=a[0],t[3]=a[1],t[6]=a[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],ze(n,Le(n,t))}}();function Be(){var t=new _(2);return _!=Float32Array&&(t[0]=0,t[1]=0),t}function Ve(t,n){var r=new _(2);return r[0]=t,r[1]=n,r}function He(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t}function Ue(t){var n=t[0],r=t[1];return Math.sqrt(n*n+r*r)}function We(t){var n=t[0],r=t[1];return n*n+r*r}function Ge(t,n){return t[0]*n[0]+t[1]*n[1]}function Ke(t,n,r){var a=n[0],o=n[1];return t[0]=r[0]*a+r[4]*o+r[12],t[1]=r[1]*a+r[5]*o+r[13],t}function qe(t){return t[0]=0,t[1]=0,t}var Je=We;(function(){var t=Be();return function(n,r,a,o,s,c){var l,u;for(r||=2,a||=0,u=o?Math.min(o*r+a,n.length):n.length,l=a;l0?l:-l}function lt(t,n){let r=dt(t,360),a=dt(n,360),o=a-r,s=a>r?o-360:o+360;return Math.abs(o)t.canonical.z)),r=1/0,a=-1/0,o=1/0,s=-1/0,c=[];for(let l of t){let{x:t,y:u,z:d}=l.canonical,f=2**(n-d),p=t*f,m=u*f;c.push({id:l,x:p,y:m}),pa&&(a=p),ms&&(s=m)}let l=/* @__PURE__ */ new Set;for(let t of c)(t.x===r||t.x===a||t.y===o||t.y===s)&&l.add(t.id);return l}function gt(t){if(t<=0)return 0;if(t>=1)return 1;let n=t*t,r=n*t;return 4*(t<.5?r:3*(t-n)+r-.75)}function _t(t,n,r,a){return f(t,n,r,a)}const vt=_t(.25,.1,.25,1);function yt(t,n,r){return Math.min(r,Math.max(n,t))}function bt(t,n,r){let a=r-n,o=((t-n)%a+a)%a+n;return o===n?r:o}function xt(t,...n){for(let r of n)for(let n in r)t[n]=r[n];return t}function St(t,n){let r={};for(let a of n)a in t&&(r[a]=t[a]);return r}let Ct=1;function wt(){return Ct++}function Tt(t){return Math.log(t)/Math.LN2%1==0}function Et(t){return t<=1?1:2**Math.ceil(Math.log(t)/Math.LN2)}function Dt(t){return 2**t}function Ot(t){return Math.log(t)/Math.LN2}function kt(t,n,r){if(n<=0)return t;let a=1/n;return r===void 0||Math.abs(r)<1e-10?Math.round(t*a)/a:(r>0?Math.ceil(t*a-1e-9):Math.floor(t*a+1e-10))/a}function At(t,n,r){let a={};for(let o in t)a[o]=n.call(r||this,t[o],o,t);return a}function jt(t,n,r){let a={};for(let o in t)n.call(r||this,t[o],o,t)&&(a[o]=t[o]);return a}function Mt(t,n){if(Array.isArray(t)){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let r=0;r(n.y-t.y)*(r.x-t.x)}function Lt(t,n,r,a){let o=n.y-t.y,s=n.x-t.x,c=a.y-r.y,l=a.x-r.x,u=c*s-l*o;if(u===0)return null;let f=t.y-r.y,p=t.x-r.x,m=(l*f-c*p)/u;return new d(t.x+m*s,t.y+m*o)}function Rt([t,n,r]){return n+=90,n*=Math.PI/180,r*=Math.PI/180,[t*Math.cos(n)*Math.sin(r),t*Math.sin(n)*Math.sin(r),t*Math.cos(r)]}function zt(t){return typeof WorkerGlobalScope<`u`&&t!==void 0&&t instanceof WorkerGlobalScope}function Bt(t){let n=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,r={};if(t.replace(n,(t,n,a,o)=>{let s=a||o;return r[n]=!s||s.toLowerCase(),``}),r[`max-age`]){let t=parseInt(r[`max-age`],10);isNaN(t)?delete r[`max-age`]:r[`max-age`]=t}return r}let Vt=null;function Ht(t){if(Vt==null){let n=t.navigator?t.navigator.userAgent:null;Vt=!!t.safari||!!(n&&(/\b(iPad|iPhone|iPod)\b/.test(n)||n.match(`Safari`)&&!n.match(`Chrome`)))}return Vt}function Ut(t){return typeof ImageBitmap<`u`&&t instanceof ImageBitmap}const Wt=async(t,n)=>{if(t.byteLength===0)return createImageBitmap(new ImageData(1,1),n);let r=new Blob([new Uint8Array(t)],{type:`image/png`});try{return createImageBitmap(r,n)}catch(t){throw Error(`Could not load image because of ${Qe(t).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}},Gt=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=`,Kt=t=>new Promise((n,r)=>{let a=new Image;a.onload=()=>{n(a),URL.revokeObjectURL(a.src),a.onload=null,window.requestAnimationFrame(()=>a.src=Gt)},a.onerror=()=>r(Error(`Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));let o=new Blob([new Uint8Array(t)],{type:`image/png`});a.src=t.byteLength?URL.createObjectURL(o):Gt});function qt(t,n,r,a,o){let s=Math.max(-n,0)*4,c=(Math.max(0,r)-r)*a*4+s,l=a*4,u=Math.max(0,n),d=Math.max(0,r),f=Math.min(t.width,n+a),p=Math.min(t.height,r+o);return{rect:{x:u,y:d,width:f-u,height:p-d},layout:[{offset:c,stride:l}]}}async function Jt(t,n,r,a,o){if(typeof VideoFrame>`u`)throw Error(`VideoFrame not supported`);let s=new VideoFrame(t,{timestamp:0});try{let c=s?.format;if(!c||!(c.startsWith(`BGR`)||c.startsWith(`RGB`)))throw Error(`Unrecognized format ${c}`);let l=c.startsWith(`BGR`),u=new Uint8ClampedArray(a*o*4);if(await s.copyTo(u,qt(t,n,r,a,o)),l)for(let t=0;t{t.removeEventListener(n,r,a)}}}function en(t){return t*Math.PI/180}function tn(t){return t/Math.PI*180}function nn(t,n){return t.roll==n.roll&&t.pitch==n.pitch&&t.bearing==n.bearing}function rn(t){let n=new Float64Array(9);x(n,t);let r=tn(-Math.asin(yt(n[2],-1,1))),a,o;return Math.hypot(n[5],n[8])<.001?(a=0,o=-tn(Math.atan2(n[3],n[4]))):(a=tn(n[5]===0&&n[8]===0?0:Math.atan2(n[5],n[8])),o=tn(n[1]===0&&n[0]===0?0:Math.atan2(n[1],n[0]))),{roll:a,pitch:r+90,bearing:o}}function an(t,n,r){let a=Ve(n.x-r.x,n.y-r.y),o=Ve(t.x-r.x,t.y-r.y),s=a[0]*o[1]-a[1]*o[0];return tn(Math.atan2(s,Ge(a,o)))}function on(t,n,r){let a=new Float64Array(4);return Re(a,t,n-90,r),a}const sn=85.051129,cn={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ln={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function un(t,n){return cn[n]&&`touches`in t}function dn(t,n){if(!ln[n])return!1;let r=t,a=(r?.target)?.ownerDocument?.defaultView||window;return r instanceof a.MouseEvent||r instanceof a.WheelEvent}function fn(t){return cn[t]||ln[t]}const pn=`AbortError`;var mn=class extends Error{constructor(t=pn){super(t instanceof Error?t.message:t),this.name=pn,t instanceof Error&&t.stack&&(this.stack=t.stack)}};function hn(t){return t instanceof Error&&t.name===`AbortError`}function gn(t){if(t.aborted)throw new mn(t.reason)}const _n={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:``};function vn(t){return _n.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf(`://`))]}function yn(t,n){_n.REGISTERED_PROTOCOLS[t]=n}function bn(t){delete _n.REGISTERED_PROTOCOLS[t]}const xn=`global-dispatcher`;var Sn=class extends Error{constructor(t,n,r,a){super(`AJAXError: ${n} (${t}): ${r}`),this.status=t,this.statusText=n,this.url=r,this.body=a}};function Cn(){if(zt(self))return self.worker?.referrer;if(window.location.protocol===`blob:`)try{return window.parent.location.href}catch{}return window.location.href}const wn=t=>t.startsWith(`file:`)||Cn()?.startsWith(`file:`)&&!/^\w+:/.test(t);async function Tn(t,n){let r=new Request(t.url,{method:t.method||`GET`,body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:Cn(),referrerPolicy:t.referrerPolicy,signal:n.signal});t.type===`json`&&!r.headers.has(`Accept`)&&r.headers.set(`Accept`,`application/json`);let a;try{a=await fetch(r)}catch(n){throw hn(n)?n:new Sn(0,Qe(n).message,t.url,new Blob)}if(!a.ok){let n=await a.blob();throw new Sn(a.status,a.statusText,t.url,n)}let o;o=t.type===`arrayBuffer`||t.type===`image`?a.arrayBuffer():t.type===`json`?a.json():a.text();let s=await o;return gn(n.signal),{data:s,cacheControl:a.headers.get(`Cache-Control`),expires:a.headers.get(`Expires`),etag:a.headers.get(`ETag`)}}function En(t,n){return new Promise((r,a)=>{let o=new XMLHttpRequest;o.open(t.method||`GET`,t.url,!0),(t.type===`arrayBuffer`||t.type===`image`)&&(o.responseType=`arraybuffer`);for(let n in t.headers)o.setRequestHeader(n,t.headers[n]);t.type===`json`&&(o.responseType=`text`,t.headers?.Accept||o.setRequestHeader(`Accept`,`application/json`)),o.withCredentials=t.credentials===`include`,o.onerror=()=>{a(Error(o.statusText))},o.onload=()=>{if(!n.signal.aborted)if((o.status>=200&&o.status<300||o.status===0)&&o.response!==null){let n=o.response;if(t.type===`json`)try{n=JSON.parse(o.response)}catch(t){a(t);return}r({data:n,cacheControl:o.getResponseHeader(`Cache-Control`),expires:o.getResponseHeader(`Expires`),etag:o.getResponseHeader(`ETag`)})}else{let n=new Blob([o.response],{type:o.getResponseHeader(`Content-Type`)});a(new Sn(o.status,o.statusText,t.url,n))}},n.signal.addEventListener(`abort`,()=>{o.abort(),a(new mn(n.signal.reason))}),o.send(t.body)})}const Dn=async function(t,n){if(t.url.includes(`://`)&&!/^https?:|^file:/.test(t.url)){let r=vn(t.url);if(r){let a=await r(t,n);return!a.data&&t.type===`arrayBuffer`?xt(a,{data:/* @__PURE__ */ new ArrayBuffer(0)}):a}if(zt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:t,targetMapId:xn},n)}if(!wn(t.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,`signal`))return Tn(t,n);if(zt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:t,mustQueue:!0,targetMapId:xn},n)}return En(t,n)},On=(t,n)=>Dn(xt(t,{type:`json`}),n),kn=(t,n)=>Dn(xt(t,{type:`arrayBuffer`}),n);function An(t){if(!t||t.startsWith(`data:image/`))return!0;if(t.startsWith(`blob:`)&&(t=t.slice(5),t.startsWith(`null`)))return!1;if(t.indexOf(`://`)<=0)return!0;let n=new URL(t),r=window.location;return n.protocol===r.protocol&&n.host===r.host}const jn=t=>{let n=window.document.createElement(`video`);return n.muted=!0,new Promise(r=>{n.onloadstart=()=>{r(n)};for(let r of t){let t=window.document.createElement(`source`);An(r)||(n.crossOrigin=`Anonymous`),t.src=r,n.appendChild(t)}})};function Mn(t,n,r){r[t]?.includes(n)||(r[t]||=[],r[t].push(n))}function Nn(t,n,r){if(r?.[t]){let a=r[t].indexOf(n);a!==-1&&r[t].splice(a,1)}}var Pn=class{constructor(t,n={}){xt(this,n),this.type=t}},Fn=class extends Pn{constructor(t,n={}){super(`error`,xt({error:t},n))}},In=class{on(t,n){return this._listeners||={},Mn(t,n,this._listeners),{unsubscribe:()=>{this.off(t,n)}}}off(t,n){return Nn(t,n,this._listeners),Nn(t,n,this._oneTimeListeners),this}once(t,n){return n?(this._oneTimeListeners||={},Mn(t,n,this._oneTimeListeners),this):new Promise(n=>this.once(t,n))}fire(t,n){typeof t==`string`&&(t=new Pn(t,n||{}));let r=t.type;if(this.listens(r)){t.target=this;let n=this._listeners?.[r]?this._listeners[r].slice():[];for(let r of n)r.call(this,t);let a=this._oneTimeListeners?.[r]?this._oneTimeListeners[r].slice():[];for(let n of a)Nn(r,n,this._oneTimeListeners),n.call(this,t);let o=this._eventedParent;o&&(xt(t,typeof this._eventedParentData==`function`?this._eventedParentData():this._eventedParentData),o.fire(t))}else t instanceof Fn&&console.error(t.error);return this}listens(t){return this._listeners?.[t]?.length>0||this._oneTimeListeners?.[t]?.length>0||this._eventedParent?.listens(t)}setEventedParent(t,n){return this._eventedParent=t,this._eventedParentData=n,this}};const P={$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:{required:!0,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`}},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`]},"property-type":`data-constant`},"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`},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,minimum:0,units:`meters`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-base":{type:`number`,default:0,minimum: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`}]}}}}},Ln=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function Rn(t,n){let r={};for(let n in t)n!==`ref`&&(r[n]=t[n]);return Ln.forEach(t=>{t in n&&(r[t]=n[t])}),r}function zn(t){t=t.slice();let n=Object.create(null);for(let r=0;r{`source`in t&&a[t.source]?r.push({command:`removeLayer`,args:[t.id]}):s.push(t)}),r=r.concat(o),Yn(s,n.layers,r)}catch(t){console.warn(`Unable to compute style diff:`,t),r=[{command:`setStyle`,args:[n]}]}return r}var N=class{constructor(t,n,r,a,o=`error`){this.message=(t?`${t}: `:``)+r,a&&(this.identifier=a),this.severity=o,n!=null&&n.__line__&&(this.line=n.__line__)}},Zn=class extends Error{constructor(t,n){super(n),this.message=n,this.key=t}},Qn=class e{constructor(t,n=[]){this.parent=t,this.bindings={};for(let[t,r]of n)this.bindings[t]=r}concat(t){return new e(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}};const $n={kind:`null`},I={kind:`number`},L={kind:`string`},R={kind:`boolean`},er={kind:`color`},tr={kind:`projectionDefinition`},nr={kind:`object`},z={kind:`value`},rr={kind:`error`},ir={kind:`collator`},ar={kind:`formatted`},or={kind:`padding`},sr={kind:`colorArray`},cr={kind:`numberArray`},lr={kind:`resolvedImage`},ur={kind:`variableAnchorOffsetCollection`};function dr(t,n){return{kind:`array`,itemType:t,N:n}}function V(t){if(t.kind===`array`){let n=V(t.itemType);return typeof t.N==`number`?`array<${n}, ${t.N}>`:t.itemType.kind===`value`?`array`:`array<${n}>`}else return t.kind}const fr=[$n,I,L,R,er,tr,ar,nr,dr(z),or,cr,sr,lr,ur];function pr(t,n){if(n.kind===`error`)return null;if(t.kind===`array`){if(n.kind===`array`&&(n.N===0&&n.itemType.kind===`value`||!pr(t.itemType,n.itemType))&&(typeof t.N!=`number`||t.N===n.N))return null}else if(t.kind===n.kind)return null;else if(t.kind===`value`){for(let t of fr)if(!pr(t,n))return null}return`Expected ${V(t)} but found ${V(n)} instead.`}function mr(t,n){return n.some(n=>n.kind===t.kind)}function hr(t,n){return n.some(n=>n===`null`?t===null:n===`array`?Array.isArray(t):n===`object`?t&&!Array.isArray(t)&&typeof t==`object`:n===typeof t)}function gr(t,n){return t.kind===`array`&&n.kind===`array`?t.itemType.kind===n.itemType.kind&&typeof t.N==`number`:t.kind===n.kind}const _r=.96422,vr=.82521,yr=4/29,br=6/29,xr=3*br*br,Sr=Math.PI/180,Cr=180/Math.PI;function wr(t){return t%=360,t<0&&(t+=360),t}function Tr([t,n,r,a]){t=Er(t),n=Er(n),r=Er(r);let o,s,c=Dr((.2225045*t+.7168786*n+.0606169*r)/1);t===n&&n===r?o=s=c:(o=Dr((.4360747*t+.3850649*n+.1430804*r)/_r),s=Dr((.0139322*t+.0971045*n+.7141733*r)/vr));let l=116*c-16;return[l<0?0:l,500*(o-c),200*(c-s),a]}function Er(t){return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Dr(t){return t>.008856451679035631?t**(1/3):t/xr+yr}function Or([t,n,r,a]){let o=(t+16)/116,s=isNaN(n)?o:o+n/500,c=isNaN(r)?o:o-r/200;return o=1*Ar(o),s=_r*Ar(s),c=vr*Ar(c),[kr(3.1338561*s-1.6168667*o-.4906146*c),kr(-.9787684*s+1.9161415*o+.033454*c),kr(.0719453*s-.2289914*o+1.4052427*c),a]}function kr(t){return t=t<=.00304?12.92*t:1.055*t**(1/2.4)-.055,t<0?0:t>1?1:t}function Ar(t){return t>br?t*t*t:xr*(t-yr)}function jr(t){let[n,r,a,o]=Tr(t),s=Math.sqrt(r*r+a*a);return[Math.round(s*1e4)?wr(Math.atan2(a,r)*Cr):NaN,s,n,o]}function Mr([t,n,r,a]){return t=isNaN(t)?0:t*Sr,Or([r,Math.cos(t)*n,Math.sin(t)*n,a])}function Nr([t,n,r,a]){t=wr(t),n/=100,r/=100;function o(a){let o=(a+t/30)%12,s=n*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(o-3,9-o,1))}return[o(0),o(8),o(4),a]}const Pr=Object.hasOwn||function(t,n){return Object.prototype.hasOwnProperty.call(t,n)};function Fr(t,n){return Pr(t,n)?t[n]:void 0}function Ir(t){if(t=t.toLowerCase().trim(),t===`transparent`)return[0,0,0,0];let n=Fr(Vr,t);if(n){let[t,r,a]=n;return[t/255,r/255,a/255,1]}if(t.startsWith(`#`)&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){let n=t.length<6?1:2,r=1;return[Lr(t.slice(r,r+=n)),Lr(t.slice(r,r+=n)),Lr(t.slice(r,r+=n)),Lr(t.slice(r,r+n)||`ff`)]}if(t.startsWith(`rgb`)){let n=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){let[t,r,a,o,s,c,l,u,d,f,p,m]=n,h=[o||` `,l||` `,f].join(``);if(h===` `||h===` /`||h===`,,`||h===`,,,`){let t=[a,c,d].join(``),n=t===`%%%`?100:t===``?255:0;if(n){let t=[zr(+r/n,0,1),zr(+s/n,0,1),zr(+u/n,0,1),p?Rr(+p,m):1];if(Br(t))return t}}return}}let r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){let[t,n,a,o,s,c,l,u,d]=r,f=[a||` `,s||` `,l].join(``);if(f===` `||f===` /`||f===`,,`||f===`,,,`){let t=[+n,zr(+o,0,100),zr(+c,0,100),u?Rr(+u,d):1];if(Br(t))return Nr(t)}}}function Lr(t){return parseInt(t.padEnd(2,t),16)/255}function Rr(t,n){return zr(n?t/100:t,0,1)}function zr(t,n,r){return Math.min(Math.max(n,t),r)}function Br(t){return!t.some(Number.isNaN)}const Vr={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 Hr(t,n,r){return t+r*(n-t)}function Ur(t,n,r){return t.map((t,a)=>Hr(t,n[a],r))}function Wr(t){return t===`rgb`||t===`hcl`||t===`lab`}var H=class e{constructor(t,n,r,a=1,o=!0){this.r=t,this.g=n,this.b=r,this.a=a,o||(this.r*=a,this.g*=a,this.b*=a,a||this.overwriteGetter(`rgb`,[t,n,r,a]))}static{this.black=new e(0,0,0,1)}static{this.white=new e(1,1,1,1)}static{this.transparent=new e(0,0,0,0)}static{this.red=new e(1,0,0,1)}static parse(t){if(t instanceof e)return t;if(typeof t!=`string`)return;let n=Ir(t);if(n)return new e(...n,!1)}get rgb(){let{r:t,g:n,b:r,a}=this,o=a||1/0;return this.overwriteGetter(`rgb`,[t/o,n/o,r/o,a])}get hcl(){return this.overwriteGetter(`hcl`,jr(this.rgb))}get lab(){return this.overwriteGetter(`lab`,Tr(this.rgb))}overwriteGetter(t,n){return Object.defineProperty(this,t,{value:n}),n}toString(){let[t,n,r,a]=this.rgb;return`rgba(${[t,n,r].map(t=>Math.round(t*255)).join(`,`)},${a})`}static interpolate(t,n,r,a=`rgb`){switch(a){case`rgb`:{let[a,o,s,c]=Ur(t.rgb,n.rgb,r);return new e(a,o,s,c,!1)}case`hcl`:{let[a,o,s,c]=t.hcl,[l,u,d,f]=n.hcl,p,m;if(!isNaN(a)&&!isNaN(l)){let t=l-a;l>a&&t>180?t-=360:l180&&(t+=360),p=a+r*t}else isNaN(a)?isNaN(l)?p=NaN:(p=l,(s===1||s===0)&&(m=u)):(p=a,(d===1||d===0)&&(m=o));let[h,g,_,v]=Mr([p,m??Hr(o,u,r),Hr(s,d,r),Hr(c,f,r)]);return new e(h,g,_,v,!1)}case`lab`:{let[a,o,s,c]=Or(Ur(t.lab,n.lab,r));return new e(a,o,s,c,!1)}}}},Gr=class{constructor(t,n,r){t?this.sensitivity=n?`variant`:`case`:this.sensitivity=n?`accent`:`base`,this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:`search`})}compare(t,n){return this.collator.compare(t,n)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};const Kr=[`bottom`,`center`,`top`];var qr=class{constructor(t,n,r,a,o,s){this.text=t,this.image=n,this.scale=r,this.fontStack=a,this.textColor=o,this.verticalAlign=s}},Jr=class e{constructor(t){this.sections=t}static fromString(t){return new e([new qr(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 e?t:e.fromString(t)}toString(){return this.sections.length===0?``:this.sections.map(t=>t.text).join(``)}},Yr=class e{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`number`)return new e([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let n of t)if(typeof n!=`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]];break}return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r){return new e(Ur(t.values,n.values,r))}},Xr=class e{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`number`)return new e([t]);if(Array.isArray(t)){for(let n of t)if(typeof n!=`number`)return;return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r){return new e(Ur(t.values,n.values,r))}},Zr=class e{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`string`){let n=H.parse(t);return n?new e([n]):void 0}if(!Array.isArray(t))return;let n=[];for(let r of t){if(typeof r!=`string`)return;let t=H.parse(r);if(!t)return;n.push(t)}return new e(n)}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r,a=`rgb`){let o=[];if(t.values.length!=n.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${n.values.length}), cannot interpolate.`);for(let s=0;s=0&&t<=255&&typeof n==`number`&&n>=0&&n<=255&&typeof r==`number`&&r>=0&&r<=255?a===void 0||typeof a==`number`&&a>=0&&a<=1?null:`Invalid rgba value [${[t,n,r,a].join(`, `)}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof a==`number`?[t,n,r,a]:[t,n,r]).join(`, `)}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ri(t){if(t===null||typeof t==`string`||typeof t==`boolean`||typeof t==`number`||t instanceof ti||t instanceof H||t instanceof Gr||t instanceof Jr||t instanceof Yr||t instanceof Xr||t instanceof Zr||t instanceof $r||t instanceof ei)return!0;if(Array.isArray(t)){for(let n of t)if(!ri(n))return!1;return!0}else if(typeof t==`object`){for(let n in t)if(!ri(t[n]))return!1;return!0}else return!1}function ii(t){if(t===null)return $n;if(typeof t==`string`)return L;if(typeof t==`boolean`)return R;if(typeof t==`number`)return I;if(t instanceof H)return er;if(t instanceof ti)return tr;if(t instanceof Gr)return ir;if(t instanceof Jr)return ar;if(t instanceof Yr)return or;if(t instanceof Xr)return cr;if(t instanceof Zr)return sr;if(t instanceof $r)return ur;if(t instanceof ei)return lr;if(Array.isArray(t)){let n=t.length,r;for(let n of t){let t=ii(n);if(!r)r=t;else if(r===t)continue;else{r=z;break}}return dr(r||z,n)}else return nr}function ai(t){let n=typeof t;return t===null?``:n===`string`||n===`number`||n===`boolean`?String(t):t instanceof H||t instanceof ti||t instanceof Jr||t instanceof Yr||t instanceof Xr||t instanceof Zr||t instanceof $r||t instanceof ei?t.toString():JSON.stringify(t)}var oi=class e{constructor(t,n){this.type=t,this.value=n}static parse(t,n){if(t.length!==2)return n.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!ri(t[1]))return n.error(`invalid value`);let r=t[1],a=ii(r),o=n.expectedType;return a.kind===`array`&&a.N===0&&o&&o.kind===`array`&&(typeof o.N!=`number`||o.N===0)&&(a=o),new e(a,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const si={string:L,number:I,boolean:R,object:nr};var ci=class e{constructor(t,n,r){this.type=t,this.args=n,this.key=r}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=1,a,o=t[0];if(o===`array`){let o;if(t.length>2){let a=t[1];if(typeof a!=`string`||!(a in si)||a===`object`)return n.error(`The item type argument of "array" must be one of string, number, boolean`,1);o=si[a],r++}else o=z;let s;if(t.length>3){if(t[2]!==null&&(typeof t[2]!=`number`||t[2]<0||t[2]!==Math.floor(t[2])))return n.error(`The length argument to "array" must be a positive integer literal`,2);s=t[2],r++}a=dr(o,s)}else{if(!si[o])throw Error(`Types doesn't contain name = ${o}`);a=si[o]}let s=[];for(;rt.outputDefined())}};const li={"to-boolean":R,"to-color":er,"to-number":I,"to-string":L};var ui=class e{constructor(t,n,r){this.type=t,this.args=n,this.key=r}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=t[0];if(!li[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 n.error(`Expected one argument.`);let a=li[r],o=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(n)}: expected an array containing either three or four numeric values.`:ni(n[0],n[1],n[2],n[3]),!r))return new H(n[0]/255,n[1]/255,n[2]/255,n[3])}throw new B(r||`Could not parse color from value '${typeof n==`string`?n:JSON.stringify(n)}'`,this.key)}case`padding`:{let n;for(let r of this.args){n=r.evaluate(t);let a=Yr.parse(n);if(a)return a}throw new B(`Could not parse padding from value '${typeof n==`string`?n:JSON.stringify(n)}'`,this.key)}case`numberArray`:{let n;for(let r of this.args){n=r.evaluate(t);let a=Xr.parse(n);if(a)return a}throw new B(`Could not parse numberArray from value '${typeof n==`string`?n:JSON.stringify(n)}'`,this.key)}case`colorArray`:{let n;for(let r of this.args){n=r.evaluate(t);let a=Zr.parse(n);if(a)return a}throw new B(`Could not parse colorArray from value '${typeof n==`string`?n:JSON.stringify(n)}'`,this.key)}case`variableAnchorOffsetCollection`:{let n;for(let r of this.args){n=r.evaluate(t);let a=$r.parse(n);if(a)return a}throw new B(`Could not parse variableAnchorOffsetCollection from value '${typeof n==`string`?n:JSON.stringify(n)}'`,this.key)}case`number`:{let n=null;for(let r of this.args){if(n=r.evaluate(t),n===null)return 0;let a=Number(n);if(!isNaN(a))return a}throw new B(`Could not convert ${JSON.stringify(n)} to number.`,this.key)}case`formatted`:return Jr.fromString(ai(this.args[0].evaluate(t)));case`resolvedImage`:return ei.fromString(ai(this.args[0].evaluate(t)));case`projectionDefinition`:return this.args[0].evaluate(t);default:return ai(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};const di=[`Unknown`,`Point`,`LineString`,`Polygon`];var fi=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=/* @__PURE__ */ 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`?di[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&`geometry`in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let n=this._parseColorCache.get(t);return n||(n=H.parse(t),this._parseColorCache.set(t,n)),n}},pi=class e{constructor(t,n,r=[],a,o=new Qn,s=[]){this.registry=t,this.path=r,this.key=r.map(t=>`[${t}]`).join(``),this.scope=o,this.errors=s,this.expectedType=a,this._isConstant=n}parse(t,n,r,a,o={}){return n?this.concat(n,r,a)._parse(t,o):this._parse(t,o)}_parse(t,n){(t===null||typeof t==`string`||typeof t==`boolean`||typeof t==`number`)&&(t=[`literal`,t]);let r=this.key;function a(t,n,a){return a===`assert`?new ci(n,[t],r):a===`coerce`?new ui(n,[t],r):t}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 r=t[0];if(typeof r!=`string`)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let o=this.registry[r];if(o){let r=o.parse(t,this);if(!r)return null;if(this.expectedType){let t=this.expectedType,o=r.type;if((t.kind===`string`||t.kind===`number`||t.kind===`boolean`||t.kind===`object`||t.kind===`array`)&&o.kind===`value`)r=a(r,t,n.typeAnnotation||`assert`);else if(t.kind===`projectionDefinition`&&[`string`,`array`].includes(o.kind)||[`color`,`formatted`,`resolvedImage`].includes(t.kind)&&[`value`,`string`].includes(o.kind)||[`padding`,`numberArray`].includes(t.kind)&&[`value`,`number`,`array`].includes(o.kind)||t.kind===`colorArray`&&[`value`,`string`,`array`].includes(o.kind)||t.kind===`variableAnchorOffsetCollection`&&[`value`,`array`].includes(o.kind))r=a(r,t,n.typeAnnotation||`coerce`);else if(this.checkSubtype(t,o))return null}if(!(r instanceof oi)&&r.type.kind!==`resolvedImage`&&this._isConstant(r)){let t=new fi;try{r=new oi(r.type,r.evaluate(t))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}else if(t===void 0)return this.error(`'undefined' value invalid. Use null instead.`);else if(typeof t==`object`)return this.error(`Bare objects invalid. Use ["literal", {...}] instead.`);else return this.error(`Expected an array, but found ${typeof t} instead.`)}concat(t,n,r){let a=typeof t==`number`?this.path.concat(t):this.path,o=r?this.scope.concat(r):this.scope;return new e(this.registry,this._isConstant,a,n||null,o,this.errors)}error(t,...n){let r=`${this.key}${n.map(t=>`[${t}]`).join(``)}`;this.errors.push(new Zn(r,t))}checkSubtype(t,n){let r=pr(t,n);return r&&this.error(r),r}},mi=class e{constructor(t,n){this.type=n.type,this.bindings=[].concat(t),this.result=n}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let n of this.bindings)t(n[1]);t(this.result)}static parse(t,n){if(t.length<4)return n.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let a=1;a=r.length)throw new B(`Array index out of bounds: ${n} > ${r.length-1}.`,this.key);if(n!==Math.floor(n))throw new B(`Array index must be an integer, but found ${n} instead.`,this.key);return r[n]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},_i=class e{constructor(t,n,r){this.needle=t,this.haystack=n,this.key=r,this.type=R}static parse(t,n){if(t.length!==3)return n.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,z),a=n.parse(t[2],2,z);return!r||!a?null:mr(r.type,[R,L,I,$n,z])?new e(r,a,n.key):n.error(`Expected first argument to be of type boolean, string, number or null, but found ${V(r.type)} instead`)}evaluate(t){let n=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return!1;if(!hr(n,[`boolean`,`string`,`number`,`null`]))throw new B(`Expected first argument to be of type boolean, string, number or null, but found ${V(ii(n))} instead.`,this.key);if(!hr(r,[`string`,`array`]))throw new B(`Expected second argument to be of type array or string, but found ${V(ii(r))} instead.`,this.key);return r.indexOf(n)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},vi=class e{constructor(t,n,r,a){this.needle=t,this.haystack=n,this.key=r,this.fromIndex=a,this.type=I}static parse(t,n){if(t.length<=2||t.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,z),a=n.parse(t[2],2,z);if(!r||!a)return null;if(!mr(r.type,[R,L,I,$n,z]))return n.error(`Expected first argument to be of type boolean, string, number or null, but found ${V(r.type)} instead`);if(t.length===4){let o=n.parse(t[3],3,I);return o?new e(r,a,n.key,o):null}else return new e(r,a,n.key)}evaluate(t){let n=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!hr(n,[`boolean`,`string`,`number`,`null`]))throw new B(`Expected first argument to be of type boolean, string, number or null, but found ${V(ii(n))} instead.`,this.key);let a;if(this.fromIndex&&(a=this.fromIndex.evaluate(t)),hr(r,[`string`])){let t=r.indexOf(n,a);return t===-1?-1:[...r.slice(0,t)].length}else if(hr(r,[`array`]))return r.indexOf(n,a);else throw new B(`Expected second argument to be of type array or string, but found ${V(ii(r))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},yi=class e{constructor(t,n,r,a,o,s){this.inputType=t,this.type=n,this.input=r,this.cases=a,this.outputs=o,this.otherwise=s}static parse(t,n){if(t.length<5)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return n.error(`Expected an even number of arguments.`);let r,a;n.expectedType&&n.expectedType.kind!==`value`&&(a=n.expectedType);let o={},s=[];for(let c=2;c2**53-1)return d.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof t==`number`&&Math.floor(t)!==t)return d.error(`Numeric branch labels must be integer values.`);if(!r)r=ii(t);else if(d.checkSubtype(r,ii(t)))return null;if(o[String(t)]!==void 0)return d.error(`Branch labels must be unique.`);o[String(t)]=s.length}let f=n.parse(u,c,a);if(!f)return null;a||=f.type,s.push(f)}let c=n.parse(t[1],1,z);if(!c)return null;let l=n.parse(t[t.length-1],t.length-1,a);return!l||c.type.kind!==`value`&&n.concat(1).checkSubtype(r,c.type)?null:new e(r,a,c,o,s,l)}evaluate(t){let n=this.input.evaluate(t);return(ii(n)===this.inputType&&this.outputs[this.cases[n]]||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()}},bi=class e{constructor(t,n,r){this.type=t,this.branches=n,this.otherwise=r}static parse(t,n){if(t.length<4)return n.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return n.error(`Expected an odd number of arguments.`);let r;n.expectedType&&n.expectedType.kind!==`value`&&(r=n.expectedType);let a=[];for(let o=1;on.outputDefined())&&this.otherwise.outputDefined()}},xi=class e{constructor(t,n,r,a,o){this.type=t,this.input=n,this.beginIndex=r,this.key=a,this.endIndex=o}static parse(t,n){if(t.length<=2||t.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,z),a=n.parse(t[2],2,I);if(!r||!a)return null;if(!mr(r.type,[dr(z),L,z]))return n.error(`Expected first argument to be of type array or string, but found ${V(r.type)} instead`);if(t.length===4){let o=n.parse(t[3],3,I);return o?new e(r.type,r,a,n.key,o):null}else return new e(r.type,r,a,n.key)}evaluate(t){let n=this.input.evaluate(t),r=this.beginIndex.evaluate(t),a;if(this.endIndex&&(a=this.endIndex.evaluate(t)),hr(n,[`string`]))return[...n].slice(r,a).join(``);if(hr(n,[`array`]))return n.slice(r,a);throw new B(`Expected first argument to be of type array or string, but found ${V(ii(n))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}};function Si(t,n,r){let a=t.length-1,o=0,s=a,c=0,l,u;for(;o<=s;)if(c=Math.floor((o+s)/2),l=t[c],u=t[c+1],l<=n){if(c===a||nn)s=c-1;else throw new B(`Input is not a number.`,r);return 0}var Ci=class e{constructor(t,n,r,a){this.type=t,this.input=n,this.key=a,this.labels=[],this.outputs=[];for(let[t,n]of r)this.labels.push(t),this.outputs.push(n)}static parse(t,n){if(t.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return n.error(`Expected an even number of arguments.`);let r=n.parse(t[1],1,I);if(!r)return null;let a=[],o=null;n.expectedType&&n.expectedType.kind!==`value`&&(o=n.expectedType);for(let r=1;r=s)return n.error(`Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.`,l);let d=n.parse(c,u,o);if(!d)return null;o||=d.type,a.push([s,d])}return new e(o,r,a,n.key)}evaluate(t){let n=this.labels,r=this.outputs;if(n.length===1)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=n[0])return r[0].evaluate(t);let o=n.length;return a>=n[o-1]?r[o-1].evaluate(t):r[Si(n,a,this.key)].evaluate(t)}eachChild(t){t(this.input);for(let n of this.outputs)t(n)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function wi(t,n,r,a){let o=3*t,s=3*(r-t)-o,c=1-o-s,l=3*n,u=3*(a-n)-l,d=1-l-u;return function(t,n=1e-6){if(t<=0)return 0;if(t>=1)return 1;let r=t;for(let a=0;a<8;a++){let a=((c*r+s)*r+o)*r-t;if(Math.abs(a)l?a=r:f=r,r=(a+f)*.5}return((d*r+u)*r+l)*r}}var Ti=class e{constructor(t,n,r,a,o,s){this.type=t,this.operator=n,this.interpolation=r,this.input=a,this.key=s,this.labels=[],this.outputs=[];for(let[t,n]of o)this.labels.push(t),this.outputs.push(n)}static interpolationFactor(t,n,r,a){let o=0;if(t.name===`exponential`)o=Ei(n,t.base,r,a);else if(t.name===`linear`)o=Ei(n,1,r,a);else if(t.name===`cubic-bezier`){let s=t.controlPoints;o=wi(s[0],s[1],s[2],s[3])(Ei(n,1,r,a))}return o}static parse(t,n){let[r,a,o,...s]=t;if(!Array.isArray(a)||a.length===0)return n.error(`Expected an interpolation type expression.`,1);if(a[0]===`linear`)a={name:`linear`};else if(a[0]===`exponential`){let t=a[1];if(typeof t!=`number`)return n.error(`Exponential interpolation requires a numeric base.`,1,1);a={name:`exponential`,base:t}}else if(a[0]===`cubic-bezier`){let t=a.slice(1);if(t.length!==4||t.some(t=>typeof t!=`number`||t<0||t>1))return n.error(`Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.`,1);a={name:`cubic-bezier`,controlPoints:t}}else return n.error(`Unknown interpolation type ${String(a[0])}`,1,0);if(t.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return n.error(`Expected an even number of arguments.`);if(o=n.parse(o,2,I),!o)return null;let c=[],l=null;(r===`interpolate-hcl`||r===`interpolate-lab`)&&n.expectedType!=sr?l=er:n.expectedType&&n.expectedType.kind!==`value`&&(l=n.expectedType);for(let t=0;t=r)return n.error(`Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.`,o);let d=n.parse(a,u,l);if(!d)return null;l||=d.type,c.push([r,d])}return!gr(l,I)&&!gr(l,tr)&&!gr(l,er)&&!gr(l,or)&&!gr(l,cr)&&!gr(l,sr)&&!gr(l,ur)&&!gr(l,dr(I))?n.error(`Type ${V(l)} is not interpolatable.`):new e(l,r,a,o,c,n.key)}evaluate(t){let n=this.labels,r=this.outputs;if(n.length===1)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=n[0])return r[0].evaluate(t);let o=n.length;if(a>=n[o-1])return r[o-1].evaluate(t);let s=Si(n,a,this.key),c=n[s],l=n[s+1],u=e.interpolationFactor(this.interpolation,a,c,l),d=r[s].evaluate(t),f=r[s+1].evaluate(t);switch(this.operator){case`interpolate`:switch(this.type.kind){case`number`:return Hr(d,f,u);case`color`:return H.interpolate(d,f,u);case`padding`:return Yr.interpolate(d,f,u);case`colorArray`:return Zr.interpolate(d,f,u);case`numberArray`:return Xr.interpolate(d,f,u);case`variableAnchorOffsetCollection`:return $r.interpolate(d,f,u,this.key);case`array`:return Ur(d,f,u);case`projectionDefinition`:return ti.interpolate(d,f,u)}case`interpolate-hcl`:switch(this.type.kind){case`color`:return H.interpolate(d,f,u,`hcl`);case`colorArray`:return Zr.interpolate(d,f,u,`hcl`)}case`interpolate-lab`:switch(this.type.kind){case`color`:return H.interpolate(d,f,u,`lab`);case`colorArray`:return Zr.interpolate(d,f,u,`lab`)}}}eachChild(t){t(this.input);for(let n of this.outputs)t(n)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function Ei(t,n,r,a){let o=a-r,s=t-r;return o===0?0:n===1?s/o:(n**+s-1)/(n**+o-1)}const Di={color:H.interpolate,number:Hr,padding:Yr.interpolate,numberArray:Xr.interpolate,colorArray:Zr.interpolate,variableAnchorOffsetCollection:$r.interpolate,array:Ur};var Oi=class e{constructor(t,n){this.type=t,this.args=n}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=null,a=n.expectedType;a&&a.kind!==`value`&&(r=a);let o=[];for(let a of t.slice(1)){let t=n.parse(a,1+o.length,r,void 0,{typeAnnotation:`omit`});if(!t)return null;r||=t.type,o.push(t)}if(!r)throw Error(`No output type`);return a&&o.some(t=>pr(a,t.type))?new e(z,o):new e(r,o)}evaluate(t){let n=null,r=0,a;for(let o of this.args)if(r++,n=o.evaluate(t),n&&n instanceof ei&&!n.available&&(a||=n.name,n=null,r===this.args.length&&(n=a)),n!==null)break;return n}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function ki(t,n){return t===`==`||t===`!=`?n.kind===`boolean`||n.kind===`string`||n.kind===`number`||n.kind===`null`||n.kind===`value`:n.kind===`string`||n.kind===`number`||n.kind===`value`}function Ai(t,n,r){return n===r}function ji(t,n,r){return n!==r}function Mi(t,n,r){return nr}function Pi(t,n,r){return n<=r}function Fi(t,n,r){return n>=r}function Ii(t,n,r,a){return a.compare(n,r)===0}function Li(t,n,r,a){return!Ii(t,n,r,a)}function Ri(t,n,r,a){return a.compare(n,r)<0}function zi(t,n,r,a){return a.compare(n,r)>0}function Bi(t,n,r,a){return a.compare(n,r)<=0}function Vi(t,n,r,a){return a.compare(n,r)>=0}function Hi(t,n,r){let a=t!==`==`&&t!==`!=`;return class i{constructor(t,n,r,a){this.lhs=t,this.rhs=n,this.key=r,this.collator=a,this.type=R,this.hasUntypedArgument=t.type.kind===`value`||n.type.kind===`value`}static parse(t,n){if(t.length!==3&&t.length!==4)return n.error(`Expected two or three arguments.`);let r=t[0],o=n.parse(t[1],1,z);if(!o)return null;if(!ki(r,o.type))return n.concat(1).error(`"${r}" comparisons are not supported for type '${V(o.type)}'.`);let s=n.parse(t[2],2,z);if(!s)return null;if(!ki(r,s.type))return n.concat(2).error(`"${r}" comparisons are not supported for type '${V(s.type)}'.`);if(o.type.kind!==s.type.kind&&o.type.kind!==`value`&&s.type.kind!==`value`)return n.error(`Cannot compare types '${V(o.type)}' and '${V(s.type)}'.`);a&&(o.type.kind===`value`&&s.type.kind!==`value`?o=new ci(s.type,[o],n.key):o.type.kind!==`value`&&s.type.kind===`value`&&(s=new ci(o.type,[s],n.key)));let c=null;if(t.length===4){if(o.type.kind!==`string`&&s.type.kind!==`string`&&o.type.kind!==`value`&&s.type.kind!==`value`)return n.error(`Cannot use collator to compare non-string types.`);if(c=n.parse(t[3],3,ir),!c)return null}return new i(o,s,n.key,c)}evaluate(o){let s=this.lhs.evaluate(o),c=this.rhs.evaluate(o);if(a&&this.hasUntypedArgument){let n=ii(s),r=ii(c);if(n.kind!==r.kind||n.kind!==`string`&&n.kind!==`number`)throw new B(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${n.kind}, ${r.kind}) instead.`,this.key)}if(this.collator&&!a&&this.hasUntypedArgument){let t=ii(s),r=ii(c);if(t.kind!==`string`||r.kind!==`string`)return n(o,s,c)}return this.collator?r(o,s,c,this.collator.evaluate(o)):n(o,s,c)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const Ui=Hi(`==`,Ai,Ii),Wi=Hi(`!=`,ji,Li),Gi=Hi(`<`,Mi,Ri),Ki=Hi(`>`,Ni,zi),qi=Hi(`<=`,Pi,Bi),Ji=Hi(`>=`,Fi,Vi);var Yi=class e{constructor(t,n,r){this.type=ir,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=n}static parse(t,n){if(t.length!==2)return n.error(`Expected one argument.`);let r=t[1];if(typeof r!=`object`||Array.isArray(r))return n.error(`Collator options argument must be an object.`);let a=n.parse(r[`case-sensitive`]!==void 0&&r[`case-sensitive`],1,R);if(!a)return null;let o=n.parse(r[`diacritic-sensitive`]!==void 0&&r[`diacritic-sensitive`],1,R);if(!o)return null;let s=null;return r.locale&&(s=n.parse(r.locale,1,L),!s)?null:new e(a,o,s)}evaluate(t){return new Gr(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}},Xi=class e{constructor(t,n,r,a,o,s){this.type=L,this.number=t,this.locale=n,this.currency=r,this.unit=a,this.minFractionDigits=o,this.maxFractionDigits=s}static parse(t,n){if(t.length!==3)return n.error(`Expected two arguments.`);let r=n.parse(t[1],1,I);if(!r)return null;let a=t[2];if(typeof a!=`object`||Array.isArray(a))return n.error(`NumberFormat options argument must be an object.`);let o=null;if(a.locale&&(o=n.parse(a.locale,1,L),!o))return null;let s=null;if(a.currency&&(s=n.parse(a.currency,1,L),!s))return null;let c=null;if(a.unit&&(c=n.parse(a.unit,1,L),!c))return null;if(s&&c)return n.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(a[`min-fraction-digits`]&&(l=n.parse(a[`min-fraction-digits`],1,I),!l))return null;let u=null;return a[`max-fraction-digits`]&&(u=n.parse(a[`max-fraction-digits`],1,I),!u)?null:new e(r,o,s,c,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}},Zi=class e{constructor(t){this.type=ar,this.sections=t}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=t[1];if(!Array.isArray(r)&&typeof r==`object`)return n.error(`First argument must be an image or text section.`);let a=[],o=!1;for(let r=1;r<=t.length-1;++r){let s=t[r];if(o&&typeof s==`object`&&!Array.isArray(s)){o=!1;let t=null;if(s[`font-scale`]&&(t=n.parse(s[`font-scale`],1,I),!t))return null;let r=null;if(s[`text-font`]&&(r=n.parse(s[`text-font`],1,dr(L)),!r))return null;let c=null;if(s[`text-color`]&&(c=n.parse(s[`text-color`],1,er),!c))return null;let l=null;if(s[`vertical-align`]){if(typeof s[`vertical-align`]==`string`&&!Kr.includes(s[`vertical-align`]))return n.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s[`vertical-align`]}' instead.`);if(l=n.parse(s[`vertical-align`],1,L),!l)return null}let u=a[a.length-1];u.scale=t,u.font=r,u.textColor=c,u.verticalAlign=l}else{let s=n.parse(t[r],1,z);if(!s)return null;let c=s.type.kind;if(c!==`string`&&c!==`value`&&c!==`null`&&c!==`resolvedImage`)return n.error(`Formatted text type must be 'string', 'value', 'image' or 'null'.`);o=!0,a.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null})}}return new e(a)}evaluate(t){return new Jr(this.sections.map(n=>{let r=n.content.evaluate(t);return ii(r)===lr?new qr(``,r,null,null,null,n.verticalAlign?n.verticalAlign.evaluate(t):null):new qr(ai(r),null,n.scale?n.scale.evaluate(t):null,n.font?n.font.evaluate(t).join(`,`):null,n.textColor?n.textColor.evaluate(t):null,n.verticalAlign?n.verticalAlign.evaluate(t):null)}))}eachChild(t){for(let n of this.sections)t(n.content),n.scale&&t(n.scale),n.font&&t(n.font),n.textColor&&t(n.textColor),n.verticalAlign&&t(n.verticalAlign)}outputDefined(){return!1}},Qi=class e{constructor(t){this.type=lr,this.input=t}static parse(t,n){if(t.length!==2)return n.error(`Expected two arguments.`);let r=n.parse(t[1],1,L);return r?new e(r):n.error(`No image name provided.`)}evaluate(t){let n=this.input.evaluate(t),r=ei.fromString(n);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(n)>-1),r}eachChild(t){t(this.input)}outputDefined(){return!1}},$i=class e{constructor(t,n){this.input=t,this.key=n,this.type=I}static parse(t,n){if(t.length!==2)return n.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=n.parse(t[1],1);return r?r.type.kind!==`array`&&r.type.kind!==`string`&&r.type.kind!==`value`?n.error(`Expected argument of type string or array, but found ${V(r.type)} instead.`):new e(r,n.key):null}evaluate(t){let n=this.input.evaluate(t);if(typeof n==`string`)return[...n].length;if(Array.isArray(n))return n.length;throw new B(`Expected value to be of type string or array, but found ${V(ii(n))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}};const ea=8192;function ta(t,n){let r=ra(t[0]),a=aa(t[1]),o=2**n.z;return[Math.round(r*o*ea),Math.round(a*o*ea)]}function na(t,n){let r=2**n.z,a=(t[0]/ea+n.x)/r,o=(t[1]/ea+n.y)/r;return[ia(a),oa(o)]}function ra(t){return(180+t)/360}function ia(t){return t*360-180}function aa(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function oa(t){return 360/Math.PI*Math.atan(Math.exp((180-t*360)*Math.PI/180))-90}function sa(t,n){t[0]=Math.min(t[0],n[0]),t[1]=Math.min(t[1],n[1]),t[2]=Math.max(t[2],n[0]),t[3]=Math.max(t[3],n[1])}function ca(t,n){return!(t[0]<=n[0]||t[2]>=n[2]||t[1]<=n[1]||t[3]>=n[3])}function la(t,n,r){return n[1]>t[1]!=r[1]>t[1]&&t[0]<(r[0]-n[0])*(t[1]-n[1])/(r[1]-n[1])+n[0]}function ua(t,n,r){let a=t[0]-n[0],o=t[1]-n[1],s=t[0]-r[0],c=t[1]-r[1];return a*c-s*o===0&&a*s<=0&&o*c<=0}function da(t,n,r,a){let o=[n[0]-t[0],n[1]-t[1]];return _a([a[0]-r[0],a[1]-r[1]],o)!==0&&!!(va(t,n,r,a)&&va(r,a,t,n))}function fa(t,n,r){for(let a of r)for(let r=0;r0&&p<0||f<0&&p>0}function ya(t,n,r){let a=[];for(let o=0;or[2]){let n=a*.5,o=t[0]-r[0]>n?-a:r[0]-t[0]>n?a:0;o===0&&(o=t[0]-r[2]>n?-a:r[2]-t[0]>n?a:0),t[0]+=o}sa(n,t)}function Sa(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}function Ca(t,n,r,a){let o=2**a.z*ea,s=[a.x*ea,a.y*ea],c=[];for(let a of t)for(let t of a){let a=[t.x+s[0],t.y+s[1]];xa(a,n,r,o),c.push(a)}return c}function wa(t,n,r,a){let o=2**a.z*ea,s=[a.x*ea,a.y*ea],c=[];for(let r of t){let t=[];for(let a of r){let r=[a.x+s[0],a.y+s[1]];sa(n,r),t.push(r)}c.push(t)}if(n[2]-n[0]<=o/2){Sa(n);for(let t of c)for(let a of t)xa(a,n,r,o)}return c}function Ta(t,n){let r=[1/0,1/0,-1/0,-1/0],a=[1/0,1/0,-1/0,-1/0],o=t.canonicalID();if(n.type===`Polygon`){let s=ya(n.coordinates,a,o),c=Ca(t.geometry(),r,a,o);if(!ca(r,a))return!1;for(let t of c)if(!pa(t,s))return!1}if(n.type===`MultiPolygon`){let s=ba(n.coordinates,a,o),c=Ca(t.geometry(),r,a,o);if(!ca(r,a))return!1;for(let t of c)if(!ma(t,s))return!1}return!0}function Ea(t,n){let r=[1/0,1/0,-1/0,-1/0],a=[1/0,1/0,-1/0,-1/0],o=t.canonicalID();if(n.type===`Polygon`){let s=ya(n.coordinates,a,o),c=wa(t.geometry(),r,a,o);if(!ca(r,a))return!1;for(let t of c)if(!ha(t,s))return!1}if(n.type===`MultiPolygon`){let s=ba(n.coordinates,a,o),c=wa(t.geometry(),r,a,o);if(!ca(r,a))return!1;for(let t of c)if(!ga(t,s))return!1}return!0}var Da=class e{constructor(t,n){this.type=R,this.geojson=t,this.geometries=n}static parse(t,n){if(t.length!==2)return n.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ri(t[1])){let n=t[1];if(n.type===`FeatureCollection`){let t=[];for(let r of n.features){let{type:n,coordinates:a}=r.geometry;n===`Polygon`&&t.push(a),n===`MultiPolygon`&&t.push(...a)}if(t.length)return new e(n,{type:`MultiPolygon`,coordinates:t})}else if(n.type===`Feature`){let t=n.geometry.type;if(t===`Polygon`||t===`MultiPolygon`)return new e(n,n.geometry)}else if(n.type===`Polygon`||n.type===`MultiPolygon`)return new e(n,n)}return n.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 Ta(t,this.geometries);if(t.geometryType()===`LineString`)return Ea(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},Oa=class{constructor(t=[],n=(t,n)=>tn)){if(this.data=t,this.length=this.data.length,this.compare=n,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],n=this.data.pop();return--this.length>0&&(this.data[0]=n,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:n,compare:r}=this,a=n[t];for(;t>0;){let o=t-1>>1,s=n[o];if(r(a,s)>=0)break;n[t]=s,t=o}n[t]=a}_down(t){let{data:n,compare:r}=this,a=this.length>>1,o=n[t];for(;t=0)break;n[t]=n[a],t=a}n[t]=o}};function ka(t,n,r=0,a=t.length-1,o=ja){for(;a>r;){if(a-r>600){let s=a-r+1,c=n-r+1,l=Math.log(s),u=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*u*(s-u)/s)*(c-s/2<0?-1:1);ka(t,n,Math.max(r,Math.floor(n-c*u/s+d)),Math.min(a,Math.floor(n+(s-c)*u/s+d)),o)}let s=t[n],c=r,l=a;for(Aa(t,r,n),o(t[a],s)>0&&Aa(t,r,a);c0;)l--}o(t[r],s)===0?Aa(t,r,l):(l++,Aa(t,l,a)),l<=n&&(r=l+1),n<=l&&(a=l-1)}}function Aa(t,n,r){let a=t[n];t[n]=t[r],t[r]=a}function ja(t,n){return tn)}function Ma(t,n){if(t.length<=1)return[t];let r=[],a,o;for(let n of t){let t=Pa(n);t!==0&&(n.area=Math.abs(t),o===void 0&&(o=t<0),o===t<0?(a&&r.push(a),a=[n]):a.push(n))}if(a&&r.push(a),n>1)for(let t=0;t1?(u=t[l+1][0],d=t[l+1][1]):m>0&&(u+=f/this.kx*m,d+=p/this.ky*m)),f=this.wrap(n[0]-u)*this.kx,p=(n[1]-d)*this.ky;let h=f*f+p*p;h180;)t-=360;return t}};function za(t,n){return n[0]-t[0]}function Ba(t){return t[1]-t[0]+1}function Va(t,n){return t[1]>=t[0]&&t[1]t[1])return[null,null];let r=Ba(t);if(n){if(r===2)return[t,null];let n=Math.floor(r/2);return[[t[0],t[0]+n],[t[0]+n,t[1]]]}if(r===1)return[t,null];let a=Math.floor(r/2)-1;return[[t[0],t[0]+a],[t[0]+a+1,t[1]]]}function Ua(t,n){if(!Va(n,t.length))return[1/0,1/0,-1/0,-1/0];let r=[1/0,1/0,-1/0,-1/0];for(let a=n[0];a<=n[1];++a)sa(r,t[a]);return r}function Wa(t){let n=[1/0,1/0,-1/0,-1/0];for(let r of t)for(let t of r)sa(n,t);return n}function Ga(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Ka(t,n,r){if(!Ga(t)||!Ga(n))return NaN;let a=0,o=0;return t[2]n[2]&&(a=t[0]-n[2]),t[1]>n[3]&&(o=t[1]-n[3]),t[3]=a)return a;if(ca(o,s)){if($a(t,n))return 0}else if($a(n,t))return 0;let c=1/0;for(let a of t)for(let t=0,o=a.length,s=o-1;t0;){let o=c.pop();if(o[0]>=s)continue;let u=o[1],d=n?50:100;if(Ba(u)<=d){if(!Va(u,t.length))return NaN;if(n){let n=Qa(t,u,r,a);if(isNaN(n)||n===0)return n;s=Math.min(s,n)}else for(let n=u[0];n<=u[1];++n){let o=Za(t[n],r,a);if(s=Math.min(s,o),s===0)return 0}}else{let r=Ha(u,n);to(c,s,a,t,l,r[0]),to(c,s,a,t,l,r[1])}}return s}function io(t,n,r,a,o,s=1/0){let c=Math.min(s,o.distance(t[0],r[0]));if(c===0)return c;let l=new Oa([[0,[0,t.length-1],[0,r.length-1]]],za);for(;l.length>0;){let s=l.pop();if(s[0]>=c)continue;let u=s[1],d=s[2],f=n?50:100,p=a?50:100;if(Ba(u)<=f&&Ba(d)<=p){if(!Va(u,t.length)&&Va(d,r.length))return NaN;let s;if(n&&a)s=Ya(t,u,r,d,o),c=Math.min(c,s);else if(n&&!a){let n=t.slice(u[0],u[1]+1);for(let t=d[0];t<=d[1];++t)if(s=qa(r[t],n,o),c=Math.min(c,s),c===0)return c}else if(!n&&a){let n=r.slice(d[0],d[1]+1);for(let r=u[0];r<=u[1];++r)if(s=qa(t[r],n,o),c=Math.min(c,s),c===0)return c}else s=Xa(t,u,r,d,o),c=Math.min(c,s)}else{let s=Ha(u,n),f=Ha(d,a);no(l,c,o,t,r,s[0],f[0]),no(l,c,o,t,r,s[0],f[1]),no(l,c,o,t,r,s[1],f[0]),no(l,c,o,t,r,s[1],f[1])}}return c}function ao(t,n){let r=t.geometry(),a=r.flat().map(n=>na([n.x,n.y],t.canonical));if(r.length===0)return NaN;let o=new Ra(a[0][1]),s=1/0;for(let t of n){switch(t.type){case`Point`:s=Math.min(s,io(a,!1,[t.coordinates],!1,o,s));break;case`LineString`:s=Math.min(s,io(a,!1,t.coordinates,!0,o,s));break;case`Polygon`:s=Math.min(s,ro(a,!1,t.coordinates,o,s));break}if(s===0)return s}return s}function oo(t,n){let r=t.geometry(),a=r.flat().map(n=>na([n.x,n.y],t.canonical));if(r.length===0)return NaN;let o=new Ra(a[0][1]),s=1/0;for(let t of n){switch(t.type){case`Point`:s=Math.min(s,io(a,!0,[t.coordinates],!1,o,s));break;case`LineString`:s=Math.min(s,io(a,!0,t.coordinates,!0,o,s));break;case`Polygon`:s=Math.min(s,ro(a,!0,t.coordinates,o,s));break}if(s===0)return s}return s}function so(t,n){let r=t.geometry();if(r.length===0||r[0].length===0)return NaN;let a=Ma(r,0).map(n=>n.map(n=>n.map(n=>na([n.x,n.y],t.canonical)))),o=new Ra(a[0][0][0][1]),s=1/0;for(let t of n)for(let n of a){switch(t.type){case`Point`:s=Math.min(s,ro([t.coordinates],!1,n,o,s));break;case`LineString`:s=Math.min(s,ro(t.coordinates,!0,n,o,s));break;case`Polygon`:s=Math.min(s,eo(n,t.coordinates,o,s));break}if(s===0)return s}return s}function co(t){return t.type===`MultiPolygon`?t.coordinates.map(t=>({type:`Polygon`,coordinates:t})):t.type===`MultiLineString`?t.coordinates.map(t=>({type:`LineString`,coordinates:t})):t.type===`MultiPoint`?t.coordinates.map(t=>({type:`Point`,coordinates:t})):[t]}var lo=class e{constructor(t,n){this.type=I,this.geojson=t,this.geometries=n}static parse(t,n){if(t.length!==2)return n.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ri(t[1])){let n=t[1];if(n.type===`FeatureCollection`)return new e(n,n.features.map(t=>co(t.geometry)).flat());if(n.type===`Feature`)return new e(n,co(n.geometry));if(`type`in n&&`coordinates`in n)return new e(n,co(n))}return n.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 ao(t,this.geometries);if(t.geometryType()===`LineString`)return oo(t,this.geometries);if(t.geometryType()===`Polygon`)return so(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},uo=class e{constructor(t){this.key=t,this.type=z}static parse(t,n){if(t.length!==2)return n.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=t[1];return r==null?n.error(`Global state property must be defined.`):typeof r==`string`?new e(r):n.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(t){let n=t.globals?.globalState;return!n||Object.keys(n).length===0?null:Fr(n,this.key)??null}eachChild(){}outputDefined(){return!1}};const fo={"==":Ui,"!=":Wi,">":Ki,"<":Gi,">=":Ji,"<=":qi,array:ci,at:gi,boolean:ci,case:bi,coalesce:Oi,collator:Yi,format:Zi,image:Qi,in:_i,"index-of":vi,interpolate:Ti,"interpolate-hcl":Ti,"interpolate-lab":Ti,length:$i,let:mi,literal:oi,match:yi,number:ci,"number-format":Xi,object:ci,slice:xi,step:Ci,string:ci,"to-boolean":ui,"to-color":ui,"to-number":ui,"to-string":ui,var:hi,within:Da,distance:lo,"global-state":uo};var po=class e{constructor(t,n,r,a,o){this.name=t,this.type=n,this._evaluate=r,this.args=a,this.key=o}evaluate(t){return this._evaluate(t,this.args,this.key)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,n){let r=t[0],a=e.definitions[r];if(!a)return n.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let o=Array.isArray(a)?a[0]:a.type,s=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,c=s.filter(([n])=>!Array.isArray(n)||n.length===t.length-1),l=null;for(let[a,s]of c){l=new pi(n.registry,bo,n.path,null,n.scope);let c=[],u=!1;for(let n=1;nyo(t)).join(` | `),a=[];for(let r=1;r>1;if(n[o]===t)return!0;n[o]>t?a=o-1:r=o+1}return!1}function vo(t){return{type:t}}po.register(fo,{error:[rr,[L],(t,[n],r)=>{throw new B(n.evaluate(t),r)}],typeof:[L,[z],(t,[n])=>V(ii(n.evaluate(t)))],"to-rgba":[dr(I,4),[er],(t,[n])=>{let[r,a,o,s]=n.evaluate(t).rgb;return[r*255,a*255,o*255,s]}],rgb:[er,[I,I,I],mo],rgba:[er,[I,I,I,I],mo],has:{type:R,overloads:[[[L],(t,[n])=>ho(n.evaluate(t),t.properties())],[[L,nr],(t,[n,r])=>ho(n.evaluate(t),r.evaluate(t))]]},get:{type:z,overloads:[[[L],(t,[n])=>go(n.evaluate(t),t.properties())],[[L,nr],(t,[n,r])=>go(n.evaluate(t),r.evaluate(t))]]},"feature-state":[z,[L],(t,[n])=>go(n.evaluate(t),t.featureState||{})],properties:[nr,[],t=>t.properties()],"geometry-type":[L,[],t=>t.geometryType()],id:[z,[],t=>t.id()],zoom:[I,[],t=>t.globals.zoom],"heatmap-density":[I,[],t=>t.globals.heatmapDensity||0],elevation:[I,[],t=>t.globals.elevation||0],"line-progress":[I,[],t=>t.globals.lineProgress||0],accumulated:[z,[],t=>t.globals.accumulated===void 0?null:t.globals.accumulated],"+":[I,vo(I),(t,n)=>{let r=0;for(let a of n)r+=a.evaluate(t);return r}],"*":[I,vo(I),(t,n)=>{let r=1;for(let a of n)r*=a.evaluate(t);return r}],"-":{type:I,overloads:[[[I,I],(t,[n,r])=>n.evaluate(t)-r.evaluate(t)],[[I],(t,[n])=>-n.evaluate(t)]]},"/":[I,[I,I],(t,[n,r])=>n.evaluate(t)/r.evaluate(t)],"%":[I,[I,I],(t,[n,r])=>n.evaluate(t)%r.evaluate(t)],ln2:[I,[],()=>Math.LN2],pi:[I,[],()=>Math.PI],e:[I,[],()=>Math.E],"^":[I,[I,I],(t,[n,r])=>n.evaluate(t)**+r.evaluate(t)],sqrt:[I,[I],(t,[n])=>Math.sqrt(n.evaluate(t))],log10:[I,[I],(t,[n])=>Math.log(n.evaluate(t))/Math.LN10],ln:[I,[I],(t,[n])=>Math.log(n.evaluate(t))],log2:[I,[I],(t,[n])=>Math.log(n.evaluate(t))/Math.LN2],sin:[I,[I],(t,[n])=>Math.sin(n.evaluate(t))],cos:[I,[I],(t,[n])=>Math.cos(n.evaluate(t))],tan:[I,[I],(t,[n])=>Math.tan(n.evaluate(t))],asin:[I,[I],(t,[n])=>Math.asin(n.evaluate(t))],acos:[I,[I],(t,[n])=>Math.acos(n.evaluate(t))],atan:[I,[I],(t,[n])=>Math.atan(n.evaluate(t))],min:[I,vo(I),(t,n)=>Math.min(...n.map(n=>n.evaluate(t)))],max:[I,vo(I),(t,n)=>Math.max(...n.map(n=>n.evaluate(t)))],abs:[I,[I],(t,[n])=>Math.abs(n.evaluate(t))],round:[I,[I],(t,[n])=>{let r=n.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[I,[I],(t,[n])=>Math.floor(n.evaluate(t))],ceil:[I,[I],(t,[n])=>Math.ceil(n.evaluate(t))],"filter-==":[R,[L,z],(t,[n,r])=>t.properties()[n.value]===r.value],"filter-id-==":[R,[z],(t,[n])=>t.id()===n.value],"filter-type-==":[R,[L],(t,[n])=>t.geometryType()===n.value],"filter-<":[R,[L,z],(t,[n,r])=>{let a=t.properties()[n.value],o=r.value;return typeof a==typeof o&&a{let r=t.id(),a=n.value;return typeof r==typeof a&&r":[R,[L,z],(t,[n,r])=>{let a=t.properties()[n.value],o=r.value;return typeof a==typeof o&&a>o}],"filter-id->":[R,[z],(t,[n])=>{let r=t.id(),a=n.value;return typeof r==typeof a&&r>a}],"filter-<=":[R,[L,z],(t,[n,r])=>{let a=t.properties()[n.value],o=r.value;return typeof a==typeof o&&a<=o}],"filter-id-<=":[R,[z],(t,[n])=>{let r=t.id(),a=n.value;return typeof r==typeof a&&r<=a}],"filter->=":[R,[L,z],(t,[n,r])=>{let a=t.properties()[n.value],o=r.value;return typeof a==typeof o&&a>=o}],"filter-id->=":[R,[z],(t,[n])=>{let r=t.id(),a=n.value;return typeof r==typeof a&&r>=a}],"filter-has":[R,[z],(t,[n])=>{let r=n.value,a=t.properties();return r in a&&a[r]!==void 0}],"filter-has-id":[R,[],t=>t.id()!==null&&t.id()!==void 0],"filter-type-in":[R,[dr(L)],(t,[n])=>n.value.indexOf(t.geometryType())>=0],"filter-id-in":[R,[dr(z)],(t,[n])=>n.value.indexOf(t.id())>=0],"filter-in-small":[R,[L,dr(z)],(t,[n,r])=>r.value.indexOf(t.properties()[n.value])>=0],"filter-in-large":[R,[L,dr(z)],(t,[n,r])=>_o(t.properties()[n.value],r.value,0,r.value.length-1)],all:{type:R,overloads:[[[R,R],(t,[n,r])=>n.evaluate(t)&&r.evaluate(t)],[vo(R),(t,n)=>{for(let r of n)if(!r.evaluate(t))return!1;return!0}]]},any:{type:R,overloads:[[[R,R],(t,[n,r])=>n.evaluate(t)||r.evaluate(t)],[vo(R),(t,n)=>{for(let r of n)if(r.evaluate(t))return!0;return!1}]]},"!":[R,[R],(t,[n])=>!n.evaluate(t)],"is-supported-script":[R,[L],(t,[n])=>{let r=t.globals&&t.globals.isSupportedScript;return!r||r(n.evaluate(t))}],upcase:[L,[L],(t,[n])=>n.evaluate(t).toUpperCase()],downcase:[L,[L],(t,[n])=>n.evaluate(t).toLowerCase()],concat:[L,vo(z),(t,n)=>n.map(n=>ai(n.evaluate(t))).join(``)],split:[dr(L),[L,L],(t,[n,r])=>n.evaluate(t).split(r.evaluate(t))],join:[L,[dr(L),L],(t,[n,r])=>n.evaluate(t).join(r.evaluate(t))],"resolved-locale":[L,[ir],(t,[n])=>n.evaluate(t).resolvedLocale()]});function yo(t){return Array.isArray(t)?`(${t.map(V).join(`, `)})`:`(${V(t.type)}...)`}function bo(t){if(t instanceof hi)return bo(t.boundExpression);if(t instanceof po&&t.name===`error`||t instanceof Yi||t instanceof Da||t instanceof lo||t instanceof uo)return!1;let n=t instanceof ui||t instanceof ci,r=!0;return t.eachChild(t=>{n?r&&=bo(t):r&&=t instanceof oi}),r?xo(t)&&Co(t,[`zoom`,`heatmap-density`,`elevation`,`line-progress`,`accumulated`,`is-supported-script`]):!1}function xo(t){if(t instanceof po&&(t.name===`get`&&t.args.length===1||t.name===`feature-state`||t.name===`has`&&t.args.length===1||t.name===`properties`||t.name===`geometry-type`||t.name===`id`||/^filter-/.test(t.name))||t instanceof Da||t instanceof lo)return!1;let n=!0;return t.eachChild(t=>{n&&!xo(t)&&(n=!1)}),n}function So(t){if(t instanceof po&&t.name===`feature-state`)return!1;let n=!0;return t.eachChild(t=>{n&&!So(t)&&(n=!1)}),n}function Co(t,n){if(t instanceof po&&n.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild(t=>{r&&!Co(t,n)&&(r=!1)}),r}function wo(t){return{result:`success`,value:t}}function To(t){return{result:`error`,value:t}}function Eo(t){return t[`property-type`]===`data-driven`||t[`property-type`]===`cross-faded-data-driven`}function Do(t){return!!t.expression&&t.expression.parameters.indexOf(`zoom`)>-1}function Oo(t){return!!t.expression&&t.expression.interpolated}function ko(t,...n){for(let r of n)for(let n in r)t[n]=r[n];return t}function q(t){return t instanceof Number?`number`:t instanceof String?`string`:t instanceof Boolean?`boolean`:Array.isArray(t)?`array`:t===null?`null`:typeof t}function Ao(t){return typeof t==`object`&&!!t&&!Array.isArray(t)&&ii(t)===nr}function jo(t){return t}function Mo(t){switch(t.type){case`color`:return H.parse;case`padding`:return Yr.parse;case`numberArray`:return Xr.parse;case`colorArray`:return Zr.parse;default:return null}}function No(t){switch(t){case`exponential`:return Ro;case`interval`:return Lo;case`categorical`:return Io;case`identity`:return zo;default:throw Error(`Unknown function type "${t}"`)}}function Po(t,n){let r=t.stops&&typeof t.stops[0][0]==`object`,a=r||t.property!==void 0,o=r||!a,s=t.type||(Oo(n)?`exponential`:`interval`),c=Mo(n);if(c&&(t=ko({},t),t.stops&&=t.stops.map(t=>[t[0],c(t[1])]),t.default?t.default=c(t.default):t.default=c(n.default)),t.colorSpace&&!Wr(t.colorSpace))throw Error(`Unknown color space: "${t.colorSpace}"`);let l=No(s),u,d;if(s===`categorical`){u=Object.create(null);for(let n of t.stops)u[n[0]]=n[1];d=typeof t.stops[0][0]}if(r){let r={},a=[];for(let n=0;nt[0]),evaluate({zoom:r},a){return Ro({stops:o,base:t.base},n,r).evaluate(r,a)}}}else if(o){let r=s===`exponential`?{name:`exponential`,base:t.base===void 0?1:t.base}:null;return{kind:`camera`,interpolationType:r,interpolationFactor:Ti.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map(t=>t[0]),evaluate:({zoom:r})=>l(t,n,r,u,d)}}else return{kind:`source`,evaluate(r,a){let o=a&&a.properties?a.properties[t.property]:void 0;return o===void 0?Fo(t.default,n.default):l(t,n,o,u,d)}}}function Fo(t,n,r){if(t!==void 0)return t;if(n!==void 0)return n;if(r!==void 0)return r}function Io(t,n,r,a,o){return Fo(typeof r===o?a[r]:void 0,t.default,n.default)}function Lo(t,n,r){if(q(r)!==`number`)return Fo(t.default,n.default);let a=t.stops.length;if(a===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[a-1][0])return t.stops[a-1][1];let o=Si(t.stops.map(t=>t[0]),r,``);return t.stops[o][1]}function Ro(t,n,r){let a=t.base===void 0?1:t.base;if(q(r)!==`number`)return Fo(t.default,n.default);let o=t.stops.length;if(o===1||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[o-1][0])return t.stops[o-1][1];let s=Si(t.stops.map(t=>t[0]),r,``),c=Bo(r,a,t.stops[s][0],t.stops[s+1][0]),l=t.stops[s][1],u=t.stops[s+1][1],d=Di[n.type]||jo;return typeof l.evaluate==`function`?{evaluate(...n){let r=l.evaluate.apply(void 0,n),a=u.evaluate.apply(void 0,n);if(r!==void 0&&a!==void 0)return d(r,a,c,t.colorSpace)}}:d(l,u,c,t.colorSpace)}function zo(t,n,r){switch(n.type){case`color`:r=H.parse(r);break;case`formatted`:r=Jr.fromString(r.toString());break;case`resolvedImage`:r=ei.fromString(r.toString());break;case`padding`:r=Yr.parse(r);break;case`colorArray`:r=Zr.parse(r);break;case`numberArray`:r=Xr.parse(r);break;default:q(r)!==n.type&&(n.type!==`enum`||!n.values[r])&&(r=void 0)}return Fo(r,t.default,n.default)}function Bo(t,n,r,a){let o=a-r,s=t-r;return o===0?0:n===1?s/o:(n**+s-1)/(n**+o-1)}var Vo=class{constructor(t,n,r,a){this.expression=t,this._warningHistory={},this._evaluator=new fi,this._defaultValue=r?ts(r):null,this._enumValues=r&&r.type===`enum`?r.values:null,this._globalState=a,this._rootKey=n}evaluateWithoutErrorHandling(t,n,r,a,o,s){return this._globalState&&(t=ns(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=n,this._evaluator.featureState=r,this._evaluator.canonical=a,this._evaluator.availableImages=o||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,n,r,a,o,s){this._globalState&&(t=ns(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=n||null,this._evaluator.featureState=r||null,this._evaluator.canonical=a,this._evaluator.availableImages=o||null,this._evaluator.formattedSection=s||null;try{let t=this.expression.evaluate(this._evaluator);if(t==null||typeof t==`number`&&t!==t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new B(`Expected value to be one of ${Object.keys(this._enumValues).map(t=>JSON.stringify(t)).join(`, `)}, but found ${JSON.stringify(t)} instead.`,``);return t}catch(t){let n=t instanceof B?t.path:``,r=`${n}|${t.message}`;return this._warningHistory[r]||(this._warningHistory[r]=!0,typeof console<`u`&&console.warn(Ho(this._rootKey,n,t.message,this._defaultValue))),this._defaultValue}}};function Ho(t,n,r,a){return`${t}${n}: ${r}${a==null?``:` Falling back to ${String(a)}.`}`}function Uo(t){if(!t)throw Error(`rootKey must identify the location of the expression in the style JSON, e.g. "layers[3].paint.line-width".`)}function Wo(t){return Array.isArray(t)&&t.length>0&&typeof t[0]==`string`&&t[0]in fo}function Go(t,n,r,a){Uo(n);let o=new pi(fo,bo,[],r?es(r):void 0),s=o.parse(t,void 0,void 0,void 0,r&&r.type===`string`?{typeAnnotation:`coerce`}:void 0);return s?wo(new Vo(s,n,r,a)):To(o.errors)}var Ko=class{constructor(t,n,r){this.kind=t,this._styleExpression=n,this.isStateDependent=t!==`constant`&&!So(n.expression),this.globalStateRefs=$o(n.expression),this._globalState=r}evaluateWithoutErrorHandling(t,n,r,a,o,s){return this._globalState&&(t=ns(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,n,r,a,o,s)}evaluate(t,n,r,a,o,s){return this._globalState&&(t=ns(t,this._globalState)),this._styleExpression.evaluate(t,n,r,a,o,s)}},qo=class{constructor(t,n,r,a,o){this.kind=t,this.zoomStops=r,this._styleExpression=n,this.isStateDependent=t!==`camera`&&!So(n.expression),this.globalStateRefs=$o(n.expression),this.interpolationType=a,this._globalState=o}evaluateWithoutErrorHandling(t,n,r,a,o,s){return this._globalState&&(t=ns(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,n,r,a,o,s)}evaluate(t,n,r,a,o,s){return this._globalState&&(t=ns(t,this._globalState)),this._styleExpression.evaluate(t,n,r,a,o,s)}interpolationFactor(t,n,r){return this.interpolationType?Ti.interpolationFactor(this.interpolationType,t,n,r):0}};function Jo(t){return t._styleExpression!==void 0}function Yo(t,n,r,a){let o=Go(t,n,r,a);if(o.result===`error`)return o;let s=o.value.expression,c=xo(s);if(!c&&!Eo(r))return To([new Zn(``,`data expressions not supported`)]);let l=Co(s,[`zoom`]);if(!l&&!Do(r))return To([new Zn(``,`zoom expressions not supported`)]);let u=Qo(s);if(!u&&!l)return To([new Zn(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`)]);if(u instanceof Zn)return To([u]);if(u instanceof Ti&&!Oo(r))return To([new Zn(``,`"interpolate" expressions cannot be used with this property`)]);if(!u)return wo(c?new Ko(`constant`,o.value,a):new Ko(`source`,o.value,a));let d=u instanceof Ti?u.interpolation:void 0;return wo(c?new qo(`camera`,o.value,u.labels,d,a):new qo(`composite`,o.value,u.labels,d,a))}var Xo=class e{constructor(t,n,r){this.isStateDependent=!1,this.globalStateRefs=/* @__PURE__ */ new Set,this._globalState=null,Uo(n),this._parameters=t,this._specification=r,this._rootKey=n,this._defaultValue=ts(r),this._warningHistory={};let a=Po(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,n){try{return this._innerEvaluate(t,n)}catch(t){let n=t instanceof Error?t.message:String(t),r=`|${n}`;return this._warningHistory[r]||(this._warningHistory[r]=!0,typeof console<`u`&&console.warn(Ho(this._rootKey,``,n,this._defaultValue))),this._defaultValue}}static deserialize(t){return new e(t._parameters,t._rootKey,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification,_rootKey:t._rootKey}}};function Zo(t,n,r,a){if(Ao(t))return new Xo(t,n,r);if(Wo(t)){let o=Yo(t,n,r,a);if(o.result===`error`)throw Error(o.value.map(t=>`${t.key}: ${t.message}`).join(`, `));return o.value}else{let n=t;return r.type===`color`&&typeof t==`string`?n=H.parse(t):r.type===`padding`&&(typeof t==`number`||Array.isArray(t))?n=Yr.parse(t):r.type===`numberArray`&&(typeof t==`number`||Array.isArray(t))?n=Xr.parse(t):r.type===`colorArray`&&(typeof t==`string`||Array.isArray(t))?n=Zr.parse(t):r.type===`variableAnchorOffsetCollection`&&Array.isArray(t)?n=$r.parse(t):r.type===`projectionDefinition`&&typeof t==`string`&&(n=ti.parse(t)),{globalStateRefs:/* @__PURE__ */ new Set,_globalState:null,kind:`constant`,evaluate:()=>n}}}function Qo(t){let n=null;if(t instanceof mi)n=Qo(t.result);else if(t instanceof Oi){for(let r of t.args)if(n=Qo(r),n)break}else (t instanceof Ci||t instanceof Ti)&&t.input instanceof po&&t.input.name===`zoom`&&(n=t);return n instanceof Zn||t.eachChild(t=>{let r=Qo(t);r instanceof Zn?n=r:!n&&r?n=new Zn(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`):n&&r&&n!==r&&(n=new Zn(``,`Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.`))}),n}function $o(t,n=/* @__PURE__ */ new Set){return t instanceof uo&&n.add(t.key),t.eachChild(t=>{$o(t,n)}),n}function es(t){let n={color:er,string:L,number:I,enum:L,boolean:R,formatted:ar,padding:or,numberArray:cr,colorArray:sr,projectionDefinition:tr,resolvedImage:lr,variableAnchorOffsetCollection:ur};return t.type===`array`?dr(n[t.value]||z,t.length):n[t.type]}function ts(t){if(t.type===`color`&&Ao(t.default))return new H(0,0,0,0);switch(t.type){case`color`:return H.parse(t.default)||null;case`padding`:return Yr.parse(t.default)||null;case`numberArray`:return Xr.parse(t.default)||null;case`colorArray`:return Zr.parse(t.default)||null;case`variableAnchorOffsetCollection`:return $r.parse(t.default)||null;case`projectionDefinition`:return ti.parse(t.default)||null;default:return t.default===void 0?null:t.default}}function ns(t,n){let{zoom:r,heatmapDensity:a,elevation:o,lineProgress:s,isSupportedScript:c,accumulated:l}=t??{};return{zoom:r,heatmapDensity:a,elevation:o,lineProgress:s,isSupportedScript:c,accumulated:l,globalState:n}}function rs(t){let n=!1;for(let r of t){let t=is(r);if(t===`expression`)return`expression`;t===`legacy`&&(n=!0)}return n?`legacy`:`neutral`}function is(t){if(typeof t==`boolean`)return`neutral`;if(!Array.isArray(t)||t.length===0)return`legacy`;switch(t[0]){case`has`:return t.length<2||t[1]===`$id`||t[1]===`$type`?`legacy`:t.length===2?`neutral`:`expression`;case`in`:return t.length>=3&&(typeof t[1]!=`string`||Array.isArray(t[2]))?`expression`:`legacy`;case`!in`:case`!has`:return`legacy`;case`==`:case`!=`:case`>`:case`>=`:case`<`:case`<=`:return t.length!==3||Array.isArray(t[1])||Array.isArray(t[2])?`expression`:`legacy`;case`none`:return`legacy`;case`any`:case`all`:return rs(t.slice(1));default:return`expression`}}function as(t){return is(t)!==`legacy`}function os(t){return t===`$type`?[`geometry-type`]:t===`$id`?[`id`]:[`get`,t]}function ss(t){switch(t[0]){case`==`:case`!=`:case`<`:case`<=`:case`>`:case`>=`:return t.length!==3||typeof t[1]!=`string`?null:[t[0],os(t[1]),t[2]];case`in`:case`!in`:{if(t.length<2||typeof t[1]!=`string`)return null;let n=[`in`,os(t[1]),[`literal`,t.slice(2)]];return t[0]===`!in`?[`!`,n]:n}case`has`:case`!has`:{if(t.length!==2||typeof t[1]!=`string`||t[1]===`$type`||t[1]===`$id`)return null;let n=[`has`,t[1]];return t[0]===`!has`?[`!`,n]:n}default:return null}}function cs(t){if((t[0]===`<`||t[0]===`<=`||t[0]===`>`||t[0]===`>=`)&&t[1]===`$type`)return`"$type" cannot be use with operator "${t[0]}"`;let n=ss(t);return n?`Mixing deprecated filter syntax with expression syntax is not supported. Replace ${JSON.stringify(t)} with ${JSON.stringify(n)}.`:`Mixing deprecated filter syntax with expression syntax is not supported. Convert ${JSON.stringify(t)} to expression syntax.`}function ls(t,n,r){let a=r[t];return Array.isArray(a)?as(a)?us(a,n.concat(t)):{path:n.concat(t),legacyFilter:a}:null}function us(t,n=[]){if(!Array.isArray(t)||t.length<1)return null;switch(t[0]){case`all`:case`any`:case`none`:for(let r=1;r`u`)return;let a=r.path.map(t=>`[${t}]`).join(``);console.warn(`${n}${a}: ${cs(r.legacyFilter)}`)}const fs={type:`boolean`,default:!1,transition:!1,"property-type":`data-driven`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]}};function ps(t,n,r){if(t==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>/* @__PURE__ */ new Set};as(t)?ds(t,n):t=gs(t);let a=Go(t,n,fs,r);if(a.result===`error`)throw Error(a.value.map(t=>`${t.key}: ${t.message}`).join(`, `));return{filter:(t,n,r)=>a.value.evaluate(t,n,{},r),needGeometry:hs(t),getGlobalStateRefs:()=>$o(a.value.expression)}}function ms(t,n){return tn)}function hs(t){if(!Array.isArray(t))return!1;if(t[0]===`within`||t[0]===`distance`)return!0;for(let n=1;n`||n===`<=`||n===`>=`?_s(t[1],t[2],n):n===`any`?vs(t.slice(1)):n===`all`?[`all`].concat(t.slice(1).map(gs)):n===`none`?[`all`].concat(t.slice(1).map(gs).map(xs)):n===`in`?ys(t[1],t.slice(2)):n===`!in`?xs(ys(t[1],t.slice(2))):n===`has`?bs(t[1]):n!==`!has`||xs(bs(t[1]))}function _s(t,n,r){switch(t){case`$type`:return[`filter-type-${r}`,n];case`$id`:return[`filter-id-${r}`,n];default:return[`filter-${r}`,t,n]}}function vs(t){return[`any`].concat(t.map(gs))}function ys(t,n){if(n.length===0)return!1;switch(t){case`$type`:return[`filter-type-in`,[`literal`,n]];case`$id`:return[`filter-id-in`,[`literal`,n]];default:return n.length>200&&!n.some(t=>typeof t!=typeof n[0])?[`filter-in-large`,t,[`literal`,n.sort(ms)]]:[`filter-in-small`,t,[`literal`,n]]}}function bs(t){switch(t){case`$type`:return!0;case`$id`:return[`filter-has-id`];default:return[`filter-has`,t]}}function xs(t){return[`!`,t]}function Ss(t){let n=typeof t;if(n===`number`||n===`boolean`||n===`string`||t==null)return JSON.stringify(t);if(Array.isArray(t)){let n=`[`;for(let r of t)n+=`${Ss(r)},`;return`${n}]`}let r=Object.keys(t).sort(),a=`{`;for(let n=0;na.maximum?[new N(n,r,`${r} is greater than the maximum value ${a.maximum}`)]:[]:[new N(n,r,`number expected, ${o} found`)]}function Ms(t){let n=t.valueSpec,r=Ds(t.value.type),a,o={},s,c,l=r!==`categorical`&&t.value.property===void 0,u=!l,d=q(t.value.stops)===`array`&&q(t.value.stops[0])===`array`&&q(t.value.stops[0][0])===`object`,f=ks({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:p,default:g}});return r===`identity`&&l&&f.push(new N(t.key,t.value,`missing required property "property"`)),r!==`identity`&&!t.value.stops&&f.push(new N(t.key,t.value,`missing required property "stops"`)),r===`exponential`&&t.valueSpec.expression&&!Oo(t.valueSpec)&&f.push(new N(t.key,t.value,`exponential functions not supported`)),t.styleSpec.$version>=8&&(u&&!Eo(t.valueSpec)?f.push(new N(t.key,t.value,`property functions not supported`)):l&&!Do(t.valueSpec)&&f.push(new N(t.key,t.value,`zoom functions not supported`))),(r===`categorical`||d)&&t.value.property===void 0&&f.push(new N(t.key,t.value,`"property" property is required`)),f;function p(t){if(r===`identity`)return[new N(t.key,t.value,`identity function may not have a "stops" property`)];let n=[],a=t.value;return n=n.concat(As({key:t.key,value:a,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:m})),q(a)===`array`&&a.length===0&&n.push(new N(t.key,a,`array must have at least one stop`)),n}function m(t){let r=[],a=t.value,l=t.key;if(q(a)!==`array`)return[new N(l,a,`array expected, ${q(a)} found`)];if(a.length!==2)return[new N(l,a,`array length 2 expected, length ${a.length} found`)];if(d){if(q(a[0])!==`object`)return[new N(l,a,`object expected, ${q(a[0])} found`)];if(a[0].zoom===void 0)return[new N(l,a,`object stop key must have zoom`)];if(a[0].value===void 0)return[new N(l,a,`object stop key must have value`)];if(c&&c>Ds(a[0].zoom))return[new N(l,a[0].zoom,`stop zoom values must appear in ascending order`)];Ds(a[0].zoom)!==c&&(c=Ds(a[0].zoom),s=void 0,o={}),r=r.concat(ks({key:`${l}[0]`,value:a[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:js,value:h}}))}else r=r.concat(h({key:`${l}[0]`,value:a[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},a));return Wo(Os(a[1]))?r.concat([new N(`${l}[1]`,a[1],`expressions are not allowed in function stops.`)]):r.concat(t.validateSpec({key:`${l}[1]`,value:a[1],valueSpec:n,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function h(t,c){let l=q(t.value),u=Ds(t.value),d=t.value===null?c:t.value;if(!a)a=l;else if(l!==a)return[new N(t.key,d,`${l} stop domain type must match previous stop domain type ${a}`)];if(l!==`number`&&l!==`string`&&l!==`boolean`)return[new N(t.key,d,`stop domain value must be a number, string, or boolean`)];if(l!==`number`&&r!==`categorical`){let a=`number expected, ${l} found`;return Eo(n)&&r===void 0&&(a+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new N(t.key,d,a)]}return r===`categorical`&&l===`number`&&(!isFinite(u)||Math.floor(u)!==u)?[new N(t.key,d,`integer expected, found ${u}`)]:r!==`categorical`&&l===`number`&&s!==void 0&&unew N(`${t.key}${n.key}`,t.value,n.message));let r=n.value.expression||n.value._styleExpression.expression;if(t.expressionContext===`property`&&t.propertyKey===`text-font`&&!r.outputDefined())return[new N(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if(t.expressionContext===`property`&&t.propertyType===`layout`&&!So(r))return[new N(t.key,t.value,`"feature-state" data expressions are not supported with layout properties.`)];if(t.expressionContext===`filter`&&!So(r))return[new N(t.key,t.value,`"feature-state" data expressions are not supported with filters.`)];if(t.expressionContext&&t.expressionContext.indexOf(`cluster`)===0){if(!Co(r,[`zoom`,`feature-state`]))return[new N(t.key,t.value,`"zoom" and "feature-state" expressions are not supported with cluster properties.`)];if(t.expressionContext===`cluster-initial`&&!xo(r))return[new N(t.key,t.value,`Feature data expressions are not supported with initial expression part of cluster properties.`)]}return[]}function Ps(t){let n=t.value,r=t.key,a=q(n);return a===`boolean`?[]:[new N(r,n,`boolean expected, ${a} found`)]}function Fs(t){let n=t.key,r=t.value,a=q(r);return a===`string`?H.parse(String(r))?[]:[new N(n,r,`color expected, "${r}" found`)]:[new N(n,r,`color expected, ${a} found`)]}function Is(t){let n=t.key,r=t.value,a=t.valueSpec,o=[];return Array.isArray(a.values)?a.values.indexOf(Ds(r))===-1&&o.push(new N(n,r,`expected one of [${a.values.join(`, `)}], ${JSON.stringify(r)} found`)):Object.keys(a.values).indexOf(Ds(r))===-1&&o.push(new N(n,r,`expected one of [${Object.keys(a.values).join(`, `)}], ${JSON.stringify(r)} found`)),o}function Ls(t,n){let r=t;for(let t of n)r=r[t];return r}function Rs(t,n){let r=us(n);return r?[new N(`${t.key}${r.path.map(t=>`[${t}]`).join(``)}`,Ls(t.value,r.path),cs(r.legacyFilter),null,`warning`)]:[]}function zs(t){let n=Os(t.value);return as(n)?[...Rs(t,n),...Ns(ko({},t,{expressionContext:`filter`,valueSpec:{value:`boolean`}}))]:Bs(t)}function Bs(t){let n=t.value,r=t.key;if(q(n)!==`array`)return[new N(r,n,`array expected, ${q(n)} found`)];let a=t.styleSpec,o,s=[];if(n.length<1)return[new N(r,n,`filter array must have at least 1 element`)];switch(s=s.concat(Is({key:`${r}[0]`,value:n[0],valueSpec:a.filter_operator,style:t.style,styleSpec:t.styleSpec})),Ds(n[0])){case`<`:case`<=`:case`>`:case`>=`:n.length>=2&&Ds(n[1])===`$type`&&s.push(new N(r,n,`"$type" cannot be use with operator "${n[0]}"`));case`==`:case`!=`:n.length!==3&&s.push(new N(r,n,`filter array for operator "${n[0]}" must have 3 elements`));case`in`:case`!in`:n.length>=2&&(o=q(n[1]),o!==`string`&&s.push(new N(`${r}[1]`,n[1],`string expected, ${o} found`)));for(let c=2;c{t in r&&n.push(new N(a,r[t],`"${t}" is prohibited for ref layers`))});let t;o.layers.forEach(n=>{Ds(n.id)===l&&(t=n)}),t?t.ref?n.push(new N(a,r.ref,`ref cannot reference another ref layer`)):c=Ds(t.type):n.push(new N(a,r.ref,`ref layer "${l}" not found`))}else if(c!==`background`)if(!r.source)n.push(new N(a,r,`missing required property "source"`));else{let t=o.sources&&o.sources[r.source],s=t&&Ds(t.type);t?s===`vector`&&c===`raster`?n.push(new N(a,r.source,`layer "${r.id}" requires a raster source`)):s!==`raster-dem`&&c===`hillshade`||s!==`raster-dem`&&c===`color-relief`?n.push(new N(a,r.source,`layer "${r.id}" requires a raster-dem source`)):s===`raster`&&c!==`raster`?n.push(new N(a,r.source,`layer "${r.id}" requires a vector source`)):s===`vector`&&!r[`source-layer`]?n.push(new N(a,r,`layer "${r.id}" must specify a "source-layer"`)):s===`raster-dem`&&c!==`hillshade`&&c!==`color-relief`?n.push(new N(a,r.source,`raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.`)):c===`line`&&r.paint&&r.paint[`line-gradient`]&&(s!==`geojson`||!t.lineMetrics)&&n.push(new N(a,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):n.push(new N(a,r.source,`source "${r.source}" not found`))}return c===`raster`&&r.paint?.resampling&&r.paint?.[`raster-resampling`]&&n.push(new N(a,r.paint,`layer "${r.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),n=n.concat(ks({key:a,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*"(){return[]},type(){return t.validateSpec({key:`${a}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:`type`})},filter:zs,layout(t){return ks({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*"(t){return Us(ko({layerType:c},t))}}})},paint(t){return ks({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*"(t){return Hs(ko({layerType:c},t))}}})}}})),n}function Gs(t){let n=t.value,r=t.key,a=q(n);return a===`string`?[]:[new N(r,n,`string expected, ${a} found`)]}function Ks(t){let n=t.sourceName??``,r=t.value,a=t.styleSpec,o=a.source_raster_dem,s=t.style,c=[],l=q(r);if(r===void 0)return c;if(l!==`object`)return c.push(new N(`source_raster_dem`,r,`object expected, ${l} found`)),c;let u=Ds(r.encoding)===`custom`,d=[`redFactor`,`greenFactor`,`blueFactor`,`baseShift`],f=t.value.encoding?`"${t.value.encoding}"`:`Default`;for(let l in r)!u&&d.includes(l)?c.push(new N(l,r[l],`In "${n}": "${l}" is only valid when "encoding" is set to "custom". ${f} encoding found`)):o[l]?c=c.concat(t.validateSpec({key:l,value:r[l],valueSpec:o[l],validateSpec:t.validateSpec,style:s,styleSpec:a})):c.push(new N(l,r[l],`unknown property "${l}"`));return c}const qs={promoteId:Ys};function Js(t){let n=t.value,r=t.key,a=t.styleSpec,o=t.style,s=t.validateSpec;if(!n.type)return[new N(r,n,`"type" is required`)];let c=Ds(n.type),l;switch(c){case`vector`:case`raster`:return l=ks({key:r,value:n,valueSpec:a[`source_${c.replace(`-`,`_`)}`],style:t.style,styleSpec:a,objectElementValidators:qs,validateSpec:s}),l;case`raster-dem`:return l=Ks({sourceName:r,value:n,style:t.style,styleSpec:a,validateSpec:s}),l;case`geojson`:if(l=ks({key:r,value:n,valueSpec:a.source_geojson,style:o,styleSpec:a,validateSpec:s,objectElementValidators:qs}),n.cluster)for(let t in n.clusterProperties){let[a,o]=n.clusterProperties[t],c=typeof a==`string`?[a,[`accumulated`],[`get`,t]]:a;l.push(...Ns({key:`${r}.${t}.map`,value:o,validateSpec:s,expressionContext:`cluster-map`})),l.push(...Ns({key:`${r}.${t}.reduce`,value:c,validateSpec:s,expressionContext:`cluster-reduce`}))}return l;case`video`:return ks({key:r,value:n,valueSpec:a.source_video,style:o,validateSpec:s,styleSpec:a});case`image`:return ks({key:r,value:n,valueSpec:a.source_image,style:o,validateSpec:s,styleSpec:a});case`canvas`:return[new N(r,null,`Please use runtime APIs to add canvas sources, rather than including them in stylesheets.`,`source.canvas`)];default:return Is({key:`${r}.type`,value:n.type,valueSpec:{values:[`vector`,`raster`,`raster-dem`,`geojson`,`video`,`image`]},style:o,validateSpec:s,styleSpec:a})}}function Ys({key:t,value:n}){if(q(n)===`string`)return Gs({key:t,value:n});{let r=[];for(let a in n)r.push(...Gs({key:`${t}.${a}`,value:n[a]}));return r}}function Xs(t){let n=t.value,r=t.styleSpec,a=r.light,o=t.style,s=[],c=q(n);if(n===void 0)return s;if(c!==`object`)return s=s.concat([new N(`light`,n,`object expected, ${c} found`)]),s;for(let c in n){let l=c.match(/^(.*)-transition$/);s=l&&a[l[1]]&&a[l[1]].transition?s.concat(t.validateSpec({key:c,value:n[c],valueSpec:r.transition,validateSpec:t.validateSpec,style:o,styleSpec:r})):a[c]?s.concat(t.validateSpec({key:c,value:n[c],valueSpec:a[c],validateSpec:t.validateSpec,style:o,styleSpec:r})):s.concat([new N(c,n[c],`unknown property "${c}"`)])}return s}function Zs(t){let n=t.value,r=t.styleSpec,a=r.sky,o=t.style,s=q(n);if(n===void 0)return[];if(s!==`object`)return[new N(`sky`,n,`object expected, ${s} found`)];let c=[];for(let s in n)c=a[s]?c.concat(t.validateSpec({key:s,value:n[s],valueSpec:a[s],style:o,styleSpec:r})):c.concat([new N(s,n[s],`unknown property "${s}"`)]);return c}function Qs(t){let n=t.value,r=t.styleSpec,a=r.terrain,o=t.style,s=[],c=q(n);if(n===void 0)return s;if(c!==`object`)return s=s.concat([new N(`terrain`,n,`object expected, ${c} found`)]),s;for(let c in n)s=a[c]?s.concat(t.validateSpec({key:c,value:n[c],valueSpec:a[c],validateSpec:t.validateSpec,style:o,styleSpec:r})):s.concat([new N(c,n[c],`unknown property "${c}"`)]);return s}function $s(t){return Gs(t).length===0?[]:Ns(t)}function ec(t){return Gs(t).length===0?[]:Ns(t)}function tc(t){let n=t.key,r=t.value;if(q(r)===`array`){if(r.length<1||r.length>4)return[new N(n,r,`padding requires 1 to 4 values; ${r.length} values found`)];let a={type:`number`},o=[];for(let s=0;st.line-n.line)}function yc(t){return function(...n){return vc(t.apply(this,n))}}const bc={type:`enum`,"property-type":`data-constant`,expression:{interpolated:!1,parameters:[`global-state`]},values:{visible:{},none:{}},transition:!1,default:`visible`};var xc=class{constructor(t,n,r){this._rootKey=n,this._globalState=r,this.setValue(t)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(t){if(t==null||t===`visible`||t===`none`){this._literalValue=t===`none`?`none`:`visible`,this._compiledValue=void 0,this._globalStateRefs=/* @__PURE__ */ new Set;return}let n=Go(t,this._rootKey,bc,this._globalState);if(n.result===`error`)throw this._literalValue=`visible`,this._compiledValue=void 0,Error(n.value.map(t=>`${t.key}: ${t.message}`).join(`, `));this._literalValue=void 0,this._compiledValue=n.value,this._globalStateRefs=$o(n.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function Sc(t,n,r){return new xc(t,n,r)}const Cc=gc,wc=new Set(Object.keys(P).filter(t=>t.startsWith(`source_`)).map(t=>t.slice(7).replaceAll(`_`,`-`)));function Tc(t){return Object.entries(t.sources??{}).filter(([,t])=>!wc.has(t.type)).map(([t])=>`sources.${t}`)}function Ec(t,n){let r=Tc(n);return Dc(t,Cc(n).filter(({message:t})=>!r.some(n=>t.startsWith(`${n}:`)||t.startsWith(`${n}.`))))}function Dc(t,n){let r=!1;for(let a of n){if(a.severity===`warning`){Ft(a.message);continue}t.fire(new Fn(Error(a.message))),r=!0}return r}function Oc(t,n,r,a){return a?.validate!==!1&&Dc(t,n({styleSpec:P,...r}))}var kc=class e{constructor(t,n,r){let a=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let o=new Int32Array(this.arrayBuffer);t=o[0],n=o[1],r=o[2],this.d=n+2*r;for(let t=0;t=d[u+0]&&a>=d[u+1])?(c[f]=!0,s.push(o[f])):c[f]=!1}}}_forEachCell(t,n,r,a,o,s,c,l){let u=this._convertToCellCoord(t),d=this._convertToCellCoord(n),f=this._convertToCellCoord(r),p=this._convertToCellCoord(a);for(let m=u;m<=f;m++)for(let u=d;u<=p;u++){let d=this.d*u+m;if(!(l&&!l(this._convertFromCellCoord(m),this._convertFromCellCoord(u),this._convertFromCellCoord(m+1),this._convertFromCellCoord(u+1)))&&o.call(this,t,n,r,a,d,s,c,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,n=3+this.cells.length+1+1,r=0;for(let t of this.cells)r+=t.length;let a=new Int32Array(n+r+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;let o=n;for(let n=0;nr?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=n):this.lastFloorZoom{try{return RegExp(`\\p{sc=${t}}`,`u`).source}catch{return null}}).filter(t=>t);return new RegExp(n.join(`|`),`u`)}const qc=Kc([`Arab`,`Dupl`,`Mong`,`Ougr`,`Syrc`]);function Jc(t){return!qc.test(String.fromCodePoint(t))}function Yc(t){return!(Bc(t)||Vc(t))}function Xc(t){return/\p{sc=Arab}/u.test(String.fromCodePoint(t))}const Zc=Kc(`Adlm.Arab.Armi.Avst.Chrs.Cprt.Egyp.Elym.Gara.Hatr.Hebr.Hung.Khar.Lydi.Mand.Mani.Mend.Merc.Mero.Narb.Nbat.Nkoo.Orkh.Palm.Phli.Phlp.Phnx.Prti.Rohg.Samr.Sarb.Sogo.Syrc.Thaa.Todr.Yezi`.split(`.`));function Qc(t){return Zc.test(String.fromCodePoint(t))}function $c(t,n){return!n&&Qc(t)?!1:!Hc(t)}function el(t){for(let n of t)if(Qc(n.codePointAt(0)))return!0;return!1}function tl(t,n){for(let r of t)if(!$c(r.codePointAt(0),n))return!1;return!0}const nl=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus=`unavailable`,this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(nl.isParsed())throw Error(`RTL text plugin already registered.`);this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(t,n){if(this.isParsed())return this.getState();if(t.pluginStatus!==`loading`)return this.setState(t),t;let r=t.pluginURL,a=new Promise(t=>{this.loadScriptResolve=t}),o=new Promise(t=>setTimeout(()=>t(),this.TIMEOUT));if(await n(r),await Promise.race([a,o]),this.isParsed()){let t={pluginStatus:`loaded`,pluginURL:r};return this.setState(t),t}throw this.setState({pluginStatus:`error`,pluginURL:``}),Error(`RTL Text Plugin failed to import scripts from ${r}`)}};var U=class{constructor(t,n){this.isSupportedScript=rl,this.zoom=t,n?(this.now=n.now||0,this.fadeDuration=n.fadeDuration||0,this.zoomHistory=n.zoomHistory||new Lc,this.transition=n.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Lc,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,n=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:n+(1-n)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*n}}};function rl(t){return tl(t,nl.getRTLTextPluginStatus()===`loaded`)}const il=`-transition`;var al=class{constructor(t,n,r,a){this.property=t,this.value=n,this.expression=Zo(n===void 0?t.specification.default:n,r,t.specification,a)}isDataDriven(){return this.expression.kind===`source`||this.expression.kind===`composite`}getGlobalStateRefs(){return this.expression.globalStateRefs||/* @__PURE__ */ new Set}possiblyEvaluate(t,n,r){return this.property.possiblyEvaluate(this,t,n,r)}},ol=class{constructor(t,n,r){this.property=t,this.value=new al(t,void 0,n,r)}transitioned(t,n){return new cl(this.property,this.value,n,xt({},t.transition,this.transition),t.now)}untransitioned(){return new cl(this.property,this.value,null,{},0)}},sl=class{constructor(t,n,r){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=r,this._rootKey=n}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasProperty(t){return t in this._properties.defaultTransitionablePropertyValues}getValue(t){return Nt(this._values[t].value.value)}setValue(t,n){Object.hasOwn(this._values,t)||(this._values[t]=new ol(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new al(this._values[t].property,n===null?void 0:Nt(n),this._propertyRootKey(t),this._globalState)}getTransition(t){return Nt(this._values[t].transition)}setTransition(t,n){Object.hasOwn(this._values,t)||(this._values[t]=new ol(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].transition=Nt(n)||void 0}serialize(){let t={};for(let n of Object.keys(this._values)){let r=this.getValue(n);r!==void 0&&(t[n]=r);let a=this.getTransition(n);a!==void 0&&(t[`${n}${il}`]=a)}return t}transitioned(t,n){let r=new ll(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].transitioned(t,n._values[a]);return r}untransitioned(){let t=new ll(this._properties);for(let n of Object.keys(this._values))t._values[n]=this._values[n].untransitioned();return t}},cl=class{constructor(t,n,r,a,o){this.property=t,this.value=n,this.begin=o+a.delay||0,this.end=this.begin+a.duration||0,t.specification.transition&&(a.delay||a.duration)&&(this.prior=r)}possiblyEvaluate(t,n,r){let a=t.now||0,o=this.value.possiblyEvaluate(t,n,r),s=this.prior;if(!s)return o;if(a>this.end||this.value.isDataDriven())return this.prior=null,o;if(aa.zoomHistory.lastIntegerZoom?{from:t,to:n}:{from:r,to:n}}interpolate(t){return t}},ml=class{constructor(t,n){this.specification=t,this.name=n}possiblyEvaluate(t,n,r,a){if(t.value!==void 0)if(t.expression.kind===`constant`){let o=t.expression.evaluate(n,null,{},r,a);return this._calculate(o,o,o,n)}else return this._calculate(t.expression.evaluate(new U(Math.floor(n.zoom-1),n)),t.expression.evaluate(new U(Math.floor(n.zoom),n)),t.expression.evaluate(new U(Math.floor(n.zoom+1),n)),n)}_calculate(t,n,r,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:t,to:n}:{from:r,to:n}}interpolate(t){return t}},hl=class{constructor(t,n){this.specification=t,this.name=n}possiblyEvaluate(t,n,r,a){return!!t.expression.evaluate(n,null,{},r,a)}interpolate(){return!1}},gl=class{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let n in t){let r=t[n];r.specification.overridable&&this.overridableProperties.push(n);let a=this.defaultPropertyValues[n]=new al(r,void 0,r.name,void 0),o=this.defaultTransitionablePropertyValues[n]=new ol(r,r.name,void 0);this.defaultTransitioningPropertyValues[n]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[n]=a.possiblyEvaluate({})}}};J(`DataDrivenProperty`,G),J(`DataConstantProperty`,W),J(`CrossFadedDataDrivenProperty`,pl),J(`CrossFadedProperty`,ml),J(`ColorRampProperty`,hl);const _l=` is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?`,vl=` is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?`;var yl=class extends In{constructor(t,n,r){if(super(),this.id=t.id,this.type=t.type,this._globalState=r,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>/* @__PURE__ */ new Set},this._visibilityExpression=Sc(this.visibility,`layers[${this.id}].layout.visibility`,r),t.type!==`custom`&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!==`background`&&(this.source=t.source,this.sourceLayer=t[`source-layer`],this.filter=t.filter,this._featureFilter=ps(t.filter,`layers[${this.id}].filter`,r)),n.layout&&(this._unevaluatedLayout=new ul(n.layout,`layers[${this.id}].layout`,r)),n.paint)){this._transitionablePaint=new sl(n.paint,`layers[${this.id}].paint`,r);for(let n in t.paint)this.setPaintProperty(n,t.paint[n],{validate:!1});for(let n in t.layout)this.setLayoutProperty(n,t.layout[n],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new fl(n.paint)}}setFilter(t){this.filter=t,this._featureFilter=ps(t,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){if(t===`visibility`)return this.visibility;if(this._transitionablePaint?.hasProperty(t))throw Error(t+_l);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${t}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){let t=/* @__PURE__ */ new Set;for(let n of this._visibilityExpression.getGlobalStateRefs())t.add(n);if(this._unevaluatedLayout)for(let n in this._unevaluatedLayout._values){let r=this._unevaluatedLayout._values[n];for(let n of r.getGlobalStateRefs())t.add(n)}for(let n of this._featureFilter.getGlobalStateRefs())t.add(n);return t}getPaintAffectingGlobalStateRefs(){let t=new globalThis.Map;if(this._transitionablePaint)for(let n in this._transitionablePaint._values){let r=this._transitionablePaint._values[n].value;for(let a of r.getGlobalStateRefs()){let o=t.get(a)??[];o.push({name:n,value:r.value}),t.set(a,o)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,n,r={}){if(t===`visibility`){this.visibility=n,this._visibilityExpression.setValue(n),this.recalculateVisibility();return}if(this._transitionablePaint?.hasProperty(t)){this.fire(new Fn(Error(t+_l)));return}n!=null&&this._validate(Cc.layoutProperty,`layers.${this.id}.layout.${t}`,t,n,r)||this._unevaluatedLayout.setValue(t,n)}getPaintProperty(t){if(t.endsWith(`-transition`)){let n=t.slice(0,-11);if(n===`visibility`||this._unevaluatedLayout?.hasProperty(n))throw Error(t+vl);return this._transitionablePaint.getTransition(n)}else{if(t===`visibility`||this._unevaluatedLayout?.hasProperty(t))throw Error(t+vl);return this._transitionablePaint.getValue(t)}}setPaintProperty(t,n,r={}){if(t===`visibility`||this._unevaluatedLayout?.hasProperty(t))return this.fire(new Fn(Error(t+vl))),!1;if(n!=null&&this._validate(Cc.paintProperty,`layers.${this.id}.paint.${t}`,t,n,r))return!1;if(t.endsWith(`-transition`))return this._transitionablePaint.setTransition(t.slice(0,-11),n||void 0),!1;{let r=this._transitionablePaint._values[t],a=r.property.specification[`property-type`]===`cross-faded-data-driven`,o=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,n),this._handleSpecialPaintPropertyUpdate(t);let c=this._transitionablePaint._values[t].value;return c.isDataDriven()||o||a||this._handleOverridablePaintPropertyUpdate(t,s,c)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,n,r){return!1}isHidden(t=this.minzoom,n=!1){return this.minzoom&&t<(n?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&t>=this.maxzoom?!0:this._evaluatedVisibility===`none`}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(t,n){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,n)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,n)}serialize(){let t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(t.layout||={},t.layout.visibility=this.visibility),jt(t,(t,n)=>t!==void 0&&!(n===`layout`&&!Object.keys(t).length)&&!(n===`paint`&&!Object.keys(t).length))}_validate(t,n,r,a,o={}){return Oc(this,t,{key:n,layerType:this.type,objectKey:r,value:a},o)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let n=this.paint.get(t);if(!(!(n instanceof dl)||!Eo(n.property.specification))&&(n.value.kind===`source`||n.value.kind===`composite`)&&n.value.isStateDependent)return!0}return!1}};let bl;const xl=()=>bl||=new gl({"raster-opacity":new W(P.paint_raster[`raster-opacity`],`raster-opacity`),"raster-hue-rotate":new W(P.paint_raster[`raster-hue-rotate`],`raster-hue-rotate`),"raster-brightness-min":new W(P.paint_raster[`raster-brightness-min`],`raster-brightness-min`),"raster-brightness-max":new W(P.paint_raster[`raster-brightness-max`],`raster-brightness-max`),"raster-saturation":new W(P.paint_raster[`raster-saturation`],`raster-saturation`),"raster-contrast":new W(P.paint_raster[`raster-contrast`],`raster-contrast`),resampling:new W(P.paint_raster.resampling,`resampling`),"raster-resampling":new W(P.paint_raster[`raster-resampling`],`raster-resampling`),"raster-fade-duration":new W(P.paint_raster[`raster-fade-duration`],`raster-fade-duration`)});var Sl={get paint(){return xl()}};const Cl=t=>t.type===`raster`;var wl=class extends yl{constructor(t,n){super(t,Sl,n)}};const Tl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var El=class{constructor(t,n){this._structArray=t,this._pos1=n*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},K=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,n){return t._trim(),n&&(t.isTransferred=!0,n.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let n=Object.create(this.prototype);return n.arrayBuffer=t.arrayBuffer,n.length=t.length,n.capacity=t.arrayBuffer.byteLength/n.bytesPerElement,n._refreshViews(),n}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(this.capacity*5),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let n=this.uint8;this._refreshViews(),n&&this.uint8.set(n)}}_refreshViews(){throw Error(`_refreshViews() must be implemented by each concrete StructArray layout`)}freeBufferAfterUpload(){this.arrayBuffer=/* @__PURE__ */ new ArrayBuffer(0),this._refreshViews()}};function Dl(t,n=1){let r=0,a=0;return{members:t.map(t=>{let o=Ol(t.type),s=r=ju(r,Math.max(n,o)),c=t.components||1;return a=Math.max(a,o),r+=o*c,{name:t.name,type:t.type,components:c,offset:s}}),size:ju(r,Math.max(a,n)),alignment:n}}function Ol(t){return Tl[t].BYTES_PER_ELEMENT}function ju(t,n){return Math.ceil(t/n)*n}var kl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,n){let r=this.length;return this.resize(r+1),this.emplace(r,t,n)}emplace(t,n,r){let a=t*2;return this.int16[a+0]=n,this.int16[a+1]=r,t}};kl.prototype.bytesPerElement=4,J(`StructArrayLayout2i4`,kl);var Al=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,n,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,n,r)}emplace(t,n,r,a){let o=t*3;return this.int16[o+0]=n,this.int16[o+1]=r,this.int16[o+2]=a,t}};Al.prototype.bytesPerElement=6,J(`StructArrayLayout3i6`,Al);var jl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,n,r,a){let o=this.length;return this.resize(o+1),this.emplace(o,t,n,r,a)}emplace(t,n,r,a,o){let s=t*4;return this.int16[s+0]=n,this.int16[s+1]=r,this.int16[s+2]=a,this.int16[s+3]=o,t}};jl.prototype.bytesPerElement=8,J(`StructArrayLayout4i8`,jl);var Ml=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,t,n,r,a,o,s)}emplace(t,n,r,a,o,s,c){let l=t*6;return this.int16[l+0]=n,this.int16[l+1]=r,this.int16[l+2]=a,this.int16[l+3]=o,this.int16[l+4]=s,this.int16[l+5]=c,t}};Ml.prototype.bytesPerElement=12,J(`StructArrayLayout2i4i12`,Ml);var Nl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,t,n,r,a,o,s)}emplace(t,n,r,a,o,s,c){let l=t*4,u=t*8;return this.int16[l+0]=n,this.int16[l+1]=r,this.uint8[u+4]=a,this.uint8[u+5]=o,this.uint8[u+6]=s,this.uint8[u+7]=c,t}};Nl.prototype.bytesPerElement=8,J(`StructArrayLayout2i4ub8`,Nl);var Pl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,n){let r=this.length;return this.resize(r+1),this.emplace(r,t,n)}emplace(t,n,r){let a=t*2;return this.float32[a+0]=n,this.float32[a+1]=r,t}};Pl.prototype.bytesPerElement=8,J(`StructArrayLayout2f8`,Pl);var Fl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s,c,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,n,r,a,o,s,c,l,u,d)}emplace(t,n,r,a,o,s,c,l,u,d,f){let p=t*10;return this.uint16[p+0]=n,this.uint16[p+1]=r,this.uint16[p+2]=a,this.uint16[p+3]=o,this.uint16[p+4]=s,this.uint16[p+5]=c,this.uint16[p+6]=l,this.uint16[p+7]=u,this.uint16[p+8]=d,this.uint16[p+9]=f,t}};Fl.prototype.bytesPerElement=20,J(`StructArrayLayout10ui20`,Fl);var Il=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s,c,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,n,r,a,o,s,c,l)}emplace(t,n,r,a,o,s,c,l,u){let d=t*8;return this.uint16[d+0]=n,this.uint16[d+1]=r,this.uint16[d+2]=a,this.uint16[d+3]=o,this.uint16[d+4]=s,this.uint16[d+5]=c,this.uint16[d+6]=l,this.uint16[d+7]=u,t}};Il.prototype.bytesPerElement=16,J(`StructArrayLayout8ui16`,Il);var Ll=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s,c,l,u,d,f,p){let m=this.length;return this.resize(m+1),this.emplace(m,t,n,r,a,o,s,c,l,u,d,f,p)}emplace(t,n,r,a,o,s,c,l,u,d,f,p,m){let h=t*12;return this.int16[h+0]=n,this.int16[h+1]=r,this.int16[h+2]=a,this.int16[h+3]=o,this.uint16[h+4]=s,this.uint16[h+5]=c,this.uint16[h+6]=l,this.uint16[h+7]=u,this.int16[h+8]=d,this.int16[h+9]=f,this.int16[h+10]=p,this.int16[h+11]=m,t}};Ll.prototype.bytesPerElement=24,J(`StructArrayLayout4i4ui4i24`,Ll);var Rl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,n,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,n,r)}emplace(t,n,r,a){let o=t*3;return this.float32[o+0]=n,this.float32[o+1]=r,this.float32[o+2]=a,t}};Rl.prototype.bytesPerElement=12,J(`StructArrayLayout3f12`,Rl);var zl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let n=this.length;return this.resize(n+1),this.emplace(n,t)}emplace(t,n){let r=t*1;return this.uint32[r+0]=n,t}};zl.prototype.bytesPerElement=4,J(`StructArrayLayout1ul4`,zl);var Bl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s,c,l,u){let d=this.length;return this.resize(d+1),this.emplace(d,t,n,r,a,o,s,c,l,u)}emplace(t,n,r,a,o,s,c,l,u,d){let f=t*10,p=t*5;return this.int16[f+0]=n,this.int16[f+1]=r,this.int16[f+2]=a,this.int16[f+3]=o,this.int16[f+4]=s,this.int16[f+5]=c,this.uint32[p+3]=l,this.uint16[f+8]=u,this.uint16[f+9]=d,t}};Bl.prototype.bytesPerElement=20,J(`StructArrayLayout6i1ul2ui20`,Bl);var Vl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,t,n,r,a,o,s)}emplace(t,n,r,a,o,s,c){let l=t*6;return this.int16[l+0]=n,this.int16[l+1]=r,this.int16[l+2]=a,this.int16[l+3]=o,this.int16[l+4]=s,this.int16[l+5]=c,t}};Vl.prototype.bytesPerElement=12,J(`StructArrayLayout2i2i2i12`,Vl);var Hl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o){let s=this.length;return this.resize(s+1),this.emplace(s,t,n,r,a,o)}emplace(t,n,r,a,o,s){let c=t*4,l=t*8;return this.float32[c+0]=n,this.float32[c+1]=r,this.float32[c+2]=a,this.int16[l+6]=o,this.int16[l+7]=s,t}};Hl.prototype.bytesPerElement=16,J(`StructArrayLayout2f1f2i16`,Hl);var Ul=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,t,n,r,a,o,s)}emplace(t,n,r,a,o,s,c){let l=t*16,u=t*4,d=t*8;return this.uint8[l+0]=n,this.uint8[l+1]=r,this.float32[u+1]=a,this.float32[u+2]=o,this.int16[d+6]=s,this.int16[d+7]=c,t}};Ul.prototype.bytesPerElement=16,J(`StructArrayLayout2ub2f2i16`,Ul);var Wl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,n,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,n,r)}emplace(t,n,r,a){let o=t*3;return this.uint16[o+0]=n,this.uint16[o+1]=r,this.uint16[o+2]=a,t}};Wl.prototype.bytesPerElement=6,J(`StructArrayLayout3ui6`,Wl);var Gl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=this.length;return this.resize(y+1),this.emplace(y,t,n,r,a,o,s,c,l,u,d,f,p,m,h,g,_,v)}emplace(t,n,r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y){let b=t*24,x=t*12,S=t*48;return this.int16[b+0]=n,this.int16[b+1]=r,this.uint16[b+2]=a,this.uint16[b+3]=o,this.uint32[x+2]=s,this.uint32[x+3]=c,this.uint32[x+4]=l,this.uint16[b+10]=u,this.uint16[b+11]=d,this.uint16[b+12]=f,this.float32[x+7]=p,this.float32[x+8]=m,this.uint8[S+36]=h,this.uint8[S+37]=g,this.uint8[S+38]=_,this.uint32[x+10]=v,this.int16[b+22]=y,t}};Gl.prototype.bytesPerElement=48,J(`StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48`,Gl);var Kl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,n,r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k){let A=this.length;return this.resize(A+1),this.emplace(A,t,n,r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k)}emplace(t,n,r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A){let j=t*32,M=t*16;return this.int16[j+0]=n,this.int16[j+1]=r,this.int16[j+2]=a,this.int16[j+3]=o,this.int16[j+4]=s,this.int16[j+5]=c,this.int16[j+6]=l,this.int16[j+7]=u,this.uint16[j+8]=d,this.uint16[j+9]=f,this.uint16[j+10]=p,this.uint16[j+11]=m,this.uint16[j+12]=h,this.uint16[j+13]=g,this.uint16[j+14]=_,this.uint16[j+15]=v,this.uint16[j+16]=y,this.uint16[j+17]=b,this.uint16[j+18]=x,this.uint16[j+19]=S,this.uint16[j+20]=C,this.uint16[j+21]=w,this.uint16[j+22]=T,this.uint32[M+12]=E,this.float32[M+13]=D,this.float32[M+14]=O,this.uint16[j+30]=k,this.uint16[j+31]=A,t}};Kl.prototype.bytesPerElement=64,J(`StructArrayLayout8i15ui1ul2f2ui64`,Kl);var ql=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let n=this.length;return this.resize(n+1),this.emplace(n,t)}emplace(t,n){let r=t*1;return this.float32[r+0]=n,t}};ql.prototype.bytesPerElement=4,J(`StructArrayLayout1f4`,ql);var Jl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,n,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,n,r)}emplace(t,n,r,a){let o=t*6,s=t*3;return this.uint16[o+0]=n,this.float32[s+1]=r,this.float32[s+2]=a,t}};Jl.prototype.bytesPerElement=12,J(`StructArrayLayout1ui2f12`,Jl);var Yl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,n,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,n,r)}emplace(t,n,r,a){let o=t*2,s=t*4;return this.uint32[o+0]=n,this.uint16[s+2]=r,this.uint16[s+3]=a,t}};Yl.prototype.bytesPerElement=8,J(`StructArrayLayout1ul2ui8`,Yl);var Xl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,n){let r=this.length;return this.resize(r+1),this.emplace(r,t,n)}emplace(t,n,r){let a=t*2;return this.uint16[a+0]=n,this.uint16[a+1]=r,t}};Xl.prototype.bytesPerElement=4,J(`StructArrayLayout2ui4`,Xl);var Zl=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let n=this.length;return this.resize(n+1),this.emplace(n,t)}emplace(t,n){let r=t*1;return this.uint16[r+0]=n,t}};Zl.prototype.bytesPerElement=2,J(`StructArrayLayout1ui2`,Zl);var Ql=class extends K{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,n,r,a){let o=this.length;return this.resize(o+1),this.emplace(o,t,n,r,a)}emplace(t,n,r,a,o){let s=t*4;return this.float32[s+0]=n,this.float32[s+1]=r,this.float32[s+2]=a,this.float32[s+3]=o,t}};Ql.prototype.bytesPerElement=16,J(`StructArrayLayout4f16`,Ql);var $l=class extends El{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 d(this.anchorPointX,this.anchorPointY)}};$l.prototype.size=20;var eu=class extends Bl{get(t){return new $l(this,t)}};J(`CollisionBoxArray`,eu);var tu=class extends El{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}};tu.prototype.size=48;var nu=class extends Gl{get(t){return new tu(this,t)}};J(`PlacedSymbolArray`,nu);var ru=class extends El{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}};ru.prototype.size=64;var iu=class extends Kl{get(t){return new ru(this,t)}};J(`SymbolInstanceArray`,iu);var au=class extends ql{getoffsetX(t){return this.float32[t*1+0]}};J(`GlyphOffsetArray`,au);var ou=class extends Al{getx(t){return this.int16[t*3+0]}gety(t){return this.int16[t*3+1]}gettileUnitDistanceFromAnchor(t){return this.int16[t*3+2]}};J(`SymbolLineVertexArray`,ou);var su=class extends El{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]}};su.prototype.size=12;var cu=class extends Jl{get(t){return new su(this,t)}};J(`TextAnchorOffsetArray`,cu);var lu=class extends El{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]}};lu.prototype.size=8;var uu=class extends Yl{get(t){return new lu(this,t)}};J(`FeatureIndexArray`,uu);var du=class extends kl{},fu=class extends Al{},pu=class extends jl{},mu=class extends kl{},hu=class extends kl{},gu=class extends Ml{},_u=class extends Nl{},vu=class extends Pl{},yu=class extends Fl{},bu=class extends Il{},xu=class extends Ll{},Su=class extends Rl{},Cu=class extends zl{},wu=class extends Vl{},Tu=class extends Hl{},Eu=class extends Ul{},Du=class extends Wl{},Ou=class extends Wl{},ku=class extends Xl{},Au=class extends Zl{};const Mu=Dl([{name:`a_pos`,components:2,type:`Int16`}],4),Nu=Mu.members;Mu.size,Mu.alignment;var Pu=class e{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,n,r,a){let o=this.segments[this.segments.length-1];return t>e.MAX_VERTEX_ARRAY_LENGTH&&Ft(`Max vertices per segment is ${e.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${e.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!o||o.vertexLength+t>e.MAX_VERTEX_ARRAY_LENGTH||o.sortKey!==a?this.createNewSegment(n,r,a):o}createNewSegment(t,n,r){let a={vertexOffset:t.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0,vaos:{}};return r!==void 0&&(a.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(a),a}getOrCreateLatestSegment(t,n,r){return this.prepareSegment(0,t,n,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let t of this.segments)for(let n in t.vaos)t.vaos[n].destroy()}static simpleSegment(t,n,r,a){return new e([{vertexOffset:t,primitiveOffset:n,vertexLength:r,primitiveLength:a,vaos:{},sortKey:0}])}};Pu.MAX_VERTEX_ARRAY_LENGTH=2**16-1,J(`SegmentVector`,Pu);function Fu(t,n){return t=yt(Math.floor(t),0,255),n=yt(Math.floor(n),0,255),256*t+n}const Iu=Dl([{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`}]),Lu=Dl([{name:`a_dasharray_from`,components:4,type:`Uint16`},{name:`a_dasharray_to`,components:4,type:`Uint16`}]);var Ru=c(((t,n)=>{function r(t,n){for(var r=t.length&3,a=t.length-r,o=n,s,c=3432918353,l=461845907,u,d=0;d>>16)*c&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*l+(((u>>>16)*l&65535)<<16)&4294967295,o^=u,o=o<<13|o>>>19,s=(o&65535)*5+(((o>>>16)*5&65535)<<16)&4294967295,o=(s&65535)+27492+(((s>>>16)+58964&65535)<<16);switch(u=0,r){case 3:u^=(t.charCodeAt(d+2)&255)<<16;case 2:u^=(t.charCodeAt(d+1)&255)<<8;case 1:u^=t.charCodeAt(d)&255,u=(u&65535)*c+(((u>>>16)*c&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*l+(((u>>>16)*l&65535)<<16)&4294967295,o^=u}return o^=t.length,o^=o>>>16,o=(o&65535)*2246822507+(((o>>>16)*2246822507&65535)<<16)&4294967295,o^=o>>>13,o=(o&65535)*3266489909+(((o>>>16)*3266489909&65535)<<16)&4294967295,o^=o>>>16,o>>>0}n!==void 0&&(n.exports=r)})),zu=c(((t,n)=>{function r(t,n){for(var r=t.length,a=n^r,o=0,s;r>=4;)s=t.charCodeAt(o)&255|(t.charCodeAt(++o)&255)<<8|(t.charCodeAt(++o)&255)<<16|(t.charCodeAt(++o)&255)<<24,s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16),s^=s>>>24,s=(s&65535)*1540483477+(((s>>>16)*1540483477&65535)<<16),a=(a&65535)*1540483477+(((a>>>16)*1540483477&65535)<<16)^s,r-=4,++o;switch(r){case 3:a^=(t.charCodeAt(o+2)&255)<<16;case 2:a^=(t.charCodeAt(o+1)&255)<<8;case 1:a^=t.charCodeAt(o)&255,a=(a&65535)*1540483477+(((a>>>16)*1540483477&65535)<<16)}return a^=a>>>13,a=(a&65535)*1540483477+(((a>>>16)*1540483477&65535)<<16),a^=a>>>15,a>>>0}n.exports=r})),Bu=u(c(((t,n)=>{var r=Ru(),a=zu();n.exports=r,n.exports.murmur3=r,n.exports.murmur2=a}))(),1),Vu=class e{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,n,r,a){this.ids.push(Hu(t)),this.positions.push(n,r,a)}getPositions(t){if(!this.indexed)throw Error(`Trying to get index, but feature positions are not indexed`);let n=Hu(t),r=0,a=this.ids.length-1;for(;r>1;this.ids[t]>=n?a=t:r=t+1}let o=[];for(;this.ids[r]===n;){let t=this.positions[3*r],n=this.positions[3*r+1],a=this.positions[3*r+2];o.push({index:t,start:n,end:a}),r++}return o}static serialize(t,n){let r=new Float64Array(t.ids),a=new Uint32Array(t.positions);return Uu(r,a,0,r.length-1),n&&n.push(r.buffer,a.buffer),{ids:r,positions:a}}static deserialize(t){let n=new e;return n.ids=t.ids,n.positions=t.positions,n.indexed=!0,n}};function Hu(t){let n=+t;return!isNaN(n)&&n<=2**53-1?n:(0,Bu.default)(String(t))}function Uu(t,n,r,a){for(;r>1],s=r-1,c=a+1;for(;;){do s++;while(t[s]o);if(s>=c)break;$u(t,s,c),$u(n,3*s,3*c),$u(n,3*s+1,3*c+1),$u(n,3*s+2,3*c+2)}c-r`u_${t}`),this.type=r}setUniform(t,n,r){t.set(r.constantOr(this.value))}getBinding(t,n,r){return this.type===`color`?new Xu(t,n):new Ku(t,n)}},rd=class{constructor(t,n){this.uniformNames=n.map(t=>`u_${t}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,n){this.pixelRatioFrom=n.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=n.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,n){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,n.y,n.height,n.width]}setUniform(t,n,r,a){let o=null;a===`u_pattern_to`?o=this.patternTo:a===`u_pattern_from`?o=this.patternFrom:a===`u_dasharray_to`?o=this.dashTo:a===`u_dasharray_from`?o=this.dashFrom:a===`u_pixel_ratio_to`?o=this.pixelRatioTo:a===`u_pixel_ratio_from`&&(o=this.pixelRatioFrom),o!==null&&t.set(o)}getBinding(t,n,r){return r.startsWith(`u_pattern`)||r.startsWith(`u_dasharray_`)?new Yu(t,n):new Ku(t,n)}},id=class{constructor(t,n,r,a){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=n.map(t=>({name:`a_${t}`,type:`Float32`,components:r===`color`?2:1,offset:0})),this.paintVertexArray=new a}populatePaintArray(t,n,r){let a=this.paintVertexArray.length,o=this.expression.evaluate(new U(0,r),n,{},r.canonical,[],r.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(a,t,o)}updatePaintArray(t,n,r,a,o){let s=this.expression.evaluate(new U(0,o),r,a);this._setPaintValue(t,n,s)}_setPaintValue(t,n,r){if(this.type===`color`){let a=dd(r);for(let r=t;r`u_${t}_t`),this.type=r,this.useIntegerZoom=a,this.zoom=o,this.maxValue=0,this.paintVertexAttributes=n.map(t=>({name:`a_${t}`,type:`Float32`,components:r===`color`?4:2,offset:0})),this.paintVertexArray=new s}populatePaintArray(t,n,r){let a=this.expression.evaluate(new U(this.zoom,r),n,{},r.canonical,[],r.formattedSection),o=this.expression.evaluate(new U(this.zoom+1,r),n,{},r.canonical,[],r.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,a,o)}updatePaintArray(t,n,r,a,o){let s=this.expression.evaluate(new U(this.zoom,o),r,a),c=this.expression.evaluate(new U(this.zoom+1,o),r,a);this._setPaintValue(t,n,s,c)}_setPaintValue(t,n,r,a){if(this.type===`color`){let o=dd(r),s=dd(a);for(let r=t;r`#define HAS_UNIFORM_${t}`))}return t}getBinderAttributes(){let t=[];for(let n in this.binders){let r=this.binders[n];if(r instanceof id||r instanceof ad)for(let n of r.paintVertexAttributes)t.push(n.name);else if(r instanceof od){let n=r.getVertexAttributes();for(let r of n)t.push(r.name)}}return t}getBinderUniforms(){let t=[];for(let n in this.binders){let r=this.binders[n];if(r instanceof nd||r instanceof rd||r instanceof ad)for(let n of r.uniformNames)t.push(n)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,n){let r=[];for(let a in this.binders){let o=this.binders[a];if(o instanceof nd||o instanceof rd||o instanceof ad){for(let s of o.uniformNames)if(n[s]){let c=o.getBinding(t,n[s],s);r.push({name:s,property:a,binding:c})}}}return r}setUniforms(t,n,r,a){for(let{name:t,property:o,binding:s}of n)this.binders[o].setUniform(s,a,r.get(o),t)}updatePaintBuffers(t){this._buffers=[];for(let n in this.binders){let r=this.binders[n];if(t&&r instanceof od){let n=t.fromScale===2?r.zoomInPaintVertexBuffer:r.zoomOutPaintVertexBuffer;n&&this._buffers.push(n)}else (r instanceof id||r instanceof ad)&&r.paintVertexBuffer&&this._buffers.push(r.paintVertexBuffer)}}upload(t){for(let n in this.binders){let r=this.binders[n];(r instanceof id||r instanceof ad||r instanceof od)&&r.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let n=this.binders[t];(n instanceof id||n instanceof ad||n instanceof od)&&n.destroy()}}},ud=class{constructor(t,n,r=()=>!0){this.programConfigurations={};for(let a of t)this.programConfigurations[a.id]=new ld(a,n,r);this.needsUpload=!1,this._featureMap=new Vu,this._bufferOffset=0}populatePaintArrays(t,n,r,a){for(let r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,n,a);n.id!==void 0&&this._featureMap.add(n.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,n,r,a){for(let o of r)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(t,this._featureMap,n,o,a)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let n in this.programConfigurations)this.programConfigurations[n].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}};function fd(t,n){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`]}[t]||[t.replace(`${n}-`,``).replace(/-/g,`_`)]}function pd(t){return{"line-pattern":{source:yu,composite:yu},"fill-pattern":{source:yu,composite:yu},"fill-extrusion-pattern":{source:yu,composite:yu},"line-dasharray":{source:bu,composite:bu}}[t]}function md(t,n,r){let a={color:{source:Pl,composite:Ql},number:{source:ql,composite:Pl}};return pd(t)?.[r]||a[n][r]}J(`ConstantBinder`,nd),J(`CrossFadedConstantBinder`,rd),J(`SourceExpressionBinder`,id),J(`CrossFadedPatternBinder`,sd),J(`CrossFadedDasharrayBinder`,cd),J(`CompositeExpressionBinder`,ad),J(`ProgramConfiguration`,ld,{omit:[`_buffers`]}),J(`ProgramConfigurationSet`,ud);const hd=2**14-1,gd=-hd-1;function _d(t){let n=Ye/t.extent,r=t.loadGeometry();for(let t of r)for(let r of t){let t=Math.round(r.x*n),a=Math.round(r.y*n);r.x=yt(t,gd,hd),r.y=yt(a,gd,hd),(tr.x+1||ar.y+1)&&Ft(`Geometry exceeds allowed extent, reduce your vector tile buffer size`)}return r}function vd(t,n){return{type:t.type,id:t.id,properties:t.properties,geometry:n?_d(t):[]}}const yd=-32768;function xd(t,n,r,a,o){t.emplaceBack(yd+n*8+a,yd+r*8+o)}var bd=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new mu,this.indexArray=new Ou,this.segments=new Pu,this.programConfigurations=new ud(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(t,n,r){let a=this.layers[0],o=[],s=null,c=!1,l=a.type===`heatmap`;if(a.type===`circle`){let t=a;s=t.layout.get(`circle-sort-key`),c=!s.isConstant(),l||=t.paint.get(`circle-pitch-alignment`)===`map`}let u=l?n.subdivisionGranularity.circle:1;for(let{feature:n,id:a,index:l,sourceLayerIndex:u}of t){let t=this.layers[0]._featureFilter.needGeometry,d=vd(n,t);if(!this.layers[0]._featureFilter.filter(new U(this.zoom),d,r))continue;let f=c?s.evaluate(d,{},r):void 0,p={id:a,properties:n.properties,type:n.type,sourceLayerIndex:u,index:l,geometry:t?d.geometry:_d(n),patterns:{},sortKey:f};o.push(p)}c&&o.sort((t,n)=>t.sortKey-n.sortKey);for(let a of o){let{geometry:o,index:s,sourceLayerIndex:c}=a,l=t[s].feature;this.addFeature(a,o,s,r,u),n.featureIndex.insert(l,o,s,c,this.index)}}update(t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,n,this.stateDependentLayers,{imagePositions:r})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Nu),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,n,r,a,o=1){let s;switch(o){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${o}; valid values are 1, 3, 5, 7.`)}let c=s.length;for(let r of n)for(let n of r){let r=n.x,a=n.y;if(r<0||r>=8192||a<0||a>=8192)continue;let o=this.segments.prepareSegment(c*c,this.layoutVertexArray,this.indexArray,t.sortKey),l=o.vertexLength;for(let t=0;t=3){for(let n of a)if(Md(t,n))return!0}if(Ed(t,a,r))return!0}return!1}function Ed(t,n,r){if(t.length>1){if(Dd(t,n))return!0;for(let a of n)if(kd(a,t,r))return!0}for(let a of t)if(kd(a,n,r))return!0;return!1}function Dd(t,n){if(t.length===0||n.length===0)return!1;for(let r=0;r1?t.distSqr(r):t.distSqr(r.sub(n)._mult(o)._add(n))}function jd(t,n){let r=!1,a,o,s;for(let c of t){a=c;for(let t=0,c=a.length-1;tn.y!=s.y>n.y&&n.x<(s.x-o.x)*(n.y-o.y)/(s.y-o.y)+o.x&&(r=!r)}return r}function Md(t,n){let r=!1;for(let a=0,o=t.length-1;an.y!=c.y>n.y&&n.x<(c.x-s.x)*(n.y-s.y)/(c.y-s.y)+s.x&&(r=!r)}return r}function Nd(t,n,r,a,o){for(let s of t)if(n<=s.x&&r<=s.y&&a>=s.x&&o>=s.y)return!0;let s=[new d(n,r),new d(n,o),new d(a,o),new d(a,r)];if(t.length>2){for(let n of s)if(Md(t,n))return!0}for(let n=0;no.x&&n.x>o.x||t.yo.y&&n.y>o.y)return!1;let s=It(t,n,r[0]);return s!==It(t,n,r[1])||s!==It(t,n,r[2])||s!==It(t,n,r[3])}function Fd(t,n,r){let a=n.paint.get(t).value;return a.kind===`constant`?a.value:r.programConfigurations.get(n.id).getMaxValue(t)}function Id(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ld(t,n,r,a,o){if(!n[0]&&!n[1])return t;let s=d.convert(n)._mult(o);r===`viewport`&&s._rotate(-a);let c=[];for(let n of t)c.push(n.sub(s));return c}function Rd(t){let n=[];for(let r=0;rGd(t,n,r,a))}let qd;const Jd=()=>qd||=new gl({"circle-sort-key":new G(P.layout_circle[`circle-sort-key`],`circle-sort-key`)});let Yd;const Xd=()=>Yd||=new gl({"circle-radius":new G(P.paint_circle[`circle-radius`],`circle-radius`),"circle-color":new G(P.paint_circle[`circle-color`],`circle-color`),"circle-blur":new G(P.paint_circle[`circle-blur`],`circle-blur`),"circle-opacity":new G(P.paint_circle[`circle-opacity`],`circle-opacity`),"circle-translate":new W(P.paint_circle[`circle-translate`],`circle-translate`),"circle-translate-anchor":new W(P.paint_circle[`circle-translate-anchor`],`circle-translate-anchor`),"circle-pitch-scale":new W(P.paint_circle[`circle-pitch-scale`],`circle-pitch-scale`),"circle-pitch-alignment":new W(P.paint_circle[`circle-pitch-alignment`],`circle-pitch-alignment`),"circle-stroke-width":new G(P.paint_circle[`circle-stroke-width`],`circle-stroke-width`),"circle-stroke-color":new G(P.paint_circle[`circle-stroke-color`],`circle-stroke-color`),"circle-stroke-opacity":new G(P.paint_circle[`circle-stroke-opacity`],`circle-stroke-opacity`)});var Zd={get paint(){return Xd()},get layout(){return Jd()}};const ef=t=>t.type===`circle`;var Qd=class extends yl{constructor(t,n){super(t,Zd,n)}createBucket(t){return new bd(t)}queryRadius(t){let n=t;return Fd(`circle-radius`,this,n)+Fd(`circle-stroke-width`,this,n)+Id(this.paint.get(`circle-translate`))}queryIntersectsFeature({queryGeometry:t,feature:n,featureState:r,geometry:a,transform:o,pixelsToTileUnits:s,unwrappedTileID:c,getElevation:l}){let u=Ld(t,this.paint.get(`circle-translate`),this.paint.get(`circle-translate-anchor`),-o.bearingInRadians,s),d=this.paint.get(`circle-radius`).evaluate(n,r)+this.paint.get(`circle-stroke-width`).evaluate(n,r),f=this.paint.get(`circle-pitch-scale`),p=this.paint.get(`circle-pitch-alignment`),m,h;return p===`map`?(m=u,h=d*s):(m=Kd(u,o,c,l),h=d),Wd({queryGeometry:m,size:h,transform:o,unwrappedTileID:c,getElevation:l,pitchAlignment:p,pitchScale:f},a)}},$d=class extends bd{};J(`HeatmapBucket`,$d,{omit:[`layers`]});let tf;const nf=()=>tf||=new gl({"heatmap-radius":new G(P.paint_heatmap[`heatmap-radius`],`heatmap-radius`),"heatmap-weight":new G(P.paint_heatmap[`heatmap-weight`],`heatmap-weight`),"heatmap-intensity":new W(P.paint_heatmap[`heatmap-intensity`],`heatmap-intensity`),"heatmap-color":new hl(P.paint_heatmap[`heatmap-color`],`heatmap-color`),"heatmap-opacity":new W(P.paint_heatmap[`heatmap-opacity`],`heatmap-opacity`)});var rf={get paint(){return nf()}};function af(t,{width:n,height:r},a,o){if(!o)o=new Uint8Array(n*r*a);else if(o instanceof Uint8ClampedArray)o=new Uint8Array(o.buffer);else if(o.length!==n*r*a)throw RangeError(`mismatched image size. expected: ${o.length} but got: ${n*r*a}`);return t.width=n,t.height=r,t.data=o,t}function of(t,{width:n,height:r},a){if(n===t.width&&r===t.height)return;let o=af({},{width:n,height:r},a);sf(t,o,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,n),height:Math.min(t.height,r)},a),t.width=n,t.height=r,t.data=o.data}function sf(t,n,r,a,o,s){if(o.width===0||o.height===0)return n;if(o.width>t.width||o.height>t.height||r.x>t.width-o.width||r.y>t.height-o.height)throw RangeError(`out of range source coordinates for image copy`);if(o.width>n.width||o.height>n.height||a.x>n.width-o.width||a.y>n.height-o.height)throw RangeError(`out of range destination coordinates for image copy`);let c=t.data,l=n.data;if(c===l)throw Error(`srcData equals dstData, so image is already copied`);for(let u=0;u{n[t.evaluationKey]=c;let l=t.expression.evaluate(n);o.setPixel(a/4/r,s/4,l)};if(t.clips)for(let n=0,o=0;nt.type===`heatmap`;var pf=class extends yl{createBucket(t){return new $d(t)}constructor(t,n){super(t,rf,n),this.heatmapFbos=/* @__PURE__ */ new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t===`heatmap-color`&&this._updateColorRamp()}_updateColorRamp(){let t=this._transitionablePaint._values[`heatmap-color`].value.expression;this.colorRamp=df({expression:t,evaluationKey:`heatmapDensity`,image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(`big-fb`)&&this.heatmapFbos.delete(ff)}queryRadius(t){return Fd(`heatmap-radius`,this,t)}queryIntersectsFeature({queryGeometry:t,feature:n,featureState:r,geometry:a,transform:o,pixelsToTileUnits:s,unwrappedTileID:c,getElevation:l}){return Wd({queryGeometry:t,size:this.paint.get(`heatmap-radius`).evaluate(n,r)*s,transform:o,unwrappedTileID:c,getElevation:l},a)}hasOffscreenPass(){return this.paint.get(`heatmap-opacity`)!==0&&!this.isHidden()}};let hf;const gf=()=>hf||=new gl({"hillshade-illumination-direction":new W(P.paint_hillshade[`hillshade-illumination-direction`],`hillshade-illumination-direction`),"hillshade-illumination-altitude":new W(P.paint_hillshade[`hillshade-illumination-altitude`],`hillshade-illumination-altitude`),"hillshade-illumination-anchor":new W(P.paint_hillshade[`hillshade-illumination-anchor`],`hillshade-illumination-anchor`),"hillshade-exaggeration":new W(P.paint_hillshade[`hillshade-exaggeration`],`hillshade-exaggeration`),"hillshade-shadow-color":new W(P.paint_hillshade[`hillshade-shadow-color`],`hillshade-shadow-color`),"hillshade-highlight-color":new W(P.paint_hillshade[`hillshade-highlight-color`],`hillshade-highlight-color`),"hillshade-accent-color":new W(P.paint_hillshade[`hillshade-accent-color`],`hillshade-accent-color`),"hillshade-method":new W(P.paint_hillshade[`hillshade-method`],`hillshade-method`),resampling:new W(P.paint_hillshade.resampling,`resampling`)});var _f={get paint(){return gf()}};const yf=t=>t.type===`hillshade`;var vf=class extends yl{constructor(t,n){super(t,_f,n),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get(`hillshade-illumination-direction`).values,n=this.paint.get(`hillshade-illumination-altitude`).values,r=this.paint.get(`hillshade-highlight-color`).values,a=this.paint.get(`hillshade-shadow-color`).values,o=Math.max(t.length,n.length,r.length,a.length);t=t.concat(Array(o-t.length).fill(t.at(-1))),n=n.concat(Array(o-n.length).fill(n.at(-1))),r=r.concat(Array(o-r.length).fill(r.at(-1))),a=a.concat(Array(o-a.length).fill(a.at(-1)));let s=n.map(en);return{directionRadians:t.map(en),altitudeRadians:s,shadowColor:a,highlightColor:r}}hasOffscreenPass(){return this.paint.get(`hillshade-exaggeration`)!==0&&!this.isHidden()}};let bf;const xf=()=>bf||=new gl({"color-relief-opacity":new W(P[`paint_color-relief`][`color-relief-opacity`],`color-relief-opacity`),"color-relief-color":new hl(P[`paint_color-relief`][`color-relief-color`],`color-relief-color`),resampling:new W(P[`paint_color-relief`].resampling,`resampling`)});var Sf={get paint(){return xf()}};function wf(t){return`data`in t}var Cf=class{constructor(t,n,r,a){this.context=t,this.format=r,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(n,a)}update(t,n,r){let{width:a,height:o}=t,s=(this.size?.[0]!==a||this.size[1]!==o)&&!r,{context:c}=this,{gl:l}=c;this.useMipmap=!!n?.useMipmap,s&&this.size&&this.format===l.RGBA&&(l.deleteTexture(this.texture),this.texture=l.createTexture(),this._ownedHandle=this.texture),l.bindTexture(l.TEXTURE_2D,this.texture),c.pixelStoreUnpackFlipY.set(!1),c.pixelStoreUnpack.set(1);let u=this.format===l.RGBA&&n?.premultiply!==!1;if(s)if(this.size=[a,o],this.format===l.RGBA&&a>0&&o>0){let n=this.useMipmap?Math.floor(Math.log2(Math.max(a,o)))+1:1;if(l.texStorage2D(l.TEXTURE_2D,n,l.RGBA8,a,o),wf(t)){c.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:n}=t;u&&n&&(n=uf(n)),n&&l.texSubImage2D(l.TEXTURE_2D,0,0,0,a,o,l.RGBA,l.UNSIGNED_BYTE,n)}else c.pixelStoreUnpackPremultiplyAlpha.set(u),l.texSubImage2D(l.TEXTURE_2D,0,0,0,l.RGBA,l.UNSIGNED_BYTE,t)}else wf(t)?(c.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(t,u,a,o,l)):(c.pixelStoreUnpackPremultiplyAlpha.set(u),this._uploadDomImage(t,l));else{let{x:n,y:s}=r||{x:0,y:0};wf(t)?(c.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(t,u,n,s,a,o,l)):(c.pixelStoreUnpackPremultiplyAlpha.set(u),this._updateDomImage(t,n,s,l))}this.useMipmap&&l.generateMipmap(l.TEXTURE_2D),c.pixelStoreUnpackFlipY.setDefault(),c.pixelStoreUnpack.setDefault(),c.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(t,n){n.texImage2D(n.TEXTURE_2D,0,this.format,this.format,n.UNSIGNED_BYTE,t)}_uploadRawData(t,n,r,a,o){let{data:s}=t;n&&s&&(s=uf(s)),o.texImage2D(o.TEXTURE_2D,0,this.format,r,a,0,this.format,o.UNSIGNED_BYTE,s)}_updateDomImage(t,n,r,a){a.texSubImage2D(a.TEXTURE_2D,0,n,r,a.RGBA,a.UNSIGNED_BYTE,t)}_updateRawData(t,n,r,a,o,s,c){let{data:l}=t;n&&l&&(l=uf(l)),c.texSubImage2D(c.TEXTURE_2D,0,r,a,o,s,c.RGBA,c.UNSIGNED_BYTE,l)}bind(t,n,r){let{context:a}=this,{gl:o}=a;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),o.bindTexture(o.TEXTURE_2D,this.texture),r===o.LINEAR_MIPMAP_NEAREST&&!this.useMipmap&&(r=o.LINEAR),t!==this.filter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,r||t),this.filter=t),n!==this.wrap&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,n),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrap=n)}destroy(){let{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},Tf=class e{static{this.byteViewCache=/* @__PURE__ */ new WeakMap}constructor(t,n,r,a=1,o=1,s=1,c=0){if(this.uid=t,n.height!==n.width)throw RangeError(`DEM tiles must be square`);if(r&&![`mapbox`,`terrarium`,`custom`].includes(r)){Ft(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=n.height;let l=this.dim=n.height-2;switch(this.data=new Uint32Array(n.data.buffer),e.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=o,this.blueFactor=s,this.baseShift=c;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4;break}for(let t=0;tthis.max&&(this.max=a),a=this.dim||a<-1||a>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${n}, dim: ${this.dim}`);let o=this._getByteView(),s=((a+1)*this.stride+r+1)*4,c=this.stride*4,l=t-r,u=n-a,d=this._unpackAtIndex(o,s),f=this._unpackAtIndex(o,s+4),p=this._unpackAtIndex(o,s+c),m=this._unpackAtIndex(o,s+c+4);return d*(1-l)*(1-u)+f*l*(1-u)+p*(1-l)*u+m*l*u}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,n){if(t<-1||t>=this.dim+1||n<-1||n>=this.dim+1)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${n}, dim: ${this.dim}`);return(n+1)*this.stride+(t+1)}unpack(t,n,r){return t*this.redFactor+n*this.greenFactor+r*this.blueFactor-this.baseShift}pack(t){return Ef(t,this.getUnpackVector())}getPixels(){return new lf({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(t,n,r){if(this.dim!==t.dim)throw Error(`dem dimension mismatch`);let a=n*this.dim,o=n*this.dim+this.dim,s=r*this.dim,c=r*this.dim+this.dim;switch(n){case-1:a=o-1;break;case 1:o=a+1;break}switch(r){case-1:s=c-1;break;case 1:c=s+1;break}let l=-n*this.dim,u=-r*this.dim;for(let n=s;nt.type===`color-relief`;var Df=class extends yl{constructor(t,n){super(t,Sf,n)}_createColorRamp(t){let n={elevationStops:[],colorStops:[]},r=this._transitionablePaint._values[`color-relief-color`].value.expression;if(r instanceof Ko&&r._styleExpression.expression instanceof Ti){this.colorRampExpression=r;let t=r._styleExpression.expression;n.elevationStops=t.labels,n.colorStops=[];for(let r of n.elevationStops)n.colorStops.push(t.evaluate({globals:{elevation:r}}))}if(n.elevationStops.length<1&&(n.elevationStops=[0],n.colorStops=[H.transparent]),n.elevationStops.length<2&&(n.elevationStops.push(n.elevationStops[0]+1),n.colorStops.push(n.colorStops[0])),n.elevationStops.length<=t)return n;let a={elevationStops:[],colorStops:[]},o=(n.elevationStops.length-1)/(t-1);for(let t=0;t80*r){l=t[0],u=t[1];let n=l,a=u;for(let s=r;sn&&(n=r),o>a&&(a=o)}d=Math.max(n-l,a-u),d=d===0?0:32767/d}return Rf(s,c,l,u,d),c}function If(t,n,r,a,o){let s=null;if(o===Op(t,n,r,a)>0)for(let o=n;o=n;o-=a)s=wp(o/a|0,t[o],t[o+1],s);return s&&_p(s,s.next)&&(Tp(s),s=s.next),s}function Lf(t,n=t){let r=n===t,a=t,o;do o=!1,a!==a.next&&(Nf.size===0||!Nf.has(a))&&(_p(a,a.next)||gp(a.prev,a,a.next)===0)?((r||a===n)&&(n=a.prev),Pf=!0,Tp(a),a=a.prev,o=!0):(r||a!==n)&&(a=a.next,o=!r);while(o||a!==n);return n}function Rf(t,n,r,a,o){o&&lp(t,r,a,o);let s=t,c=!1;for(;t.prev!==t.next;){let l=t.prev,u=t.next;if(gp(l,t,u)<0&&(o?Bf(t,r,a,o):zf(t))){n.push(l.i,t.i,u.i),Tp(t),t=u,s=u;continue}if(t=u,t===s){if(Pf=!1,t=Lf(t),Pf){s=t;continue}if(!c){t=Vf(t,n),s=t,c=!0;continue}Hf(t,n,r,a,o);break}}}function zf(t){let n=t.prev,r=t,a=t.next,o=n.x,s=r.x,c=a.x,l=n.y,u=r.y,d=a.y,f=Math.min(o,s,c),p=Math.min(l,u,d),m=Math.max(o,s,c),h=Math.max(l,u,d),g=a.next;for(;g!==n;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=h&&(o!==g.x||l!==g.y)&&mp(o,l,s,u,c,d,g.x,g.y)&&gp(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function Bf(t,n,r,a){let o=t.prev,s=t,c=t.next,l=o.x,u=s.x,d=c.x,f=o.y,p=s.y,m=c.y,h=Math.min(l,u,d),g=Math.min(f,p,m),_=Math.max(l,u,d),v=Math.max(f,p,m),y=fp(h,g,n,r,a),b=fp(_,v,n,r,a),x=t.prevZ;for(;x&&x.z>=y;){if(x.x>=h&&x.x<=_&&x.y>=g&&x.y<=v&&x!==c&&(l!==x.x||f!==x.y)&&mp(l,f,u,p,d,m,x.x,x.y)&&gp(x.prev,x,x.next)>=0)return!1;x=x.prevZ}let S=t.nextZ;for(;S&&S.z<=b;){if(S.x>=h&&S.x<=_&&S.y>=g&&S.y<=v&&S!==c&&(l!==S.x||f!==S.y)&&mp(l,f,u,p,d,m,S.x,S.y)&&gp(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function Vf(t,n){let r=t,a=!1;do{let o=r.prev,s=r.next.next;vp(o,r,r.next,s,!1)&&xp(o,s)&&xp(s,o)&&(n.push(o.i,r.i,s.i),Tp(r),Tp(r.next),r=t=s,a=!0),r=r.next}while(r!==t);return a?Lf(r):r}function Hf(t,n,r,a,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&hp(s,t)){let c=Cp(s,t);s=Lf(s,s.next),c=Lf(c,c.next),Rf(s,n,r,a,o),Rf(c,n,r,a,o);return}t=t.next}s=s.next}while(s!==t)}let Uf=!1;function Wf(t,n,r,a){let o=[];for(let r=0,s=n.length;rs&&(s=r.x),r.yc&&(c=r.y),n.xs&&(s=n.x),n.yc&&(c=n.y),r=n}while(++l<16&&r!==n);Xf[t]=r;let u=t*4;qf[u]=a,qf[u+1]=o,qf[u+2]=s,qf[u+3]=c}while(r!==n)}function $f(t,n){let r=t.z*4;n.xqf[r+2]&&(qf[r+2]=n.x),n.y>qf[r+3]&&(qf[r+3]=n.y)}function ep(t){let n=Xf[t];for(;n.prev.next!==n;)n=n.next;return Xf[t]=n,n}function tp(t){let n=Yf[t];for(;n.prev.next!==n;)n=n.next;return Yf[t]=n,n}function np(t,n){let r=n,a=t.x,o=t.y,s=-1/0,c;if(_p(t,r))return r;for(let n=0,l=0;nqf[l+3]||qf[l]>a||qf[l+2]<=s)continue;let u=ep(n);r=tp(n);do{if(r.prev.next===r){if(_p(t,r.next))return r.next;if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){let t=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=a&&t>s&&(s=t,c=r.xa||qf[m+3]f)continue;let h=ep(n);r=tp(n);do{if(r.prev.next===r&&a>=r.x&&r.x>=l&&a!==r.x&&mp(oa)&&(nc.x||r.x===c.x&&rp(c,r)))&&(c=r,p=n)}r=r.next}while(r!==h)}return c}function rp(t,n){return gp(t.prev,t,n.prev)<0&&gp(n.next,t,t.next)<0}const ip=[];let ap=[],op=new Uint32Array,sp=new Uint32Array;const cp=new Uint32Array(256);function lp(t,n,r,a){let o=t,s=0;do o.z=fp(o.x,o.y,n,r,a),ip[s++]=o,o=o.next;while(o!==t);up(s);let c=null;for(let t=0;t=0&&ip[a].z>r;)ip[a+1]=ip[a],a--;ip[a+1]=t}return}op.length>>s&255]++;let c=0;for(let t=0;t<256;t++){let n=cp[t];cp[t]=c,c+=n}for(let c=0;c>>s&255]++;a[l]=n[c],o[l]=t}}function fp(t,n,r,a,o){return t=(t-r)*o|0,n=(n-a)*o|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t|n<<1}function pp(t){let n=t,r=t;do(n.x=(t-c)*(s-l)&&(t-c)*(a-l)>=(r-c)*(n-l)&&(r-c)*(s-l)>=(o-c)*(a-l)}function hp(t,n){let r=_p(t,n)&&gp(t.prev,t,t.next)>0&&gp(n.prev,n,n.next)>0;return t.next.i!==n.i&&(r||xp(t,n)&&xp(n,t)&&(gp(t.prev,t,n.prev)!==0||gp(t,n.prev,n)!==0))&&!bp(t,n)&&(r||Sp(t,n))}function gp(t,n,r){return(n.y-t.y)*(r.x-n.x)-(n.x-t.x)*(r.y-n.y)}function _p(t,n){return t.x===n.x&&t.y===n.y}function vp(t,n,r,a,o=!0){let s=gp(t,n,r),c=gp(t,n,a),l=gp(r,a,t),u=gp(r,a,n);return(s>0&&c<0||s<0&&c>0)&&(l>0&&u<0||l<0&&u>0)?!0:o?!!(s===0&&yp(t,r,n)||c===0&&yp(t,a,n)||l===0&&yp(r,t,a)||u===0&&yp(r,n,a)):!1}function yp(t,n,r){return n.x<=Math.max(t.x,r.x)&&n.x>=Math.min(t.x,r.x)&&n.y<=Math.max(t.y,r.y)&&n.y>=Math.min(t.y,r.y)}function bp(t,n){let r=Math.min(t.x,n.x),a=Math.max(t.x,n.x),o=Math.min(t.y,n.y),s=Math.max(t.y,n.y),c=t;do{let l=c.next;if(c.x>a&&l.x>a||c.xs&&l.y>s||c.y=0&&gp(t,t.prev,n)>=0:gp(t,n,t.prev)<0||gp(t,t.next,n)<0}function Sp(t,n){let r=t,a=!1,o=(t.x+n.x)/2,s=(t.y+n.y)/2;do{let t=r.next;r.y>s!=t.y>s&&o<(t.x-r.x)*(s-r.y)/(t.y-r.y)+r.x&&(a=!a),r=t}while(r!==t);return a}function Cp(t,n){let r=Dp(t.i,t.x,t.y),a=Dp(n.i,n.x,n.y),o=t.next,s=n.prev;return t.next=n,n.prev=t,r.next=o,o.prev=r,a.next=r,r.prev=a,s.next=a,a.prev=s,a}function wp(t,n,r,a){let o=Dp(t,n,r);return a?(o.next=a.next,o.prev=a,a.next.prev=o,a.next=o):(o.prev=o,o.next=o),o}function Tp(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ),Uf&&$f(t.prev,t.next)}function Dp(t,n,r){return{i:t,x:n,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function Op(t,n,r,a){let o=0;for(let s=n,c=r-a;st)throw Error(`Min granularity must not be greater than base granularity.`);this._baseZoomGranularity=t,this._minGranularity=n}getGranularityForZoomLevel(t){let n=1<32767||n>32767)throw Error(`Vertex coordinates are out of signed 16 bit integer range.`);let r=Math.round(t)|0,a=Math.round(n)|0,o=this._getKey(r,a);if(this._vertexDictionary.has(o))return this._vertexDictionary.get(o);let s=this._vertexBuffer.length/2;return this._vertexDictionary.set(o,s),this._vertexBuffer.push(r,a),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return Ip(this._vertexBuffer,t);let n=[],r=t.length;for(let a=0;a=1||x<=0)||_&&(lo)){d>=a&&d<=o&&s.push(r[(t+1)%3]);continue}if(!_&&b>0){let t=c+m*b,n=l+h*b;s.push(this._vertexToIndex(t,n))}let S=c+m*Math.max(b,0),C=c+m*Math.min(x,1);if(g||this._generateIntraEdgeVertices(s,c,l,u,d,S,C),!_&&x<1){let t=c+m*x,n=l+h*x;s.push(this._vertexToIndex(t,n))}(_||d>=a&&d<=o)&&s.push(r[(t+1)%3]),!_&&(d<=a||d>=o)&&this._generateInterEdgeVertices(s,c,l,u,d,f,p,C,a,o)}return s}_generateIntraEdgeVertices(t,n,r,a,o,s,c){let l=a-n,u=o-r,d=u===0,f=d?Math.min(n,a):Math.min(s,c),p=d?Math.max(n,a):Math.max(s,c),m=Math.floor(f/this._granularityCellSize)+1,h=Math.ceil(p/this._granularityCellSize)-1;if(d?n=m;a--){let o=a*this._granularityCellSize,s=r+u*(o-n)/l;t.push(this._vertexToIndex(o,s))}}_generateInterEdgeVertices(t,n,r,a,o,s,c,l,u,d){let f=o-r,p=s-a,m=c-o,h=(u-o)/m,g=(d-o)/m,_=Math.min(h,g),v=Math.max(h,g),y=a+p*_,b=Math.floor(Math.min(y,l)/this._granularityCellSize)+1,x=Math.ceil(Math.max(y,l)/this._granularityCellSize)-1,S=l=1||v<=0){let t=n-s,a=r-c,o=(u-c)/a,f=(d-c)/a,p=s+t*Math.min(o,f);b=Math.floor(Math.min(p,l)/this._granularityCellSize)+1,x=Math.ceil(Math.max(p,l)/this._granularityCellSize)-1,S=l0?d:u;if(S)for(let n=b;n<=x;n++){let r=n*this._granularityCellSize;t.push(this._vertexToIndex(r,w))}else for(let n=x;n>=b;n--){let r=n*this._granularityCellSize;t.push(this._vertexToIndex(r,w))}}_generateOutline(t){let n=[];for(let r of t){let t=Pp(r,this._granularity,!0),a=this._pointArrayToIndices(t),o=[];for(let t=1;to==(s===-32768)?(t.push(r),t.push(n),t.push(this._vertexToIndex(a,s)),t.push(this._vertexToIndex(o,s)),t.push(r),t.push(this._vertexToIndex(a,s))):(t.push(n),t.push(r),t.push(this._vertexToIndex(a,s)),t.push(r),t.push(this._vertexToIndex(o,s)),t.push(this._vertexToIndex(a,s)))}_fillPoles(t,n,r){let a=this._vertexBuffer,o=Ye,s=t.length;for(let c=2;c0?(Math.floor(b/c)+1)*c:(Math.ceil(b/c)-1)*c,n=_>0?(Math.floor(x/c)+1)*c:(Math.ceil(x/c)-1)*c,r=Math.abs(b-t),a=Math.abs(x-n),o=Math.abs(b-f),s=Math.abs(x-p),u=m?r/v:1/0,S=h?a/y:1/0;if((o<=r||!m)&&(s<=a||!h))break;if(u0?(r.push(o),r.push(c),r.push(s)):(r.push(o),r.push(s),r.push(c))}return r}function Lp(t,n,r){if(n.length===0)throw Error(`Subdivision vertex ring is empty.`);let a=0,o=t[n[0]*2];for(let r=1;r=0?c-1:s-1,o=(l+1)%s,u=t[n[a]*2],d=t[n[a]*2+1],f=t[n[o]*2],p=t[n[o]*2+1],m=t[n[c]*2],h=t[n[c]*2+1],g=t[n[l]*2],_=t[n[l]*2+1],v=!1;if(uf)v=!1;else{let t=_-h,n=-(g-m),r=h<_?1:-1;((u-m)*t+(d-h)*n)*r>((f-m)*t+(p-h)*n)*r&&(v=!0)}if(v){let t=n[a],o=n[c],u=n[l];t!==o&&t!==u&&o!==u&&r.push(u,o,t),c--,c<0&&(c=s-1)}else{let t=n[o],a=n[c],u=n[l];t!==a&&t!==u&&a!==u&&r.push(u,a,t),l++,l>=s&&(l=0)}if(a===o)break}}function Rp(t,n,r,a,o,s,c,l,u){let d=o.length/2,f=c&&l&&u;if(dPu.MAX_VERTEX_ARRAY_LENGTH&&(d=t.createNewSegment(n,r),u=l.count,_=!0,v=!0,y=!0,f=0);let x=zp(c,a,s,l,m,_,d),S=zp(c,a,s,l,h,v,d),C=zp(c,a,s,l,g,y,d);r.emplaceBack(f+x-u,f+S-u,f+C-u),d.primitiveLength++}}function Hp(t,n,r,a,o,s){let c=[];for(let t=0;tPu.MAX_VERTEX_ARRAY_LENGTH&&(d=t.createNewSegment(n,r),u=l.count,g=!0,_=!0,f=0);let y=zp(c,a,s,l,m,g,d),b=zp(c,a,s,l,h,_,d);r.emplaceBack(f+y-u,f+b-u),d.primitiveLength++}}var Bp=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.id),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new hu,this.indexArray=new Ou,this.indexArray2=new ku,this.programConfigurations=new ud(t.layers,t.zoom),this.segments=new Pu,this.segments2=new Pu,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(t,n,r){this.hasDependencies=jf(`fill`,this.layers,n);let a=this.layers[0].layout.get(`fill-sort-key`),o=!a.isConstant(),s=[];for(let{feature:c,id:l,index:u,sourceLayerIndex:d}of t){let t=this.layers[0]._featureFilter.needGeometry,f=vd(c,t);if(!this.layers[0]._featureFilter.filter(new U(this.zoom),f,r))continue;let p=o?a.evaluate(f,{},r,n.availableImages):void 0,m={id:l,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:t?f.geometry:_d(c),patterns:{},sortKey:p};s.push(m)}o&&s.sort((t,n)=>t.sortKey-n.sortKey);for(let a of s){let{geometry:o,index:s,sourceLayerIndex:c}=a;if(this.hasDependencies){let t=Mf(`fill`,this.layers,a,{zoom:this.zoom},n);this.patternFeatures.push(t)}else this.addFeature(a,o,s,r,{},n.subdivisionGranularity);let l=t[s].feature;n.featureIndex.insert(l,o,s,c,this.index)}}update(t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,n,this.stateDependentLayers,{imagePositions:r})}addFeatures(t,n,r){for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,n,r,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Af),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,n,r,a,o,s){for(let t of Ma(n,500)){let n=Np(t,a,s.fill.getGranularityForZoomLevel(a.z)),r=this.layoutVertexArray;Rp((t,n)=>{r.emplaceBack(t,n)},this.segments,this.layoutVertexArray,this.indexArray,n.verticesFlattened,n.indicesTriangles,this.segments2,this.indexArray2,n.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{imagePositions:o,canonical:a})}};J(`FillBucket`,Bp,{omit:[`layers`,`patternFeatures`]});let Up;const Wp=()=>Up||=new gl({"fill-sort-key":new G(P.layout_fill[`fill-sort-key`],`fill-sort-key`)});let Gp;const Kp=()=>Gp||=new gl({"fill-antialias":new W(P.paint_fill[`fill-antialias`],`fill-antialias`),"fill-opacity":new G(P.paint_fill[`fill-opacity`],`fill-opacity`),"fill-layer-opacity":new W(P.paint_fill[`fill-layer-opacity`],`fill-layer-opacity`),"fill-color":new G(P.paint_fill[`fill-color`],`fill-color`),"fill-outline-color":new G(P.paint_fill[`fill-outline-color`],`fill-outline-color`),"fill-translate":new W(P.paint_fill[`fill-translate`],`fill-translate`),"fill-translate-anchor":new W(P.paint_fill[`fill-translate-anchor`],`fill-translate-anchor`),"fill-pattern":new pl(P.paint_fill[`fill-pattern`],`fill-pattern`)});var Jp={get paint(){return Kp()},get layout(){return Wp()}};const Yp=t=>t.type===`fill`;var qp=class extends yl{constructor(t,n){super(t,Jp,n)}recalculate(t,n){super.recalculate(t,n);let r=this.paint._values[`fill-outline-color`];r.value.kind===`constant`&&r.value.value===void 0&&(this.paint._values[`fill-outline-color`]=this.paint._values[`fill-color`])}createBucket(t){return new Bp(t)}queryRadius(){return Id(this.paint.get(`fill-translate`))}queryIntersectsFeature({queryGeometry:t,geometry:n,transform:r,pixelsToTileUnits:a}){return wd(Ld(t,this.paint.get(`fill-translate`),this.paint.get(`fill-translate-anchor`),-r.bearingInRadians,a),n)}isTileClipped(){return!0}};const Xp=Dl([{name:`a_pos`,components:2,type:`Int16`},{name:`a_normal_ed`,components:4,type:`Int16`}],4),Qp=Dl([{name:`a_centroid`,components:2,type:`Int16`}],4),$p=Xp.members;Xp.size,Xp.alignment;var Zp=class{constructor(t,n,r,a,o){for(this.properties=Object.create(null),this.extent=r,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=a,this._values=o;t.pos>3,s===0)continue}if(s--,o===1)c+=t.readSVarint(),l+=t.readSVarint(),a&&r.push(a),a=[new d(c,l)];else if(o===2)c+=t.readSVarint(),l+=t.readSVarint(),a&&a.push(new d(c,l));else if(o===7)a&&a.push(a[0].clone());else throw Error(`unknown command ${o}`)}return a&&r.push(a),r}bbox(){if(this._geometry<0)throw Error(`feature has no geometry`);let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,a=0,o=0,s=0,c=1/0,l=-1/0,u=1/0,d=-1/0;for(;t.pos>3,a===0)continue}if(a--,r===1||r===2)o+=t.readSVarint(),s+=t.readSVarint(),ol&&(l=o),sd&&(d=s);else if(r!==7)throw Error(`unknown command ${r}`)}return[c,u,l,d]}toGeoJSON(t,n,r){let a=this.extent*2**r,o=this.extent*t,s=this.extent*n,c=this.loadGeometry();function l(t){return[(t.x+o)*360/a-180,360/Math.PI*Math.atan(Math.exp((1-(t.y+s)*2/a)*Math.PI))-90]}function u(t){return t.map(l)}let d;if(this.type===1){let t=[];for(let n of c)t.push(n[0]);let n=u(t);d=t.length===1?{type:`Point`,coordinates:n[0]}:{type:`MultiPoint`,coordinates:n}}else if(this.type===2){let t=c.map(u);d=t.length===1?{type:`LineString`,coordinates:t[0]}:{type:`MultiLineString`,coordinates:t}}else if(this.type===3){let t=tm(c),n=[];for(let r of t)n.push(r.map(u));d=n.length===1?{type:`Polygon`,coordinates:n[0]}:{type:`MultiPolygon`,coordinates:n}}else throw Error(`unknown feature type`);let f={type:`Feature`,geometry:d,properties:this.properties};return this.id!=null&&(f.id=this.id),f}};Zp.types=[`Unknown`,`Point`,`LineString`,`Polygon`];function tm(t){let n=t.length;if(n<=1)return[t];let r=[],a,o;for(let s=0;s=this._features.length)throw Error(`feature index out of bounds`);this._pbf.pos=this._features[t];let n=this._pbf.readVarint()+this._pbf.pos;return new Zp(this._pbf,n,this.extent,this._keys,this._values)}};function im(t){let n=null,r=t.readVarint()+t.pos;for(;t.post.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new gu,this.centroidVertexArray=new du,this.indexArray=new Ou,this.programConfigurations=new ud(t.layers,t.zoom),this.segments=new Pu,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(t,n,r){this.features=[],this.hasDependencies=jf(`fill-extrusion`,this.layers,n);for(let{feature:a,id:o,index:s,sourceLayerIndex:c}of t){let t=this.layers[0]._featureFilter.needGeometry,l=vd(a,t);if(!this.layers[0]._featureFilter.filter(new U(this.zoom),l,r))continue;let u={id:o,sourceLayerIndex:c,index:s,geometry:t?l.geometry:_d(a),properties:a.properties,type:a.type,patterns:{}};this.hasDependencies?this.features.push(Mf(`fill-extrusion`,this.layers,u,{zoom:this.zoom},n)):this.addFeature(u,u.geometry,s,r,{},n.subdivisionGranularity),n.featureIndex.insert(a,u.geometry,s,c,this.index,!0)}}addFeatures(t,n,r){for(let a of this.features){let{geometry:o}=a;this.addFeature(a,o,a.index,n,r,t.subdivisionGranularity)}}update(t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,n,this.stateDependentLayers,{imagePositions:r})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,$p),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Qp.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,n,r,a,o,s){for(let r of Ma(n,500)){let n={x:0,y:0,sampleCount:0},o=this.layoutVertexArray.length;this.processPolygon(n,a,t,r,s);let c=this.layoutVertexArray.length-o,l=Math.floor(n.x/n.sampleCount),u=Math.floor(n.y/n.sampleCount);for(let t=0;t{sm(d,t,n,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,u.verticesFlattened,u.indicesTriangles)}_generateSideFaces(t,n){let r=0;for(let a=1;aPu.MAX_VERTEX_ARRAY_LENGTH&&(n.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let c=o.sub(s)._perp()._unit(),l=s.dist(o);r+l>32768&&(r=0),sm(this.layoutVertexArray,o.x,o.y,c.x,c.y,0,0,r),sm(this.layoutVertexArray,o.x,o.y,c.x,c.y,0,1,r),r+=l,sm(this.layoutVertexArray,s.x,s.y,c.x,c.y,0,0,r),sm(this.layoutVertexArray,s.x,s.y,c.x,c.y,0,1,r);let u=n.segment.vertexLength;this.indexArray.emplaceBack(u,u+2,u+1),this.indexArray.emplaceBack(u+1,u+2,u+3),n.segment.vertexLength+=4,n.segment.primitiveLength+=2}}};function cm(t,n){for(let r=0;r8192)||t.y===n.y&&(t.y<0||t.y>8192)}function um(t){return t.every(t=>t.x<0)||t.every(t=>t.x>8192)||t.every(t=>t.y<0)||t.every(t=>t.y>8192)}let dm;const fm=()=>dm||=new gl({"fill-extrusion-opacity":new W(P[`paint_fill-extrusion`][`fill-extrusion-opacity`],`fill-extrusion-opacity`),"fill-extrusion-color":new G(P[`paint_fill-extrusion`][`fill-extrusion-color`],`fill-extrusion-color`),"fill-extrusion-translate":new W(P[`paint_fill-extrusion`][`fill-extrusion-translate`],`fill-extrusion-translate`),"fill-extrusion-translate-anchor":new W(P[`paint_fill-extrusion`][`fill-extrusion-translate-anchor`],`fill-extrusion-translate-anchor`),"fill-extrusion-pattern":new pl(P[`paint_fill-extrusion`][`fill-extrusion-pattern`],`fill-extrusion-pattern`),"fill-extrusion-height":new G(P[`paint_fill-extrusion`][`fill-extrusion-height`],`fill-extrusion-height`),"fill-extrusion-base":new G(P[`paint_fill-extrusion`][`fill-extrusion-base`],`fill-extrusion-base`),"fill-extrusion-vertical-gradient":new W(P[`paint_fill-extrusion`][`fill-extrusion-vertical-gradient`],`fill-extrusion-vertical-gradient`)});var mm={get paint(){return fm()}};const hm=t=>t.type===`fill-extrusion`;var pm=class extends yl{constructor(t,n){super(t,mm,n)}createBucket(t){return new am(t)}queryRadius(){return Id(this.paint.get(`fill-extrusion-translate`))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:n,featureState:r,geometry:a,transform:o,pixelsToTileUnits:s,pixelPosMatrix:c}){let l=Ld(t,this.paint.get(`fill-extrusion-translate`),this.paint.get(`fill-extrusion-translate-anchor`),-o.bearingInRadians,s),u=this.paint.get(`fill-extrusion-height`).evaluate(n,r),d=this.paint.get(`fill-extrusion-base`).evaluate(n,r),f=bm(l,c,0),p=ym(a,d,u,c),m=p[0],h=p[1];return vm(m,h,f)}};function gm(t,n){return t.x*n.x+t.y*n.y}function _m(t,n){if(t.length===1){let r=0,a=n[r++],o;for(;!o||a.equals(o);)if(o=n[r++],!o)return 1/0;for(;r>1),c=r-n,l,u=t[n],d=t[n+1],f=t[r],p=t[r+1];for(let a=n+3;ao){l=a,o=n;continue}if(n===o){let t=Math.abs(a-s);ta&&(l-n>3&&xm(t,n,l,a),t[l+2]=o,r-l>3&&xm(t,l,r,a))}function Sm(t,n,r,a,o,s){let c=o-r,l=s-a;if(c!==0||l!==0){let u=((t-r)*c+(n-a)*l)/(c*c+l*l);u>1?(r=o,a=s):u>0&&(r+=c*u,a+=l*u)}return c=t-r,l=n-a,c*c+l*l}function Cm(t,n,r,a){let o={type:n,geom:r},s={id:t??null,type:o.type,geometry:o.geom,tags:a,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(o.type){case`Point`:case`MultiPoint`:Tm(s,o.geom);break;case`LineString`:Tm(s,o.geom.points);break;case`Polygon`:Tm(s,o.geom[0].points);break;case`MultiLineString`:for(let t of o.geom)Tm(s,t.points);break;case`MultiPolygon`:for(let t of o.geom)Tm(s,t[0].points);break}return s}function wm(t){let n=t;t.points.length>64&&(n.points=new Float64Array(t.points))}function Tm(t,n){for(let r=0;r1024)throw Error(`GeometryCollection nesting exceeds supported depth: 1024`);if(n.geometry.type===`GeometryCollection`){km(t,n,n.geometry,r,a,o+1);return}if(!n.geometry.coordinates?.length)return;let s=Om(n,r,a),c=(r.tolerance/((1<0&&(a?c+=(o*u-l*s)/2:c+=Math.sqrt((l-o)**2+(u-s)**2)),o=l,s=u}let l=n.points.length-3;n.points[2]=1,r>0&&xm(n.points,0,l,r),n.points[l+2]=1,wm(n),n.size=Math.abs(c),n.start=0,n.end=n.size}function Lm(t,n,r,a){for(let o=0;o1?1:r}function Bm(t){return{type:`FeatureCollection`,features:t.map(t=>Vm(t))}}function Vm(t){let n={type:`Feature`,geometry:Hm(t),properties:t.tags};return t.id!=null&&(n.id=t.id),n}function Hm(t){let{type:n,geometry:r}=t;switch(n){case`Point`:return{type:n,coordinates:Wm(r[0],r[1])};case`MultiPoint`:return{type:n,coordinates:Um(r)};case`LineString`:return{type:n,coordinates:Um(r.points)};case`MultiLineString`:case`Polygon`:return{type:n,coordinates:r.map(t=>Um(t.points))};case`MultiPolygon`:return{type:n,coordinates:r.map(t=>t.map(t=>Um(t.points)))}}}function Um(t){let n=[];for(let r=0;r=r&&c=a)return null;let u=[];for(let n of t){let t=o===0?n.minX:n.minY,s=o===0?n.maxX:n.maxY;if(t>=r&&s=a))switch(n.type){case`Point`:case`MultiPoint`:Jm(n,u,r,a,o);continue;case`LineString`:Ym(n,u,r,a,o,l);continue;case`MultiLineString`:Xm(n,u,r,a,o);continue;case`Polygon`:Zm(n,u,r,a,o);continue;case`MultiPolygon`:Qm(n,u,r,a,o);continue}}return u.length?u:null}function Jm(t,n,r,a,o){let s=[];if($m(t.geometry,s,r,a,o),!s.length)return;let c=s.length===3?`Point`:`MultiPoint`;n.push(Cm(t.id,c,s,t.tags))}function Ym(t,n,r,a,o,s){let c=[];if(eh(t.geometry,c,r,a,o,!1,s.lineMetrics),c.length){if(s.lineMetrics){for(let r of c)n.push(Cm(t.id,`LineString`,r,t.tags));return}if(c.length>1){n.push(Cm(t.id,`MultiLineString`,c,t.tags));return}n.push(Cm(t.id,`LineString`,c[0],t.tags))}}function Xm(t,n,r,a,o){let s=[];if(nh(t.geometry,s,r,a,o,!1),s.length){if(s.length===1){n.push(Cm(t.id,`LineString`,s[0],t.tags));return}n.push(Cm(t.id,`MultiLineString`,s,t.tags))}}function Zm(t,n,r,a,o){let s=[];nh(t.geometry,s,r,a,o,!0),s.length&&n.push(Cm(t.id,`Polygon`,s,t.tags))}function Qm(t,n,r,a,o){let s=[];for(let n of t.geometry){let t=[];nh(n,t,r,a,o,!0),t.length&&s.push(t)}s.length&&n.push(Cm(t.id,`MultiPolygon`,s,t.tags))}function $m(t,n,r,a,o){for(let s=0;s=r&&c<=a&&rh(n,t[s],t[s+1],t[s+2])}}function eh(t,n,r,a,o,s,c){let l=th(t),u=o===0?ih:ah,d=t.start,f,p;for(let m=0;mr&&(p=u(l,h,g,v,y,r),c&&(l.start=d+f*p)):b>a?x=r&&(p=u(l,h,g,v,y,r),S=!0),x>a&&b<=a&&(p=u(l,h,g,v,y,a),S=!0),!s&&S&&(c&&(l.end=d+f*p),n.push(l),l=th(t)),c&&(d+=f)}let m=t.points.length-3,h=t.points[m],g=t.points[m+1],_=t.points[m+2],v=o===0?h:g;v>=r&&v<=a&&rh(l.points,h,g,_),m=l.points.length-3,s&&m>=3&&(l.points[m]!==l.points[0]||l.points[m+1]!==l.points[1])&&rh(l.points,l.points[0],l.points[1],l.points[2]),l.points.length&&(wm(l),n.push(l))}function th(t){return{points:[],size:t.size,start:t.start,end:t.end}}function nh(t,n,r,a,o,s){for(let c of t)eh(c,n,r,a,o,s,!1)}function rh(t,n,r,a){t.push(n,r,a)}function ih(t,n,r,a,o,s){let c=(s-n)/(a-n);return rh(t.points,s,r+(o-r)*c,1),c}function ah(t,n,r,a,o,s){let c=(s-r)/(o-r);return rh(t.points,n+(a-n)*c,s,1),c}function oh(t,n){let r=n.buffer/n.extent,a=t,o=qm(t,1,-1-r,r,0,-1,2,n),s=qm(t,1,1-r,2+r,0,-1,2,n);return!o&&!s?a:(a=qm(t,1,-r,1+r,0,-1,2,n)||[],o&&(a=sh(o,1).concat(a)),s&&(a=a.concat(sh(s,-1))),a)}function sh(t,n){let r=[];for(let a of t)switch(a.type){case`Point`:case`MultiPoint`:{let t=ch(a.geometry,n);r.push(Cm(a.id,a.type,t,a.tags));continue}case`LineString`:{let t=lh(a.geometry,n);r.push(Cm(a.id,a.type,t,a.tags));continue}case`MultiLineString`:case`Polygon`:{let t=[];for(let r of a.geometry)t.push(lh(r,n));r.push(Cm(a.id,a.type,t,a.tags));continue}case`MultiPolygon`:{let t=[];for(let r of a.geometry){let a=[];for(let t of r)a.push(lh(t,n));t.push(a)}r.push(Cm(a.id,a.type,t,a.tags));continue}}return r}function ch(t,n){let r=[];for(let a=0;at.id));t=t.filter(t=>!r.has(t.id))}if(a.add.size){let n=Em({type:`FeatureCollection`,features:Array.from(a.add.values())},r);n=oh(n,r),o=o.concat(n),t=t.concat(n)}}if(a.update.size){let n=/* @__PURE__ */ new Map,s=[];for(let r of t)a.update.has(r.id)?n.set(r.id,[...n.get(r.id)||[],r]):s.push(r);for(let[t,c]of a.update){let a=n.get(t);if(!a||a.length===0)continue;let l=dh(a,c,r);o=o.concat(a,l),s=s.concat(l)}t=s}return{affected:o,source:t}}function dh(t,n,r){let a=!!n.newGeometry,o=n.removeAllProperties||n.removeProperties?.length>0||n.addOrUpdateProperties?.length>0;if(a){let a=t[0],s=Em({type:`FeatureCollection`,features:[{type:`Feature`,id:a.id,geometry:n.newGeometry,properties:o?fh(a.tags,n):a.tags}]},r);return s=oh(s,r),s}if(o){let r=[];for(let a of t){let t={...a};t.tags=fh(t.tags,n),r.push(t)}return r}return t}function fh(t,n){if(n.removeAllProperties)return{};let r={...t||{}};if(n.removeProperties)for(let t of n.removeProperties)delete r[t];if(n.addOrUpdateProperties)for(let{key:t,value:a}of n.addOrUpdateProperties)r[t]=a;return r}function ph(t,n){return t?{removeAll:t.removeAll,remove:new Set(t.remove||[]),add:new Map(t.add?.map(t=>[n.promoteId?t.properties[n.promoteId]:t.id,t])),update:new Map(t.update?.map(t=>[t.id,t]))}:{remove:/* @__PURE__ */ new Set,add:/* @__PURE__ */ new Map,update:/* @__PURE__ */ new Map}}const mh=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Y=new Uint32Array(96);var hh=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==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 o=mh[r&15];if(!o)throw Error(`Unrecognized array type.`);let[s]=new Uint16Array(t,2,1),[c]=new Uint32Array(t,4,1);return new e(c,s,o,void 0,t)}constructor(t,n=64,r=Float64Array,a=ArrayBuffer,o){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let s=mh.indexOf(this.ArrayType),c=t*2*this.ArrayType.BYTES_PER_ELEMENT,l=t*this.IndexArrayType.BYTES_PER_ELEMENT,u=(8-l%8)%8;if(s<0)throw Error(`Unexpected typed array class: ${r}.`);if(o)this.data=o,this.ids=new this.IndexArrayType(o,8,t),this.coords=new r(o,8+l+u,t*2),this._pos=t*2,this._finished=!0;else{let o=this.data=new a(8+c+l+u);this.ids=new this.IndexArrayType(o,8,t),this.coords=new r(o,8+l+u,t*2),this._pos=0,this._finished=!1,new Uint8Array(o,0,2).set([219,16+s]),new Uint16Array(o,2,1)[0]=n,new Uint32Array(o,4,1)[0]=t}}add(t,n){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return gh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,a){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:o,coords:s,nodeSize:c}=this;Y[0]=0,Y[1]=o.length-1,Y[2]=0;let l=3,u=[];for(;l>0;){let d=Y[--l],f=Y[--l],p=Y[--l];if(f-p<=c){for(let c=p;c<=f;c++){let l=s[2*c],d=s[2*c+1];l>=t&&l<=r&&d>=n&&d<=a&&u.push(o[c])}continue}let m=p+f>>1,h=s[2*m],g=s[2*m+1];h>=t&&h<=r&&g>=n&&g<=a&&u.push(o[m]),(d===0?t<=h:n<=g)&&(Y[l++]=p,Y[l++]=m-1,Y[l++]=1-d),(d===0?r>=h:a>=g)&&(Y[l++]=m+1,Y[l++]=f,Y[l++]=1-d)}return u}within(t,n,r){let a=[];return this.withinInto(t,n,r,a),a}withinInto(t,n,r,a){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:o,coords:s,nodeSize:c}=this;Y[0]=0,Y[1]=o.length-1,Y[2]=0;let l=3,u=0,d=r*r;for(;l>0;){let f=Y[--l],p=Y[--l],m=Y[--l];if(p-m<=c){for(let r=m;r<=p;r++)xh(s[2*r],s[2*r+1],t,n)<=d&&(a[u++]=o[r]);continue}let h=m+p>>1,g=s[2*h],_=s[2*h+1];xh(g,_,t,n)<=d&&(a[u++]=o[h]),(f===0?t-r<=g:n-r<=_)&&(Y[l++]=m,Y[l++]=h-1,Y[l++]=1-f),(f===0?t+r>=g:n+r>=_)&&(Y[l++]=h+1,Y[l++]=p,Y[l++]=1-f)}return u}};function gh(t,n,r,a,o,s){if(o-a<=r)return;let c=a+o>>1;_h(t,n,c,a,o,s),gh(t,n,r,a,c-1,1-s),gh(t,n,r,c+1,o,1-s)}function _h(t,n,r,a,o,s){for(;o>a;){if(o-a>600){let c=o-a+1,l=r-a+1,u=Math.log(c),d=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*d*(c-d)/c)*(l-c/2<0?-1:1);_h(t,n,r,Math.max(a,Math.floor(r-l*d/c+f)),Math.min(o,Math.floor(r+(c-l)*d/c+f)),s)}let c=n[2*r+s],l=a,u=o;for(vh(t,n,a,r),n[2*o+s]>c&&vh(t,n,a,o);lc;)u--}n[2*a+s]===c?vh(t,n,a,u):(u++,vh(t,n,u,o)),u<=r&&(a=u+1),r<=u&&(o=u-1)}}function vh(t,n,r,a){yh(t,r,a),yh(n,2*r,2*a),yh(n,2*r+1,2*a+1)}function yh(t,n,r){let a=t[n];t[n]=t[r],t[r]=a}function xh(t,n,r,a){let o=t-r,s=n-a;return o*o+s*s}const Sh={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t};var bh=class{constructor(t){this.options=Object.assign(Object.create(Sh),t),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(t){let n=[];for(let r of t){if(!r.geometry)continue;let[t,a]=r.geometry.coordinates,[o,s]=[Rm(t),zm(a)],c={id:r.id,type:`Point`,geometry:[o,s],tags:r.properties};n.push(c)}this.createIndex(n)}initialize(t){let n=[];for(let r of t)r.type===`Point`&&n.push(r);this.createIndex(n)}updateIndex(t,n,r){this.options=Object.assign(Object.create(Sh),r.clusterOptions),this.initialize(t)}createIndex(t){let{log:n,minZoom:r,maxZoom:a}=this.options;n&&console.time(`total time`);let o=`prepare ${t.length} points`;n&&console.time(o),this.points=t;let s=[];for(let n=0;n=r;t--){let r=Date.now();c=this.trees[t]=this.createTree(this.cluster(c,t)),n&&console.log(`z%d: %d clusters in %dms`,t,c.numItems,Date.now()-r)}n&&console.timeEnd(`total time`)}getClusters(t,n){return this.getClustersInternal(t,n).map(t=>Vm(t))}getClustersInternal(t,n){let r=((t[0]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,t[1])),o=t[2]===180?180:((t[2]+180)%360+360)%360-180,s=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,o=180;else if(r>o){let t=this.getClustersInternal([r,a,180,s],n),c=this.getClustersInternal([-180,a,o,s],n);return t.concat(c)}let c=this.trees[this.limitZoom(n)],l=c.range(Rm(r),zm(s),Rm(o),zm(a)),u=c.flatData,d=[];for(let t of l){let n=this.stride*t;d.push(u[n+5]>1?Ch(u,n,this.clusterProps):this.points[u[n+3]])}return d}getChildren(t){let n=this.getOriginId(t),r=this.getOriginZoom(t),a=Error(`No cluster with the specified id: `+t),o=this.trees[r];if(!o)throw a;let s=o.flatData;if(n*this.stride>=s.length)throw a;let c=this.options.radius/(this.options.extent*2**(r-1)),l=s[n*this.stride],u=s[n*this.stride+1],d=o.within(l,u,c),f=[];for(let n of d){let r=n*this.stride;s[r+4]===t&&f.push(s[r+5]>1?wh(s,r,this.clusterProps):Vm(this.points[s[r+3]]))}if(f.length===0)throw a;return f}getLeaves(t,n,r){n||=10,r||=0;let a=[];return this.appendLeaves(a,t,n,r,0),a}getTile(t,n,r){let a=this.trees[this.limitZoom(t)];if(!a)return null;let o=2**t,{extent:s,radius:c}=this.options,l=c/s,u=(r-l)/o,d=(r+1+l)/o,f={transformed:!0,features:[],source:null,x:n,y:r,z:t};return this.addTileFeatures(a.range((n-l)/o,u,(n+1+l)/o,d),a.flatData,n,r,o,f),n===0&&this.addTileFeatures(a.range(1-l/o,u,1,d),a.flatData,o,r,o,f),n===o-1&&this.addTileFeatures(a.range(0,u,l/o,d),a.flatData,-1,r,o,f),f}getClusterExpansionZoom(t){return this.getOriginZoom(t)}appendLeaves(t,n,r,a,o){let s=this.getChildren(n);for(let n of s){let s=n.properties;if(s?.cluster?o+s.point_count<=a?o+=s.point_count:o=this.appendLeaves(t,s.cluster_id,r,a,o):o1,u,d,f;if(l)u=Th(n,t,this.clusterProps),d=n[t],f=n[t+1];else{let r=this.points[n[t+3]];u=r.tags,[d,f]=r.geometry}let p={type:1,geometry:[[Math.round(this.options.extent*(d*o-r)),Math.round(this.options.extent*(f*o-a))]],tags:u},m;m=l||this.options.generateId?n[t+3]:this.points[n[t+3]].id,m!==void 0&&(p.id=m),s.features.push(p)}}limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}cluster(t,n){let{radius:r,extent:a,reduce:o,minPoints:s}=this.options,c=r/(a*2**n),l=t.flatData,u=[],d=this.stride;for(let r=0;rn&&(h+=l[r+5])}if(h>m&&h>=s){let t=a*m,s=f*m,c,g=-1,_=((r/d|0)<<5)+(n+1)+this.points.length;for(let a of p){let u=a*d;if(l[u+2]<=n)continue;l[u+2]=n;let f=l[u+5];t+=l[u]*f,s+=l[u+1]*f,l[u+4]=_,o&&(c||(c=this.map(l,r,!0),g=this.clusterProps.length,this.clusterProps.push(c)),o(c,this.map(l,u)))}l[r+4]=_,u.push(t/h,s/h,1/0,_,-1,h),o&&u.push(g)}else{for(let t=0;t1)for(let t of p){let r=t*d;if(!(l[r+2]<=n)){l[r+2]=n;for(let t=0;t>5}getOriginZoom(t){return(t-this.points.length)%32}map(t,n,r){if(t[n+5]>1){let a=this.clusterProps[t[n+6]];return r?Object.assign({},a):a}let a=this.points[t[n+3]].tags,o=this.options.map(a);return r&&o===a?Object.assign({},o):o}};function Ch(t,n,r){return{id:t[n+3],type:`Point`,tags:Th(t,n,r),geometry:[t[n],t[n+1]]}}function wh(t,n,r){return{type:`Feature`,id:t[n+3],properties:Th(t,n,r),geometry:{type:`Point`,coordinates:[Gm(t[n]),Km(t[n+1])]}}}function Th(t,n,r){let a=t[n+5],o=a>=1e4?`${Math.round(a/1e3)}k`:a>=1e3?`${Math.round(a/100)/10}k`:a,s=t[n+6],c=s===-1?{}:Object.assign({},r[s]);return Object.assign(c,{cluster:!0,cluster_id:t[n+3],point_count:a,point_count_abbreviated:o})}const Eh=`geojsonvt_clip_start`,Dh=`geojsonvt_clip_end`;function Oh(t,n,r,a,o){let s=n===o.maxZoom?0:o.tolerance/((1<0&&n.size<(o?c:a)){r.numPoints+=n.points.length/3;return}let l=[];for(let t=0;tc)&&(r.numSimplified++,l.push(n.points[t],n.points[t+1])),r.numPoints++;o&&Fh(l,s),t.push(l)}function Fh(t,n){let r=0;for(let n=0,a=t.length,o=a-2;n0===n)for(let n=0,r=t.length;n1&&(console.log(`invalidating tiles`),console.time(`invalidating`)),this.invalidateTiles(n),r.debug>1&&console.timeEnd(`invalidating`);let[a,o,s]=[0,0,0],c=Oh(t,a,o,s,r);c.source=t;let l=Hh(a,o,s);if(this.tiles[l]=c,this.tileCoords.push({z:a,x:o,y:s,id:l}),r.debug){let t=`z${a}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}}getClusterExpansionZoom(t){return null}getChildren(t){return null}getLeaves(t,n,r){return null}getTile(t,n,r){let{extent:a,debug:o}=this.options,s=1<1&&console.log(`drilling down to z%d-%d-%d`,t,n,r);let l=t,u=n,d=r,f;for(;!f&&l>0;)l--,u>>=1,d>>=1,f=this.tiles[Hh(l,u,d)];return!f?.source||(o>1&&(console.log(`found parent tile z%d-%d-%d`,l,u,d),console.time(`drilling down`)),this.splitTile(f.source,l,u,d,t,n,r),o>1&&console.timeEnd(`drilling down`),!this.tiles[c])?null:Ih(this.tiles[c],a)}splitTile(t,n,r,a,o,s,c){let l=[t,n,r,a],u=this.options,d=u.debug;for(;l.length;){a=l.pop(),r=l.pop(),n=l.pop(),t=l.pop();let f=1<1&&console.time(`creation`),m=this.tiles[p]=Oh(t,n,r,a,u),this.tileCoords.push({z:n,x:r,y:a,id:p}),d)){d>1&&(console.log(`tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,n,r,a,m.numFeatures,m.numPoints,m.numSimplified),console.timeEnd(`creation`));let t=`z${n}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(m.source=t,o==null){if(n===u.indexMaxZoom||m.numPoints<=u.indexMaxPoints)continue}else if(n===u.maxZoom||n===o)continue;else if(o!=null){let t=o-n;if(r!==s>>t||a!==c>>t)continue}if(m.source=null,!t.length)continue;d>1&&console.time(`clipping`);let h=.5*u.buffer/u.extent,g=.5-h,_=.5+h,v=1+h,y=null,b=null,x=null,S=null,C=qm(t,f,r-h,r+_,0,m.minX,m.maxX,u),w=qm(t,f,r+g,r+v,0,m.minX,m.maxX,u);C&&(y=qm(C,f,a-h,a+_,1,m.minY,m.maxY,u),b=qm(C,f,a+g,a+v,1,m.minY,m.maxY,u)),w&&(x=qm(w,f,a-h,a+_,1,m.minY,m.maxY,u),S=qm(w,f,a+g,a+v,1,m.minY,m.maxY,u)),d>1&&console.timeEnd(`clipping`),l.push(y||[],n+1,r*2,a*2),l.push(b||[],n+1,r*2,a*2+1),l.push(x||[],n+1,r*2+1,a*2),l.push(S||[],n+1,r*2+1,a*2+1)}}invalidateTiles(t){if(!t.length)return;let n=this.options,{debug:r}=n,a=1/0,o=-1/0,s=1/0,c=-1/0;for(let n of t)a=Math.min(a,n.minX),o=Math.max(o,n.maxX),s=Math.min(s,n.minY),c=Math.max(c,n.maxY);let l=n.buffer/n.extent,u=/* @__PURE__ */ new Set;for(let n in this.tiles){let d=this.tiles[n],f=1<=m||c=g)continue;let _=!1;for(let n of t)if(n.maxX>=p&&n.minX=h&&n.minY1&&console.log(`invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,d.z,d.x,d.y,d.numFeatures,d.numPoints,d.numSimplified);let t=`z${d.z}`;this.stats[t]=(this.stats[t]||0)-1,this.total--}delete this.tiles[n],u.add(n)}}u.size&&(this.tileCoords=this.tileCoords.filter(t=>!u.has(t.id)))}};function Hh(t,n,r){return((1<24)throw Error(`maxZoom should be in the 0-24 range`);if(n.promoteId&&n.generateId)throw Error(`promoteId and generateId cannot be used together.`);let a=Em(t,n);r&&(console.timeEnd(`preprocess data`),console.log(`index: maxZoom: %d, maxPoints: %d`,n.indexMaxZoom,n.indexMaxPoints),console.time(`generate tiles`)),a=oh(a,n),n.updateable&&(this.source=a),this.initializeIndex(a,n)}initializeIndex(t,n){this.tileIndex=n.cluster?new bh(n.clusterOptions):new Rh(n),t.length&&this.tileIndex.initialize(t)}getTile(t,n,r){return t=+t,n=+n,r=+r,t<0||t>24?null:this.tileIndex.getTile(t,n,r)}updateData(t,n){let r=this.options;if(!r.updateable)throw Error("to update tile geojson `updateable` option must be set to true");let{affected:a,source:o}=uh(this.source,t,r);n&&({affected:a,source:o}=this.filterUpdate(o,a,n)),a.length&&(this.source=o,this.tileIndex.updateIndex(o,a,r))}filterUpdate(t,n,r){let a=/* @__PURE__ */ new Set;for(let o of t)o.id!=null&&(r(Vm(o))||(n.push(o),a.add(o.id)));return t=t.filter(t=>!a.has(t.id)),{affected:n,source:t}}getData(){if(!this.options.updateable)throw Error("to retrieve data the `updateable` option must be set to true");return Bm(this.source)}updateClusterOptions(t,n){let r=this.options.cluster;if(this.options.cluster=t,this.options.clusterOptions=n,r==t){this.tileIndex.updateIndex(this.source,[],this.options);return}this.initializeIndex(this.source,this.options)}getClusterExpansionZoom(t){return this.tileIndex.getClusterExpansionZoom(t)}getClusterChildren(t){return this.tileIndex.getChildren(t)}getClusterLeaves(t,n,r){return this.tileIndex.getLeaves(t,n,r)}};const Wh=Dl([{name:`a_pos_normal`,components:2,type:`Int16`},{name:`a_data`,components:4,type:`Uint8`}],4),Gh=Wh.members;Wh.size,Wh.alignment;const Kh=Dl([{name:`a_uv_x`,components:1,type:`Float32`},{name:`a_split_index`,components:1,type:`Float32`}]),qh=Kh.members;Kh.size,Kh.alignment;const Jh=Math.cos(75/2*(Math.PI/180)),Xh=1/2,Zh=2**14/Xh;var Yh=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.id),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let t of this.layers)this.gradients[t.id]={};this.layoutVertexArray=new _u,this.layoutVertexArray2=new vu,this.indexArray=new Ou,this.programConfigurations=new ud(t.layers,t.zoom),this.segments=new Pu,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(t,n,r){this.hasDependencies=jf(`line`,this.layers,n)||this.hasLineDasharray(this.layers);let a=this.layers[0].layout.get(`line-sort-key`),o=!a.isConstant(),s=[];for(let{feature:n,id:c,index:l,sourceLayerIndex:u}of t){let t=this.layers[0]._featureFilter.needGeometry,d=vd(n,t);if(!this.layers[0]._featureFilter.filter(new U(this.zoom),d,r))continue;let f=o?a.evaluate(d,{},r):void 0,p={id:c,properties:n.properties,type:n.type,sourceLayerIndex:u,index:l,geometry:t?d.geometry:_d(n),patterns:{},dashes:{},sortKey:f};s.push(p)}o&&s.sort((t,n)=>t.sortKey-n.sortKey);for(let a of s){let{geometry:o,index:s,sourceLayerIndex:c}=a;this.hasDependencies?(jf(`line`,this.layers,n)?Mf(`line`,this.layers,a,{zoom:this.zoom},n):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,a,this.zoom,n),this.patternFeatures.push(a)):this.addFeature(a,o,s,r,{},{},n.subdivisionGranularity);let l=t[s].feature;n.featureIndex.insert(l,o,s,c,this.index)}}update(t,n,r,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,n,this.stateDependentLayers,{imagePositions:r,dashPositions:a})}addFeatures(t,n,r,a){for(let o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,n,r,a,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,qh)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Gh),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.hasOwn(t.properties,`geojsonvt_clip_start`)&&Object.hasOwn(t.properties,`geojsonvt_clip_end`))return{start:+t.properties[Eh],end:+t.properties[Dh]}}addFeature(t,n,r,a,o,s,c){let l=this.layers[0].layout,u=l.get(`line-join`).evaluate(t,{}),d=l.get(`line-cap`).evaluate(t,{}),f=l.get(`line-miter-limit`).evaluate(t,{}),p=l.get(`line-round-limit`).evaluate(t,{});this.lineClips=this.lineFeatureClips(t);for(let r of n)this.addLine(r,t,u,d,f,p,a,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{imagePositions:o,dashPositions:s,canonical:a})}addLine(t,n,r,a,o,s,c,l){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let u=c?l.line.getGranularityForZoomLevel(c.z):1;if(t=Pp(t,u),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let n=0;n=2&&t[f-1].equals(t[f-2]);)f--;let p=0;for(;p0;if(C&&n>p){let t=g.dist(_);if(t>2*m){let n=g.sub(g.sub(_)._mult(m/t)._round());this.updateDistance(_,n),this.addCurrentVertex(n,y,0,0,h),_=n}}let T=_&&v,E=T?r:d?`butt`:a;if(T&&E===`round`&&(xo&&(E=`bevel`),E===`bevel`&&(x>2&&(E=`flipbevel`),x100)c=b.mult(-1);else{let t=x*y.add(b).mag()/y.sub(b).mag();c._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(g,c,0,0,h),this.addCurrentVertex(g,c.mult(-1),0,0,h)}else if(E===`bevel`||E===`fakeround`){let t=-Math.sqrt(x*x-1),n=w?t:0,r=w?0:t;if(_&&this.addCurrentVertex(g,y,n,r,h),E===`fakeround`){let t=Math.round(S*180/Math.PI/20);for(let n=1;n2*m){let n=g.add(v.sub(g)._mult(m/t)._round());this.updateDistance(g,n),this.addCurrentVertex(n,b,0,0,h),g=n}}}}addCurrentVertex(t,n,r,a,o,s=!1){let c=n.x+n.y*r,l=n.y-n.x*r,u=-n.x+n.y*a,d=-n.y-n.x*a;this.addHalfVertex(t,c,l,s,!1,r,o),this.addHalfVertex(t,u,d,s,!0,-a,o),this.distance>Zh/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,n,r,a,o,s))}addHalfVertex({x:t,y:n},r,a,o,s,c,l){let u=(this.lineClips?this.scaledDistance*(Zh-1):this.scaledDistance)*Xh;if(this.layoutVertexArray.emplaceBack((t<<1)+ +!!o,(n<<1)+ +!!s,Math.round(63*r)+128,Math.round(63*a)+128,(c===0?0:c<0?-1:1)+1|(u&63)<<2,u>>6),this.lineClips){let t=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(t,this.lineClipsArray.length)}let d=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,d,this.e2),l.primitiveLength++),s?this.e2=d:this.e1=d}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,n){this.distance+=t.dist(n),this.updateScaledDistance()}hasLineDasharray(t){for(let n of t){let t=n.paint.get(`line-dasharray`);if(t&&!t.isConstant())return!0}return!1}addLineDashDependencies(t,n,r,a){for(let o of t){let t=o.paint.get(`line-dasharray`);if(!t||t.value.kind===`constant`)continue;let s=o.layout.get(`line-cap`).evaluate(n,{})===`round`,c={dasharray:t.value.evaluate({zoom:r-1},n,{}),round:s},l={dasharray:t.value.evaluate({zoom:r},n,{}),round:s},u={dasharray:t.value.evaluate({zoom:r+1},n,{}),round:s},d=`${c.dasharray.join(`,`)},${c.round}`,f=`${l.dasharray.join(`,`)},${l.round}`,p=`${u.dasharray.join(`,`)},${u.round}`;a.dashDependencies[d]=c,a.dashDependencies[f]=l,a.dashDependencies[p]=u,n.dashes[o.id]={min:d,mid:f,max:p}}}};J(`LineBucket`,Yh,{omit:[`layers`,`patternFeatures`]});let Qh;const $h=()=>Qh||=new gl({"line-cap":new G(P.layout_line[`line-cap`],`line-cap`),"line-join":new G(P.layout_line[`line-join`],`line-join`),"line-miter-limit":new G(P.layout_line[`line-miter-limit`],`line-miter-limit`),"line-round-limit":new G(P.layout_line[`line-round-limit`],`line-round-limit`),"line-sort-key":new G(P.layout_line[`line-sort-key`],`line-sort-key`)});let eg;const ng=()=>eg||=new gl({"line-opacity":new G(P.paint_line[`line-opacity`],`line-opacity`),"line-layer-opacity":new W(P.paint_line[`line-layer-opacity`],`line-layer-opacity`),"line-color":new G(P.paint_line[`line-color`],`line-color`),"line-translate":new W(P.paint_line[`line-translate`],`line-translate`),"line-translate-anchor":new W(P.paint_line[`line-translate-anchor`],`line-translate-anchor`),"line-width":new G(P.paint_line[`line-width`],`line-width`),"line-gap-width":new G(P.paint_line[`line-gap-width`],`line-gap-width`),"line-offset":new G(P.paint_line[`line-offset`],`line-offset`),"line-blur":new G(P.paint_line[`line-blur`],`line-blur`),"line-dasharray":new pl(P.paint_line[`line-dasharray`],`line-dasharray`),"line-pattern":new pl(P.paint_line[`line-pattern`],`line-pattern`),"line-gradient":new hl(P.paint_line[`line-gradient`],`line-gradient`)});var rg={get paint(){return ng()},get layout(){return $h()}},tg=class extends G{possiblyEvaluate(t,n){return n=new U(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),super.possiblyEvaluate(t,n)}evaluate(t,n,r,a){return n=xt({},n,{zoom:Math.floor(n.zoom)}),super.evaluate(t,n,r,a)}};let ag;const og=t=>t.type===`line`;var ig=class extends yl{constructor(t,n){super(t,rg,n),this.gradientVersion=0,ag||(ag=new tg(rg.paint.properties[`line-width`].specification,`line-floorwidth`),ag.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t===`line-gradient`){let t=this.gradientExpression();Jo(t)?this.stepInterpolant=t._styleExpression.expression instanceof Ci:this.stepInterpolant=!1,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values[`line-gradient`].value.expression}recalculate(t,n){super.recalculate(t,n),this.paint._values[`line-floorwidth`]=ag.possiblyEvaluate(this._transitioningPaint._values[`line-width`].value,t)}createBucket(t){return new Yh(t)}queryRadius(t){let n=t,r=sg(Fd(`line-width`,this,n),Fd(`line-gap-width`,this,n)),a=Fd(`line-offset`,this,n);return r/2+Math.abs(a)+Id(this.paint.get(`line-translate`))}queryIntersectsFeature({queryGeometry:t,feature:n,featureState:r,geometry:a,transform:o,pixelsToTileUnits:s}){let c=Ld(t,this.paint.get(`line-translate`),this.paint.get(`line-translate-anchor`),-o.bearingInRadians,s),l=s/2*sg(this.paint.get(`line-width`).evaluate(n,r),this.paint.get(`line-gap-width`).evaluate(n,r)),u=this.paint.get(`line-offset`).evaluate(n,r);return u&&(a=zd(a,u*s)),Td(c,a,l)}isTileClipped(){return!0}};function sg(t,n){return n>0?n+2*t:t}const cg=Dl([{name:`a_pos_offset`,components:4,type:`Int16`},{name:`a_data`,components:4,type:`Uint16`},{name:`a_pixeloffset`,components:4,type:`Int16`}],4),lg=Dl([{name:`a_projected_pos`,components:3,type:`Float32`}],4);Dl([{name:`a_fade_opacity`,components:1,type:`Uint32`}],4);const ug=Dl([{name:`a_placed`,components:2,type:`Uint8`},{name:`a_shift`,components:2,type:`Float32`},{name:`a_box_real`,components:2,type:`Int16`}]);Dl([{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 dg=Dl([{name:`a_pos`,components:2,type:`Int16`},{name:`a_anchor_pos`,components:2,type:`Int16`},{name:`a_extrude`,components:2,type:`Int16`}],4),fg=Dl([{name:`a_pos`,components:2,type:`Float32`},{name:`a_radius`,components:1,type:`Float32`},{name:`a_flags`,components:2,type:`Int16`}],4);Dl([{name:`triangle`,components:3,type:`Uint16`}]),Dl([{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`}]),Dl([{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`}]),Dl([{type:`Float32`,name:`offsetX`}]),Dl([{type:`Int16`,name:`x`},{type:`Int16`,name:`y`},{type:`Int16`,name:`tileUnitDistanceFromAnchor`}]),Dl([{type:`Uint16`,name:`textAnchor`},{type:`Float32`,components:2,name:`textOffset`}]);function pg(t,n,r){let a=n.layout.get(`text-transform`).evaluate(r,{});return a===`uppercase`?t=t.toLocaleUpperCase():a===`lowercase`&&(t=t.toLocaleLowerCase()),nl.applyArabicShaping&&(t=nl.applyArabicShaping(t)),t}function mg(t,n,r){for(let a of t.sections)a.text=pg(a.text,n,r);return t}function hg(t){let n={},r={},a=[],o=0;function s(n){a.push(t[n]),o++}function c(t,n,o){let s=r[t];return delete r[t],r[n]=s,a[s].geometry[0].pop(),a[s].geometry[0]=a[s].geometry[0].concat(o[0]),s}function l(t,r,o){let s=n[r];return delete n[r],n[t]=s,a[s].geometry[0].shift(),a[s].geometry[0]=o[0].concat(a[s].geometry[0]),s}function u(t,n,r){let a=r?n[0][n[0].length-1]:n[0][0];return`${t}:${a.x}:${a.y}`}for(let d=0;dt.geometry)}const gg={"!":`︕`,"#":`#`,$:`$`,"%":`%`,"&":`&`,"(":`︵`,")":`︶`,"*":`*`,"+":`+`,",":`︐`,"-":`︲`,".":`・`,"/":`/`,":":`︓`,";":`︔`,"<":`︿`,"=":`=`,">":`﹀`,"?":`︖`,"@":`@`,"[":`﹇`,"\\":`\`,"]":`﹈`,"^":`^`,_:`︳`,"`":```,"{":`︷`,"|":`―`,"}":`︸`,"~":`~`,"¢":`¢`,"£":`£`,"¥":`¥`,"¦":`¦`,"¬":`¬`,"¯":` ̄`,"–":`︲`,"—":`︱`,"‘":`﹃`,"’":`﹄`,"“":`﹁`,"”":`﹂`,"…":`︙`,"⋯":`︙`,"‧":`・`,"₩":`₩`,"、":`︑`,"。":`︒`,"〈":`︿`,"〉":`﹀`,"《":`︽`,"》":`︾`,"「":`﹁`,"」":`﹂`,"『":`﹃`,"』":`﹄`,"【":`︻`,"】":`︼`,"〔":`︹`,"〕":`︺`,"〖":`︗`,"〗":`︘`,"!":`︕`,"(":`︵`,")":`︶`,",":`︐`,"-":`︲`,".":`・`,":":`︓`,";":`︔`,"<":`︿`,">":`﹀`,"?":`︖`,"[":`﹇`,"]":`﹈`,"_":`︳`,"{":`︷`,"|":`―`,"}":`︸`,"⦅":`︵`,"⦆":`︶`,"。":`︒`,"「":`﹁`,"」":`﹂`};function _g(t){let n=``,r={premature:!0,value:void 0},a=t[Symbol.iterator](),o=a.next(),s=t[Symbol.iterator]();s.next();let c=s.next();for(;!o.done;)(c.done||!Yc(c.value.codePointAt(0))||gg[c.value])&&(r.premature||!Yc(r.value.codePointAt(0))||gg[r.value])&&gg[o.value]?n+=gg[o.value]:n+=o.value,r={value:o.value,premature:!1},o=a.next(),c=s.next();return n}const vg={10:!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},yg={40:!0};function bg(t,n,r,a,o,s){if(`fontStack`in n){let a=r[n.fontStack]?.[t];return a?a.metrics.advance*n.scale+o:0}else{let t=a[n.imageName];return t?t.displaySize[0]*n.scale*24/s+o:0}}function xg(t,n,r,a){let o=(t-n)**2;return a?tMath.max(t,this.sections[n].scale),0)}getMaxImageSize(t){let n=0,r=0;for(let a=0;ar))}addImageSection(t){let n=t.image?t.image.name:``;if(n.length===0){Ft(`Can't add FormattedSection with an empty image.`);return}let r=this.getNextImageSectionCharCode();if(!r){Ft(`Reached maximum number of images 6401`);return}this.text+=String.fromCharCode(r),this.sections.push({scale:1,verticalAlign:t.verticalAlign||`bottom`,imageName:n}),this.sectionIndex.push(this.sections.length-1)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,n,r,a,o){let s=[],c=this.determineAverageLineWidth(t,n,r,a,o),l=this.hasZeroWidthSpaces(),u=0,d=0,f=this.text[Symbol.iterator](),p=f.next(),m=this.text[Symbol.iterator]();m.next();let h=m.next(),g=this.text[Symbol.iterator]();g.next(),g.next();let _=g.next();for(;!p.done;){let n=this.getSection(d),v=p.value.codePointAt(0);if(Uc(v)||(u+=bg(v,n,r,a,t,o)),!h.done){let t=zc(v),r=h.value.codePointAt(0);(vg[v]||t||`imageName`in n||!_.done&&yg[r])&&s.push(Cg(d+1,u,c,s,Sg(v,r,t&&l),!1))}d++,p=f.next(),h=m.next(),_=g.next()}return wg(Cg(this.length(),u,c,s,0,!0))}determineAverageLineWidth(t,n,r,a,o){let s=0,c=0;for(let n of this.text){let l=this.getSection(c);s+=bg(n.codePointAt(0),l,r,a,t,o),c++}let l=Math.max(1,Math.ceil(s/n));return s/l}};const Eg=65536*65536,kg=1/Eg,Ag=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`);var Dg=class{constructor(t){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),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(t,n,r=this.length){let a;for(;a=this.nextField(r);)t(a,n,this);return n}readMessage(t,n){return this.readFields(t,n,this.readVarint()+this.pos)}readFixed32(){let t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){let t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Eg;return this.pos+=8,t}readSFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Eg;return this.pos+=8,t}readFloat(){let t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){let t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){let n=this.buf,r=n[this.pos++];if(r<128)return r;let a=r&127,o;return o=n[this.pos++],a|=(o&127)<<7,o<128||(o=n[this.pos++],a|=(o&127)<<14,o<128)||(o=n[this.pos++],a|=(o&127)<<21,o<128)?a:(o=n[this.pos],a|=(o&15)<<28,jg(a,t,this))}readSVarint(){let t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){let t=this.readVarint()+this.pos,n=this.pos;return this.pos=t,t-n>=12&&Ag?Ag.decode(this.buf.subarray(n,t)):Kg(this.buf,n,t)}readBytes(){let t=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,t);return this.pos=t,n}readPackedVarint(t=[],n){let r=this.readPackedEnd();for(;this.pos=t)return 0;let n=this.readVarint();return this.type=n&7,this._valueStart=this.pos,n>>>3}skip(t){let n=t&7;if(n===0)for(;this.buf[this.pos++]>127;);else if(n===2)this.pos=this.readVarint()+this.pos;else if(n===5)this.pos+=4;else if(n===1)this.pos+=8;else throw Error(`Unimplemented type: ${n}`)}},Og=class{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.length=this.buf.length}writeTag(t,n){this.writeVarint(t<<3|n)}realloc(t){let n=this.length||16;for(;n=0&&t<128){this.pos>=this.length&&this.realloc(1),this.buf[this.pos++]=t;return}if(t>268435455||t<0){Ng(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))}writeSVarint(t){this.writeVarint(t<0?-t*2-1:t*2)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(t.length*4),this.pos++;let n=this.pos;this.pos=qg(this.buf,t,this.pos);let r=this.pos-n;r>=128&&Ig(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){let n=t.length;this.writeVarint(n),this.realloc(n),this.buf.set(t,this.pos),this.pos+=n}writeRawMessage(t,n){this.pos++;let r=this.pos;t(n,this);let a=this.pos-r;a>=128&&Ig(r,a,this),this.pos=r-1,this.writeVarint(a),this.pos+=a}writeMessage(t,n,r){this.writeTag(t,2),this.writeRawMessage(n,r)}writePackedVarint(t,n){n.length&&this.writeMessage(t,Lg,n)}writePackedSVarint(t,n){n.length&&this.writeMessage(t,Rg,n)}writePackedBoolean(t,n){n.length&&this.writeMessage(t,Vg,n)}writePackedFloat(t,n){n.length&&this.writeMessage(t,zg,n)}writePackedDouble(t,n){n.length&&this.writeMessage(t,Bg,n)}writePackedFixed32(t,n){n.length&&this.writeMessage(t,Hg,n)}writePackedSFixed32(t,n){n.length&&this.writeMessage(t,Ug,n)}writePackedFixed64(t,n){n.length&&this.writeMessage(t,Wg,n)}writePackedSFixed64(t,n){n.length&&this.writeMessage(t,Gg,n)}writeBytesField(t,n){this.writeTag(t,2),this.writeBytes(n)}writeFixed32Field(t,n){this.writeTag(t,5),this.writeFixed32(n)}writeSFixed32Field(t,n){this.writeTag(t,5),this.writeSFixed32(n)}writeFixed64Field(t,n){this.writeTag(t,1),this.writeFixed64(n)}writeSFixed64Field(t,n){this.writeTag(t,1),this.writeSFixed64(n)}writeVarintField(t,n){this.writeTag(t,0),this.writeVarint(n)}writeSVarintField(t,n){this.writeTag(t,0),this.writeSVarint(n)}writeStringField(t,n){this.writeTag(t,2),this.writeString(n)}writeFloatField(t,n){this.writeTag(t,5),this.writeFloat(n)}writeDoubleField(t,n){this.writeTag(t,1),this.writeDouble(n)}writeBooleanField(t,n){this.writeVarintField(t,+n)}};function jg(t,n,r){let a=r.buf,o,s;if(s=a[r.pos++],o=(s&112)>>4,s<128||(s=a[r.pos++],o|=(s&127)<<3,s<128)||(s=a[r.pos++],o|=(s&127)<<10,s<128)||(s=a[r.pos++],o|=(s&127)<<17,s<128)||(s=a[r.pos++],o|=(s&127)<<24,s<128)||(s=a[r.pos++],o|=(s&1)<<31,s<128))return Mg(t,o,n);throw Error(`Expected varint not more than 10 bytes`)}function Mg(t,n,r){return r?n*4294967296+(t>>>0):(n>>>0)*4294967296+(t>>>0)}function Ng(t,n){let r,a;if(t>=0?(r=t%4294967296|0,a=t/4294967296|0):(r=~(-t%4294967296),a=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,a=a+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw Error(`Given varint doesn't fit into 10 bytes`);n.realloc(10),Pg(r,a,n),Fg(a,n)}function Pg(t,n,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function Fg(t,n){let r=(t&7)<<4;n.buf[n.pos++]|=r|((t>>>=3)?128:0),t&&(n.buf[n.pos++]=t&127|((t>>>=7)?128:0),t&&(n.buf[n.pos++]=t&127|((t>>>=7)?128:0),t&&(n.buf[n.pos++]=t&127|((t>>>=7)?128:0),t&&(n.buf[n.pos++]=t&127|((t>>>=7)?128:0),t&&(n.buf[n.pos++]=t&127)))))}function Ig(t,n,r){let a=n<=16383?1:n<=2097151?2:n<=268435455?3:Math.floor(Math.log(n)/(Math.LN2*7));r.realloc(a),r.buf.copyWithin(t+a,t,r.pos)}function Lg(t,n){let r=t.length,a=n.buf,o=n.pos,s=n.length;for(let c=0;cs){n.pos=o,n.writeVarint(r),a=n.buf,o=n.pos,s=n.length;continue}for(;r>127;)a[o++]=r%128|128,r=Math.floor(r/128);a[o++]=r}n.pos=o}function Rg(t,n){for(let r=0;r239?4:n>223?3:n>191?2:1;if(o+c>r)break;let l,u,d;c===1?n<128&&(s=n):c===2?(l=t[o+1],(l&192)==128&&(s=(n&31)<<6|l&63,s<=127&&(s=null))):c===3?(l=t[o+1],u=t[o+2],(l&192)==128&&(u&192)==128&&(s=(n&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):c===4&&(l=t[o+1],u=t[o+2],d=t[o+3],(l&192)==128&&(u&192)==128&&(d&192)==128&&(s=(n&15)<<18|(l&63)<<12|(u&63)<<6|d&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,c=1):s>65535&&(s-=65536,a+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),a+=String.fromCharCode(s),o+=c}return a}function qg(t,n,r){for(let a=0,o,s;a55295&&o<57344)if(s)if(o<56320){t[r++]=239,t[r++]=191,t[r++]=189,s=o;continue}else o=s-55296<<10|o-56320|65536,s=null;else{o>56319||a+1===n.length?(t[r++]=239,t[r++]=191,t[r++]=189):s=o;continue}else s&&=(t[r++]=239,t[r++]=191,t[r++]=189,null);o<128?t[r++]=o:(o<2048?t[r++]=o>>6|192:(o<65536?t[r++]=o>>12|224:(t[r++]=o>>18|240,t[r++]=o>>12&63|128),t[r++]=o>>6&63|128),t[r++]=o&63|128)}return r}function Jg(t,n,r){t===1&&r.readMessage(Yg,n)}function Yg(t,n,r){if(t===3){let{id:t,bitmap:a,width:o,height:s,left:c,top:l,advance:u}=r.readMessage(Xg,{});n.push({id:t,bitmap:new cf({width:o+6,height:s+6},a),metrics:{width:o,height:s,left:c,top:l,advance:u}})}}function Xg(t,n,r){t===1?n.id=r.readVarint():t===2?n.bitmap=r.readBytes():t===3?n.width=r.readVarint():t===4?n.height=r.readVarint():t===5?n.left=r.readSVarint():t===6?n.top=r.readSVarint():t===7&&(n.advance=r.readVarint())}function Zg(t){return new Dg(t).readFields(Jg,[])}function e_(t){let{userImage:n}=t;return n?.render&&n.render()?(t.data.replace(new Uint8Array(n.data.buffer)),!0):!1}function t_(t){let n=0,r=0;for(let a of t)n+=a.w*a.h,r=Math.max(r,a.w);t.sort((t,n)=>n.h-t.h);let a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),r),h:1/0}],o=0,s=0;for(let n of t)for(let t=a.length-1;t>=0;t--){let r=a[t];if(!(n.w>r.w||n.h>r.h)){if(n.x=r.x,n.y=r.y,s=Math.max(s,n.y+n.h),o=Math.max(o,n.x+n.w),n.w===r.w&&n.h===r.h){let n=a.pop();n&&t_.toCodeUnitIndex(t));let t=b(_.toString(),y);for(let n of t){let t=[...n].map(()=>0);v.push(new Tg(n,_.sections,t))}}else if(x){v=[],y=y.map(t=>_.toCodeUnitIndex(t));let t=0,n=[];for(let r of _.text)n.push(...Array(r.length).fill(_.sectionIndex[t])),t++;let r=x(_.text,n,y);for(let t of r){let n=[],r=``;for(let a of t[0])n.push(t[1][r.length]),r+=a;v.push(new Tg(t[0],_.sections,n))}}else v=i_(_,y);let S=[],C={positionedLines:S,text:_.toString(),top:f[1],bottom:f[1],left:f[0],right:f[0],writingMode:p,iconsInText:!1,verticalizable:!1};return d_(C,n,r,a,v,c,l,u,p,d,m,g),!r_(S)&&C}function o_(t){let n=.5,r=.5;switch(t){case`right`:case`top-right`:case`bottom-right`:n=1;break;case`left`:case`top-left`:case`bottom-left`:n=0;break}switch(t){case`bottom`:case`bottom-right`:case`bottom-left`:r=1;break;case`top`:case`top-right`:case`top-left`:r=0;break}return{horizontalAlign:n,verticalAlign:r}}function s_(t,n,r){let a=n.getMaxScale()*24,{maxImageWidth:o,maxImageHeight:s}=n.getMaxImageSize(t),c=Math.max(a,s*r);return{verticalLineContentWidth:Math.max(a,o*r),horizontalLineContentHeight:c}}function c_(t){switch(t){case`top`:return 0;case`center`:return .5;default:return 1}}function l_(t,n,r,a){if(t?.rect)return t;let o=n[r.fontStack]?.[a];return o?{rect:null,metrics:o.metrics}:null}function u_(t,n,r){return!(t===1||!n&&!Bc(r)||n&&(Uc(r)||Xc(r)))}function d_(t,n,r,a,o,s,c,l,u,d,f,p){let m=0,h=0,g=0,_=0,v=l===`right`?1:l===`left`?0:.5,y=24/p,b=0;for(let c of o){c.trim();let o=c.getMaxScale(),l={positionedGlyphs:[],lineOffset:0};t.positionedLines[b]=l;let p=l.positionedGlyphs,x=0;if(!c.length()){h+=s,++b;continue}let S=s_(a,c,y),C=0;for(let s of c.text){let l=c.getSection(C),g=s.codePointAt(0),_=u_(u,f,g),v={glyph:g,imageName:null,x:m,y:h+-17,vertical:_,scale:1,fontStack:``,sectionIndex:c.getSectionIndex(C),metrics:null,rect:null},b;if(`fontStack`in l){if(b=f_(l,g,_,S,n,r),!b)continue;v.fontStack=l.fontStack}else{if(t.iconsInText=!0,l.scale*=y,b=p_(l,_,o,S,a),!b)continue;x=Math.max(x,b.imageOffset),v.imageName=l.imageName}let{rect:w,metrics:T,baselineOffset:E}=b;if(v.y+=E,v.scale=l.scale,v.metrics=T,v.rect=w,p.push(v),!_)m+=T.advance*l.scale+d;else{t.verticalizable=!0;let n=`imageName`in l?T.advance:24;m+=n*l.scale+d}C++}if(p.length!==0){let t=m-d;g=Math.max(t,g),m_(p,0,p.length-1,v)}m=0;let w=(o-1)*24;l.lineOffset=Math.max(x,w);let T=s*o+x;h+=T,_=Math.max(T,_),++b}let{horizontalAlign:x,verticalAlign:S}=o_(c);h_(t.positionedLines,v,x,S,g,_,s,h,o.length),t.top+=-S*h,t.bottom=t.top+h,t.left+=-x*g,t.right=t.left+g}function f_(t,n,r,a,o,s){let c=s[t.fontStack]?.[n],l=l_(c,o,t,n);if(l===null)return null;let u;if(r)u=a.verticalLineContentWidth-t.scale*24;else{let n=c_(t.verticalAlign);u=(a.horizontalLineContentHeight-t.scale*24)*n}return{rect:l.rect,metrics:l.metrics,baselineOffset:u}}function p_(t,n,r,a,o){let s=o[t.imageName];if(!s)return null;let c=s.paddedRect,l=s.displaySize,u={width:l[0],height:l[1],left:1,top:-3,advance:n?l[1]:l[0]},d;if(n)d=a.verticalLineContentWidth-l[1]*t.scale;else{let n=c_(t.verticalAlign);d=(a.horizontalLineContentHeight-l[1]*t.scale)*n}let f=(n?l[0]:l[1])*t.scale-24*r;return{rect:c,metrics:u,baselineOffset:d,imageOffset:f}}function m_(t,n,r,a){if(a===0)return;let o=t[r],s=o.metrics.advance*o.scale,c=(t[r].x+s)*a;for(let a=n;a<=r;a++)t[a].x-=c}function h_(t,n,r,a,o,s,c,l,u){let d=(n-r)*o,f=0;f=s===c?-a*u*c+.5*c:-l*a- -17;for(let n of t)for(let t of n.positionedGlyphs)t.x+=d,t.y+=f}function g_(t,n,r){let{horizontalAlign:a,verticalAlign:o}=o_(r),s=n[0],c=n[1],l=s-t.displaySize[0]*a,u=l+t.displaySize[0],d=c-t.displaySize[1]*o;return{image:t,top:d,bottom:d+t.displaySize[1],left:l,right:u}}function __(t){let n=t.left,r=t.top,a=t.right-n,o=t.bottom-r,s=t.image.content[2]-t.image.content[0],c=t.image.content[3]-t.image.content[1],l=t.image.textFitWidth??`stretchOrShrink`,u=t.image.textFitHeight??`stretchOrShrink`,d=s/c;if(u===`proportional`){if(l===`stretchOnly`&&a/od){let t=Math.ceil(a/d);r*=t/o,o=t}return{x1:n,y1:r,x2:n+a,y2:r+o}}function v_(t,n,r,a,o,s){let c=t.image,l;if(c.content){let t=c.content,n=c.pixelRatio||1;l=[t[0]/n,t[1]/n,c.displaySize[0]-t[2]/n,c.displaySize[1]-t[3]/n]}let u=n.left*s,d=n.right*s,f,p,m,h;r===`width`||r===`both`?(h=o[0]+u-a[3],p=o[0]+d+a[1]):(h=o[0]+(u+d-c.displaySize[0])/2,p=h+c.displaySize[0]);let g=n.top*s,_=n.bottom*s;return r===`height`||r===`both`?(f=o[1]+g-a[0],m=o[1]+_+a[2]):(f=o[1]+(g+_-c.displaySize[1])/2,m=f+c.displaySize[1]),{image:c,top:f,right:p,bottom:m,left:h,collisionPadding:l}}const y_=32640;function b_(t,n){let{expression:r}=n;if(r.kind===`constant`)return{kind:`constant`,layoutSize:r.evaluate(new U(t+1))};if(r.kind===`source`)return{kind:`source`};{let{zoomStops:n,interpolationType:a}=r,o=0;for(;ot.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];let n=this.layers[0]._unevaluatedLayout._values;this.textSizeData=b_(this.zoom,n[`text-size`]),this.iconSizeData=b_(this.zoom,n[`icon-size`]);let r=this.layers[0].layout,a=r.get(`symbol-sort-key`),o=r.get(`symbol-z-order`);this.canOverlap=C_(r,`text-overlap`,`text-allow-overlap`)!==`never`||C_(r,`icon-overlap`,`icon-allow-overlap`)!==`never`||r.get(`text-ignore-placement`)||r.get(`icon-ignore-placement`),this.sortFeaturesByKey=o!==`viewport-y`&&!a.isConstant();let s=o===`viewport-y`||o===`auto`&&!this.sortFeaturesByKey;this.sortFeaturesByY=s&&this.canOverlap,r.get(`symbol-placement`)===`point`&&(this.writingModes=r.get(`text-writing-mode`).map(t=>n_[t])),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.sourceID=t.sourceID}createArrays(){this.text=new E_(new ud(this.layers,this.zoom,t=>t.startsWith(`text`))),this.icon=new E_(new ud(this.layers,this.zoom,t=>t.startsWith(`icon`))),this.glyphOffsetArray=new au,this.lineVertexArray=new ou,this.symbolInstances=new iu,this.textAnchorOffsets=new cu}calculateGlyphDependencies(t,n,r,a,o){for(let s of t)if(n[s.codePointAt(0)]=!0,(r||a)&&o){let t=gg[s];t&&(n[t.codePointAt(0)]=!0)}}populate(t,n,r){let a=this.layers[0],o=a.layout,s=o.get(`text-font`),c=o.get(`text-field`),l=o.get(`icon-image`),u=(c.value.kind!==`constant`||c.value.value instanceof Jr&&!c.value.value.isEmpty()||c.value.value.toString().length>0)&&(s.value.kind!==`constant`||s.value.value.length>0),d=l.value.kind!==`constant`||!!l.value.value||Object.keys(l.parameters).length>0,f=o.get(`symbol-sort-key`);if(this.features=[],!u&&!d)return;let p=n.iconDependencies,m=n.glyphDependencies,h=n.availableImages,g=new U(this.zoom);for(let{feature:n,id:c,index:l,sourceLayerIndex:_}of t){let t=a._featureFilter.needGeometry,v=vd(n,t);if(!a._featureFilter.filter(g,v,r))continue;t||(v.geometry=_d(n));let y;if(u){let t=a.getValueAndResolveTokens(`text-field`,v,r,h),n=Jr.factory(t);this.hasRTLText||=A_(n),(!this.hasRTLText||nl.getRTLTextPluginStatus()===`unavailable`||this.hasRTLText&&nl.isParsed())&&(y=mg(n,a,v))}let b;if(d){let t=a.getValueAndResolveTokens(`icon-image`,v,r,h);b=t instanceof ei?t:ei.fromString(t)}if(!y&&!b)continue;let x=this.sortFeaturesByKey?f.evaluate(v,{},r):void 0,S={id:c,text:y,icon:b,index:l,sourceLayerIndex:_,geometry:v.geometry,properties:n.properties,type:Zp.types[n.type],sortKey:x};if(this.features.push(S),b&&(p[b.name]=!0),y){let t=s.evaluate(v,{},r).join(`,`),n=o.get(`text-rotation-alignment`)!==`viewport`&&o.get(`symbol-placement`)!==`point`;this.allowVerticalPlacement=this.writingModes?.includes(2);for(let r of y.sections)if(r.image)p[r.image.name]=!0;else{let a=Wc(y.toString()),o=r.fontStack||t;m[o]||={},this.calculateGlyphDependencies(r.text,m[o],n,this.allowVerticalPlacement,a)}}}o.get(`symbol-placement`)===`line`&&(this.features=hg(this.features)),this.sortFeaturesByKey&&this.features.sort((t,n)=>t.sortKey-n.sortKey)}update(t,n,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,n,this.layers,{imagePositions:r}),this.icon.programConfigurations.updatePaintArrays(t,n,this.layers,{imagePositions:r}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,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(t,n){let r=this.lineVertexArray.length;if(t.segment!==void 0){let r=t.dist(n[t.segment+1]),a=t.dist(n[t.segment]),o={};for(let a=t.segment+1;a=0;r--)o[r]={x:n[r].x,y:n[r].y,tileUnitDistanceFromAnchor:a},r>0&&(a+=n[r-1].dist(n[r]));for(let t=0;t0}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(t,n){let r=t.placedSymbolArray.get(n),a=r.vertexStartIndex+r.numGlyphs*4;for(let n=r.vertexStartIndex;na[t]-a[n]||o[n]-o[t]),s}addToSortKeyRanges(t,n){let r=this.sortKeyRanges[this.sortKeyRanges.length-1];r?.sortKey===n?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:n,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let t of this.symbolInstanceIndexes){let n=this.symbolInstances.get(t);this.featureSortOrder.push(n.featureIndex);let r=[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex];for(let t=0;t=0&&r.indexOf(n)===t&&this.addIndicesForPlacedSymbol(this.text,n)}n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};J(`SymbolBucket`,O_,{omit:[`layers`,`collisionBoxArray`,`features`,`compareText`]}),O_.MAX_GLYPHS=65535,O_.addDynamicAttributes=k_;function j_(t,n){return n.replace(/{([^{}]+)}/g,(n,r)=>t&&r in t?String(t[r]):``)}let M_;const N_=()=>M_||=new gl({"symbol-placement":new W(P.layout_symbol[`symbol-placement`],`symbol-placement`),"symbol-spacing":new W(P.layout_symbol[`symbol-spacing`],`symbol-spacing`),"symbol-avoid-edges":new W(P.layout_symbol[`symbol-avoid-edges`],`symbol-avoid-edges`),"symbol-sort-key":new G(P.layout_symbol[`symbol-sort-key`],`symbol-sort-key`),"symbol-z-order":new W(P.layout_symbol[`symbol-z-order`],`symbol-z-order`),"icon-allow-overlap":new W(P.layout_symbol[`icon-allow-overlap`],`icon-allow-overlap`),"icon-overlap":new W(P.layout_symbol[`icon-overlap`],`icon-overlap`),"icon-ignore-placement":new W(P.layout_symbol[`icon-ignore-placement`],`icon-ignore-placement`),"icon-optional":new W(P.layout_symbol[`icon-optional`],`icon-optional`),"icon-rotation-alignment":new W(P.layout_symbol[`icon-rotation-alignment`],`icon-rotation-alignment`),"icon-size":new G(P.layout_symbol[`icon-size`],`icon-size`),"icon-text-fit":new W(P.layout_symbol[`icon-text-fit`],`icon-text-fit`),"icon-text-fit-padding":new W(P.layout_symbol[`icon-text-fit-padding`],`icon-text-fit-padding`),"icon-image":new G(P.layout_symbol[`icon-image`],`icon-image`),"icon-rotate":new G(P.layout_symbol[`icon-rotate`],`icon-rotate`),"icon-padding":new G(P.layout_symbol[`icon-padding`],`icon-padding`),"icon-keep-upright":new W(P.layout_symbol[`icon-keep-upright`],`icon-keep-upright`),"icon-offset":new G(P.layout_symbol[`icon-offset`],`icon-offset`),"icon-anchor":new G(P.layout_symbol[`icon-anchor`],`icon-anchor`),"icon-pitch-alignment":new W(P.layout_symbol[`icon-pitch-alignment`],`icon-pitch-alignment`),"text-pitch-alignment":new W(P.layout_symbol[`text-pitch-alignment`],`text-pitch-alignment`),"text-rotation-alignment":new W(P.layout_symbol[`text-rotation-alignment`],`text-rotation-alignment`),"text-field":new G(P.layout_symbol[`text-field`],`text-field`),"text-font":new G(P.layout_symbol[`text-font`],`text-font`),"text-size":new G(P.layout_symbol[`text-size`],`text-size`),"text-max-width":new G(P.layout_symbol[`text-max-width`],`text-max-width`),"text-line-height":new W(P.layout_symbol[`text-line-height`],`text-line-height`),"text-letter-spacing":new G(P.layout_symbol[`text-letter-spacing`],`text-letter-spacing`),"text-justify":new G(P.layout_symbol[`text-justify`],`text-justify`),"text-radial-offset":new G(P.layout_symbol[`text-radial-offset`],`text-radial-offset`),"text-variable-anchor":new W(P.layout_symbol[`text-variable-anchor`],`text-variable-anchor`),"text-variable-anchor-offset":new G(P.layout_symbol[`text-variable-anchor-offset`],`text-variable-anchor-offset`),"text-anchor":new G(P.layout_symbol[`text-anchor`],`text-anchor`),"text-max-angle":new W(P.layout_symbol[`text-max-angle`],`text-max-angle`),"text-writing-mode":new W(P.layout_symbol[`text-writing-mode`],`text-writing-mode`),"text-rotate":new G(P.layout_symbol[`text-rotate`],`text-rotate`),"text-padding":new W(P.layout_symbol[`text-padding`],`text-padding`),"text-keep-upright":new W(P.layout_symbol[`text-keep-upright`],`text-keep-upright`),"text-transform":new G(P.layout_symbol[`text-transform`],`text-transform`),"text-offset":new G(P.layout_symbol[`text-offset`],`text-offset`),"text-allow-overlap":new W(P.layout_symbol[`text-allow-overlap`],`text-allow-overlap`),"text-overlap":new W(P.layout_symbol[`text-overlap`],`text-overlap`),"text-ignore-placement":new W(P.layout_symbol[`text-ignore-placement`],`text-ignore-placement`),"text-optional":new W(P.layout_symbol[`text-optional`],`text-optional`)});let P_;const I_=()=>P_||=new gl({"icon-opacity":new G(P.paint_symbol[`icon-opacity`],`icon-opacity`),"icon-color":new G(P.paint_symbol[`icon-color`],`icon-color`),"icon-halo-color":new G(P.paint_symbol[`icon-halo-color`],`icon-halo-color`),"icon-halo-width":new G(P.paint_symbol[`icon-halo-width`],`icon-halo-width`),"icon-halo-blur":new G(P.paint_symbol[`icon-halo-blur`],`icon-halo-blur`),"icon-translate":new W(P.paint_symbol[`icon-translate`],`icon-translate`),"icon-translate-anchor":new W(P.paint_symbol[`icon-translate-anchor`],`icon-translate-anchor`),"text-opacity":new G(P.paint_symbol[`text-opacity`],`text-opacity`),"text-color":new G(P.paint_symbol[`text-color`],`text-color`,{runtimeType:er,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new G(P.paint_symbol[`text-halo-color`],`text-halo-color`),"text-halo-width":new G(P.paint_symbol[`text-halo-width`],`text-halo-width`),"text-halo-blur":new G(P.paint_symbol[`text-halo-blur`],`text-halo-blur`),"text-translate":new W(P.paint_symbol[`text-translate`],`text-translate`),"text-translate-anchor":new W(P.paint_symbol[`text-translate-anchor`],`text-translate-anchor`)});var L_={get paint(){return I_()},get layout(){return N_()}},F_=class{constructor(t){if(t.property.overrides===void 0)throw Error(`overrides must be provided to instantiate FormatSectionOverride class`);this.type=t.property.overrides?t.property.overrides.runtimeType:$n,this.defaultValue=t}evaluate(t){if(t.formattedSection){let n=this.defaultValue.property.overrides;if(n?.hasOverride(t.formattedSection))return n.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){if(!this.defaultValue.isConstant()){let n=this.defaultValue.value;t(n._styleExpression.expression)}}outputDefined(){return!1}serialize(){return null}};J(`FormatSectionOverride`,F_,{omit:[`defaultValue`]});const R_=t=>t.type===`symbol`;var z_=class e extends yl{constructor(t,n){super(t,L_,n)}recalculate(t,n){if(super.recalculate(t,n),this.layout.get(`icon-rotation-alignment`)===`auto`&&(this.layout.get(`symbol-placement`)===`point`?this.layout._values[`icon-rotation-alignment`]=`viewport`:this.layout._values[`icon-rotation-alignment`]=`map`),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`)),this.layout.get(`symbol-placement`)===`point`){let t=this.layout.get(`text-writing-mode`);if(t){let n=[];for(let r of t)n.includes(r)||n.push(r);this.layout._values[`text-writing-mode`]=n}else this.layout._values[`text-writing-mode`]=[`horizontal`]}this._setPaintOverrides()}getValueAndResolveTokens(t,n,r,a){let o=this.layout.get(t).evaluate(n,{},r,a),s=this._unevaluatedLayout._values[t];return!s.isDataDriven()&&!Wo(s.value)&&o?j_(n.properties,o):o}createBucket(t){return new O_(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error(`Should take a different path in FeatureIndex`)}_setPaintOverrides(){for(let t of L_.paint.overridableProperties){if(!e.hasPaintOverride(this.layout,t))continue;let n=this.paint.get(t),r=new Vo(new F_(n),`layers[${this.id}].paint.${n.property.name}`,n.property.specification),a=null;a=n.value.kind===`constant`||n.value.kind===`source`?new Ko(`source`,r):new qo(`composite`,r,n.value.zoomStops),this.paint._values[t]=new dl(n.property,a,n.parameters)}}_handleOverridablePaintPropertyUpdate(t,n,r){return!this.layout||n.isDataDriven()||r.isDataDriven()?!1:e.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,n){let r=t.get(`text-field`),a=L_.paint.properties[n],o=!1,s=t=>{for(let n of t)if(a.overrides?.hasOverride(n)){o=!0;return}};if(r.value.kind===`constant`&&r.value.value instanceof Jr)s(r.value.value.sections);else if(r.value.kind===`source`||r.value.kind===`composite`){let t=n=>{if(!o)if(n instanceof oi&&ii(n.value)===ar){let t=n.value;s(t.sections)}else n instanceof Zi?s(n.sections):n.eachChild(t)},n=r.value;n._styleExpression&&t(n._styleExpression.expression)}return o}};function B_(t,n,r,a=1){let o=t.get(`icon-padding`).evaluate(n,{},r)?.values;return[o[0]*a,o[1]*a,o[2]*a,o[3]*a]}let V_;const H_=()=>V_||=new gl({"background-color":new W(P.paint_background[`background-color`],`background-color`),"background-pattern":new ml(P.paint_background[`background-pattern`],`background-pattern`),"background-opacity":new W(P.paint_background[`background-opacity`],`background-opacity`)});var W_={get paint(){return H_()}};const G_=t=>t.type===`background`;var U_=class extends yl{constructor(t,n){super(t,W_,n)}};function q_(t){let n=[],r=t.id;return r===void 0&&n.push(new N(`layers.${r}`,null,`missing required property "id"`)),t.render===void 0&&n.push(new N(`layers.${r}`,null,`missing required method "render"`)),t.renderingMode&&t.renderingMode!==`2d`&&t.renderingMode!==`3d`&&n.push(new N(`layers.${r}`,null,`property "renderingMode" must be either "2d" or "3d"`)),n}const Y_=t=>t.type===`custom`;var K_=class extends yl{constructor(t,n){super(t,{},n),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}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 Z_(t,n){if(t.type===`custom`)return new K_(t,n);switch(t.type){case`background`:return new U_(t,n);case`circle`:return new Qd(t,n);case`color-relief`:return new Df(t,n);case`fill`:return new qp(t,n);case`fill-extrusion`:return new pm(t,n);case`heatmap`:return new pf(t,n);case`hillshade`:return new vf(t,n);case`line`:return new ig(t,n);case`raster`:return new wl(t,n);case`symbol`:return new z_(t,n)}}var J_=class{constructor(t){this._methodToThrottle=t,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}};const Q_={once:!0};var X_=class{constructor(t,n){this.target=t,this.mapId=n,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new J_(()=>this.process()),this.subscription=$t(this.target,`message`,t=>this.receive(t),!1),this.globalScope=zt(self)?t:window}registerMessageHandler(t,n){this.messageHandlers[t]=n}unregisterMessageHandler(t){delete this.messageHandlers[t]}sendAsync(t,n){return new Promise((r,a)=>{let o=Math.round(Math.random()*0xde0b6b3a7640000).toString(36).substring(0,10),s=n?$t(n.signal,`abort`,()=>{s?.unsubscribe(),delete this.resolveRejects[o];let r={id:o,type:``,origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(r),a(new mn(n.signal.reason))},Q_):null;this.resolveRejects[o]={resolve:t=>{s?.unsubscribe(),r(t)},reject:t=>{s?.unsubscribe(),a(t)}};let c=[],l={...t,id:o,sourceMapId:this.mapId,origin:location.origin,data:Fc(t.data,c)};this.target.postMessage(l,{transfer:c})})}receive(t){let n=t.data,r=n.id,a=[`file://`,`resource://android`,`null`],o=[n.origin,location.origin],s=n.origin===location.origin,c=o.some(t=>a.includes(t));if(!(!s&&!c)&&!(n.targetMapId&&this.mapId!==n.targetMapId)){if(n.type===``){delete this.tasks[r];let t=this.abortControllers[r];delete this.abortControllers[r],t&&t.abort();return}if(zt(self)||n.mustQueue){this.tasks[r]=n,this.taskQueue.push(r),this.invoker.trigger();return}this.processTask(r,n)}}process(){if(this.taskQueue.length===0)return;let t=this.taskQueue.shift(),n=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),n&&this.processTask(t,n)}async processTask(t,n){if(n.type===``){let r=this.resolveRejects[t];if(delete this.resolveRejects[t],!r)return;n.error?r.reject(Qe(Ic(n.error))):r.resolve(Ic(n.data));return}if(!this.messageHandlers[n.type]){this.completeTask(t,null,null);return}let r=Ic(n.data),a=new AbortController;this.abortControllers[t]=a;try{let o=await this.messageHandlers[n.type](n.sourceMapId,r,a);this.completeTask(t,null,o)}catch(n){this.completeTask(t,Qe(n))}}completeTask(t,n,r){let a=[];delete this.abortControllers[t];let o={id:t,type:``,sourceMapId:this.mapId,origin:location.origin,error:n?Fc(n):null,data:Fc(r,a)};this.target.postMessage(o,{transfer:a})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};const $_=6371008.8;var ev=class e{constructor(t,n){if(isNaN(t)||isNaN(n))throw Error(`Invalid LngLat object: (${t}, ${n})`);if(this.lng=+t,this.lat=+n,this.lat>90||this.lat<-90)throw Error(`Invalid LngLat latitude value: must be between -90 and 90`)}wrap(){return new e(bt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let n=Math.PI/180,r=this.lat*n,a=t.lat*n,o=Math.sin(r)*Math.sin(a)+Math.cos(r)*Math.cos(a)*Math.cos((t.lng-this.lng)*n);return $_*Math.acos(Math.min(o,1))}static convert(t){if(t instanceof e)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new e(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t==`object`&&t)return new e(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}};const tv=2*Math.PI*$_;function nv(t){return tv*Math.cos(t*Math.PI/180)}function rv(t){return(180+t)/360}function iv(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function av(t,n){return t/nv(n)}function ov(t){return t*360-180}function sv(t){let n=180-t*360;return 360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90}function cv(t,n){return t*nv(sv(n))}function lv(t){return 1/Math.cos(t*Math.PI/180)}var uv=class e{constructor(t,n,r=0){this.x=+t,this.y=+n,this.z=+r}static fromLngLat(t,n=0){let r=ev.convert(t);return new e(rv(r.lng),iv(r.lat),av(n,r.lat))}toLngLat(){return new ev(ov(this.x),sv(this.y))}toAltitude(){return cv(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/tv*lv(sv(this.y))}};function pv(t,n,r){return!(t<0||t>25||r<0||r>=2**t||n<0||n>=2**t)}function mv(t,n){let{x:r,y:a}=uv.fromLngLat(n);return!(t<0||t>25||a<0||a>=1||r<0||r>=1)}var dv=class{constructor(t,n,r){if(!pv(t,n,r))throw Error(`x=${n}, y=${r}, z=${t} outside of bounds. 0<=x<${2**t}, 0<=y<${2**t} 0<=z<=25 `);this.z=t,this.x=n,this.y=r,this.key=gv(0,t,t,n,r)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,n,r){let a=vv(this.x,this.y,this.z),o=bv(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(r===`tms`?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,n>1?`@2x`:``).replace(/{quadkey}/g,o).replace(/{bbox-epsg-3857}/g,a)}isChildOf(t){let n=this.z-t.z;return n>0&&t.x===this.x>>n&&t.y===this.y>>n}getTilePoint(t){let n=2**this.z;return new d((t.x*n-this.x)*Ye,(t.y*n-this.y)*Ye)}toString(){return`${this.z}/${this.x}/${this.y}`}},fv=class{constructor(t,n){this.wrap=t,this.canonical=n,this.key=gv(t,n.z,n.z,n.x,n.y)}},hv=class e{constructor(t,n,r,a,o){if(this.terrainRttPosMatrix32f=null,t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=n,this.canonical=new dv(r,+a,+o),this.key=gv(n,t,r,a,o)}clone(){return new e(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 n=this.canonical.z-t;return t>this.canonical.z?new e(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new e(t,this.wrap,t,this.canonical.x>>n,this.canonical.y>>n)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,n){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?gv(this.wrap*+n,t,this.canonical.z,this.canonical.x,this.canonical.y):gv(this.wrap*+n,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 n=this.canonical.z-t.canonical.z;return n<0?!1:t.canonical.x===this.canonical.x>>n&&t.canonical.y===this.canonical.y>>n}children(t){if(this.overscaledZ>=t)return[new e(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let n=this.canonical.z+1,r=this.canonical.x*2,a=this.canonical.y*2;return[new e(n,this.wrap,n,r,a),new e(n,this.wrap,n,r+1,a),new e(n,this.wrap,n,r,a+1),new e(n,this.wrap,n,r+1,a+1)]}isLessThan(t){return this.wrapt.wrap?!1:this.overscaledZt.overscaledZ?!1:this.canonical.xt.canonical.x?!1:this.canonical.y=0&&t=0&&n=u)return null;let f=this.canonical.x+a,p=this.wrap;return f<0?(p-=Math.ceil(-f/u),f=(f%u+u)%u):f>=u&&(p+=Math.floor(f/u),f%=u),{tileID:new e(this.overscaledZ,p,l,f,d),x:s,y:c}}};function gv(t,n,r,a,o){t*=2,t<0&&(t=t*-1-1);let s=1<0;o--){let t=1<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 n=new e;return n.extend(t(new d(this.minX,this.minY))),n.extend(t(new d(this.maxX,this.minY))),n.extend(t(new d(this.minX,this.maxY))),n.extend(t(new d(this.maxX,this.maxY))),n}static fromPoints(t){let n=new e;for(let r of t)n.extend(r);return n}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}},xv=class{constructor(t,n){this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},this.extent=n,`id`in t&&(typeof t.id==`string`?this.id=parseInt(t.id,10):typeof t.id==`number`&&!isNaN(t.id)&&(this.id=t.id))}loadGeometry(){let t=[],n=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(let r of n){let n=[];for(let t of r)n.push(new d(t[0],t[1]));t.push(n)}return t}};const Tv=`_geojsonTileLayer`;var Cv=class{constructor(t,n){this.layers={[Tv]:this},this.name=Tv,this.version=n?n.version:1,this.extent=n?n.extent:4096,this.length=t.length,this.features=t}feature(t){return new xv(this.features[t],this.extent)}};function Ev(t,n=``){let r=new Og;return Dv(t,r,n),r.finish()}function Dv(t,n,r=``){for(let a in t.layers)n.writeMessage(3,(t,n)=>Ov(t,n,r),t.layers[a])}function Ov(t,n,r=``){n.writeVarintField(15,t.version||1),n.writeStringField(1,t.name||``),n.writeVarintField(5,t.extent||4096);let a={jsonPrefix:r,keys:[],values:[],keycache:{},valuecache:{}};for(let r=0;r>31}function Uv(t,n){let r=t.loadGeometry(),a=t.type,o=0,s=0;for(let c of r){let r=1;a===1&&(r=c.length),n.writeVarint(jv(1,r));let l=a===3?c.length-1:c.length;for(let t=0;t=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}},Pv=class{constructor(t,n,r,a,o){this.type=`Feature`,this._vectorTileFeature=t,this._x=r,this._y=a,this._z=n;for(let n in t.properties)typeof t.properties[n]!=`string`||!t.properties[n].startsWith(`__$json__:`)||(t.properties[n]=JSON.parse(t.properties[n].slice(10)));this.properties=t.properties,this.id=o}projectPoint(t,n,r,a){return[(t.x+n)*360/a-180,360/Math.PI*Math.atan(Math.exp((1-(t.y+r)*2/a)*Math.PI))-90]}projectLine(t,n,r,a){return t.map(t=>this.projectPoint(t,n,r,a))}get geometry(){if(this._geometry)return this._geometry;let t=this._vectorTileFeature,n=t.extent*2**this._z,r=t.extent*this._x,a=t.extent*this._y,o=t.loadGeometry();switch(t.type){case 1:{let t=[];for(let n of o)t.push(n[0]);let s=this.projectLine(t,r,a,n);this._geometry=t.length===1?{type:`Point`,coordinates:s[0]}:{type:`MultiPoint`,coordinates:s};break}case 2:{let t=o.map(t=>this.projectLine(t,r,a,n));this._geometry=t.length===1?{type:`LineString`,coordinates:t[0]}:{type:`MultiLineString`,coordinates:t};break}case 3:{let t=tm(o),s=[];for(let o of t)s.push(o.map(t=>this.projectLine(t,r,a,n)));this._geometry=s.length===1?{type:`Polygon`,coordinates:s[0]}:{type:`MultiPolygon`,coordinates:s};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 n in this)n!==`_geometry`&&n!==`_vectorTileFeature`&&n!==`_x`&&n!==`_y`&&n!==`_z`&&(t[n]=this[n]);return t}},Fv=class{constructor(t,n,r){this._name=t,this.dataBuffer=n,typeof r==`number`?this._size=r:(this.nullabilityBuffer=r,this._size=r.size())}getValue(t){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(t)?null:this.getValueFromBuffer(t)}has(t){return this.nullabilityBuffer?.get(t)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},Iv=class extends Fv{},Lv=class extends Iv{getValueFromBuffer(t){return this.dataBuffer[t]}},Rv=class extends Iv{getValueFromBuffer(t){return this.dataBuffer[t]}},zv=class extends Fv{constructor(t,n,r,a){super(t,n,a),this.delta=r}},Bv=class extends zv{constructor(t,n,r,a){super(t,Int32Array.of(n),r,a)}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}},Vv=class extends Fv{constructor(t,n,r,a){super(t,a?Int32Array.of(n):Uint32Array.of(n),r)}getValueFromBuffer(t){return this.dataBuffer[0]}},Hv=class{constructor(t,n,r,a,o=4096){if(this._name=t,this._geometryVector=n,this._idVector=r,this._propertyVectors=a,this._extent=o,t.length===0)throw Error(`Missing layer name`)}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(t){return this.propertyVectorsMap||=new Map(this._propertyVectors.map(t=>[t.name,t])),this.propertyVectorsMap.get(t)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let t=[],n=this.geometryVector.getGeometries();for(let r=0;r>>32-t;const Zv=Xv,Qv=65536;function $v(t,n){return t-t%n}function ey(t){return $v(t+31,32)}function ty(t){if(!Number.isFinite(t)||t<=0)return Qv;let n=$v(Math.floor(t),256);return n===0?256:n}function ny(t){let n=t>>>0;return((n&255)<<24|(n&65280)<<8|n>>>8&65280|n>>>24&255)>>>0}function ry(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0;r[o++]=s>>>0&3,r[o++]=s>>>2&3,r[o++]=s>>>4&3,r[o++]=s>>>6&3,r[o++]=s>>>8&3,r[o++]=s>>>10&3,r[o++]=s>>>12&3,r[o++]=s>>>14&3,r[o++]=s>>>16&3,r[o++]=s>>>18&3,r[o++]=s>>>20&3,r[o++]=s>>>22&3,r[o++]=s>>>24&3,r[o++]=s>>>26&3,r[o++]=s>>>28&3,r[o++]=s>>>30&3,r[o++]=c>>>0&3,r[o++]=c>>>2&3,r[o++]=c>>>4&3,r[o++]=c>>>6&3,r[o++]=c>>>8&3,r[o++]=c>>>10&3,r[o++]=c>>>12&3,r[o++]=c>>>14&3,r[o++]=c>>>16&3,r[o++]=c>>>18&3,r[o++]=c>>>20&3,r[o++]=c>>>22&3,r[o++]=c>>>24&3,r[o++]=c>>>26&3,r[o++]=c>>>28&3,r[o]=c>>>30&3}function iy(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0;r[o++]=s>>>0&7,r[o++]=s>>>3&7,r[o++]=s>>>6&7,r[o++]=s>>>9&7,r[o++]=s>>>12&7,r[o++]=s>>>15&7,r[o++]=s>>>18&7,r[o++]=s>>>21&7,r[o++]=s>>>24&7,r[o++]=s>>>27&7,r[o++]=(s>>>30|(c&1)<<2)&7,r[o++]=c>>>1&7,r[o++]=c>>>4&7,r[o++]=c>>>7&7,r[o++]=c>>>10&7,r[o++]=c>>>13&7,r[o++]=c>>>16&7,r[o++]=c>>>19&7,r[o++]=c>>>22&7,r[o++]=c>>>25&7,r[o++]=c>>>28&7,r[o++]=(c>>>31|(l&3)<<1)&7,r[o++]=l>>>2&7,r[o++]=l>>>5&7,r[o++]=l>>>8&7,r[o++]=l>>>11&7,r[o++]=l>>>14&7,r[o++]=l>>>17&7,r[o++]=l>>>20&7,r[o++]=l>>>23&7,r[o++]=l>>>26&7,r[o]=l>>>29&7}function ay(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0;r[o++]=s>>>0&15,r[o++]=s>>>4&15,r[o++]=s>>>8&15,r[o++]=s>>>12&15,r[o++]=s>>>16&15,r[o++]=s>>>20&15,r[o++]=s>>>24&15,r[o++]=s>>>28&15,r[o++]=c>>>0&15,r[o++]=c>>>4&15,r[o++]=c>>>8&15,r[o++]=c>>>12&15,r[o++]=c>>>16&15,r[o++]=c>>>20&15,r[o++]=c>>>24&15,r[o++]=c>>>28&15,r[o++]=l>>>0&15,r[o++]=l>>>4&15,r[o++]=l>>>8&15,r[o++]=l>>>12&15,r[o++]=l>>>16&15,r[o++]=l>>>20&15,r[o++]=l>>>24&15,r[o++]=l>>>28&15,r[o++]=u>>>0&15,r[o++]=u>>>4&15,r[o++]=u>>>8&15,r[o++]=u>>>12&15,r[o++]=u>>>16&15,r[o++]=u>>>20&15,r[o++]=u>>>24&15,r[o]=u>>>28&15}function oy(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0;r[o++]=s>>>0&31,r[o++]=s>>>5&31,r[o++]=s>>>10&31,r[o++]=s>>>15&31,r[o++]=s>>>20&31,r[o++]=s>>>25&31,r[o++]=(s>>>30|(c&7)<<2)&31,r[o++]=c>>>3&31,r[o++]=c>>>8&31,r[o++]=c>>>13&31,r[o++]=c>>>18&31,r[o++]=c>>>23&31,r[o++]=(c>>>28|(l&1)<<4)&31,r[o++]=l>>>1&31,r[o++]=l>>>6&31,r[o++]=l>>>11&31,r[o++]=l>>>16&31,r[o++]=l>>>21&31,r[o++]=l>>>26&31,r[o++]=(l>>>31|(u&15)<<1)&31,r[o++]=u>>>4&31,r[o++]=u>>>9&31,r[o++]=u>>>14&31,r[o++]=u>>>19&31,r[o++]=u>>>24&31,r[o++]=(u>>>29|(d&3)<<3)&31,r[o++]=d>>>2&31,r[o++]=d>>>7&31,r[o++]=d>>>12&31,r[o++]=d>>>17&31,r[o++]=d>>>22&31,r[o]=d>>>27&31}function sy(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0,f=t[n+5]>>>0;r[o++]=s>>>0&63,r[o++]=s>>>6&63,r[o++]=s>>>12&63,r[o++]=s>>>18&63,r[o++]=s>>>24&63,r[o++]=(s>>>30|(c&15)<<2)&63,r[o++]=c>>>4&63,r[o++]=c>>>10&63,r[o++]=c>>>16&63,r[o++]=c>>>22&63,r[o++]=(c>>>28|(l&3)<<4)&63,r[o++]=l>>>2&63,r[o++]=l>>>8&63,r[o++]=l>>>14&63,r[o++]=l>>>20&63,r[o++]=l>>>26&63,r[o++]=u>>>0&63,r[o++]=u>>>6&63,r[o++]=u>>>12&63,r[o++]=u>>>18&63,r[o++]=u>>>24&63,r[o++]=(u>>>30|(d&15)<<2)&63,r[o++]=d>>>4&63,r[o++]=d>>>10&63,r[o++]=d>>>16&63,r[o++]=d>>>22&63,r[o++]=(d>>>28|(f&3)<<4)&63,r[o++]=f>>>2&63,r[o++]=f>>>8&63,r[o++]=f>>>14&63,r[o++]=f>>>20&63,r[o]=f>>>26&63}function cy(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0,f=t[n+5]>>>0,p=t[n+6]>>>0;r[o++]=s>>>0&127,r[o++]=s>>>7&127,r[o++]=s>>>14&127,r[o++]=s>>>21&127,r[o++]=(s>>>28|(c&7)<<4)&127,r[o++]=c>>>3&127,r[o++]=c>>>10&127,r[o++]=c>>>17&127,r[o++]=c>>>24&127,r[o++]=(c>>>31|(l&63)<<1)&127,r[o++]=l>>>6&127,r[o++]=l>>>13&127,r[o++]=l>>>20&127,r[o++]=(l>>>27|(u&3)<<5)&127,r[o++]=u>>>2&127,r[o++]=u>>>9&127,r[o++]=u>>>16&127,r[o++]=u>>>23&127,r[o++]=(u>>>30|(d&31)<<2)&127,r[o++]=d>>>5&127,r[o++]=d>>>12&127,r[o++]=d>>>19&127,r[o++]=(d>>>26|(f&1)<<6)&127,r[o++]=f>>>1&127,r[o++]=f>>>8&127,r[o++]=f>>>15&127,r[o++]=f>>>22&127,r[o++]=(f>>>29|(p&15)<<3)&127,r[o++]=p>>>4&127,r[o++]=p>>>11&127,r[o++]=p>>>18&127,r[o]=p>>>25&127}function ly(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0,f=t[n+5]>>>0,p=t[n+6]>>>0,m=t[n+7]>>>0;r[o++]=s>>>0&255,r[o++]=s>>>8&255,r[o++]=s>>>16&255,r[o++]=s>>>24&255,r[o++]=c>>>0&255,r[o++]=c>>>8&255,r[o++]=c>>>16&255,r[o++]=c>>>24&255,r[o++]=l>>>0&255,r[o++]=l>>>8&255,r[o++]=l>>>16&255,r[o++]=l>>>24&255,r[o++]=u>>>0&255,r[o++]=u>>>8&255,r[o++]=u>>>16&255,r[o++]=u>>>24&255,r[o++]=d>>>0&255,r[o++]=d>>>8&255,r[o++]=d>>>16&255,r[o++]=d>>>24&255,r[o++]=f>>>0&255,r[o++]=f>>>8&255,r[o++]=f>>>16&255,r[o++]=f>>>24&255,r[o++]=p>>>0&255,r[o++]=p>>>8&255,r[o++]=p>>>16&255,r[o++]=p>>>24&255,r[o++]=m>>>0&255,r[o++]=m>>>8&255,r[o++]=m>>>16&255,r[o]=m>>>24&255}function uy(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0,f=t[n+5]>>>0,p=t[n+6]>>>0,m=t[n+7]>>>0,h=t[n+8]>>>0;r[o++]=s>>>0&511,r[o++]=s>>>9&511,r[o++]=s>>>18&511,r[o++]=(s>>>27|(c&15)<<5)&511,r[o++]=c>>>4&511,r[o++]=c>>>13&511,r[o++]=c>>>22&511,r[o++]=(c>>>31|(l&255)<<1)&511,r[o++]=l>>>8&511,r[o++]=l>>>17&511,r[o++]=(l>>>26|(u&7)<<6)&511,r[o++]=u>>>3&511,r[o++]=u>>>12&511,r[o++]=u>>>21&511,r[o++]=(u>>>30|(d&127)<<2)&511,r[o++]=d>>>7&511,r[o++]=d>>>16&511,r[o++]=(d>>>25|(f&3)<<7)&511,r[o++]=f>>>2&511,r[o++]=f>>>11&511,r[o++]=f>>>20&511,r[o++]=(f>>>29|(p&63)<<3)&511,r[o++]=p>>>6&511,r[o++]=p>>>15&511,r[o++]=(p>>>24|(m&1)<<8)&511,r[o++]=m>>>1&511,r[o++]=m>>>10&511,r[o++]=m>>>19&511,r[o++]=(m>>>28|(h&31)<<4)&511,r[o++]=h>>>5&511,r[o++]=h>>>14&511,r[o]=h>>>23&511}function dy(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0,f=t[n+5]>>>0,p=t[n+6]>>>0,m=t[n+7]>>>0,h=t[n+8]>>>0,g=t[n+9]>>>0;r[o++]=s>>>0&1023,r[o++]=s>>>10&1023,r[o++]=s>>>20&1023,r[o++]=(s>>>30|(c&255)<<2)&1023,r[o++]=c>>>8&1023,r[o++]=c>>>18&1023,r[o++]=(c>>>28|(l&63)<<4)&1023,r[o++]=l>>>6&1023,r[o++]=l>>>16&1023,r[o++]=(l>>>26|(u&15)<<6)&1023,r[o++]=u>>>4&1023,r[o++]=u>>>14&1023,r[o++]=(u>>>24|(d&3)<<8)&1023,r[o++]=d>>>2&1023,r[o++]=d>>>12&1023,r[o++]=d>>>22&1023,r[o++]=f>>>0&1023,r[o++]=f>>>10&1023,r[o++]=f>>>20&1023,r[o++]=(f>>>30|(p&255)<<2)&1023,r[o++]=p>>>8&1023,r[o++]=p>>>18&1023,r[o++]=(p>>>28|(m&63)<<4)&1023,r[o++]=m>>>6&1023,r[o++]=m>>>16&1023,r[o++]=(m>>>26|(h&15)<<6)&1023,r[o++]=h>>>4&1023,r[o++]=h>>>14&1023,r[o++]=(h>>>24|(g&3)<<8)&1023,r[o++]=g>>>2&1023,r[o++]=g>>>12&1023,r[o]=g>>>22&1023}function fy(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0,f=t[n+5]>>>0,p=t[n+6]>>>0,m=t[n+7]>>>0,h=t[n+8]>>>0,g=t[n+9]>>>0,_=t[n+10]>>>0;r[o++]=s>>>0&2047,r[o++]=s>>>11&2047,r[o++]=(s>>>22|(c&1)<<10)&2047,r[o++]=c>>>1&2047,r[o++]=c>>>12&2047,r[o++]=(c>>>23|(l&3)<<9)&2047,r[o++]=l>>>2&2047,r[o++]=l>>>13&2047,r[o++]=(l>>>24|(u&7)<<8)&2047,r[o++]=u>>>3&2047,r[o++]=u>>>14&2047,r[o++]=(u>>>25|(d&15)<<7)&2047,r[o++]=d>>>4&2047,r[o++]=d>>>15&2047,r[o++]=(d>>>26|(f&31)<<6)&2047,r[o++]=f>>>5&2047,r[o++]=f>>>16&2047,r[o++]=(f>>>27|(p&63)<<5)&2047,r[o++]=p>>>6&2047,r[o++]=p>>>17&2047,r[o++]=(p>>>28|(m&127)<<4)&2047,r[o++]=m>>>7&2047,r[o++]=m>>>18&2047,r[o++]=(m>>>29|(h&255)<<3)&2047,r[o++]=h>>>8&2047,r[o++]=h>>>19&2047,r[o++]=(h>>>30|(g&511)<<2)&2047,r[o++]=g>>>9&2047,r[o++]=g>>>20&2047,r[o++]=(g>>>31|(_&1023)<<1)&2047,r[o++]=_>>>10&2047,r[o]=_>>>21&2047}function py(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0,f=t[n+5]>>>0,p=t[n+6]>>>0,m=t[n+7]>>>0,h=t[n+8]>>>0,g=t[n+9]>>>0,_=t[n+10]>>>0,v=t[n+11]>>>0;r[o++]=s>>>0&4095,r[o++]=s>>>12&4095,r[o++]=(s>>>24|(c&15)<<8)&4095,r[o++]=c>>>4&4095,r[o++]=c>>>16&4095,r[o++]=(c>>>28|(l&255)<<4)&4095,r[o++]=l>>>8&4095,r[o++]=l>>>20&4095,r[o++]=u>>>0&4095,r[o++]=u>>>12&4095,r[o++]=(u>>>24|(d&15)<<8)&4095,r[o++]=d>>>4&4095,r[o++]=d>>>16&4095,r[o++]=(d>>>28|(f&255)<<4)&4095,r[o++]=f>>>8&4095,r[o++]=f>>>20&4095,r[o++]=p>>>0&4095,r[o++]=p>>>12&4095,r[o++]=(p>>>24|(m&15)<<8)&4095,r[o++]=m>>>4&4095,r[o++]=m>>>16&4095,r[o++]=(m>>>28|(h&255)<<4)&4095,r[o++]=h>>>8&4095,r[o++]=h>>>20&4095,r[o++]=g>>>0&4095,r[o++]=g>>>12&4095,r[o++]=(g>>>24|(_&15)<<8)&4095,r[o++]=_>>>4&4095,r[o++]=_>>>16&4095,r[o++]=(_>>>28|(v&255)<<4)&4095,r[o++]=v>>>8&4095,r[o]=v>>>20&4095}function my(t,n,r,a){let o=a,s=t[n]>>>0,c=t[n+1]>>>0,l=t[n+2]>>>0,u=t[n+3]>>>0,d=t[n+4]>>>0,f=t[n+5]>>>0,p=t[n+6]>>>0,m=t[n+7]>>>0,h=t[n+8]>>>0,g=t[n+9]>>>0,_=t[n+10]>>>0,v=t[n+11]>>>0,y=t[n+12]>>>0,b=t[n+13]>>>0,x=t[n+14]>>>0,S=t[n+15]>>>0;r[o++]=s>>>0&65535,r[o++]=s>>>16&65535,r[o++]=c>>>0&65535,r[o++]=c>>>16&65535,r[o++]=l>>>0&65535,r[o++]=l>>>16&65535,r[o++]=u>>>0&65535,r[o++]=u>>>16&65535,r[o++]=d>>>0&65535,r[o++]=d>>>16&65535,r[o++]=f>>>0&65535,r[o++]=f>>>16&65535,r[o++]=p>>>0&65535,r[o++]=p>>>16&65535,r[o++]=m>>>0&65535,r[o++]=m>>>16&65535,r[o++]=h>>>0&65535,r[o++]=h>>>16&65535,r[o++]=g>>>0&65535,r[o++]=g>>>16&65535,r[o++]=_>>>0&65535,r[o++]=_>>>16&65535,r[o++]=v>>>0&65535,r[o++]=v>>>16&65535,r[o++]=y>>>0&65535,r[o++]=y>>>16&65535,r[o++]=b>>>0&65535,r[o++]=b>>>16&65535,r[o++]=x>>>0&65535,r[o++]=x>>>16&65535,r[o++]=S>>>0&65535,r[o]=S>>>16&65535}function hy(t,n,r,a){let o=a,s=n;for(let n=0;n<8;n++){let n=t[s++]>>>0;r[o++]=n>>>0&1,r[o++]=n>>>1&1,r[o++]=n>>>2&1,r[o++]=n>>>3&1,r[o++]=n>>>4&1,r[o++]=n>>>5&1,r[o++]=n>>>6&1,r[o++]=n>>>7&1,r[o++]=n>>>8&1,r[o++]=n>>>9&1,r[o++]=n>>>10&1,r[o++]=n>>>11&1,r[o++]=n>>>12&1,r[o++]=n>>>13&1,r[o++]=n>>>14&1,r[o++]=n>>>15&1,r[o++]=n>>>16&1,r[o++]=n>>>17&1,r[o++]=n>>>18&1,r[o++]=n>>>19&1,r[o++]=n>>>20&1,r[o++]=n>>>21&1,r[o++]=n>>>22&1,r[o++]=n>>>23&1,r[o++]=n>>>24&1,r[o++]=n>>>25&1,r[o++]=n>>>26&1,r[o++]=n>>>27&1,r[o++]=n>>>28&1,r[o++]=n>>>29&1,r[o++]=n>>>30&1,r[o++]=n>>>31&1}}function gy(t,n,r,a){let o=a,s=n;for(let n=0;n<8;n++){let n=t[s++]>>>0,a=t[s++]>>>0;r[o++]=n>>>0&3,r[o++]=n>>>2&3,r[o++]=n>>>4&3,r[o++]=n>>>6&3,r[o++]=n>>>8&3,r[o++]=n>>>10&3,r[o++]=n>>>12&3,r[o++]=n>>>14&3,r[o++]=n>>>16&3,r[o++]=n>>>18&3,r[o++]=n>>>20&3,r[o++]=n>>>22&3,r[o++]=n>>>24&3,r[o++]=n>>>26&3,r[o++]=n>>>28&3,r[o++]=n>>>30&3,r[o++]=a>>>0&3,r[o++]=a>>>2&3,r[o++]=a>>>4&3,r[o++]=a>>>6&3,r[o++]=a>>>8&3,r[o++]=a>>>10&3,r[o++]=a>>>12&3,r[o++]=a>>>14&3,r[o++]=a>>>16&3,r[o++]=a>>>18&3,r[o++]=a>>>20&3,r[o++]=a>>>22&3,r[o++]=a>>>24&3,r[o++]=a>>>26&3,r[o++]=a>>>28&3,r[o++]=a>>>30&3}}function _y(t,n,r,a){let o=a,s=n;for(let n=0;n<8;n++){let n=t[s++]>>>0,a=t[s++]>>>0,c=t[s++]>>>0;r[o++]=n>>>0&7,r[o++]=n>>>3&7,r[o++]=n>>>6&7,r[o++]=n>>>9&7,r[o++]=n>>>12&7,r[o++]=n>>>15&7,r[o++]=n>>>18&7,r[o++]=n>>>21&7,r[o++]=n>>>24&7,r[o++]=n>>>27&7,r[o++]=(n>>>30|(a&1)<<2)&7,r[o++]=a>>>1&7,r[o++]=a>>>4&7,r[o++]=a>>>7&7,r[o++]=a>>>10&7,r[o++]=a>>>13&7,r[o++]=a>>>16&7,r[o++]=a>>>19&7,r[o++]=a>>>22&7,r[o++]=a>>>25&7,r[o++]=a>>>28&7,r[o++]=(a>>>31|(c&3)<<1)&7,r[o++]=c>>>2&7,r[o++]=c>>>5&7,r[o++]=c>>>8&7,r[o++]=c>>>11&7,r[o++]=c>>>14&7,r[o++]=c>>>17&7,r[o++]=c>>>20&7,r[o++]=c>>>23&7,r[o++]=c>>>26&7,r[o++]=c>>>29&7}}function vy(t,n,r,a){let o=a,s=n;for(let n=0;n<8;n++){let n=t[s++]>>>0,a=t[s++]>>>0,c=t[s++]>>>0,l=t[s++]>>>0;r[o++]=n>>>0&15,r[o++]=n>>>4&15,r[o++]=n>>>8&15,r[o++]=n>>>12&15,r[o++]=n>>>16&15,r[o++]=n>>>20&15,r[o++]=n>>>24&15,r[o++]=n>>>28&15,r[o++]=a>>>0&15,r[o++]=a>>>4&15,r[o++]=a>>>8&15,r[o++]=a>>>12&15,r[o++]=a>>>16&15,r[o++]=a>>>20&15,r[o++]=a>>>24&15,r[o++]=a>>>28&15,r[o++]=c>>>0&15,r[o++]=c>>>4&15,r[o++]=c>>>8&15,r[o++]=c>>>12&15,r[o++]=c>>>16&15,r[o++]=c>>>20&15,r[o++]=c>>>24&15,r[o++]=c>>>28&15,r[o++]=l>>>0&15,r[o++]=l>>>4&15,r[o++]=l>>>8&15,r[o++]=l>>>12&15,r[o++]=l>>>16&15,r[o++]=l>>>20&15,r[o++]=l>>>24&15,r[o++]=l>>>28&15}}function yy(t,n,r,a){let o=a,s=n;for(let n=0;n<8;n++){let n=t[s++]>>>0,a=t[s++]>>>0,c=t[s++]>>>0,l=t[s++]>>>0,u=t[s++]>>>0;r[o++]=n>>>0&31,r[o++]=n>>>5&31,r[o++]=n>>>10&31,r[o++]=n>>>15&31,r[o++]=n>>>20&31,r[o++]=n>>>25&31,r[o++]=(n>>>30|(a&7)<<2)&31,r[o++]=a>>>3&31,r[o++]=a>>>8&31,r[o++]=a>>>13&31,r[o++]=a>>>18&31,r[o++]=a>>>23&31,r[o++]=(a>>>28|(c&1)<<4)&31,r[o++]=c>>>1&31,r[o++]=c>>>6&31,r[o++]=c>>>11&31,r[o++]=c>>>16&31,r[o++]=c>>>21&31,r[o++]=c>>>26&31,r[o++]=(c>>>31|(l&15)<<1)&31,r[o++]=l>>>4&31,r[o++]=l>>>9&31,r[o++]=l>>>14&31,r[o++]=l>>>19&31,r[o++]=l>>>24&31,r[o++]=(l>>>29|(u&3)<<3)&31,r[o++]=u>>>2&31,r[o++]=u>>>7&31,r[o++]=u>>>12&31,r[o++]=u>>>17&31,r[o++]=u>>>22&31,r[o++]=u>>>27&31}}function by(t,n,r,a){let o=a,s=n;for(let n=0;n<8;n++){let n=t[s++]>>>0,a=t[s++]>>>0,c=t[s++]>>>0,l=t[s++]>>>0,u=t[s++]>>>0,d=t[s++]>>>0;r[o++]=n>>>0&63,r[o++]=n>>>6&63,r[o++]=n>>>12&63,r[o++]=n>>>18&63,r[o++]=n>>>24&63,r[o++]=(n>>>30|(a&15)<<2)&63,r[o++]=a>>>4&63,r[o++]=a>>>10&63,r[o++]=a>>>16&63,r[o++]=a>>>22&63,r[o++]=(a>>>28|(c&3)<<4)&63,r[o++]=c>>>2&63,r[o++]=c>>>8&63,r[o++]=c>>>14&63,r[o++]=c>>>20&63,r[o++]=c>>>26&63,r[o++]=l>>>0&63,r[o++]=l>>>6&63,r[o++]=l>>>12&63,r[o++]=l>>>18&63,r[o++]=l>>>24&63,r[o++]=(l>>>30|(u&15)<<2)&63,r[o++]=u>>>4&63,r[o++]=u>>>10&63,r[o++]=u>>>16&63,r[o++]=u>>>22&63,r[o++]=(u>>>28|(d&3)<<4)&63,r[o++]=d>>>2&63,r[o++]=d>>>8&63,r[o++]=d>>>14&63,r[o++]=d>>>20&63,r[o++]=d>>>26&63}}function xy(t,n,r,a){let o=a,s=n;for(let n=0;n<8;n++){let n=t[s++]>>>0,a=t[s++]>>>0,c=t[s++]>>>0,l=t[s++]>>>0,u=t[s++]>>>0,d=t[s++]>>>0,f=t[s++]>>>0;r[o++]=n>>>0&127,r[o++]=n>>>7&127,r[o++]=n>>>14&127,r[o++]=n>>>21&127,r[o++]=(n>>>28|(a&7)<<4)&127,r[o++]=a>>>3&127,r[o++]=a>>>10&127,r[o++]=a>>>17&127,r[o++]=a>>>24&127,r[o++]=(a>>>31|(c&63)<<1)&127,r[o++]=c>>>6&127,r[o++]=c>>>13&127,r[o++]=c>>>20&127,r[o++]=(c>>>27|(l&3)<<5)&127,r[o++]=l>>>2&127,r[o++]=l>>>9&127,r[o++]=l>>>16&127,r[o++]=l>>>23&127,r[o++]=(l>>>30|(u&31)<<2)&127,r[o++]=u>>>5&127,r[o++]=u>>>12&127,r[o++]=u>>>19&127,r[o++]=(u>>>26|(d&1)<<6)&127,r[o++]=d>>>1&127,r[o++]=d>>>8&127,r[o++]=d>>>15&127,r[o++]=d>>>22&127,r[o++]=(d>>>29|(f&15)<<3)&127,r[o++]=f>>>4&127,r[o++]=f>>>11&127,r[o++]=f>>>18&127,r[o++]=f>>>25&127}}function Sy(t,n,r,a){let o=a,s=n;for(let n=0;n<8;n++){let n=t[s++]>>>0,a=t[s++]>>>0,c=t[s++]>>>0,l=t[s++]>>>0,u=t[s++]>>>0,d=t[s++]>>>0,f=t[s++]>>>0,p=t[s++]>>>0;r[o++]=n>>>0&255,r[o++]=n>>>8&255,r[o++]=n>>>16&255,r[o++]=n>>>24&255,r[o++]=a>>>0&255,r[o++]=a>>>8&255,r[o++]=a>>>16&255,r[o++]=a>>>24&255,r[o++]=c>>>0&255,r[o++]=c>>>8&255,r[o++]=c>>>16&255,r[o++]=c>>>24&255,r[o++]=l>>>0&255,r[o++]=l>>>8&255,r[o++]=l>>>16&255,r[o++]=l>>>24&255,r[o++]=u>>>0&255,r[o++]=u>>>8&255,r[o++]=u>>>16&255,r[o++]=u>>>24&255,r[o++]=d>>>0&255,r[o++]=d>>>8&255,r[o++]=d>>>16&255,r[o++]=d>>>24&255,r[o++]=f>>>0&255,r[o++]=f>>>8&255,r[o++]=f>>>16&255,r[o++]=f>>>24&255,r[o++]=p>>>0&255,r[o++]=p>>>8&255,r[o++]=p>>>16&255,r[o++]=p>>>24&255}}function Cy(t,n,r,a){let o=a,s=n;for(let n=0;n<128;n++){let n=t[s++]>>>0;r[o++]=n&65535,r[o++]=n>>>16&65535}}function wy(t,n,r,a,o){let s=Zv[o]>>>0,c=n,l=0,u=t[c]>>>0,d=a;for(let n=0;n<8;n++){for(let n=0;n<32;n++)if(l+o<=32){let a=u>>>l&s;r[d+n]=a|0,l+=o,l===32&&(l=0,c++,n!==31&&(u=t[c]>>>0))}else{let a=32-l,f=u>>>l;c++,u=t[c]>>>0;let p=o-a,m=-1>>>32-p>>>0,h=(f|(u&m)<>>0)}}const Ty=ty(Qv),Ey=3*Ty/256+Ty|0;function Dy(){let t=new Uint8Array(Ey);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:t,byteContainerI32:new Int32Array(t.buffer,t.byteOffset,t.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function Oy(t=16){if(t<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${t}`);let n=Math.max(16,t|0);return{encodedWords:new Uint32Array(n),decoderWorkspace:Dy()}}function ky(t,n){if(n<=t.encodedWords.length)return t.encodedWords;let r=new Uint32Array(Math.max(16,n*2));return t.encodedWords=r,r}function Ay(t,n,r,a){a.byteContainer.length>>2;if(o.byteOffset&3)for(let r=0;r>>8&255,o[s+2|0]=a>>>16&255,o[s+3|0]=a>>>24&255}else{let r=a.byteContainerI32;(!r||r.buffer!==o.buffer||r.byteOffset!==o.byteOffset||r.length>>2)),r.set(t.subarray(n,n+s))}let c=r&3;if(c>0){let r=t[n+s|0]|0,a=s<<2;for(let t=0;t>>(t<<3)&255}return o}function jy(t,n,r){let a=t[n++]|0,o=r.dataToBePacked;for(let s=2;s<=32;s=s+1|0){if(!(a>>>s-1&1))continue;if(n>=t.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${s}, streamWordIndex=${n}, needWords=1, availableWords=${t.length-n}, encodedWords=${t.length})`);let c=t[n++]>>>0,l=ey(c),u=c*s+31>>>5;if(n+u>t.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${s}, size=${c}, streamWordIndex=${n}, needWords=${u}, availableWords=${t.length-n}, encodedWords=${t.length})`);let d=o[s];(!d||d.length>>5)|0,r.exceptionSizes[s]=c}return n}function My(t,n,r,a,o){switch(o){case 1:hy(t,n,r,a);break;case 2:gy(t,n,r,a);break;case 3:_y(t,n,r,a);break;case 4:vy(t,n,r,a);break;case 5:yy(t,n,r,a);break;case 6:by(t,n,r,a);break;case 7:xy(t,n,r,a);break;case 8:Sy(t,n,r,a);break;case 16:Cy(t,n,r,a);break;default:wy(t,n,r,a,o);break}return n+(o<<3)|0}function Ny(t,n,r,a){if(r+2>n)throw Error(`FastPFOR decode: byteContainer underflow at block=${a} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${r}, byteSize=${n})`);let o=t[r++],s=t[r++];if(o>32)throw Error(`FastPFOR decode: invalid bitWidth=${o} at block=${a} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:o,exceptionCount:s,bytePosIn:r}}function Py(t,n,r,a,o,s){if(r+1>n)throw Error(`FastPFOR decode: exception header underflow at block=${s} (need 1 byte for maxBits, bytePos=${r}, byteSize=${n})`);let c=t[r++];if(c32)throw Error(`FastPFOR decode: invalid maxBits=${c} at block=${s} (bitWidth=${a}, expected ${a}..32)`);let l=c-a|0;if(l<1||l>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${l} at block=${s} (bitWidth=${a}, maxBits=${c})`);if(r+o>n)throw Error(`FastPFOR decode: exception positions underflow at block=${s} (need=${o}, have=${n-r})`);return{maxBits:c,exceptionBitWidth:l,bytePosIn:r}}function Fy(t,n,r,a,o,s,c,l,u){let{maxBits:d,exceptionBitWidth:f,bytePosIn:p}=Py(o,s,c,r,a,u);if(c=p,f===1){let s=1<_)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${f} (ptr=${g}, need ${a}, size=${_}) at block ${u}`);for(let s=0;s0&&(p=Fy(o,m,a,c,l,u,p,d,n))}if(f!==a)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${n}, packedStart=${r}, consumedPackedEnd=${f}, expectedPackedEnd=${a}, packedWords=${a-r}, encoded.length=${t.length})`)}function Ly(t,n,r,a,o,s){let c=r|0,l=t[c]|0;if(l<=0||c+l>t.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${l} at pageStart=${c} (expected > 0 and pageStart+whereMeta < encoded.length=${t.length})`);let u=c+1|0,d=c+l|0,f=t[d]>>>0,p=f+3>>>2,m=d+1,h=m+p;if(h>=t.length)throw Error(`FastPFOR decode: invalid byteSize=${f} (metaInts=${p}, pageStart=${c}, packedEnd=${d}, byteContainerStart=${m}) causes bitmapPos=${h} out of bounds (encoded.length=${t.length})`);let g=Ay(t,m,f,s),_=f,v=jy(t,h,s);return s.dataPointers.fill(0),Iy(t,c,u,d,n,a|0,o/256|0,g,_,s),v}function Ry(t,n,r,a,o,s){let c=a+$v(o,256),l=a,u=r;for(;l!==c;){let r=Math.min(Ty,c-l);u=Ly(t,n,u,l,r,s),l=l+r|0}return u}function zy(t,n,r,a,o,s){if(s===0)return n;let c=0,l=n,u=n+r,d=o,f=o,p=o+s,m=0,h=0;for(;l>>c&255;if(c+=8,l+=c>>>5,c&=31,m|=(n&127)<28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${h}, partial=${m}, decoded=${f-d}/${s}, inPos=${l}, inEnd=${u})`)}if(f!==p)throw Error(`FastPFOR VByte: truncated stream (decoded=${f-d}, expected=${s}, consumedWords=${l-n}/${r}, vbyteStart=${n}, vbyteEnd=${u})`);return l}function By(t,n,r){let a=0,o=0,s=new Uint32Array(n),c=r??Dy();if(t.length>0){let n=t[a]|0;if(a=a+1|0,n&255)throw Error(`FastPFOR decode: invalid alignedLength=${n} (expected multiple of 256)`);if(o+n>s.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${o}, alignedLength=${n}, out.length=${s.length})`);a=Ry(t,s,a,o,n,c),o=o+n|0}let l=t.length-a|0,u=n-o|0;return zy(t,a,l,s,o,u),s}function Vy(t,n,r,a,o){switch(o){case 2:ry(t,n,r,a);return;case 3:iy(t,n,r,a);return;case 4:ay(t,n,r,a);return;case 5:oy(t,n,r,a);return;case 6:sy(t,n,r,a);return;case 7:cy(t,n,r,a);return;case 8:ly(t,n,r,a);return;case 9:uy(t,n,r,a);return;case 10:dy(t,n,r,a);return;case 11:fy(t,n,r,a);return;case 12:py(t,n,r,a);return;case 16:my(t,n,r,a);return;case 32:for(let o=0;o<32;o=o+1|0)r[a+o|0]=t[n+o|0]|0;return;default:break}let s=Zv[o]>>>0,c=n,l=0,u=t[c]>>>0;for(let n=0;n<32;n++)if(l+o<=32){let d=u>>>l&s;r[a+n]=d|0,l+=o,l===32&&(l=0,c++,n!==31&&(u=t[c]>>>0))}else{let d=32-l,f=u>>>l;c++,u=t[c]>>>0;let p=Zv[o-d]>>>0,m=(f|(u&p)<t.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${n}, byteLength=${r}, bytes.length=${t.length})`);let o=Math.floor(r/4),s=r%4!=0,c=s?o+1:o;if(a.length0){let r=t.byteOffset+n;if(r&3)for(let r=0;r=64)throw Error(`Varint too long`)}return n.set(o),r}function Ky(t,n,r){let a=new Float64Array(r);for(let o=0;o>4,o<128||(o=n[r.get()],r.increment(),a|=(o&127)<<3,o<128)||(o=n[r.get()],r.increment(),a|=(o&127)<<10,o<128)||(o=n[r.get()],r.increment(),a|=(o&127)<<17,o<128)||(o=n[r.get()],r.increment(),a|=(o&127)<<24,o<128)||(o=n[r.get()],r.increment(),a|=(o&1)<<31,o<128))return a*4294967296+(t>>>0);throw Error(`Expected varint not more than 10 bytes`)}function Yy(t,n,r,a){return Xy(t,n,r,a,Oy(r>>>2))}function Xy(t,n,r,a,o){let s=a.get();if(r&3)throw Error(`FastPFOR: invalid encodedByteLength=${r} at offset=${s} (encodedBytes.length=${t.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let c=r>>>2,l=ky(o,c);Hy(t,s,r,l);let u=By(l.subarray(0,c),n,o.decoderWorkspace);return a.add(r),u}function Q(t){return t>>>1^-(t&1)}function Zy(t){return t>>1n^-(t&1n)}function Qy(t){return t%2==1?(t+1)/-2:t/2}function $y(t){let n=new Int32Array(t.length);for(let r=0;r=4)for(;a=4)for(;a=4)for(;r=4)for(let a=t[0];r=4)for(;a=4)for(;u>>0;for(let r=1;r>>0;return n}function Sb(t){let n=new BigUint64Array(t.length);n[0]=BigInt.asUintN(64,Zy(t[0]));for(let r=1;r>>0,n[1]=Q(t[1])>>>0;for(let r=2;r>>0,n[r+1]=n[r-1]+Q(t[r+1])>>>0;return n}function wb(t,n,r,a){let o=mb(t,n,r,a);return new Uint32Array(o)}function Tb(t){return t[1]}function Eb(t){return Q(t[1])}function Db(t){if(t.length===2){let n=Q(t[1]);return[n,n]}return[Q(t[2]),Q(t[3])]}function Ob(t){return t[1]}function kb(t){return Zy(t[1])}function Ab(t){if(t.length===2){let n=Zy(t[1]);return[n,n]}return[Zy(t[2]),Zy(t[3])]}var jb;(function(t){t.PRESENT=`PRESENT`,t.DATA=`DATA`,t.OFFSET=`OFFSET`,t.LENGTH=`LENGTH`})(jb||={});var Mb;(function(t){t.NONE=`NONE`,t.SINGLE=`SINGLE`,t.SHARED=`SHARED`,t.VERTEX=`VERTEX`,t.MORTON=`MORTON`,t.FSST=`FSST`})(Mb||={});var Nb;(function(t){t.VERTEX=`VERTEX`,t.INDEX=`INDEX`,t.STRING=`STRING`,t.KEY=`KEY`})(Nb||={});var Pb;(function(t){t.VAR_BINARY=`VAR_BINARY`,t.GEOMETRIES=`GEOMETRIES`,t.PARTS=`PARTS`,t.RINGS=`RINGS`,t.TRIANGLES=`TRIANGLES`,t.SYMBOL=`SYMBOL`,t.DICTIONARY=`DICTIONARY`})(Pb||={});const Fb=[jb.PRESENT,jb.DATA,jb.OFFSET,jb.LENGTH],Ib=[Z.NONE,Z.DELTA,Z.COMPONENTWISE_DELTA,Z.RLE,Z.MORTON,Z.PDE],Lb=[Yv.NONE,Yv.FAST_PFOR,Yv.VARINT],Rb=[Mb.NONE,Mb.SINGLE,Mb.SHARED,Mb.VERTEX,Mb.MORTON,Mb.FSST],zb=[Nb.VERTEX,Nb.INDEX,Nb.STRING,Nb.KEY],Bb=[Pb.VAR_BINARY,Pb.GEOMETRIES,Pb.PARTS,Pb.RINGS,Pb.TRIANGLES,Pb.SYMBOL,Pb.DICTIONARY];function Vb(t,n){let r=Gb(t,n);return r.logicalLevelTechnique1===Z.MORTON?Hb(r,t,n):(Z.RLE===r.logicalLevelTechnique1||Z.RLE===r.logicalLevelTechnique2)&&Yv.NONE!==r.physicalLevelTechnique?Wb(r,t,n):r}function Hb(t,n,r){let a=Uy(n,r,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:t.decompressedCount,numBits:a[0],coordinateShift:a[1]}}function Wb(t,n,r){let a=Uy(n,r,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:a[1],runs:a[0],numRleValues:a[1]}}function Gb(t,n){let r=t[n.get()],a=Fb[r>>4],o={};switch(a){case jb.DATA:o={dictionaryType:Rb[r&15]};break;case jb.OFFSET:o={offsetType:zb[r&15]};break;case jb.LENGTH:o={lengthType:Bb[r&15]};break}n.increment();let s=t[n.get()],c=Ib[s>>5],l=Ib[s>>2&7],u=Lb[s&3];n.increment();let d=Uy(t,n,2),f=d[0],p=d[1];return{physicalStreamType:a,logicalStreamType:o,logicalLevelTechnique1:c,logicalLevelTechnique2:l,physicalLevelTechnique:u,numValues:f,byteLength:p,decompressedCount:f}}var $;(function(t){t[t.FLAT=0]=`FLAT`,t[t.CONST=1]=`CONST`,t[t.SEQUENCE=2]=`SEQUENCE`,t[t.DICTIONARY=3]=`DICTIONARY`,t[t.FSST_DICTIONARY=4]=`FSST_DICTIONARY`})($||={});var Ub=class{constructor(t,n){this.values=t,this._size=n}get(t){let n=Math.floor(t/8),r=t%8;return(this.values[n]>>r&1)==1}set(t,n){let r=Math.floor(t/8),a=t%8;this.values[r]=this.values[r]|+!!n<>r&1}size(){return this._size}getBuffer(){return this.values}};function Kb(t,n,r){if(!n)return t;let a=n.size(),o=t.constructor,s=new o(a),c=0;for(let o=0;o>1,n)-r}}function yx(t,n){let r=0;for(let a=0;a>a;return r}var bx;(function(t){t[t.POINT=0]=`POINT`,t[t.LINESTRING=1]=`LINESTRING`,t[t.POLYGON=2]=`POLYGON`,t[t.MULTIPOINT=3]=`MULTIPOINT`,t[t.MULTILINESTRING=4]=`MULTILINESTRING`,t[t.MULTIPOLYGON=5]=`MULTIPOLYGON`})(bx||={});var xx;(function(t){t[t.POINT=0]=`POINT`,t[t.LINESTRING=1]=`LINESTRING`,t[t.POLYGON=2]=`POLYGON`})(xx||={});var Sx;(function(t){t[t.MORTON=0]=`MORTON`,t[t.VEC_2=1]=`VEC_2`,t[t.VEC_3=2]=`VEC_3`})(Sx||={});function Cx(t){let n=Array(t.numGeometries),r=1,a=1,o=1,s=0,c=0,l=0,u=t.mortonSettings,f=t.topologyVector,p=f.geometryOffsets,m=f.partOffsets,h=f.ringOffsets,g=t.vertexOffsets,_=!g||g.length===0,v=t.containsPolygonGeometry(),y=t.vertexBuffer;for(let f=0;f[t]),r+=t,a+=t}break;case bx.LINESTRING:{let d;v?(d=h[a]-h[a-1],a++):d=m[r]-m[r-1],r++;let f;_?(f=Tx(y,c,d,!1),c+=d*2):(f=wx(t.vertexBufferType,y,g,l,d,!1,u),l+=d),n[s++]=[f],p&&o++}break;case bx.POLYGON:{let d=m[r]-m[r-1];r++;let f=Array(d-1),v,b=h[a]-h[a-1];if(a++,_){v=Tx(y,c,b,!0),c+=b*2;for(let t=0;t0&&n.push(n[0]),p.push(n)}t[n]=p,o&&u++}break;case bx.MULTIPOLYGON:{let f=o[u]-o[u-1];u++;let p=[];for(let t=0;t0&&n.push(n[0]),p.push(n)}}t[n]=p}break}return t}[Symbol.iterator](){return null}};function Rx(t,n,r,a,o,s){return new Fx(t,n,r,a,o,s)}var Fx=class extends Nx{constructor(t,n,r,a,o,s){super(r,a,o,s),this._numGeometries=t,this._geometryType=n}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function zx(t,n,r,a,o){return new Lx(t,n,r,a,o)}var Lx=class extends Nx{constructor(t,n,r,a,o){super(n,r,a,o),this._geometryTypes=t}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function Bx(t,n,r,a,o){let s=Vb(t,r),c=px(s,a,t,r),l,u,d,f;if(c===$.CONST){let c=$b(t,r,s),p,m,h,g;for(let a=0;ar?n[s++]:1);return a}function Hx(t,n,r,a){let o=new Uint32Array(n[n.length-1]+1),s=0;o[0]=s;let c=1,l=0;for(let u=0;u=c);){let r=t[a.increment()];if(r<=127){let c=r+3,l=t[a.increment()],u=Math.min(s+c,n);o.fill(l,s,u),s=u}else{let c=256-r;for(let r=0;r=12?$x.decode(t.subarray(n,r)):aS(t,n,r)}function aS(t,n,r){let a=``,o=n;for(;o239?4:n>223?3:n>191?2:1;if(o+c>r)break;let l,u,d;c===1?n<128&&(s=n):c===2?(l=t[o+1],(l&192)==128&&(s=(n&31)<<6|l&63,s<=127&&(s=null))):c===3?(l=t[o+1],u=t[o+2],(l&192)==128&&(u&192)==128&&(s=(n&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):c===4&&(l=t[o+1],u=t[o+2],d=t[o+3],(l&192)==128&&(u&192)==128&&(d&192)==128&&(s=(n&15)<<18|(l&63)<<12|(u&63)<<6|d&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,c=1):s>65535&&(s-=65536,a+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),a+=String.fromCharCode(s),o+=c}return a}var eS=class extends Fv{constructor(t,n,r,a){super(t,r,a),this.offsetBuffer=n}},tS=class extends eS{constructor(t,n,r,a){super(t,n,r,a??n.length-1)}getValueFromBuffer(t){let n=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return rS(this.dataBuffer,n,r)}},nS=class extends eS{constructor(t,n,r,a,o){super(t,r,a,o??n.length),this.indexBuffer=n,this.indexBuffer=n}getValueFromBuffer(t){let n=this.indexBuffer[t],r=this.offsetBuffer[n],a=this.offsetBuffer[n+1];return rS(this.dataBuffer,r,a)}};function oS(t,n,r){let a=[],o=Array(n.length).fill(0);for(let t=1;t1&&!u.nullable||d===1&&u.nullable)throw Error(`The number of streams for the child field ${u.name} does not match its nullability. nullibilty: ${u.nullable}, numStreams: ${d}`);let h;if(u.nullable){let r=Vb(t,n);h=new Ub(Yx(t,r.numValues,r.byteLength,n),r.numValues)}let g=Yb(t,n,Vb(t,n),void 0,h);f[p++]=l?new iS(m,g,o,s,c,l,h):new nS(m,g,o,s,h)}return f}function fS(t,n,r,a,o,s){return r.type===`scalarType`?s&&!s.has(r.name)?(Jx(a,t,n),null):pS(a,t,n,o,r.scalarType,r):a===0?null:dS(t,n,r,s)}function pS(t,n,r,a,o,s){let c=null;if(t===0)return null;if(s.nullable){let t=Vb(n,r),a=t.numValues,o=r.get(),s=Yx(n,a,t.byteLength,r);r.set(o+t.byteLength),c=new Ub(s,t.numValues)}let l=c??a;switch(o.physicalType){case X.UINT_32:case X.INT_32:return vS(n,r,s,o,l);case X.STRING:{let a=s.nullable?t-1:t;return sS(s.name,n,r,a,c)}case X.BOOLEAN:return mS(n,r,s,a,l);case X.UINT_64:case X.INT_64:return _S(n,r,s,l,o);case X.FLOAT:return hS(n,r,s,l);case X.DOUBLE:return gS(n,r,s,l);default:throw Error(`The specified data type for the field is currently not supported: ${o}`)}}function mS(t,n,r,a,o){let s=Vb(t,n),c=s.numValues,l=n.get(),u=yS(o)?o:void 0,d=Yx(t,c,s.byteLength,n,u);n.set(l+s.byteLength);let f=new Ub(d,c);return new Ux(r.name,f,o)}function hS(t,n,r,a){let o=Vb(t,n),s=yS(a)?a:void 0,c=Zx(t,n,o.numValues,s);return new Wx(r.name,c,a)}function gS(t,n,r,a){let o=Vb(t,n),s=yS(a)?a:void 0,c=Qx(t,n,o.numValues,s);return new Rv(r.name,c,a)}function _S(t,n,r,a,o){let s=Vb(t,n),c=px(s,a,t,n,`int64`),l=o.physicalType===X.INT_64;if(c===$.FLAT){let o=yS(a)?a:void 0,c=l?nx(t,n,s,o):rx(t,n,s,o);return new mx(r.name,c,a)}if(c===$.SEQUENCE){let a=tx(t,n,s);return new hx(r.name,a[0],a[1],s.numRleValues)}let u=l?ax(t,n,s):ox(t,n,s);return new Gx(r.name,u,a,l)}function vS(t,n,r,a,o){let s=Vb(t,n),c=px(s,o,t,n),l=a.physicalType===X.INT_32;if(c===$.FLAT){let a=yS(o)?o:void 0,c=l?Jb(t,n,s,void 0,a):Yb(t,n,s,void 0,a);return new Lv(r.name,c,o)}if(c===$.SEQUENCE){let a=ex(t,n,s);return new Bv(r.name,a[0],a[1],s.numRleValues)}let u=l?Qb(t,n,s):$b(t,n,s);return new Vv(r.name,u,o,l)}function yS(t){return t instanceof Ub}function bS(t){switch(t){case 0:case 1:case 2:case 3:{let n={};n.nullable=(t&1)!=0,n.columnScope=Gv.FEATURE;let r={};return r.type=`logicalType`,r.logicalType=Jv.ID,r.longID=(t&2)!=0,n.scalarType=r,n.type=`scalarType`,n}case 4:{let t={};t.nullable=!1,t.columnScope=Gv.FEATURE;let n={};return n.type=`physicalType`,n.physicalType=qv.GEOMETRY,t.type=`complexType`,t.complexType=n,t}case 30:{let t={};t.nullable=!1,t.columnScope=Gv.FEATURE;let n={};return n.type=`physicalType`,n.physicalType=qv.STRUCT,t.type=`complexType`,t.complexType=n,t}default:return ES(t)}}function xS(t){return t>=10}function SS(t){return t===30}function CS(t){if(t.type===`scalarType`){let n=t.scalarType;if(n.type===`physicalType`)switch(n.physicalType){case X.BOOLEAN:case X.INT_8:case X.UINT_8:case X.INT_32:case X.UINT_32:case X.INT_64:case X.UINT_64:case X.FLOAT:case X.DOUBLE:return!1;case X.STRING:return!0;default:return!1}if(n.type===`logicalType`)return!1}else if(t.type===`complexType`){let n=t.complexType;if(n.type===`physicalType`)switch(n.physicalType){case qv.GEOMETRY:case qv.STRUCT:return!0;default:return!1}}return console.warn(`Unexpected column type in hasStreamCount`,t),!1}function wS(t){return t.type===`scalarType`&&t.scalarType?.type===`logicalType`&&t.scalarType.logicalType===Jv.ID}function TS(t){return t.type===`complexType`&&t.complexType?.type===`physicalType`&&t.complexType.physicalType===qv.GEOMETRY}function ES(t){let n;switch(t){case 10:case 11:n=X.BOOLEAN;break;case 12:case 13:n=X.INT_8;break;case 14:case 15:n=X.UINT_8;break;case 16:case 17:n=X.INT_32;break;case 18:case 19:n=X.UINT_32;break;case 20:case 21:n=X.INT_64;break;case 22:case 23:n=X.UINT_64;break;case 24:case 25:n=X.FLOAT;break;case 26:case 27:n=X.DOUBLE;break;case 28:case 29:n=X.STRING;break;default:return null}let r={};r.nullable=(t&1)!=0,r.columnScope=Gv.FEATURE;let a={};return a.type=`physicalType`,a.physicalType=n,r.type=`scalarType`,r.scalarType=a,r}const DS=new TextDecoder;function OS(t,n){let r=Uy(t,n,1)[0];if(r===0)return``;let a=n.get(),o=a+r,s=t.subarray(a,o);return n.add(r),DS.decode(s)}function kS(t){return{name:t.name,nullable:t.nullable,scalarField:t.scalarType,complexField:t.complexType,type:t.type===`scalarType`?`scalarField`:`complexField`}}function AS(t,n){let r=Uy(t,n,1)[0]>>>0;if(r<10||r>30)throw Error(`Unsupported field type code ${r}. Supported: 10-29(scalars), 30(STRUCT)`);let a=bS(r);if(xS(r)&&(a.name=OS(t,n)),SS(r)){let r=Uy(t,n,1)[0]>>>0;a.complexType.children=Array(r);for(let o=0;o>>0,a=bS(r);if(!a)throw Error(`Unsupported column type code ${r}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(xS(r)?a.name=OS(t,n):r>=0&&r<=3?a.name=`id`:r===4&&(a.name=`geometry`),SS(r)){let r=Uy(t,n,1)[0]>>>0,o=a.complexType;o.children=Array(r);for(let a=0;a>>0,s=Uy(t,n,1)[0]>>>0;a.columns=Array(s);for(let r=0;r>>0,c=a.get()+s;if(c>t.length)throw Error(`Block overruns tile: ${c} > ${t.length}`);if(Uy(t,a,1)[0]>>>0!=1){a.set(c);continue}let[l,u]=MS(t,a),d=l.featureTables[0],f=null,p=null,m=[],h=0;for(let o of d.columns){let s=o.name;if(wS(o)){let n=null;if(o.nullable){let r=Vb(t,a),o=a.get(),s=Yx(t,r.numValues,r.byteLength,a);a.set(o+r.byteLength),n=new Ub(s,r.numValues)}let c=Vb(t,a);h=n?n.size():c.decompressedCount,f=RS(t,o,a,s,c,n??h,r)}else if(TS(o)){let r=Uy(t,a,1)[0];if(h===0){let n=a.get();h=Vb(t,a).decompressedCount,a.set(n)}n&&(n.scale=n.extent/u),p=Bx(t,r,a,h,n)}else{let n=CS(o)?Uy(t,a,1)[0]:1;if(n===0)continue;let r=fS(t,a,o,n,h,void 0);if(r)if(Array.isArray(r))for(let t of r)m.push(t);else m.push(r)}}let g=new Hv(d.name,p,f,m,u);o.push(g),a.set(c)}return o}function RS(t,n,r,a,o,s,c=!1){let l=n.scalarType;if(l?.type!==`logicalType`||l.logicalType!==Jv.ID)throw Error(`ID column must be a logical ID scalar type: ${a}`);let u=l.longID?X.UINT_64:X.UINT_32,d=typeof s==`number`?void 0:s,f=px(o,s,t,r,u===X.UINT_64?`int64`:`int32`);if(u===X.UINT_32)switch(f){case $.FLAT:return new Lv(a,Yb(t,r,o,void 0,d),s);case $.SEQUENCE:{let n=ex(t,r,o);return new Bv(a,n[0],n[1],o.numRleValues)}case $.CONST:return new Vv(a,$b(t,r,o),s,!1)}switch(f){case $.FLAT:return c?new Rv(a,ix(t,r,o),s):new mx(a,rx(t,r,o,d),s);case $.SEQUENCE:{let n=tx(t,r,o);return new hx(a,n[0],n[1],o.numRleValues)}case $.CONST:return new Gx(a,ox(t,r,o),s,!1)}throw Error(`Vector type not supported for id column.`)}var NS=class{constructor(t,n){switch(this._featureData=t,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case bx.POINT:case bx.MULTIPOINT:this.type=1;break;case bx.LINESTRING:case bx.MULTILINESTRING:this.type=2;break;case bx.POLYGON:case bx.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=n,this.id=Number(this._featureData.id)}loadGeometry(){let t=[];for(let n of this._featureData.geometry.coordinates){let r=[];for(let t of n)r.push(new d(t.x,t.y));t.push(r)}return t}},PS=class{constructor(t){this.features=[],this.featureTable=t,this.name=t.name,this.extent=t.extent,this.version=2,this.features=t.getFeatures(),this.length=this.features.length}feature(t){return new NS(this.features[t],this.extent)}},FS=class{constructor(t){this.layers={};let n=LS(new Uint8Array(t));this.layers=n.reduce((t,n)=>({...t,[n.name]:new PS(n)}),{})}},IS=class{constructor(t,n){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new kc(Ye,16,0),this.grid3D=new kc(Ye,16,0),this.featureIndexArray=new uu,this.promoteId=n}insert(t,n,r,a,o,s){let c=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,a,o);let l=s?this.grid3D:this.grid;for(let t of n){let n=[1/0,1/0,-1/0,-1/0];for(let r of t)n[0]=Math.min(n[0],r.x),n[1]=Math.min(n[1],r.y),n[2]=Math.max(n[2],r.x),n[3]=Math.max(n[3],r.y);n[0]<8192&&n[1]<8192&&n[2]>=0&&n[3]>=0&&l.insert(c,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){switch(this.encoding){case`mlt`:this.vtLayers=new FS(this.rawTileData).layers;break;default:this.vtLayers=new nm(new Dg(this.rawTileData)).layers}this.sourceLayerCoder=new Nv(this.vtLayers?Object.keys(this.vtLayers).sort():[Tv])}return this.vtLayers}query(t,n,r,a){this.loadVTLayers();let o=t.params,s=Ye/t.tileSize/t.scale,c=ps(o.filter,`queryRenderedFeatures filter`,o.globalState),l=t.queryGeometry,u=t.queryPadding*s,d=wv.fromPoints(l),f=this.grid.query(d.minX-u,d.minY-u,d.maxX+u,d.maxY+u),p=wv.fromPoints(t.cameraQueryGeometry).expandBy(u),m=this.grid3D.query(p.minX,p.minY,p.maxX,p.maxY,(n,r,a,o)=>Nd(t.cameraQueryGeometry,n-u,r-u,a+u,o+u));for(let t of m)f.push(t);f.sort(HS);let h={},g;for(let u of f){if(u===g)continue;g=u;let d=this.featureIndexArray.get(u),f=null;this.loadMatchingFeature(h,d.bucketIndex,d.sourceLayerIndex,d.featureIndex,c,o.layers,o.availableImages,n,r,a,(n,r,a)=>(f||=_d(n),r.queryIntersectsFeature({queryGeometry:l,feature:n,featureState:a,geometry:f,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation})))}return h}loadMatchingFeature(t,n,r,a,o,s,c,l,u,d,f){let p=this.bucketLayerIDs[n];if(s&&!p.some(t=>s.has(t)))return;let m=this.sourceLayerCoder.decode(r),h=this.vtLayers[m].feature(a);if(o.needGeometry){let t=vd(h,!0);if(!o.filter(new U(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!o.filter(new U(this.tileID.overscaledZ),h))return;let g=this.getId(h,m);for(let n of p){if(s&&!s.has(n))continue;let r=l[n];if(!r)continue;let o={};g&&d&&(o=d.getState(r.sourceLayer||`_geojsonTileLayer`,g));let p=xt({},u[n]);p.paint=VS(p.paint,r.paint,h,o,c),p.layout=VS(p.layout,r.layout,h,o,c);let m=!f||f(h,r,o);if(!m)continue;let _=new Pv(h,this.z,this.x,this.y,g);_.layer=p;let v=t[n];v===void 0&&(v=t[n]=[]),v.push({featureIndex:a,feature:_,intersectionZ:m})}}lookupSymbolFeatures(t,n,r,a,o,s,c,l){let u={};this.loadVTLayers();let d=ps(o.filterSpec,`queryRenderedFeatures symbol filter`,o.globalState);for(let o of t)this.loadMatchingFeature(u,r,a,o,d,s,c,l,n);return u}hasLayer(t){for(let n of this.bucketLayerIDs)for(let r of n)if(t===r)return!0;return!1}getId(t,n){let r=t.id;if(this.promoteId){let a=typeof this.promoteId==`string`?this.promoteId:this.promoteId[n];r=t.properties[a],typeof r==`boolean`&&(r=Number(r)),r===void 0&&t.properties?.cluster&&this.promoteId&&(r=Number(t.properties.cluster_id))}return r}};J(`FeatureIndex`,IS,{omit:[`rawTileData`,`sourceLayerCoder`]});function VS(t,n,r,a,o){return At(t,(t,s)=>{let c=n instanceof fl?n.get(s):null;return c?.evaluate?c.evaluate(r,a,o):c})}function HS(t,n){return n-t}var zS=class{constructor(t,n){this.max=t,this.onRemove=n,this.reset()}reset(){for(let t in this.data)for(let n of this.data[t])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(t,n,r){let a=t.wrapped().key;this.data[a]===void 0&&(this.data[a]=[]);let o={value:n,timeout:void 0};if(r!==void 0&&(o.timeout=setTimeout(()=>{this.remove(t,o)},r)),this.data[a].push(o),this.order.push(a),this.order.length>this.max){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){let n=this.data[t].shift();return n.timeout&&clearTimeout(n.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),n.value}getByKey(t){let n=this.data[t];return n?n[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,n){if(!this.has(t))return this;let r=t.wrapped().key,a=n===void 0?0:this.data[r].indexOf(n),o=this.data[r][a];return this.data[r].splice(a,1),o.timeout&&clearTimeout(o.timeout),this.data[r].length===0&&delete this.data[r],this.onRemove(o.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){let n=[];for(let r in this.data)for(let a of this.data[r])t(a.value)||n.push(a);for(let t of n)this.remove(t.value.tileID,t)}},BS=class{constructor(t){this.maxEntries=t,this.map=/* @__PURE__ */ new Map}get(t){let n=this.map.get(t);return n!==void 0&&(this.map.delete(t),this.map.set(t,n)),n}set(t,n){if(this.map.has(t))this.map.delete(t);else if(this.map.size>=this.maxEntries){let t=this.map.keys().next().value;this.map.delete(t)}this.map.set(t,n)}clear(){this.map.clear()}};function US(t,n,r,a,o){let s=[];for(let c of t){let t;for(let l=0;l=a&&f.x>=a)&&(u.x>=a?u=new d(a,u.y+(f.y-u.y)*((a-u.x)/(f.x-u.x)))._round():f.x>=a&&(f=new d(a,u.y+(f.y-u.y)*((a-u.x)/(f.x-u.x)))._round()),!(u.y>=o&&f.y>=o)&&(u.y>=o?u=new d(u.x+(f.x-u.x)*((o-u.y)/(f.y-u.y)),o)._round():f.y>=o&&(f=new d(u.x+(f.x-u.x)*((o-u.y)/(f.y-u.y)),o)._round()),(!t||!u.equals(t[t.length-1]))&&(t=[u],s.push(t)),t.push(f)))))}}return s}function WS(t,n,r,a,o,s){let c=GS(t,n,r,o,0);return c=GS(c,n,a,s,1),c}function GS(t,n,r,a,o){switch(n){case 1:return KS(t,r,a,o);case 2:return JS(t,r,a,o,!1);case 3:return JS(t,r,a,o,!0)}return[]}function KS(t,n,r,a){let o=[];for(let s of t)for(let t of s){let s=a===0?t.x:t.y;s>=n&&s<=r&&o.push([t])}return o}function qS(t,n,r,a,o){let s=a===0?YS:XS,c=[],l=[];for(let u=0;un&&c.push(s(d,f,n)):p>r?m=n&&(c.push(s(d,f,n)),h=!0),m>r&&p<=r&&(c.push(s(d,f,r)),h=!0),!o&&h&&(l.push(c),c=[])}let u=t.length-1,f=a===0?t[u].x:t[u].y;return f>=n&&f<=r&&c.push(t[u]),o&&c.length>0&&!c[0].equals(c[c.length-1])&&c.push(new d(c[0].x,c[0].y)),c.length>0&&l.push(c),l}function JS(t,n,r,a,o){let s=[];for(let c of t){let t=qS(c,n,r,a,o);t.length>0&&s.push(...t)}return s}function YS(t,n,r){let a=(r-t.x)/(n.x-t.x);return new d(r,t.y+(n.y-t.y)*a)}function XS(t,n,r){let a=(r-t.y)/(n.y-t.y);return new d(t.x+(n.x-t.x)*a,r)}var ZS=class e extends d{constructor(t,n,r,a){super(t,n),this.angle=r,a!==void 0&&(this.segment=a)}clone(){return new e(this.x,this.y,this.angle,this.segment)}};J(`Anchor`,ZS);function QS(t,n,r,a,o){if(n.segment===void 0||r===0)return!0;let s=n,c=n.segment+1,l=0;for(;l>-r/2;){if(c--,c<0)return!1;l-=t[c].dist(s),s=t[c]}l+=t[c].dist(t[c+1]),c++;let u=[],d=0;for(;la;)d-=u.shift().angleDelta;if(d>o)return!1;c++,l+=r.dist(s)}return!0}function $S(t){let n=0;for(let r=0;rd){let f=(d-u)/s,p=new ZS(Di.number(a.x,o.x,f),Di.number(a.y,o.y,f),o.angleTo(a),r);return p._round(),!c||QS(t,p,l,c,n)?p:void 0}u+=s}}function rC(t,n,r,a,o,s,c,l,u){let d=eC(a,s,c),f=tC(a,o),p=f*c,m=t[0].x===0||t[0].x===u||t[0].y===0||t[0].y===u;n-p=0&&y=0&&b=0&&m+d<=f){let r=new ZS(y,b,_,n);r._round(),(!a||QS(t,r,s,a,o))&&h.push(r)}}p+=g}return!l&&!h.length&&!c&&(h=iC(t,p/2,r,a,o,s,c,!0,u)),h}function aC(t,n,r,a){let o=[],s=t.image,c=s.pixelRatio,l=s.paddedRect.w-2,u=s.paddedRect.h-2,f={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom},p=s.stretchX||[[0,l]],m=s.stretchY||[[0,u]],h=(t,n)=>t+n[1]-n[0],g=p.reduce(h,0),_=m.reduce(h,0),v=l-g,y=u-_,b=0,x=g,S=0,C=_,w=0,T=v,E=0,D=y;if(s.content&&a){let n=s.content,r=n[2]-n[0],a=n[3]-n[1];(s.textFitWidth||s.textFitHeight)&&(f=__(t)),b=oC(p,0,n[0]),S=oC(m,0,n[1]),x=oC(p,n[0],n[2]),C=oC(m,n[1],n[3]),w=n[0]-b,E=n[1]-S,T=r-x,D=a-C}let O=f.x1,k=f.y1,A=f.x2-O,j=f.y2-k,M=(t,a,o,l)=>{let u=cC(t.stretch-b,x,A,O),f=dC(t.fixed-w,T,t.stretch,g),p=cC(a.stretch-S,C,j,k),m=dC(a.fixed-E,D,a.stretch,_),h=cC(o.stretch-b,x,A,O),v=dC(o.fixed-w,T,o.stretch,g),y=cC(l.stretch-S,C,j,k),M=dC(l.fixed-E,D,l.stretch,_),ee=new d(u,p),te=new d(h,p),ne=new d(h,y),re=new d(u,y),ie=new d(f/c,m/c),ae=new d(v/c,M/c),oe=n*Math.PI/180;if(oe){let t=Math.sin(oe),n=Math.cos(oe),r=[n,-t,t,n];ee._matMult(r),te._matMult(r),re._matMult(r),ne._matMult(r)}let se=t.stretch+t.fixed,ce=o.stretch+o.fixed,le=a.stretch+a.fixed,ue=l.stretch+l.fixed;return{tl:ee,tr:te,bl:re,br:ne,tex:{x:s.paddedRect.x+1+se,y:s.paddedRect.y+1+le,w:ce-se,h:ue-le},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ie,pixelOffsetBR:ae,minFontScaleX:T/c/A,minFontScaleY:D/c/j,isSDF:r}};if(!a||!s.stretchX&&!s.stretchY)o.push(M({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:u+1}));else{let t=sC(p,v,g),n=sC(m,y,_);for(let r=0;r0&&(a=Math.max(10,a),this.circleDiameter=a)}else{let u=s.image?.content&&(s.image.textFitWidth||s.image.textFitHeight)?__(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};u.y1=u.y1*c-l[0],u.y2=u.y2*c+l[2],u.x1=u.x1*c-l[3],u.x2=u.x2*c+l[1];let p=s.collisionPadding;if(p&&(u.x1-=p[0]*c,u.y1-=p[1]*c,u.x2+=p[2]*c,u.y2+=p[3]*c),f){let t=new d(u.x1,u.y1),n=new d(u.x2,u.y1),r=new d(u.x1,u.y2),a=new d(u.x2,u.y2),o=f*Math.PI/180;t._rotate(o),n._rotate(o),r._rotate(o),a._rotate(o),u.x1=Math.min(t.x,n.x,r.x,a.x),u.x2=Math.max(t.x,n.x,r.x,a.x),u.y1=Math.min(t.y,n.y,r.y,a.y),u.y2=Math.max(t.y,n.y,r.y,a.y)}t.emplaceBack(n.x,n.y,u.x1,u.y1,u.x2,u.y2,r,a,o)}this.boxEndIndex=t.length}},uC=class{constructor(t=[],n=(t,n)=>tn)){if(this.data=t,this.length=this.data.length,this.compare=n,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],n=this.data.pop();return--this.length>0&&(this.data[0]=n,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:n,compare:r}=this,a=n[t];for(;t>0;){let o=t-1>>1,s=n[o];if(r(a,s)>=0)break;n[t]=s,t=o}n[t]=a}_down(t){let{data:n,compare:r}=this,a=this.length>>1,o=n[t];for(;t=0)break;n[t]=n[a],t=a}n[t]=o}};function mC(t,n=1){let r=wv.fromPoints(t[0]),a=Math.min(r.width(),r.height()),o=a/2,s=new uC([],hC),{minX:c,minY:l,maxX:u,maxY:f}=r;if(a===0)return new d(c,l);for(let n=c;nm.d||!m.d)&&(m=r),!(r.max-m.d<=n)&&(o=r.h/2,s.push(new pC(r.p.x-o,r.p.y-o,o,t)),s.push(new pC(r.p.x+o,r.p.y-o,o,t)),s.push(new pC(r.p.x-o,r.p.y+o,o,t)),s.push(new pC(r.p.x+o,r.p.y+o,o,t)))}return p.d>0&&m.d-p.d<=n?p.p:m.p}function hC(t,n){return n.max-t.max}var pC=class{constructor(t,n,r,a){this.p=new d(t,n),this.h=r,this.d=gC(this.p,a),this.max=this.d+this.h*Math.SQRT2}};function gC(t,n){let r=!1,a=1/0;for(let o of n)for(let n=0,s=o.length,c=s-1;nt.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(r=!r),a=Math.min(a,Ad(t,s,l))}return(r?1:-1)*Math.sqrt(a)}function _C(t){let n=0,r=0,a=0,o=t[0];for(let t=0,s=o.length,c=s-1;tt*24);a.startsWith(`top`)?o[1]-=7:a.startsWith(`bottom`)&&(o[1]+=7),n[r+1]=o}return new $r(n)}let s=a.get(`text-variable-anchor`);if(s){let o;o=t._unevaluatedLayout.getValue(`text-radial-offset`)===void 0?a.get(`text-offset`).evaluate(n,{},r).map(t=>t*24):[a.get(`text-radial-offset`).evaluate(n,{},r)*24,yC];let c=[];for(let t of s)c.push(t,bC(t,o));return new $r(c)}return null}function SC(t){t.bucket.createArrays();let n=512*t.bucket.overscaling;t.bucket.tilePixelRatio=Ye/n,t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;let r=t.bucket.layers[0],a=r.layout,o=r._unevaluatedLayout._values,s={layoutIconSize:o[`icon-size`].possiblyEvaluate(new U(t.bucket.zoom+1),t.canonical),layoutTextSize:o[`text-size`].possiblyEvaluate(new U(t.bucket.zoom+1),t.canonical),textMaxSize:o[`text-size`].possiblyEvaluate(new U(18))};if(t.bucket.textSizeData.kind===`composite`){let{minZoom:n,maxZoom:r}=t.bucket.textSizeData;s.compositeTextSizes=[o[`text-size`].possiblyEvaluate(new U(n),t.canonical),o[`text-size`].possiblyEvaluate(new U(r),t.canonical)]}if(t.bucket.iconSizeData.kind===`composite`){let{minZoom:n,maxZoom:r}=t.bucket.iconSizeData;s.compositeIconSizes=[o[`icon-size`].possiblyEvaluate(new U(n),t.canonical),o[`icon-size`].possiblyEvaluate(new U(r),t.canonical)]}let c=a.get(`text-line-height`)*24,l=a.get(`text-rotation-alignment`)!==`viewport`&&a.get(`symbol-placement`)!==`point`,u=a.get(`text-keep-upright`),d=a.get(`text-size`);for(let n of t.bucket.features){let o=a.get(`text-font`).evaluate(n,{},t.canonical).join(`,`),f=d.evaluate(n,{},t.canonical),p=s.layoutTextSize.evaluate(n,{},t.canonical),m=s.layoutIconSize.evaluate(n,{},t.canonical),h={horizontal:{},vertical:void 0},g=n.text,_=[0,0];if(g){let s=g.toString(),d=a.get(`text-letter-spacing`).evaluate(n,{},t.canonical)*24,m=Gc(s)?d:0,v=a.get(`text-anchor`).evaluate(n,{},t.canonical),y=xC(r,n,t.canonical);if(!y){let r=a.get(`text-radial-offset`).evaluate(n,{},t.canonical);_=r?bC(v,[r*24,yC]):a.get(`text-offset`).evaluate(n,{},t.canonical).map(t=>t*24)}let b=l?`center`:a.get(`text-justify`).evaluate(n,{},t.canonical),x=a.get(`symbol-placement`)===`point`?a.get(`text-max-width`).evaluate(n,{},t.canonical)*24:1/0,S=()=>{t.bucket.allowVerticalPlacement&&Wc(s)&&(h.vertical=a_(g,t.glyphMap,t.glyphPositions,t.imagePositions,o,x,c,v,`left`,m,_,2,!0,p,f))};if(!l&&y){let n=/* @__PURE__ */ new Set;if(b===`auto`)for(let t=0;t{p.x<0||p.x>=8192||p.y<0||p.y>=8192||OC(t,p,l,r,a,o,j,t.layers[0],t.collisionBoxArray,n.index,n.sourceLayerIndex,t.index,y,[C,C,C,C],E,u,x,w,D,g,n,s,d,f,c)};if(O===`line`)for(let o of US(n.geometry,0,0,Ye,Ye)){let n=Pp(o,M),s=rC(n,S,T,r.vertical||_,a,24,b,t.overscaling,Ye);for(let r of s){let a=_;(!a||!kC(t,a.text,k,r))&&ee(n,r)}}else if(O===`line-center`){for(let t of n.geometry)if(t.length>1){let n=Pp(t,M),o=nC(n,T,r.vertical||_,a,24,b);o&&ee(n,o)}}else if(n.type===`Polygon`)for(let t of Ma(n.geometry,0)){let n=mC(t,16);ee(Pp(t[0],M,!0),new ZS(n.x,n.y,0))}else if(n.type===`LineString`)for(let t of n.geometry){let n=Pp(t,M);ee(n,new ZS(n[0].x,n[0].y,0))}else if(n.type===`Point`)for(let t of n.geometry)for(let n of t)ee([n],new ZS(n.x,n.y,0))}function TC(t,n){let r=t.length,a=n?.values;if(a?.length>0)for(let n=0;n32640&&Ft(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):v.kind===`composite`&&(y=[128*h.compositeTextSizes[0].evaluate(c,{},g),128*h.compositeTextSizes[1].evaluate(c,{},g)],(y[0]>32640||y[1]>32640)&&Ft(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,_,y,l,s,c,d,n,u.lineStartIndex,u.lineLength,m,g);for(let n of f)p[n]=t.text.placedSymbolArray.length-1;return _.length*4}function DC(t){for(let n in t)return t[n];return null}function OC(t,n,r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E){let D=t.addToLineVertexArray(n,r),O,k,A,j,M=0,ee=0,te=0,ne=0,re=-1,ie=-1,ae={},oe=(0,Bu.default)(``);if(t.allowVerticalPlacement&&a.vertical){let t=l.layout.get(`text-rotate`).evaluate(S,{},T)+90,r=a.vertical;A=new lC(u,n,d,f,p,r,m,h,g,t),c&&(j=new lC(u,n,d,f,p,c,v,y,g,t))}if(o){let r=l.layout.get(`icon-rotate`).evaluate(S,{}),a=l.layout.get(`icon-text-fit`)!==`none`,s=aC(o,r,w,a),m=c?aC(c,r,w,a):void 0;k=new lC(u,n,d,f,p,o,v,y,!1,r),M=s.length*4;let h=t.iconSizeData,g=null;h.kind===`source`?(g=[128*l.layout.get(`icon-size`).evaluate(S,{})],g[0]>32640&&Ft(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):h.kind===`composite`&&(g=[128*C.compositeIconSizes[0].evaluate(S,{},T),128*C.compositeIconSizes[1].evaluate(S,{},T)],(g[0]>32640||g[1]>32640)&&Ft(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,g,x,b,S,0,n,D.lineStartIndex,D.lineLength,-1,T),re=t.icon.placedSymbolArray.length-1,m&&(ee=m.length*4,t.addSymbols(t.icon,m,g,x,b,S,2,n,D.lineStartIndex,D.lineLength,-1,T),ie=t.icon.placedSymbolArray.length-1)}let se=Object.keys(a.horizontal);for(let r of se){let o=a.horizontal[r];O||=(oe=(0,Bu.default)(o.text),new lC(u,n,d,f,p,o,m,h,g,l.layout.get(`text-rotate`).evaluate(S,{},T)));let c=o.positionedLines.length===1;if(te+=EC(t,n,o,s,l,g,S,_,D,a.vertical?1:3,c?se:[r],ae,re,C,T),c)break}a.vertical&&(ne+=EC(t,n,a.vertical,s,l,g,S,_,D,2,[`vertical`],ae,ie,C,T));let ce=O?O.boxStartIndex:t.collisionBoxArray.length,le=O?O.boxEndIndex:t.collisionBoxArray.length,ue=A?A.boxStartIndex:t.collisionBoxArray.length,de=A?A.boxEndIndex:t.collisionBoxArray.length,fe=k?k.boxStartIndex:t.collisionBoxArray.length,pe=k?k.boxEndIndex:t.collisionBoxArray.length,me=j?j.boxStartIndex:t.collisionBoxArray.length,he=j?j.boxEndIndex:t.collisionBoxArray.length,ge=-1,_e=(t,n)=>t?.circleDiameter?Math.max(t.circleDiameter,n):n;ge=_e(O,ge),ge=_e(A,ge),ge=_e(k,ge),ge=_e(j,ge);let ve=+(ge>-1);ve&&(ge*=E/24),t.glyphOffsetArray.length>=O_.MAX_GLYPHS&&Ft(`Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907`),S.sortKey!==void 0&&t.addToSortKeyRanges(t.symbolInstances.length,S.sortKey);let ye=xC(l,S,T),[be,xe]=TC(t.textAnchorOffsets,ye);t.symbolInstances.emplaceBack(n.x,n.y,ae.right>=0?ae.right:-1,ae.center>=0?ae.center:-1,ae.left>=0?ae.left:-1,ae.vertical||-1,re,ie,oe,ce,le,ue,de,fe,pe,me,he,d,te,ne,M,ee,ve,0,m,ge,be,xe)}function kC(t,n,r,a){let o=t.compareText;if(!(n in o))o[n]=[];else{let t=o[n];for(let n=t.length-1;n>=0;n--)if(a.dist(t[n])()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));function l(e,t){this.x=e,this.y=t}l.prototype={clone(){return new l(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,n=e.y-this.y;return t*t+n*n},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,n=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=n,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),n=Math.sin(e),r=t*this.x-n*this.y,i=n*this.x+t*this.y;return this.x=r,this.y=i,this},_rotateAround(e,t){let n=Math.cos(e),r=Math.sin(e),i=t.x+n*(this.x-t.x)-r*(this.y-t.y),a=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=i,this.y=a,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:l},l.convert=function(e){if(e instanceof l)return e;if(Array.isArray(e))return new l(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new l(+e.x,+e.y);throw Error(`Expected [x, y] or {x, y} point format`)};function u(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let n=e;for(let r=0;r<8;r++){let r=((o*n+a)*n+i)*n-e;if(Math.abs(r)s?r=n:u=n,n=(r+u)*.5}return((l*n+c)*n+s)*n}}let d;function f(){return d??=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)&&typeof createImageBitmap==`function`,d}let p;function m(){if(p==null&&(p=!1,f())){let e=new OffscreenCanvas(5,5).getContext(`2d`,{willReadFrequently:!0});if(e){for(let t=0;t<25;t++){let n=t*4;e.fillStyle=`rgb(${n},${n+1},${n+2})`,e.fillRect(t%5,Math.floor(t/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let e=0;e<100;e++)if(e%4!=3&&t[e]!==e){p=!0;break}}}return p||!1}var h=typeof Float32Array<`u`?Float32Array:Array;Math.PI/180,180/Math.PI;function g(){var e=new h(9);return h!=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 _(e){var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*(l*a-o*c)+n*(-l*i+o*s)+r*(c*i-a*s)}function v(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=-n,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function y(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,c=i+i,l=n*o,u=r*o,d=r*s,f=i*o,p=i*s,m=i*c,h=a*o,g=a*s,_=a*c;return e[0]=1-d-m,e[3]=u-_,e[6]=f+g,e[1]=u+_,e[4]=1-l-m,e[7]=p-h,e[2]=f-g,e[5]=p+h,e[8]=1-l-d,e}function b(){var e=new h(16);return h!=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 x(e){var t=new h(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 S(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 C(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 w(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=n*s-r*o,y=n*c-i*o,b=n*l-a*o,x=r*c-i*s,S=r*l-a*s,C=i*l-a*c,w=u*h-d*m,T=u*g-f*m,E=u*_-p*m,D=d*g-f*h,O=d*_-p*h,k=f*_-p*g,A=v*k-y*O+b*D+x*E-S*T+C*w;return A?(A=1/A,e[0]=(s*k-c*O+l*D)*A,e[1]=(i*O-r*k-a*D)*A,e[2]=(h*C-g*S+_*x)*A,e[3]=(f*S-d*C-p*x)*A,e[4]=(c*E-o*k-l*T)*A,e[5]=(n*k-i*E+a*T)*A,e[6]=(g*b-m*C-_*y)*A,e[7]=(u*C-f*b+p*y)*A,e[8]=(o*O-s*E+l*w)*A,e[9]=(r*E-n*O-a*w)*A,e[10]=(m*S-h*b+_*v)*A,e[11]=(d*b-u*S-p*v)*A,e[12]=(s*T-o*D-c*w)*A,e[13]=(n*D-r*T+i*w)*A,e[14]=(h*y-m*x-g*v)*A,e[15]=(u*x-d*y+f*v)*A,e):null}function T(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=n[0],b=n[1],x=n[2],S=n[3];return e[0]=y*r+b*s+x*d+S*h,e[1]=y*i+b*c+x*f+S*g,e[2]=y*a+b*l+x*p+S*_,e[3]=y*o+b*u+x*m+S*v,y=n[4],b=n[5],x=n[6],S=n[7],e[4]=y*r+b*s+x*d+S*h,e[5]=y*i+b*c+x*f+S*g,e[6]=y*a+b*l+x*p+S*_,e[7]=y*o+b*u+x*m+S*v,y=n[8],b=n[9],x=n[10],S=n[11],e[8]=y*r+b*s+x*d+S*h,e[9]=y*i+b*c+x*f+S*g,e[10]=y*a+b*l+x*p+S*_,e[11]=y*o+b*u+x*m+S*v,y=n[12],b=n[13],x=n[14],S=n[15],e[12]=y*r+b*s+x*d+S*h,e[13]=y*i+b*c+x*f+S*g,e[14]=y*a+b*l+x*p+S*_,e[15]=y*o+b*u+x*m+S*v,e}function E(e,t,n){var r=n[0],i=n[1],a=n[2],o,s,c,l,u,d,f,p,m,h,g,_;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*a+t[12],e[13]=t[1]*r+t[5]*i+t[9]*a+t[13],e[14]=t[2]*r+t[6]*i+t[10]*a+t[14],e[15]=t[3]*r+t[7]*i+t[11]*a+t[15]):(o=t[0],s=t[1],c=t[2],l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],e[0]=o,e[1]=s,e[2]=c,e[3]=l,e[4]=u,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=g,e[11]=_,e[12]=o*r+u*i+m*a+t[12],e[13]=s*r+d*i+h*a+t[13],e[14]=c*r+f*i+g*a+t[14],e[15]=l*r+p*i+_*a+t[15]),e}function D(e,t,n){var r=n[0],i=n[1],a=n[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]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function O(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=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]=a*i+l*r,e[5]=o*i+u*r,e[6]=s*i+d*r,e[7]=c*i+f*r,e[8]=l*i-a*r,e[9]=u*i-o*r,e[10]=d*i-s*r,e[11]=f*i-c*r,e}function k(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[8],u=t[9],d=t[10],f=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]=a*i-l*r,e[1]=o*i-u*r,e[2]=s*i-d*r,e[3]=c*i-f*r,e[8]=a*r+l*i,e[9]=o*r+u*i,e[10]=s*r+d*i,e[11]=c*r+f*i,e}function A(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[4],u=t[5],d=t[6],f=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]=a*i+l*r,e[1]=o*i+u*r,e[2]=s*i+d*r,e[3]=c*i+f*r,e[4]=l*i-a*r,e[5]=u*i-o*r,e[6]=d*i-s*r,e[7]=f*i-c*r,e}function ee(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 te(e,t,n,r,i){var a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var o=1/(r-i);e[10]=(i+r)*o,e[14]=2*i*r*o}else e[10]=-1,e[14]=-2*r;return e}var ne=te;function re(e,t,n,r,i,a,o){var s=1/(t-n),c=1/(r-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*c,e[14]=(o+a)*l,e[15]=1,e}var ie=re;function ae(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 oe(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],u=e[8],d=e[9],f=e[10],p=e[11],m=e[12],h=e[13],g=e[14],_=e[15],v=t[0],y=t[1],b=t[2],x=t[3],S=t[4],C=t[5],w=t[6],T=t[7],E=t[8],D=t[9],O=t[10],k=t[11],A=t[12],ee=t[13],te=t[14],ne=t[15];return Math.abs(n-v)<=1e-6*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(r-y)<=1e-6*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(o-S)<=1e-6*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(s-C)<=1e-6*Math.max(1,Math.abs(s),Math.abs(C))&&Math.abs(c-w)<=1e-6*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(l-T)<=1e-6*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(u-E)<=1e-6*Math.max(1,Math.abs(u),Math.abs(E))&&Math.abs(d-D)<=1e-6*Math.max(1,Math.abs(d),Math.abs(D))&&Math.abs(f-O)<=1e-6*Math.max(1,Math.abs(f),Math.abs(O))&&Math.abs(p-k)<=1e-6*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(m-A)<=1e-6*Math.max(1,Math.abs(m),Math.abs(A))&&Math.abs(h-ee)<=1e-6*Math.max(1,Math.abs(h),Math.abs(ee))&&Math.abs(g-te)<=1e-6*Math.max(1,Math.abs(g),Math.abs(te))&&Math.abs(_-ne)<=1e-6*Math.max(1,Math.abs(_),Math.abs(ne))}function se(){var e=new h(3);return h!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ce(e){var t=new h(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function le(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function ue(e,t,n){var r=new h(3);return r[0]=e,r[1]=t,r[2]=n,r}function de(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function fe(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function pe(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function me(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e}function he(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function ge(e,t){var n=t[0],r=t[1],i=t[2],a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function _e(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ve(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-a*s,e[1]=a*o-r*c,e[2]=r*s-i*o,e}function ye(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o||=1,e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/o,e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e}function be(e,t,n){var r=t[0],i=t[1],a=t[2];return e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8],e}function xe(e,t,n){var r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],c=t[1],l=t[2],u=i*l-a*c,d=a*s-r*l,f=r*c-i*s;return u+=u,d+=d,f+=f,e[0]=s+o*u+i*f-a*d,e[1]=c+o*d+a*u-r*f,e[2]=l+o*f+r*d-i*u,e}function Se(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function Ce(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function we(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function Te(e){return e[0]=0,e[1]=0,e[2]=0,e}var Ee=fe,De=le;(function(){var e=se();return function(t,n,r,i,a,o){var s,c;for(n||=3,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=i*o,e[3]=a*o,e}function Me(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}var Ne=ke;(function(){var e=Oe();return function(t,n,r,i,a,o){var s,c;for(n||=4,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s1e-6?(f=Math.acos(p),m=Math.sin(f),h=Math.sin((1-r)*f)/m,g=Math.sin(r*f)/m):(h=1-r,g=r),e[0]=h*i+g*c,e[1]=h*a+g*l,e[2]=h*o+g*u,e[3]=h*s+g*d,e}function Le(e,t){var n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+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 i=0;t[4]>t[0]&&(i=1),t[8]>t[i*3+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[i*3+i]-t[a*3+a]-t[o*3+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[a*3+o]-t[o*3+a])*r,e[a]=(t[a*3+i]+t[i*3+a])*r,e[o]=(t[o*3+i]+t[i*3+o])*r}return e}function Re(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`zyx`,a=Math.PI/360;t*=a,r*=a,n*=a;var o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=Math.sin(r),d=Math.cos(r);switch(i){case`xyz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`xzy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d+o*c*u;break;case`yxz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;case`yzx`:e[0]=o*l*d+s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d-o*c*u;break;case`zxy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`zyx`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;default:throw Error(`Unknown angle order `+i)}return e}var ze=je;(function(){var e=se(),t=ue(1,0,0),n=ue(0,1,0);return function(r,i,a){var o=_e(i,a);return o<-.999999?(ve(e,t,i),De(e)<1e-6&&ve(e,n,i),ge(e,e),Fe(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(ve(e,i,a),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,ze(r,r))}})(),function(){var e=Pe(),t=Pe();return function(n,r,i,a,o,s){return Ie(e,r,o,s),Ie(t,i,a,s),Ie(n,e,t,2*s*(1-s)),n}}(),function(){var e=g();return function(t,n,r,i){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],ze(t,Le(t,e))}}();function Be(){var e=new h(2);return h!=Float32Array&&(e[0]=0,e[1]=0),e}function Ve(e,t){var n=new h(2);return n[0]=e,n[1]=t,n}function He(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function Ue(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)}function We(e){var t=e[0],n=e[1];return t*t+n*n}function Ge(e,t){return e[0]*t[0]+e[1]*t[1]}function Ke(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e}function qe(e){return e[0]=0,e[1]=0,e}var Je=We;(function(){var e=Be();return function(t,n,r,i,a,o){var s,c;for(n||=2,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s0?s:-s}function lt(e,t){let n=dt(e,360),r=dt(t,360),i=r-n,a=r>n?i-360:i+360;return Math.abs(i)e.canonical.z)),n=1/0,r=-1/0,i=1/0,a=-1/0,o=[];for(let s of e){let{x:e,y:c,z:l}=s.canonical,u=2**(t-l),d=e*u,f=c*u;o.push({id:s,x:d,y:f}),dr&&(r=d),fa&&(a=f)}let s=new Set;for(let e of o)(e.x===n||e.x===r||e.y===i||e.y===a)&&s.add(e.id);return s}function gt(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function _t(e,t,n,r){return u(e,t,n,r)}const vt=_t(.25,.1,.25,1);function yt(e,t,n){return Math.min(n,Math.max(t,e))}function bt(e,t,n){let r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function xt(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}function St(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}let Ct=1;function wt(){return Ct++}function Tt(e){return Math.log(e)/Math.LN2%1==0}function Et(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}function Dt(e){return 2**e}function Ot(e){return Math.log(e)/Math.LN2}function kt(e,t,n){if(t<=0)return e;let r=1/t;return n===void 0||Math.abs(n)<1e-10?Math.round(e*r)/r:(n>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r}function At(e,t,n){let r={};for(let i in e)r[i]=t.call(n||this,e[i],i,e);return r}function jt(e,t,n){let r={};for(let i in e)t.call(n||this,e[i],i,e)&&(r[i]=e[i]);return r}function Mt(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n(t.y-e.y)*(n.x-e.x)}function Lt(e,t,n,r){let i=t.y-e.y,a=t.x-e.x,o=r.y-n.y,s=r.x-n.x,c=o*a-s*i;if(c===0)return null;let u=e.y-n.y,d=e.x-n.x,f=(s*u-o*d)/c;return new l(e.x+f*a,e.y+f*i)}function Rt([e,t,n]){return t+=90,t*=Math.PI/180,n*=Math.PI/180,[e*Math.cos(t)*Math.sin(n),e*Math.sin(t)*Math.sin(n),e*Math.cos(n)]}function zt(e){return typeof WorkerGlobalScope<`u`&&e!==void 0&&e instanceof WorkerGlobalScope}function Bt(e){let t=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,n={};if(e.replace(t,(e,t,r,i)=>{let a=r||i;return n[t]=!a||a.toLowerCase(),``}),n[`max-age`]){let e=parseInt(n[`max-age`],10);isNaN(e)?delete n[`max-age`]:n[`max-age`]=e}return n}let Vt=null;function Ht(e){if(Vt==null){let t=e.navigator?e.navigator.userAgent:null;Vt=!!e.safari||!!(t&&(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match(`Safari`)&&!t.match(`Chrome`)))}return Vt}function Ut(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap}const Wt=async(e,t)=>{if(e.byteLength===0)return createImageBitmap(new ImageData(1,1),t);let n=new Blob([new Uint8Array(e)],{type:`image/png`});try{return createImageBitmap(n,t)}catch(e){throw Error(`Could not load image because of ${Qe(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}},Gt=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=`,Kt=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>r.src=Gt)},r.onerror=()=>n(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 i=new Blob([new Uint8Array(e)],{type:`image/png`});r.src=e.byteLength?URL.createObjectURL(i):Gt});function qt(e,t,n,r,i){let a=Math.max(-t,0)*4,o=(Math.max(0,n)-n)*r*4+a,s=r*4,c=Math.max(0,t),l=Math.max(0,n),u=Math.min(e.width,t+r),d=Math.min(e.height,n+i);return{rect:{x:c,y:l,width:u-c,height:d-l},layout:[{offset:o,stride:s}]}}async function Jt(e,t,n,r,i){if(typeof VideoFrame>`u`)throw Error(`VideoFrame not supported`);let a=new VideoFrame(e,{timestamp:0});try{let o=a?.format;if(!o||!(o.startsWith(`BGR`)||o.startsWith(`RGB`)))throw Error(`Unrecognized format ${o}`);let s=o.startsWith(`BGR`),c=new Uint8ClampedArray(r*i*4);if(await a.copyTo(c,qt(e,t,n,r,i)),s)for(let e=0;e{e.removeEventListener(t,n,r)}}}function en(e){return e*Math.PI/180}function tn(e){return e/Math.PI*180}function nn(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function rn(e){let t=new Float64Array(9);y(t,e);let n=tn(-Math.asin(yt(t[2],-1,1))),r,i;return Math.hypot(t[5],t[8])<.001?(r=0,i=-tn(Math.atan2(t[3],t[4]))):(r=tn(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),i=tn(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:r,pitch:n+90,bearing:i}}function an(e,t,n){let r=Ve(t.x-n.x,t.y-n.y),i=Ve(e.x-n.x,e.y-n.y),a=r[0]*i[1]-r[1]*i[0];return tn(Math.atan2(a,Ge(r,i)))}function on(e,t,n){let r=new Float64Array(4);return Re(r,e,t-90,n),r}const sn=85.051129,cn={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ln={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function un(e,t){return cn[t]&&`touches`in e}function dn(e,t){if(!ln[t])return!1;let n=e,r=(n?.target)?.ownerDocument?.defaultView||window;return n instanceof r.MouseEvent||n instanceof r.WheelEvent}function fn(e){return cn[e]||ln[e]}const pn=`AbortError`;var mn=class extends Error{constructor(e=pn){super(e instanceof Error?e.message:e),this.name=pn,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function hn(e){return e instanceof Error&&e.name===`AbortError`}function gn(e){if(e.aborted)throw new mn(e.reason)}const _n={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:``};function vn(e){return _n.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf(`://`))]}function yn(e,t){_n.REGISTERED_PROTOCOLS[e]=t}function bn(e){delete _n.REGISTERED_PROTOCOLS[e]}const xn=`global-dispatcher`;var Sn=class extends Error{constructor(e,t,n,r){super(`AJAXError: ${t} (${e}): ${n}`),this.status=e,this.statusText=t,this.url=n,this.body=r}};function Cn(){if(zt(self))return self.worker?.referrer;if(window.location.protocol===`blob:`)try{return window.parent.location.href}catch{}return window.location.href}const wn=e=>e.startsWith(`file:`)||Cn()?.startsWith(`file:`)&&!/^\w+:/.test(e);async function Tn(e,t){let n=new Request(e.url,{method:e.method||`GET`,body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:Cn(),referrerPolicy:e.referrerPolicy,signal:t.signal});e.type===`json`&&!n.headers.has(`Accept`)&&n.headers.set(`Accept`,`application/json`);let r;try{r=await fetch(n)}catch(t){throw hn(t)?t:new Sn(0,Qe(t).message,e.url,new Blob)}if(!r.ok){let t=await r.blob();throw new Sn(r.status,r.statusText,e.url,t)}let i;i=e.type===`arrayBuffer`||e.type===`image`?r.arrayBuffer():e.type===`json`?r.json():r.text();let a=await i;return gn(t.signal),{data:a,cacheControl:r.headers.get(`Cache-Control`),expires:r.headers.get(`Expires`),etag:r.headers.get(`ETag`)}}function En(e,t){return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(e.method||`GET`,e.url,!0),(e.type===`arrayBuffer`||e.type===`image`)&&(i.responseType=`arraybuffer`);for(let t in e.headers)i.setRequestHeader(t,e.headers[t]);e.type===`json`&&(i.responseType=`text`,e.headers?.Accept||i.setRequestHeader(`Accept`,`application/json`)),i.withCredentials=e.credentials===`include`,i.onerror=()=>{r(Error(i.statusText))},i.onload=()=>{if(!t.signal.aborted)if((i.status>=200&&i.status<300||i.status===0)&&i.response!==null){let t=i.response;if(e.type===`json`)try{t=JSON.parse(i.response)}catch(e){r(e);return}n({data:t,cacheControl:i.getResponseHeader(`Cache-Control`),expires:i.getResponseHeader(`Expires`),etag:i.getResponseHeader(`ETag`)})}else{let t=new Blob([i.response],{type:i.getResponseHeader(`Content-Type`)});r(new Sn(i.status,i.statusText,e.url,t))}},t.signal.addEventListener(`abort`,()=>{i.abort(),r(new mn(t.signal.reason))}),i.send(e.body)})}const Dn=async function(e,t){if(e.url.includes(`://`)&&!/^https?:|^file:/.test(e.url)){let n=vn(e.url);if(n){let r=await n(e,t);return!r.data&&e.type===`arrayBuffer`?xt(r,{data:new ArrayBuffer(0)}):r}if(zt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,targetMapId:xn},t)}if(!wn(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,`signal`))return Tn(e,t);if(zt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,mustQueue:!0,targetMapId:xn},t)}return En(e,t)},On=(e,t)=>Dn(xt(e,{type:`json`}),t),kn=(e,t)=>Dn(xt(e,{type:`arrayBuffer`}),t);function An(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),n=window.location;return t.protocol===n.protocol&&t.host===n.host}const jn=e=>{let t=window.document.createElement(`video`);return t.muted=!0,new Promise(n=>{t.onloadstart=()=>{n(t)};for(let n of e){let e=window.document.createElement(`source`);An(n)||(t.crossOrigin=`Anonymous`),e.src=n,t.appendChild(e)}})};function Mn(e,t,n){n[e]?.includes(t)||(n[e]||=[],n[e].push(t))}function Nn(e,t,n){if(n?.[e]){let r=n[e].indexOf(t);r!==-1&&n[e].splice(r,1)}}var Pn=class{constructor(e,t={}){xt(this,t),this.type=e}},Fn=class extends Pn{constructor(e,t={}){super(`error`,xt({error:e},t))}},In=class{on(e,t){return this._listeners||={},Mn(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return Nn(e,t,this._listeners),Nn(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||={},Mn(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){typeof e==`string`&&(e=new Pn(e,t||{}));let n=e.type;if(this.listens(n)){e.target=this;let t=this._listeners?.[n]?this._listeners[n].slice():[];for(let n of t)n.call(this,e);let r=this._oneTimeListeners?.[n]?this._oneTimeListeners[n].slice():[];for(let t of r)Nn(n,t,this._oneTimeListeners),t.call(this,e);let i=this._eventedParent;i&&(xt(e,typeof this._eventedParentData==`function`?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Fn&&console.error(e.error);return this}listens(e){return this._listeners?.[e]?.length>0||this._oneTimeListeners?.[e]?.length>0||this._eventedParent?.listens(e)}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}};const 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:{required:!0,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`]},"property-type":`data-constant`},"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`},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,minimum:0,units:`meters`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-base":{type:`number`,default:0,minimum: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`}]}}}}},Ln=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function Rn(e,t){let n={};for(let t in e)t!==`ref`&&(n[t]=e[t]);return Ln.forEach(e=>{e in t&&(n[e]=t[e])}),n}function zn(e){e=e.slice();let t=Object.create(null);for(let n=0;n{`source`in e&&r[e.source]?n.push({command:`removeLayer`,args:[e.id]}):a.push(e)}),n=n.concat(i),Yn(a,t.layers,n)}catch(e){console.warn(`Unable to compute style diff:`,e),n=[{command:`setStyle`,args:[t]}]}return n}var N=class{constructor(e,t,n,r,i=`error`){this.message=(e?`${e}: `:``)+n,r&&(this.identifier=r),this.severity=i,t!=null&&t.__line__&&(this.line=t.__line__)}},Zn=class extends Error{constructor(e,t){super(t),this.message=t,this.key=e}},Qn=class e{constructor(e,t=[]){this.parent=e,this.bindings={};for(let[e,n]of t)this.bindings[e]=n}concat(t){return new e(this,t)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw Error(`${e} not found in scope.`)}has(e){return this.bindings[e]?!0:this.parent?this.parent.has(e):!1}};const $n={kind:`null`},P={kind:`number`},F={kind:`string`},I={kind:`boolean`},er={kind:`color`},tr={kind:`projectionDefinition`},nr={kind:`object`},L={kind:`value`},rr={kind:`error`},ir={kind:`collator`},ar={kind:`formatted`},or={kind:`padding`},sr={kind:`colorArray`},cr={kind:`numberArray`},lr={kind:`resolvedImage`},ur={kind:`variableAnchorOffsetCollection`};function dr(e,t){return{kind:`array`,itemType:e,N:t}}function R(e){if(e.kind===`array`){let t=R(e.itemType);return typeof e.N==`number`?`array<${t}, ${e.N}>`:e.itemType.kind===`value`?`array`:`array<${t}>`}else return e.kind}const fr=[$n,P,F,I,er,tr,ar,nr,dr(L),or,cr,sr,lr,ur];function pr(e,t){if(t.kind===`error`)return null;if(e.kind===`array`){if(t.kind===`array`&&(t.N===0&&t.itemType.kind===`value`||!pr(e.itemType,t.itemType))&&(typeof e.N!=`number`||e.N===t.N))return null}else if(e.kind===t.kind)return null;else if(e.kind===`value`){for(let e of fr)if(!pr(e,t))return null}return`Expected ${R(e)} but found ${R(t)} instead.`}function mr(e,t){return t.some(t=>t.kind===e.kind)}function hr(e,t){return t.some(t=>t===`null`?e===null:t===`array`?Array.isArray(e):t===`object`?e&&!Array.isArray(e)&&typeof e==`object`:t===typeof e)}function gr(e,t){return e.kind===`array`&&t.kind===`array`?e.itemType.kind===t.itemType.kind&&typeof e.N==`number`:e.kind===t.kind}const _r=.96422,vr=.82521,yr=4/29,br=6/29,xr=3*br*br,Sr=Math.PI/180,Cr=180/Math.PI;function wr(e){return e%=360,e<0&&(e+=360),e}function Tr([e,t,n,r]){e=Er(e),t=Er(t),n=Er(n);let i,a,o=Dr((.2225045*e+.7168786*t+.0606169*n)/1);e===t&&t===n?i=a=o:(i=Dr((.4360747*e+.3850649*t+.1430804*n)/_r),a=Dr((.0139322*e+.0971045*t+.7141733*n)/vr));let s=116*o-16;return[s<0?0:s,500*(i-o),200*(o-a),r]}function Er(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Dr(e){return e>.008856451679035631?e**(1/3):e/xr+yr}function Or([e,t,n,r]){let i=(e+16)/116,a=isNaN(t)?i:i+t/500,o=isNaN(n)?i:i-n/200;return i=1*Ar(i),a=_r*Ar(a),o=vr*Ar(o),[kr(3.1338561*a-1.6168667*i-.4906146*o),kr(-.9787684*a+1.9161415*i+.033454*o),kr(.0719453*a-.2289914*i+1.4052427*o),r]}function kr(e){return e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055,e<0?0:e>1?1:e}function Ar(e){return e>br?e*e*e:xr*(e-yr)}function jr(e){let[t,n,r,i]=Tr(e),a=Math.sqrt(n*n+r*r);return[Math.round(a*1e4)?wr(Math.atan2(r,n)*Cr):NaN,a,t,i]}function Mr([e,t,n,r]){return e=isNaN(e)?0:e*Sr,Or([n,Math.cos(e)*t,Math.sin(e)*t,r])}function Nr([e,t,n,r]){e=wr(e),t/=100,n/=100;function i(r){let i=(r+e/30)%12,a=t*Math.min(n,1-n);return n-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4),r]}const Pr=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function Fr(e,t){return Pr(e,t)?e[t]:void 0}function Ir(e){if(e=e.toLowerCase().trim(),e===`transparent`)return[0,0,0,0];let t=Fr(Vr,e);if(t){let[e,n,r]=t;return[e/255,n/255,r/255,1]}if(e.startsWith(`#`)&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let t=e.length<6?1:2,n=1;return[Lr(e.slice(n,n+=t)),Lr(e.slice(n,n+=t)),Lr(e.slice(n,n+=t)),Lr(e.slice(n,n+t)||`ff`)]}if(e.startsWith(`rgb`)){let t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){let[e,n,r,i,a,o,s,c,l,u,d,f]=t,p=[i||` `,s||` `,u].join(``);if(p===` `||p===` /`||p===`,,`||p===`,,,`){let e=[r,o,l].join(``),t=e===`%%%`?100:e===``?255:0;if(t){let e=[zr(+n/t,0,1),zr(+a/t,0,1),zr(+c/t,0,1),d?Rr(+d,f):1];if(Br(e))return e}}return}}let n=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){let[e,t,r,i,a,o,s,c,l]=n,u=[r||` `,a||` `,s].join(``);if(u===` `||u===` /`||u===`,,`||u===`,,,`){let e=[+t,zr(+i,0,100),zr(+o,0,100),c?Rr(+c,l):1];if(Br(e))return Nr(e)}}}function Lr(e){return parseInt(e.padEnd(2,e),16)/255}function Rr(e,t){return zr(t?e/100:e,0,1)}function zr(e,t,n){return Math.min(Math.max(t,e),n)}function Br(e){return!e.some(Number.isNaN)}const Vr={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 Hr(e,t,n){return e+n*(t-e)}function Ur(e,t,n){return e.map((e,r)=>Hr(e,t[r],n))}function Wr(e){return e===`rgb`||e===`hcl`||e===`lab`}var z=class e{constructor(e,t,n,r=1,i=!0){this.r=e,this.g=t,this.b=n,this.a=r,i||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter(`rgb`,[e,t,n,r]))}static{this.black=new e(0,0,0,1)}static{this.white=new e(1,1,1,1)}static{this.transparent=new e(0,0,0,0)}static{this.red=new e(1,0,0,1)}static parse(t){if(t instanceof e)return t;if(typeof t!=`string`)return;let n=Ir(t);if(n)return new e(...n,!1)}get rgb(){let{r:e,g:t,b:n,a:r}=this,i=r||1/0;return this.overwriteGetter(`rgb`,[e/i,t/i,n/i,r])}get hcl(){return this.overwriteGetter(`hcl`,jr(this.rgb))}get lab(){return this.overwriteGetter(`lab`,Tr(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){let[e,t,n,r]=this.rgb;return`rgba(${[e,t,n].map(e=>Math.round(e*255)).join(`,`)},${r})`}static interpolate(t,n,r,i=`rgb`){switch(i){case`rgb`:{let[i,a,o,s]=Ur(t.rgb,n.rgb,r);return new e(i,a,o,s,!1)}case`hcl`:{let[i,a,o,s]=t.hcl,[c,l,u,d]=n.hcl,f,p;if(!isNaN(i)&&!isNaN(c)){let e=c-i;c>i&&e>180?e-=360:c180&&(e+=360),f=i+r*e}else isNaN(i)?isNaN(c)?f=NaN:(f=c,(o===1||o===0)&&(p=l)):(f=i,(u===1||u===0)&&(p=a));let[m,h,g,_]=Mr([f,p??Hr(a,l,r),Hr(o,u,r),Hr(s,d,r)]);return new e(m,h,g,_,!1)}case`lab`:{let[i,a,o,s]=Or(Ur(t.lab,n.lab,r));return new e(i,a,o,s,!1)}}}},Gr=class{constructor(e,t,n){e?this.sensitivity=t?`variant`:`case`:this.sensitivity=t?`accent`:`base`,this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:`search`})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};const Kr=[`bottom`,`center`,`top`];var qr=class{constructor(e,t,n,r,i,a){this.text=e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i,this.verticalAlign=a}},Jr=class e{constructor(e){this.sections=e}static fromString(t){return new e([new qr(t,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(t){return t instanceof e?t:e.fromString(t)}toString(){return this.sections.length===0?``:this.sections.map(e=>e.text).join(``)}},Yr=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`number`)return new e([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let e of t)if(typeof e!=`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]];break}return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r){return new e(Ur(t.values,n.values,r))}},Xr=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`number`)return new e([t]);if(Array.isArray(t)){for(let e of t)if(typeof e!=`number`)return;return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r){return new e(Ur(t.values,n.values,r))}},Zr=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`string`){let n=z.parse(t);return n?new e([n]):void 0}if(!Array.isArray(t))return;let n=[];for(let e of t){if(typeof e!=`string`)return;let t=z.parse(e);if(!t)return;n.push(t)}return new e(n)}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r,i=`rgb`){let a=[];if(t.values.length!=n.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${n.values.length}), cannot interpolate.`);for(let e=0;e=0&&e<=255&&typeof t==`number`&&t>=0&&t<=255&&typeof n==`number`&&n>=0&&n<=255?r===void 0||typeof r==`number`&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(`, `)}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r==`number`?[e,t,n,r]:[e,t,n]).join(`, `)}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ri(e){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||e instanceof ti||e instanceof z||e instanceof Gr||e instanceof Jr||e instanceof Yr||e instanceof Xr||e instanceof Zr||e instanceof $r||e instanceof ei)return!0;if(Array.isArray(e)){for(let t of e)if(!ri(t))return!1;return!0}else if(typeof e==`object`){for(let t in e)if(!ri(e[t]))return!1;return!0}else return!1}function ii(e){if(e===null)return $n;if(typeof e==`string`)return F;if(typeof e==`boolean`)return I;if(typeof e==`number`)return P;if(e instanceof z)return er;if(e instanceof ti)return tr;if(e instanceof Gr)return ir;if(e instanceof Jr)return ar;if(e instanceof Yr)return or;if(e instanceof Xr)return cr;if(e instanceof Zr)return sr;if(e instanceof $r)return ur;if(e instanceof ei)return lr;if(Array.isArray(e)){let t=e.length,n;for(let t of e){let e=ii(t);if(!n)n=e;else if(n===e)continue;else{n=L;break}}return dr(n||L,t)}else return nr}function ai(e){let t=typeof e;return e===null?``:t===`string`||t===`number`||t===`boolean`?String(e):e instanceof z||e instanceof ti||e instanceof Jr||e instanceof Yr||e instanceof Xr||e instanceof Zr||e instanceof $r||e instanceof ei?e.toString():JSON.stringify(e)}var oi=class e{constructor(e,t){this.type=e,this.value=t}static parse(t,n){if(t.length!==2)return n.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!ri(t[1]))return n.error(`invalid value`);let r=t[1],i=ii(r),a=n.expectedType;return i.kind===`array`&&i.N===0&&a&&a.kind===`array`&&(typeof a.N!=`number`||a.N===0)&&(i=a),new e(i,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const si={string:F,number:P,boolean:I,object:nr};var ci=class e{constructor(e,t,n){this.type=e,this.args=t,this.key=n}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=1,i,a=t[0];if(a===`array`){let e;if(t.length>2){let i=t[1];if(typeof i!=`string`||!(i in si)||i===`object`)return n.error(`The item type argument of "array" must be one of string, number, boolean`,1);e=si[i],r++}else e=L;let a;if(t.length>3){if(t[2]!==null&&(typeof t[2]!=`number`||t[2]<0||t[2]!==Math.floor(t[2])))return n.error(`The length argument to "array" must be a positive integer literal`,2);a=t[2],r++}i=dr(e,a)}else{if(!si[a])throw Error(`Types doesn't contain name = ${a}`);i=si[a]}let o=[];for(;re.outputDefined())}};const li={"to-boolean":I,"to-color":er,"to-number":P,"to-string":F};var ui=class e{constructor(e,t,n){this.type=e,this.args=t,this.key=n}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=t[0];if(!li[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 n.error(`Expected one argument.`);let i=li[r],a=[];for(let e=1;e4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:ni(t[0],t[1],t[2],t[3]),!n))return new z(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new B(n||`Could not parse color from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`padding`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Yr.parse(t);if(r)return r}throw new B(`Could not parse padding from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`numberArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Xr.parse(t);if(r)return r}throw new B(`Could not parse numberArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`colorArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=Zr.parse(t);if(r)return r}throw new B(`Could not parse colorArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`variableAnchorOffsetCollection`:{let t;for(let n of this.args){t=n.evaluate(e);let r=$r.parse(t);if(r)return r}throw new B(`Could not parse variableAnchorOffsetCollection from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`number`:{let t=null;for(let n of this.args){if(t=n.evaluate(e),t===null)return 0;let r=Number(t);if(!isNaN(r))return r}throw new B(`Could not convert ${JSON.stringify(t)} to number.`,this.key)}case`formatted`:return Jr.fromString(ai(this.args[0].evaluate(e)));case`resolvedImage`:return ei.fromString(ai(this.args[0].evaluate(e)));case`projectionDefinition`:{let t=this.args[0].evaluate(e);if(ti.parse(t))return t;throw new B(`Could not parse projectionDefinition from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}default:return ai(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}};const di=[`Unknown`,`Point`,`LineString`,`Polygon`];var fi=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`?di[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=z.parse(e),this._parseColorCache.set(e,t)),t}},pi=class e{constructor(e,t,n=[],r,i=new Qn,a=[]){this.registry=e,this.path=n,this.key=n.map(e=>`[${e}]`).join(``),this.scope=i,this.errors=a,this.expectedType=r,this._isConstant=t}parse(e,t,n,r,i={}){return t?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`)&&(e=[`literal`,e]);let n=this.key;function r(e,t,r){return r===`assert`?new ci(t,[e],n):r===`coerce`?new ui(t,[e],n):e}if(Array.isArray(e)){if(e.length===0)return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);let n=e[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 i=this.registry[n];if(i){let n=i.parse(e,this);if(!n)return null;if(this.expectedType){let e=this.expectedType,i=n.type;if((e.kind===`string`||e.kind===`number`||e.kind===`boolean`||e.kind===`object`||e.kind===`array`)&&i.kind===`value`)n=r(n,e,t.typeAnnotation||`assert`);else if(e.kind===`projectionDefinition`&&[`string`,`array`,`value`].includes(i.kind)||[`color`,`formatted`,`resolvedImage`].includes(e.kind)&&[`value`,`string`].includes(i.kind)||[`padding`,`numberArray`].includes(e.kind)&&[`value`,`number`,`array`].includes(i.kind)||e.kind===`colorArray`&&[`value`,`string`,`array`].includes(i.kind)||e.kind===`variableAnchorOffsetCollection`&&[`value`,`array`].includes(i.kind))n=r(n,e,t.typeAnnotation||`coerce`);else if(this.checkSubtype(e,i))return null}if(!(n instanceof oi)&&n.type.kind!==`resolvedImage`&&this._isConstant(n)){let e=new fi;try{n=new oi(n.type,n.evaluate(e))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}else if(e===void 0)return this.error(`'undefined' value invalid. Use null instead.`);else if(typeof e==`object`)return this.error(`Bare objects invalid. Use ["literal", {...}] instead.`);else return this.error(`Expected an array, but found ${typeof e} instead.`)}concat(t,n,r){let i=typeof t==`number`?this.path.concat(t):this.path,a=r?this.scope.concat(r):this.scope;return new e(this.registry,this._isConstant,i,n||null,a,this.errors)}error(e,...t){let n=`${this.key}${t.map(e=>`[${e}]`).join(``)}`;this.errors.push(new Zn(n,e))}checkSubtype(e,t){let n=pr(e,t);return n&&this.error(n),n}},mi=class e{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let t of this.bindings)e(t[1]);e(this.result)}static parse(t,n){if(t.length<4)return n.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let e=1;e=n.length)throw new B(`Array index out of bounds: ${t} > ${n.length-1}.`,this.key);if(t!==Math.floor(t))throw new B(`Array index must be an integer, but found ${t} instead.`,this.key);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}},_i=class e{constructor(e,t,n){this.needle=e,this.haystack=t,this.key=n,this.type=I}static parse(t,n){if(t.length!==3)return n.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,L),i=n.parse(t[2],2,L);return!r||!i?null:mr(r.type,[I,F,P,$n,L])?new e(r,i,n.key):n.error(`Expected first argument to be of type boolean, string, number or null, but found ${R(r.type)} instead`)}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!n)return!1;if(!hr(t,[`boolean`,`string`,`number`,`null`]))throw new B(`Expected first argument to be of type boolean, string, number or null, but found ${R(ii(t))} instead.`,this.key);if(!hr(n,[`string`,`array`]))throw new B(`Expected second argument to be of type array or string, but found ${R(ii(n))} instead.`,this.key);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}},vi=class e{constructor(e,t,n,r){this.needle=e,this.haystack=t,this.key=n,this.fromIndex=r,this.type=P}static parse(t,n){if(t.length<=2||t.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,L),i=n.parse(t[2],2,L);if(!r||!i)return null;if(!mr(r.type,[I,F,P,$n,L]))return n.error(`Expected first argument to be of type boolean, string, number or null, but found ${R(r.type)} instead`);if(t.length===4){let a=n.parse(t[3],3,P);return a?new e(r,i,n.key,a):null}else return new e(r,i,n.key)}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!hr(t,[`boolean`,`string`,`number`,`null`]))throw new B(`Expected first argument to be of type boolean, string, number or null, but found ${R(ii(t))} instead.`,this.key);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(e)),hr(n,[`string`])){let e=n.indexOf(t,r);return e===-1?-1:[...n.slice(0,e)].length}else if(hr(n,[`array`]))return n.indexOf(t,r);else throw new B(`Expected second argument to be of type array or string, but found ${R(ii(n))} instead.`,this.key)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}},yi=class e{constructor(e,t,n,r,i,a){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=a}static parse(t,n){if(t.length<5)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return n.error(`Expected an even number of arguments.`);let r,i;n.expectedType&&n.expectedType.kind!==`value`&&(i=n.expectedType);let a={},o=[];for(let e=2;e2**53-1)return l.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof e==`number`&&Math.floor(e)!==e)return l.error(`Numeric branch labels must be integer values.`);if(!r)r=ii(e);else if(l.checkSubtype(r,ii(e)))return null;if(a[String(e)]!==void 0)return l.error(`Branch labels must be unique.`);a[String(e)]=o.length}let u=n.parse(c,e,i);if(!u)return null;i||=u.type,o.push(u)}let s=n.parse(t[1],1,L);if(!s)return null;let c=n.parse(t[t.length-1],t.length-1,i);return!c||s.type.kind!==`value`&&n.concat(1).checkSubtype(r,s.type)?null:new e(r,i,s,a,o,c)}evaluate(e){let t=this.input.evaluate(e);return(ii(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}},bi=class e{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(t,n){if(t.length<4)return n.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return n.error(`Expected an odd number of arguments.`);let r;n.expectedType&&n.expectedType.kind!==`value`&&(r=n.expectedType);let i=[];for(let e=1;et.outputDefined())&&this.otherwise.outputDefined()}},xi=class e{constructor(e,t,n,r,i){this.type=e,this.input=t,this.beginIndex=n,this.key=r,this.endIndex=i}static parse(t,n){if(t.length<=2||t.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,L),i=n.parse(t[2],2,P);if(!r||!i)return null;if(!mr(r.type,[dr(L),F,L]))return n.error(`Expected first argument to be of type array or string, but found ${R(r.type)} instead`);if(t.length===4){let a=n.parse(t[3],3,P);return a?new e(r.type,r,i,n.key,a):null}else return new e(r.type,r,i,n.key)}evaluate(e){let t=this.input.evaluate(e),n=this.beginIndex.evaluate(e),r;if(this.endIndex&&(r=this.endIndex.evaluate(e)),hr(t,[`string`]))return[...t].slice(n,r).join(``);if(hr(t,[`array`]))return t.slice(n,r);throw new B(`Expected first argument to be of type array or string, but found ${R(ii(t))} instead.`,this.key)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}};function Si(e,t,n){let r=e.length-1,i=0,a=r,o=0,s,c;for(;i<=a;)if(o=Math.floor((i+a)/2),s=e[o],c=e[o+1],s<=t){if(o===r||tt)a=o-1;else throw new B(`Input is not a number.`,n);return 0}var Ci=class e{constructor(e,t,n,r){this.type=e,this.input=t,this.key=r,this.labels=[],this.outputs=[];for(let[e,t]of n)this.labels.push(e),this.outputs.push(t)}static parse(t,n){if(t.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return n.error(`Expected an even number of arguments.`);let r=n.parse(t[1],1,P);if(!r)return null;let i=[],a=null;n.expectedType&&n.expectedType.kind!==`value`&&(a=n.expectedType);for(let e=1;e=r)return n.error(`Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.`,s);let l=n.parse(o,c,a);if(!l)return null;a||=l.type,i.push([r,l])}return new e(a,r,i,n.key)}evaluate(e){let t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);let i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[Si(t,r,this.key)].evaluate(e)}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function wi(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let n=e;for(let r=0;r<8;r++){let r=((o*n+a)*n+i)*n-e;if(Math.abs(r)s?r=n:u=n,n=(r+u)*.5}return((l*n+c)*n+s)*n}}var Ti=class e{constructor(e,t,n,r,i,a){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.key=a,this.labels=[],this.outputs=[];for(let[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if(e.name===`exponential`)i=Ei(t,e.base,n,r);else if(e.name===`linear`)i=Ei(t,1,n,r);else if(e.name===`cubic-bezier`){let a=e.controlPoints;i=wi(a[0],a[1],a[2],a[3])(Ei(t,1,n,r))}return i}static parse(t,n){let[r,i,a,...o]=t;if(!Array.isArray(i)||i.length===0)return n.error(`Expected an interpolation type expression.`,1);if(i[0]===`linear`)i={name:`linear`};else if(i[0]===`exponential`){let e=i[1];if(typeof e!=`number`)return n.error(`Exponential interpolation requires a numeric base.`,1,1);i={name:`exponential`,base:e}}else if(i[0]===`cubic-bezier`){let e=i.slice(1);if(e.length!==4||e.some(e=>typeof e!=`number`||e<0||e>1))return n.error(`Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.`,1);i={name:`cubic-bezier`,controlPoints:e}}else return n.error(`Unknown interpolation type ${String(i[0])}`,1,0);if(t.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return n.error(`Expected an even number of arguments.`);if(a=n.parse(a,2,P),!a)return null;let s=[],c=null;(r===`interpolate-hcl`||r===`interpolate-lab`)&&n.expectedType!=sr?c=er:n.expectedType&&n.expectedType.kind!==`value`&&(c=n.expectedType);for(let e=0;e=t)return n.error(`Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.`,i);let l=n.parse(r,a,c);if(!l)return null;c||=l.type,s.push([t,l])}return!gr(c,P)&&!gr(c,tr)&&!gr(c,er)&&!gr(c,or)&&!gr(c,cr)&&!gr(c,sr)&&!gr(c,ur)&&!gr(c,dr(P))?n.error(`Type ${R(c)} is not interpolatable.`):new e(c,r,i,a,s,n.key)}evaluate(t){let n=this.labels,r=this.outputs;if(n.length===1)return r[0].evaluate(t);let i=this.input.evaluate(t);if(i<=n[0])return r[0].evaluate(t);let a=n.length;if(i>=n[a-1])return r[a-1].evaluate(t);let o=Si(n,i,this.key),s=n[o],c=n[o+1],l=e.interpolationFactor(this.interpolation,i,s,c),u=r[o].evaluate(t),d=r[o+1].evaluate(t);switch(this.operator){case`interpolate`:switch(this.type.kind){case`number`:return Hr(u,d,l);case`color`:return z.interpolate(u,d,l);case`padding`:return Yr.interpolate(u,d,l);case`colorArray`:return Zr.interpolate(u,d,l);case`numberArray`:return Xr.interpolate(u,d,l);case`variableAnchorOffsetCollection`:return $r.interpolate(u,d,l,this.key);case`array`:return Ur(u,d,l);case`projectionDefinition`:return ti.interpolate(u,d,l)}case`interpolate-hcl`:switch(this.type.kind){case`color`:return z.interpolate(u,d,l,`hcl`);case`colorArray`:return Zr.interpolate(u,d,l,`hcl`)}case`interpolate-lab`:switch(this.type.kind){case`color`:return z.interpolate(u,d,l,`lab`);case`colorArray`:return Zr.interpolate(u,d,l,`lab`)}}}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function Ei(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}const Di={color:z.interpolate,number:Hr,padding:Yr.interpolate,numberArray:Xr.interpolate,colorArray:Zr.interpolate,variableAnchorOffsetCollection:$r.interpolate,array:Ur};var Oi=class e{constructor(e,t){this.type=e,this.args=t}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=null,i=n.expectedType;i&&i.kind!==`value`&&(r=i);let a=[];for(let e of t.slice(1)){let t=n.parse(e,1+a.length,r,void 0,{typeAnnotation:`omit`});if(!t)return null;r||=t.type,a.push(t)}if(!r)throw Error(`No output type`);return i&&a.some(e=>pr(i,e.type))?new e(L,a):new e(r,a)}evaluate(e){let t=null,n=0,r;for(let i of this.args)if(n++,t=i.evaluate(e),t&&t instanceof ei&&!t.available&&(r||=t.name,t=null,n===this.args.length&&(t=r)),t!==null)break;return t}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}};function ki(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 Ai(e,t,n){return t===n}function ji(e,t,n){return t!==n}function Mi(e,t,n){return tn}function Pi(e,t,n){return t<=n}function Fi(e,t,n){return t>=n}function Ii(e,t,n,r){return r.compare(t,n)===0}function Li(e,t,n,r){return!Ii(e,t,n,r)}function Ri(e,t,n,r){return r.compare(t,n)<0}function zi(e,t,n,r){return r.compare(t,n)>0}function Bi(e,t,n,r){return r.compare(t,n)<=0}function Vi(e,t,n,r){return r.compare(t,n)>=0}function Hi(e,t,n){let r=e!==`==`&&e!==`!=`;return class i{constructor(e,t,n,r){this.lhs=e,this.rhs=t,this.key=n,this.collator=r,this.type=I,this.hasUntypedArgument=e.type.kind===`value`||t.type.kind===`value`}static parse(e,t){if(e.length!==3&&e.length!==4)return t.error(`Expected two or three arguments.`);let n=e[0],a=t.parse(e[1],1,L);if(!a)return null;if(!ki(n,a.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${R(a.type)}'.`);let o=t.parse(e[2],2,L);if(!o)return null;if(!ki(n,o.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${R(o.type)}'.`);if(a.type.kind!==o.type.kind&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot compare types '${R(a.type)}' and '${R(o.type)}'.`);r&&(a.type.kind===`value`&&o.type.kind!==`value`?a=new ci(o.type,[a],t.key):a.type.kind!==`value`&&o.type.kind===`value`&&(o=new ci(a.type,[o],t.key)));let s=null;if(e.length===4){if(a.type.kind!==`string`&&o.type.kind!==`string`&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot use collator to compare non-string types.`);if(s=t.parse(e[3],3,ir),!s)return null}return new i(a,o,t.key,s)}evaluate(i){let a=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){let t=ii(a),n=ii(o);if(t.kind!==n.kind||t.kind!==`string`&&t.kind!==`number`)throw new B(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`,this.key)}if(this.collator&&!r&&this.hasUntypedArgument){let e=ii(a),n=ii(o);if(e.kind!==`string`||n.kind!==`string`)return t(i,a,o)}return this.collator?n(i,a,o,this.collator.evaluate(i)):t(i,a,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const Ui=Hi(`==`,Ai,Ii),Wi=Hi(`!=`,ji,Li),Gi=Hi(`<`,Mi,Ri),Ki=Hi(`>`,Ni,zi),qi=Hi(`<=`,Pi,Bi),Ji=Hi(`>=`,Fi,Vi);var Yi=class e{constructor(e,t,n){this.type=ir,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=t}static parse(t,n){if(t.length!==2)return n.error(`Expected one argument.`);let r=t[1];if(typeof r!=`object`||Array.isArray(r))return n.error(`Collator options argument must be an object.`);let i=n.parse(r[`case-sensitive`]!==void 0&&r[`case-sensitive`],1,I);if(!i)return null;let a=n.parse(r[`diacritic-sensitive`]!==void 0&&r[`diacritic-sensitive`],1,I);if(!a)return null;let o=null;return r.locale&&(o=n.parse(r.locale,1,F),!o)?null:new e(i,a,o)}evaluate(e){return new Gr(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}},Xi=class e{constructor(e,t,n,r,i,a){this.type=F,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=a}static parse(t,n){if(t.length!==3)return n.error(`Expected two arguments.`);let r=n.parse(t[1],1,P);if(!r)return null;let i=t[2];if(typeof i!=`object`||Array.isArray(i))return n.error(`NumberFormat options argument must be an object.`);let a=null;if(i.locale&&(a=n.parse(i.locale,1,F),!a))return null;let o=null;if(i.currency&&(o=n.parse(i.currency,1,F),!o))return null;let s=null;if(i.unit&&(s=n.parse(i.unit,1,F),!s))return null;if(o&&s)return n.error("NumberFormat options `currency` and `unit` are mutually exclusive");let c=null;if(i[`min-fraction-digits`]&&(c=n.parse(i[`min-fraction-digits`],1,P),!c))return null;let l=null;return i[`max-fraction-digits`]&&(l=n.parse(i[`max-fraction-digits`],1,P),!l)?null:new e(r,a,o,s,c,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?`currency`:this.unit?`unit`:`decimal`,currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}},Zi=class e{constructor(e){this.type=ar,this.sections=e}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=t[1];if(!Array.isArray(r)&&typeof r==`object`)return n.error(`First argument must be an image or text section.`);let i=[],a=!1;for(let e=1;e<=t.length-1;++e){let r=t[e];if(a&&typeof r==`object`&&!Array.isArray(r)){a=!1;let e=null;if(r[`font-scale`]&&(e=n.parse(r[`font-scale`],1,P),!e))return null;let t=null;if(r[`text-font`]&&(t=n.parse(r[`text-font`],1,dr(F)),!t))return null;let o=null;if(r[`text-color`]&&(o=n.parse(r[`text-color`],1,er),!o))return null;let s=null;if(r[`vertical-align`]){if(typeof r[`vertical-align`]==`string`&&!Kr.includes(r[`vertical-align`]))return n.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r[`vertical-align`]}' instead.`);if(s=n.parse(r[`vertical-align`],1,F),!s)return null}let c=i[i.length-1];c.scale=e,c.font=t,c.textColor=o,c.verticalAlign=s}else{let r=n.parse(t[e],1,L);if(!r)return null;let o=r.type.kind;if(o!==`string`&&o!==`value`&&o!==`null`&&o!==`resolvedImage`)return n.error(`Formatted text type must be 'string', 'value', 'image' or 'null'.`);a=!0,i.push({content:r,scale:null,font:null,textColor:null,verticalAlign:null})}}return new e(i)}evaluate(e){return new Jr(this.sections.map(t=>{let n=t.content.evaluate(e);return ii(n)===lr?new qr(``,n,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new qr(ai(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(`,`):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)}))}eachChild(e){for(let t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}},Qi=class e{constructor(e){this.type=lr,this.input=e}static parse(t,n){if(t.length!==2)return n.error(`Expected two arguments.`);let r=n.parse(t[1],1,F);return r?new e(r):n.error(`No image name provided.`)}evaluate(e){let t=this.input.evaluate(e),n=ei.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}},$i=class e{constructor(e,t){this.input=e,this.key=t,this.type=P}static parse(t,n){if(t.length!==2)return n.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=n.parse(t[1],1);return r?r.type.kind!==`array`&&r.type.kind!==`string`&&r.type.kind!==`value`?n.error(`Expected argument of type string or array, but found ${R(r.type)} instead.`):new e(r,n.key):null}evaluate(e){let t=this.input.evaluate(e);if(typeof t==`string`)return[...t].length;if(Array.isArray(t))return t.length;throw new B(`Expected value to be of type string or array, but found ${R(ii(t))} instead.`,this.key)}eachChild(e){e(this.input)}outputDefined(){return!1}};const ea=8192;function ta(e,t){let n=ra(e[0]),r=aa(e[1]),i=2**t.z;return[Math.round(n*i*ea),Math.round(r*i*ea)]}function na(e,t){let n=2**t.z,r=(e[0]/ea+t.x)/n,i=(e[1]/ea+t.y)/n;return[ia(r),oa(i)]}function ra(e){return(180+e)/360}function ia(e){return e*360-180}function aa(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function oa(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}function sa(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 ca(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function la(e,t,n){return t[1]>e[1]!=n[1]>e[1]&&e[0]<(n[0]-t[0])*(e[1]-t[1])/(n[1]-t[1])+t[0]}function ua(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[0]-n[0],o=e[1]-n[1];return r*o-a*i===0&&r*a<=0&&i*o<=0}function da(e,t,n,r){let i=[t[0]-e[0],t[1]-e[1]];return _a([r[0]-n[0],r[1]-n[1]],i)!==0&&!!(va(e,t,n,r)&&va(n,r,e,t))}function fa(e,t,n){for(let r of n)for(let n=0;n0&&d<0||u<0&&d>0}function ya(e,t,n){let r=[];for(let i=0;in[2]){let t=r*.5,i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;i===0&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}sa(t,e)}function Sa(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}function Ca(e,t,n,r){let i=2**r.z*ea,a=[r.x*ea,r.y*ea],o=[];for(let r of e)for(let e of r){let r=[e.x+a[0],e.y+a[1]];xa(r,t,n,i),o.push(r)}return o}function wa(e,t,n,r){let i=2**r.z*ea,a=[r.x*ea,r.y*ea],o=[];for(let n of e){let e=[];for(let r of n){let n=[r.x+a[0],r.y+a[1]];sa(t,n),e.push(n)}o.push(e)}if(t[2]-t[0]<=i/2){Sa(t);for(let e of o)for(let r of e)xa(r,t,n,i)}return o}function Ta(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=ya(t.coordinates,r,i),o=Ca(e.geometry(),n,r,i);if(!ca(n,r))return!1;for(let e of o)if(!pa(e,a))return!1}if(t.type===`MultiPolygon`){let a=ba(t.coordinates,r,i),o=Ca(e.geometry(),n,r,i);if(!ca(n,r))return!1;for(let e of o)if(!ma(e,a))return!1}return!0}function Ea(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=ya(t.coordinates,r,i),o=wa(e.geometry(),n,r,i);if(!ca(n,r))return!1;for(let e of o)if(!ha(e,a))return!1}if(t.type===`MultiPolygon`){let a=ba(t.coordinates,r,i),o=wa(e.geometry(),n,r,i);if(!ca(n,r))return!1;for(let e of o)if(!ga(e,a))return!1}return!0}var Da=class e{constructor(e,t){this.type=I,this.geojson=e,this.geometries=t}static parse(t,n){if(t.length!==2)return n.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ri(t[1])){let n=t[1];if(n.type===`FeatureCollection`){let t=[];for(let e of n.features){let{type:n,coordinates:r}=e.geometry;n===`Polygon`&&t.push(r),n===`MultiPolygon`&&t.push(...r)}if(t.length)return new e(n,{type:`MultiPolygon`,coordinates:t})}else if(n.type===`Feature`){let t=n.geometry.type;if(t===`Polygon`||t===`MultiPolygon`)return new e(n,n.geometry)}else if(n.type===`Polygon`||n.type===`MultiPolygon`)return new e(n,n)}return n.error(`'within' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return Ta(e,this.geometries);if(e.geometryType()===`LineString`)return Ea(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},Oa=class{constructor(e=[],t=(e,t)=>et)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}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:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[r],e=r}t[e]=i}};function ka(e,t,n=0,r=e.length-1,i=ja){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);ka(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(Aa(e,n,t),i(e[r],a)>0&&Aa(e,n,r);o0;)s--}i(e[n],a)===0?Aa(e,n,s):(s++,Aa(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function Aa(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function ja(e,t){return et)}function Ma(e,t){if(e.length<=1)return[e];let n=[],r,i;for(let t of e){let e=Pa(t);e!==0&&(t.area=Math.abs(e),i===void 0&&(i=e<0),i===e<0?(r&&n.push(r),r=[t]):r.push(t))}if(r&&n.push(r),t>1)for(let e=0;e1?(c=e[s+1][0],l=e[s+1][1]):f>0&&(c+=u/this.kx*f,l+=d/this.ky*f)),u=this.wrap(t[0]-c)*this.kx,d=(t[1]-l)*this.ky;let p=u*u+d*d;p180;)e-=360;return e}};function za(e,t){return t[0]-e[0]}function Ba(e){return e[1]-e[0]+1}function Va(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];let n=Ba(e);if(t){if(n===2)return[e,null];let t=Math.floor(n/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(n===1)return[e,null];let r=Math.floor(n/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function Ua(e,t){if(!Va(t,e.length))return[1/0,1/0,-1/0,-1/0];let n=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)sa(n,e[r]);return n}function Wa(e){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)for(let e of n)sa(t,e);return t}function Ga(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Ka(e,t,n){if(!Ga(e)||!Ga(t))return NaN;let r=0,i=0;return e[2]t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]=r)return r;if(ca(i,a)){if($a(e,t))return 0}else if($a(t,e))return 0;let o=1/0;for(let r of e)for(let e=0,i=r.length,a=i-1;e0;){let i=o.pop();if(i[0]>=a)continue;let c=i[1],l=t?50:100;if(Ba(c)<=l){if(!Va(c,e.length))return NaN;if(t){let t=Qa(e,c,n,r);if(isNaN(t)||t===0)return t;a=Math.min(a,t)}else for(let t=c[0];t<=c[1];++t){let i=Za(e[t],n,r);if(a=Math.min(a,i),a===0)return 0}}else{let n=Ha(c,t);to(o,a,r,e,s,n[0]),to(o,a,r,e,s,n[1])}}return a}function io(e,t,n,r,i,a=1/0){let o=Math.min(a,i.distance(e[0],n[0]));if(o===0)return o;let s=new Oa([[0,[0,e.length-1],[0,n.length-1]]],za);for(;s.length>0;){let a=s.pop();if(a[0]>=o)continue;let c=a[1],l=a[2],u=t?50:100,d=r?50:100;if(Ba(c)<=u&&Ba(l)<=d){if(!Va(c,e.length)&&Va(l,n.length))return NaN;let a;if(t&&r)a=Ya(e,c,n,l,i),o=Math.min(o,a);else if(t&&!r){let t=e.slice(c[0],c[1]+1);for(let e=l[0];e<=l[1];++e)if(a=qa(n[e],t,i),o=Math.min(o,a),o===0)return o}else if(!t&&r){let t=n.slice(l[0],l[1]+1);for(let n=c[0];n<=c[1];++n)if(a=qa(e[n],t,i),o=Math.min(o,a),o===0)return o}else a=Xa(e,c,n,l,i),o=Math.min(o,a)}else{let a=Ha(c,t),u=Ha(l,r);no(s,o,i,e,n,a[0],u[0]),no(s,o,i,e,n,a[0],u[1]),no(s,o,i,e,n,a[1],u[0]),no(s,o,i,e,n,a[1],u[1])}}return o}function ao(e,t){let n=e.geometry(),r=n.flat().map(t=>na([t.x,t.y],e.canonical));if(n.length===0)return NaN;let i=new Ra(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,io(r,!1,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,io(r,!1,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,ro(r,!1,e.coordinates,i,a));break}if(a===0)return a}return a}function oo(e,t){let n=e.geometry(),r=n.flat().map(t=>na([t.x,t.y],e.canonical));if(n.length===0)return NaN;let i=new Ra(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,io(r,!0,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,io(r,!0,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,ro(r,!0,e.coordinates,i,a));break}if(a===0)return a}return a}function so(e,t){let n=e.geometry();if(n.length===0||n[0].length===0)return NaN;let r=Ma(n,0).map(t=>t.map(t=>t.map(t=>na([t.x,t.y],e.canonical)))),i=new Ra(r[0][0][0][1]),a=1/0;for(let e of t)for(let t of r){switch(e.type){case`Point`:a=Math.min(a,ro([e.coordinates],!1,t,i,a));break;case`LineString`:a=Math.min(a,ro(e.coordinates,!0,t,i,a));break;case`Polygon`:a=Math.min(a,eo(t,e.coordinates,i,a));break}if(a===0)return a}return a}function co(e){return e.type===`MultiPolygon`?e.coordinates.map(e=>({type:`Polygon`,coordinates:e})):e.type===`MultiLineString`?e.coordinates.map(e=>({type:`LineString`,coordinates:e})):e.type===`MultiPoint`?e.coordinates.map(e=>({type:`Point`,coordinates:e})):[e]}var lo=class e{constructor(e,t){this.type=P,this.geojson=e,this.geometries=t}static parse(t,n){if(t.length!==2)return n.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ri(t[1])){let n=t[1];if(n.type===`FeatureCollection`)return new e(n,n.features.map(e=>co(e.geometry)).flat());if(n.type===`Feature`)return new e(n,co(n.geometry));if(`type`in n&&`coordinates`in n)return new e(n,co(n))}return n.error(`'distance' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return ao(e,this.geometries);if(e.geometryType()===`LineString`)return oo(e,this.geometries);if(e.geometryType()===`Polygon`)return so(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},uo=class e{constructor(e){this.key=e,this.type=L}static parse(t,n){if(t.length!==2)return n.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=t[1];return r==null?n.error(`Global state property must be defined.`):typeof r==`string`?new e(r):n.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(e){let t=e.globals?.globalState;return!t||Object.keys(t).length===0?null:Fr(t,this.key)??null}eachChild(){}outputDefined(){return!1}};const fo={"==":Ui,"!=":Wi,">":Ki,"<":Gi,">=":Ji,"<=":qi,array:ci,at:gi,boolean:ci,case:bi,coalesce:Oi,collator:Yi,format:Zi,image:Qi,in:_i,"index-of":vi,interpolate:Ti,"interpolate-hcl":Ti,"interpolate-lab":Ti,length:$i,let:mi,literal:oi,match:yi,number:ci,"number-format":Xi,object:ci,slice:xi,step:Ci,string:ci,"to-boolean":ui,"to-color":ui,"to-number":ui,"to-string":ui,var:hi,within:Da,distance:lo,"global-state":uo};var po=class e{constructor(e,t,n,r,i){this.name=e,this.type=t,this._evaluate=n,this.args=r,this.key=i}evaluate(e){return this._evaluate(e,this.args,this.key)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(t,n){let r=t[0],i=e.definitions[r];if(!i)return n.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let a=Array.isArray(i)?i[0]:i.type,o=Array.isArray(i)?[[i[1],i[2]]]:i.overloads,s=o.filter(([e])=>!Array.isArray(e)||e.length===t.length-1),c=null;for(let[i,o]of s){c=new pi(n.registry,bo,n.path,null,n.scope);let s=[],l=!1;for(let e=1;eyo(e)).join(` | `),r=[];for(let e=1;e>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}function vo(e){return{type:e}}po.register(fo,{error:[rr,[F],(e,[t],n)=>{throw new B(t.evaluate(e),n)}],typeof:[F,[L],(e,[t])=>R(ii(t.evaluate(e)))],"to-rgba":[dr(P,4),[er],(e,[t])=>{let[n,r,i,a]=t.evaluate(e).rgb;return[n*255,r*255,i*255,a]}],rgb:[er,[P,P,P],mo],rgba:[er,[P,P,P,P],mo],has:{type:I,overloads:[[[F],(e,[t])=>ho(t.evaluate(e),e.properties())],[[F,nr],(e,[t,n])=>ho(t.evaluate(e),n.evaluate(e))]]},get:{type:L,overloads:[[[F],(e,[t])=>go(t.evaluate(e),e.properties())],[[F,nr],(e,[t,n])=>go(t.evaluate(e),n.evaluate(e))]]},"feature-state":[L,[F],(e,[t])=>go(t.evaluate(e),e.featureState||{})],properties:[nr,[],e=>e.properties()],"geometry-type":[F,[],e=>e.geometryType()],id:[L,[],e=>e.id()],zoom:[P,[],e=>e.globals.zoom],"heatmap-density":[P,[],e=>e.globals.heatmapDensity||0],elevation:[P,[],e=>e.globals.elevation||0],"line-progress":[P,[],e=>e.globals.lineProgress||0],accumulated:[L,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[P,vo(P),(e,t)=>{let n=0;for(let r of t)n+=r.evaluate(e);return n}],"*":[P,vo(P),(e,t)=>{let n=1;for(let r of t)n*=r.evaluate(e);return n}],"-":{type:P,overloads:[[[P,P],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[P],(e,[t])=>-t.evaluate(e)]]},"/":[P,[P,P],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[P,[P,P],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[P,[],()=>Math.LN2],pi:[P,[],()=>Math.PI],e:[P,[],()=>Math.E],"^":[P,[P,P],(e,[t,n])=>t.evaluate(e)**+n.evaluate(e)],sqrt:[P,[P],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[P,[P],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[P,[P],(e,[t])=>Math.log(t.evaluate(e))],log2:[P,[P],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[P,[P],(e,[t])=>Math.sin(t.evaluate(e))],cos:[P,[P],(e,[t])=>Math.cos(t.evaluate(e))],tan:[P,[P],(e,[t])=>Math.tan(t.evaluate(e))],asin:[P,[P],(e,[t])=>Math.asin(t.evaluate(e))],acos:[P,[P],(e,[t])=>Math.acos(t.evaluate(e))],atan:[P,[P],(e,[t])=>Math.atan(t.evaluate(e))],min:[P,vo(P),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[P,vo(P),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[P,[P],(e,[t])=>Math.abs(t.evaluate(e))],round:[P,[P],(e,[t])=>{let n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[P,[P],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[P,[P],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[I,[F,L],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[I,[L],(e,[t])=>e.id()===t.value],"filter-type-==":[I,[F],(e,[t])=>e.geometryType()===t.value],"filter-<":[I,[F,L],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r{let n=e.id(),r=t.value;return typeof n==typeof r&&n":[I,[F,L],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[I,[L],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[I,[F,L],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[I,[L],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[I,[F,L],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[I,[L],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[I,[L],(e,[t])=>{let n=t.value,r=e.properties();return n in r&&r[n]!==void 0}],"filter-has-id":[I,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[I,[dr(F)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[I,[dr(L)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[I,[F,dr(L)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[I,[F,dr(L)],(e,[t,n])=>_o(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:I,overloads:[[[I,I],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[vo(I),(e,t)=>{for(let n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:I,overloads:[[[I,I],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[vo(I),(e,t)=>{for(let n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[I,[I],(e,[t])=>!t.evaluate(e)],"is-supported-script":[I,[F],(e,[t])=>{let n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[F,[F],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[F,[F],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[F,vo(L),(e,t)=>t.map(t=>ai(t.evaluate(e))).join(``)],split:[dr(F),[F,F],(e,[t,n])=>t.evaluate(e).split(n.evaluate(e))],join:[F,[dr(F),F],(e,[t,n])=>t.evaluate(e).join(n.evaluate(e))],"resolved-locale":[F,[ir],(e,[t])=>t.evaluate(e).resolvedLocale()]});function yo(e){return Array.isArray(e)?`(${e.map(R).join(`, `)})`:`(${R(e.type)}...)`}function bo(e){if(e instanceof hi)return bo(e.boundExpression);if(e instanceof po&&e.name===`error`||e instanceof Yi||e instanceof Da||e instanceof lo||e instanceof uo)return!1;let t=e instanceof ui||e instanceof ci,n=!0;return e.eachChild(e=>{t?n&&=bo(e):n&&=e instanceof oi}),n?xo(e)&&Co(e,[`zoom`,`heatmap-density`,`elevation`,`line-progress`,`accumulated`,`is-supported-script`]):!1}function xo(e){if(e instanceof po&&(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 Da||e instanceof lo)return!1;let t=!0;return e.eachChild(e=>{t&&!xo(e)&&(t=!1)}),t}function So(e){if(e instanceof po&&e.name===`feature-state`)return!1;let t=!0;return e.eachChild(e=>{t&&!So(e)&&(t=!1)}),t}function Co(e,t){if(e instanceof po&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild(e=>{n&&!Co(e,t)&&(n=!1)}),n}function wo(e){return{result:`success`,value:e}}function To(e){return{result:`error`,value:e}}function Eo(e){return e[`property-type`]===`data-driven`||e[`property-type`]===`cross-faded-data-driven`}function Do(e){return!!e.expression&&e.expression.parameters.indexOf(`zoom`)>-1}function Oo(e){return!!e.expression&&e.expression.interpolated}function ko(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}function V(e){return e instanceof Number?`number`:e instanceof String?`string`:e instanceof Boolean?`boolean`:Array.isArray(e)?`array`:e===null?`null`:typeof e}function Ao(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&ii(e)===nr}function jo(e){return e}function Mo(e){switch(e.type){case`color`:return z.parse;case`padding`:return Yr.parse;case`numberArray`:return Xr.parse;case`colorArray`:return Zr.parse;default:return null}}function No(e){switch(e){case`exponential`:return Ro;case`interval`:return Lo;case`categorical`:return Io;case`identity`:return zo;default:throw Error(`Unknown function type "${e}"`)}}function Po(e,t){let n=e.stops&&typeof e.stops[0][0]==`object`,r=n||e.property!==void 0,i=n||!r,a=e.type||(Oo(t)?`exponential`:`interval`),o=Mo(t);if(o&&(e=ko({},e),e.stops&&=e.stops.map(e=>[e[0],o(e[1])]),e.default?e.default=o(e.default):e.default=o(t.default)),e.colorSpace&&!Wr(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let s=No(a),c,l;if(a===`categorical`){c=Object.create(null);for(let t of e.stops)c[t[0]]=t[1];l=typeof e.stops[0][0]}if(n){let n={},r=[];for(let t=0;te[0]),evaluate({zoom:n},r){return Ro({stops:i,base:e.base},t,n).evaluate(n,r)}}}else if(i){let n=a===`exponential`?{name:`exponential`,base:e.base===void 0?1:e.base}:null;return{kind:`camera`,interpolationType:n,interpolationFactor:Ti.interpolationFactor.bind(void 0,n),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:n})=>s(e,t,n,c,l)}}else return{kind:`source`,evaluate(n,r){let i=r&&r.properties?r.properties[e.property]:void 0;return i===void 0?Fo(e.default,t.default):s(e,t,i,c,l)}}}function Fo(e,t,n){if(e!==void 0)return e;if(t!==void 0)return t;if(n!==void 0)return n}function Io(e,t,n,r,i){return Fo(typeof n===i?r[n]:void 0,e.default,t.default)}function Lo(e,t,n){if(V(n)!==`number`)return Fo(e.default,t.default);let r=e.stops.length;if(r===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];let i=Si(e.stops.map(e=>e[0]),n,``);return e.stops[i][1]}function Ro(e,t,n){let r=e.base===void 0?1:e.base;if(V(n)!==`number`)return Fo(e.default,t.default);let i=e.stops.length;if(i===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];let a=Si(e.stops.map(e=>e[0]),n,``),o=Bo(n,r,e.stops[a][0],e.stops[a+1][0]),s=e.stops[a][1],c=e.stops[a+1][1],l=Di[t.type]||jo;return typeof s.evaluate==`function`?{evaluate(...t){let n=s.evaluate.apply(void 0,t),r=c.evaluate.apply(void 0,t);if(n!==void 0&&r!==void 0)return l(n,r,o,e.colorSpace)}}:l(s,c,o,e.colorSpace)}function zo(e,t,n){switch(t.type){case`color`:n=z.parse(n);break;case`formatted`:n=Jr.fromString(n.toString());break;case`resolvedImage`:n=ei.fromString(n.toString());break;case`padding`:n=Yr.parse(n);break;case`colorArray`:n=Zr.parse(n);break;case`numberArray`:n=Xr.parse(n);break;default:V(n)!==t.type&&(t.type!==`enum`||!t.values[n])&&(n=void 0)}return Fo(n,e.default,t.default)}function Bo(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}var Vo=class{constructor(e,t,n,r){this.expression=e,this._warningHistory={},this._evaluator=new fi,this._defaultValue=n?ts(n):null,this._enumValues=n&&n.type===`enum`?n.values:null,this._globalState=r,this._rootKey=t}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=ns(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,a){this._globalState&&(e=ns(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a||null;try{let e=this.expression.evaluate(this._evaluator);if(e==null||typeof e==`number`&&e!==e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new B(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(`, `)}, but found ${JSON.stringify(e)} instead.`,``);return e}catch(e){let t=e instanceof B?e.path:``,n=`${t}|${e.message}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<`u`&&console.warn(Ho(this._rootKey,t,e.message,this._defaultValue))),this._defaultValue}}};function Ho(e,t,n,r){return`${e}${t}: ${n}${r==null?``:` Falling back to ${String(r)}.`}`}function Uo(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 Wo(e){return Array.isArray(e)&&e.length>0&&typeof e[0]==`string`&&e[0]in fo}function Go(e,t,n,r){Uo(t);let i=new pi(fo,bo,[],n?es(n):void 0),a=i.parse(e,void 0,void 0,void 0,n&&n.type===`string`?{typeAnnotation:`coerce`}:void 0);return a?wo(new Vo(a,t,n,r)):To(i.errors)}var Ko=class{constructor(e,t,n){this.kind=e,this._styleExpression=t,this.isStateDependent=e!==`constant`&&!So(t.expression),this.globalStateRefs=$o(t.expression),this._globalState=n}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=ns(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._globalState&&(e=ns(e,this._globalState)),this._styleExpression.evaluate(e,t,n,r,i,a)}},qo=class{constructor(e,t,n,r,i){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent=e!==`camera`&&!So(t.expression),this.globalStateRefs=$o(t.expression),this.interpolationType=r,this._globalState=i}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=ns(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._globalState&&(e=ns(e,this._globalState)),this._styleExpression.evaluate(e,t,n,r,i,a)}interpolationFactor(e,t,n){return this.interpolationType?Ti.interpolationFactor(this.interpolationType,e,t,n):0}};function Jo(e){return e._styleExpression!==void 0}function Yo(e,t,n,r){let i=Go(e,t,n,r);if(i.result===`error`)return i;let a=i.value.expression,o=xo(a);if(!o&&!Eo(n))return To([new Zn(``,`data expressions not supported`)]);let s=Co(a,[`zoom`]);if(!s&&!Do(n))return To([new Zn(``,`zoom expressions not supported`)]);let c=Qo(a);if(!c&&!s)return To([new Zn(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`)]);if(c instanceof Zn)return To([c]);if(c instanceof Ti&&!Oo(n))return To([new Zn(``,`"interpolate" expressions cannot be used with this property`)]);if(!c)return wo(o?new Ko(`constant`,i.value,r):new Ko(`source`,i.value,r));let l=c instanceof Ti?c.interpolation:void 0;return wo(o?new qo(`camera`,i.value,c.labels,l,r):new qo(`composite`,i.value,c.labels,l,r))}var Xo=class e{constructor(e,t,n){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,Uo(t),this._parameters=e,this._specification=n,this._rootKey=t,this._defaultValue=ts(n),this._warningHistory={};let r=Po(this._parameters,this._specification);this.kind=r.kind,this.interpolationFactor=r.interpolationFactor,this.zoomStops=r.zoomStops,this.interpolationType=r.interpolationType,this._innerEvaluate=r.evaluate}evaluate(e,t){try{return this._innerEvaluate(e,t)}catch(e){let t=e instanceof Error?e.message:String(e),n=`|${t}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<`u`&&console.warn(Ho(this._rootKey,``,t,this._defaultValue))),this._defaultValue}}static deserialize(t){return new e(t._parameters,t._rootKey,t._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification,_rootKey:e._rootKey}}};function Zo(e,t,n,r){if(Ao(e))return new Xo(e,t,n);if(Wo(e)){let i=Yo(e,t,n,r);if(i.result===`error`)throw Error(i.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return i.value}else{let t=e;return n.type===`color`&&typeof e==`string`?t=z.parse(e):n.type===`padding`&&(typeof e==`number`||Array.isArray(e))?t=Yr.parse(e):n.type===`numberArray`&&(typeof e==`number`||Array.isArray(e))?t=Xr.parse(e):n.type===`colorArray`&&(typeof e==`string`||Array.isArray(e))?t=Zr.parse(e):n.type===`variableAnchorOffsetCollection`&&Array.isArray(e)?t=$r.parse(e):n.type===`projectionDefinition`&&typeof e==`string`&&(t=ti.parse(e)),{globalStateRefs:new Set,_globalState:null,kind:`constant`,evaluate:()=>t}}}function Qo(e){let t=null;if(e instanceof mi)t=Qo(e.result);else if(e instanceof Oi){for(let n of e.args)if(t=Qo(n),t)break}else(e instanceof Ci||e instanceof Ti)&&e.input instanceof po&&e.input.name===`zoom`&&(t=e);return t instanceof Zn||e.eachChild(e=>{let n=Qo(e);n instanceof Zn?t=n:!t&&n?t=new Zn(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`):t&&n&&t!==n&&(t=new Zn(``,`Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.`))}),t}function $o(e,t=new Set){return e instanceof uo&&t.add(e.key),e.eachChild(e=>{$o(e,t)}),t}function es(e){let t={color:er,string:F,number:P,enum:F,boolean:I,formatted:ar,padding:or,numberArray:cr,colorArray:sr,projectionDefinition:tr,resolvedImage:lr,variableAnchorOffsetCollection:ur};return e.type===`array`?dr(t[e.value]||L,e.length):t[e.type]}function ts(e){if(e.type===`color`&&Ao(e.default))return new z(0,0,0,0);switch(e.type){case`color`:return z.parse(e.default)||null;case`padding`:return Yr.parse(e.default)||null;case`numberArray`:return Xr.parse(e.default)||null;case`colorArray`:return Zr.parse(e.default)||null;case`variableAnchorOffsetCollection`:return $r.parse(e.default)||null;case`projectionDefinition`:return ti.parse(e.default)||null;default:return e.default===void 0?null:e.default}}function ns(e,t){let{zoom:n,heatmapDensity:r,elevation:i,lineProgress:a,isSupportedScript:o,accumulated:s}=e??{};return{zoom:n,heatmapDensity:r,elevation:i,lineProgress:a,isSupportedScript:o,accumulated:s,globalState:t}}function rs(e){let t=!1;for(let n of e){let e=is(n);if(e===`expression`)return`expression`;e===`legacy`&&(t=!0)}return t?`legacy`:`neutral`}function is(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 rs(e.slice(1));default:return`expression`}}function as(e){return is(e)!==`legacy`}function os(e){return e===`$type`?[`geometry-type`]:e===`$id`?[`id`]:[`get`,e]}function ss(e){switch(e[0]){case`==`:case`!=`:case`<`:case`<=`:case`>`:case`>=`:return e.length!==3||typeof e[1]!=`string`?null:[e[0],os(e[1]),e[2]];case`in`:case`!in`:{if(e.length<2||typeof e[1]!=`string`)return null;let t=[`in`,os(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 cs(e){if((e[0]===`<`||e[0]===`<=`||e[0]===`>`||e[0]===`>=`)&&e[1]===`$type`)return`"$type" cannot be use with operator "${e[0]}"`;let t=ss(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 ls(e,t,n){let r=n[e];return Array.isArray(r)?as(r)?us(r,t.concat(e)):{path:t.concat(e),legacyFilter:r}:null}function us(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case`all`:case`any`:case`none`:for(let n=1;n`u`)return;let r=n.path.map(e=>`[${e}]`).join(``);console.warn(`${t}${r}: ${cs(n.legacyFilter)}`)}const fs={type:`boolean`,default:!1,transition:!1,"property-type":`data-driven`,expression:{interpolated:!1,parameters:[`zoom`,`feature`]}};function ps(e,t,n){if(e==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};as(e)?ds(e,t):e=gs(e);let r=Go(e,t,fs,n);if(r.result===`error`)throw Error(r.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return{filter:(e,t,n)=>r.value.evaluate(e,t,{},n),needGeometry:hs(e),getGlobalStateRefs:()=>$o(r.value.expression)}}function ms(e,t){return et)}function hs(e){if(!Array.isArray(e))return!1;if(e[0]===`within`||e[0]===`distance`)return!0;for(let t=1;t`||t===`<=`||t===`>=`?_s(e[1],e[2],t):t===`any`?vs(e.slice(1)):t===`all`?[`all`].concat(e.slice(1).map(gs)):t===`none`?[`all`].concat(e.slice(1).map(gs).map(xs)):t===`in`?ys(e[1],e.slice(2)):t===`!in`?xs(ys(e[1],e.slice(2))):t===`has`?bs(e[1]):t!==`!has`||xs(bs(e[1]))}function _s(e,t,n){switch(e){case`$type`:return[`filter-type-${n}`,t];case`$id`:return[`filter-id-${n}`,t];default:return[`filter-${n}`,e,t]}}function vs(e){return[`any`].concat(e.map(gs))}function ys(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(e=>typeof e!=typeof t[0])?[`filter-in-large`,e,[`literal`,t.sort(ms)]]:[`filter-in-small`,e,[`literal`,t]]}}function bs(e){switch(e){case`$type`:return!0;case`$id`:return[`filter-has-id`];default:return[`filter-has`,e]}}function xs(e){return[`!`,e]}function Ss(e){let t=typeof e;if(t===`number`||t===`boolean`||t===`string`||e==null)return JSON.stringify(e);if(Array.isArray(e)){let t=`[`;for(let n of e)t+=`${Ss(n)},`;return`${t}]`}let n=Object.keys(e).sort(),r=`{`;for(let t=0;tr.maximum?[new N(t,n,`${n} is greater than the maximum value ${r.maximum}`)]:[]:[new N(t,n,`number expected, ${i} found`)]}function js(e){let t=e.valueSpec,n=H(e.value.type),r,i={},a,o,s=n!==`categorical`&&e.value.property===void 0,c=!s,l=V(e.value.stops)===`array`&&V(e.value.stops[0])===`array`&&V(e.value.stops[0][0])===`object`,u=Os({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:d,default:m}});return n===`identity`&&s&&u.push(new N(e.key,e.value,`missing required property "property"`)),n!==`identity`&&!e.value.stops&&u.push(new N(e.key,e.value,`missing required property "stops"`)),n===`exponential`&&e.valueSpec.expression&&!Oo(e.valueSpec)&&u.push(new N(e.key,e.value,`exponential functions not supported`)),e.styleSpec.$version>=8&&(c&&!Eo(e.valueSpec)?u.push(new N(e.key,e.value,`property functions not supported`)):s&&!Do(e.valueSpec)&&u.push(new N(e.key,e.value,`zoom functions not supported`))),(n===`categorical`||l)&&e.value.property===void 0&&u.push(new N(e.key,e.value,`"property" property is required`)),u;function d(e){if(n===`identity`)return[new N(e.key,e.value,`identity function may not have a "stops" property`)];let t=[],r=e.value;return t=t.concat(ks({key:e.key,value:r,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:f})),V(r)===`array`&&r.length===0&&t.push(new N(e.key,r,`array must have at least one stop`)),t}function f(e){let n=[],r=e.value,s=e.key;if(V(r)!==`array`)return[new N(s,r,`array expected, ${V(r)} found`)];if(r.length!==2)return[new N(s,r,`array length 2 expected, length ${r.length} found`)];if(l){if(V(r[0])!==`object`)return[new N(s,r,`object expected, ${V(r[0])} found`)];if(r[0].zoom===void 0)return[new N(s,r,`object stop key must have zoom`)];if(r[0].value===void 0)return[new N(s,r,`object stop key must have value`)];if(o&&o>H(r[0].zoom))return[new N(s,r[0].zoom,`stop zoom values must appear in ascending order`)];H(r[0].zoom)!==o&&(o=H(r[0].zoom),a=void 0,i={}),n=n.concat(Os({key:`${s}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:As,value:p}}))}else n=n.concat(p({key:`${s}[0]`,value:r[0],valueSpec:{},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},r));return Wo(Ds(r[1]))?n.concat([new N(`${s}[1]`,r[1],`expressions are not allowed in function stops.`)]):n.concat(e.validateSpec({key:`${s}[1]`,value:r[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function p(e,o){let s=V(e.value),c=H(e.value),l=e.value===null?o:e.value;if(!r)r=s;else if(s!==r)return[new N(e.key,l,`${s} stop domain type must match previous stop domain type ${r}`)];if(s!==`number`&&s!==`string`&&s!==`boolean`)return[new N(e.key,l,`stop domain value must be a number, string, or boolean`)];if(s!==`number`&&n!==`categorical`){let r=`number expected, ${s} found`;return Eo(t)&&n===void 0&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new N(e.key,l,r)]}return n===`categorical`&&s===`number`&&(!isFinite(c)||Math.floor(c)!==c)?[new N(e.key,l,`integer expected, found ${c}`)]:n!==`categorical`&&s===`number`&&a!==void 0&&cnew N(`${e.key}${t.key}`,e.value,t.message));let n=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext===`property`&&e.propertyKey===`text-font`&&!n.outputDefined())return[new N(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`&&!So(n))return[new N(e.key,e.value,`"feature-state" data expressions are not supported with layout properties.`)];if(e.expressionContext===`filter`&&!So(n))return[new N(e.key,e.value,`"feature-state" data expressions are not supported with filters.`)];if(e.expressionContext&&e.expressionContext.indexOf(`cluster`)===0){if(!Co(n,[`zoom`,`feature-state`]))return[new N(e.key,e.value,`"zoom" and "feature-state" expressions are not supported with cluster properties.`)];if(e.expressionContext===`cluster-initial`&&!xo(n))return[new N(e.key,e.value,`Feature data expressions are not supported with initial expression part of cluster properties.`)]}return[]}function Ns(e){let t=e.value,n=e.key,r=V(t);return r===`boolean`?[]:[new N(n,t,`boolean expected, ${r} found`)]}function Ps(e){let t=e.key,n=e.value,r=V(n);return r===`string`?z.parse(String(n))?[]:[new N(t,n,`color expected, "${n}" found`)]:[new N(t,n,`color expected, ${r} found`)]}function Fs(e){let t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?r.values.indexOf(H(n))===-1&&i.push(new N(t,n,`expected one of [${r.values.join(`, `)}], ${JSON.stringify(n)} found`)):Object.keys(r.values).indexOf(H(n))===-1&&i.push(new N(t,n,`expected one of [${Object.keys(r.values).join(`, `)}], ${JSON.stringify(n)} found`)),i}function Is(e,t){let n=e;for(let e of t)n=n[e];return n}function Ls(e,t){let n=us(t);return n?[new N(`${e.key}${n.path.map(e=>`[${e}]`).join(``)}`,Is(e.value,n.path),cs(n.legacyFilter),null,`warning`)]:[]}function Rs(e){let t=Ds(e.value);return as(t)?[...Ls(e,t),...Ms(ko({},e,{expressionContext:`filter`,valueSpec:{value:`boolean`}}))]:zs(e)}function zs(e){let t=e.value,n=e.key;if(V(t)!==`array`)return[new N(n,t,`array expected, ${V(t)} found`)];let r=e.styleSpec,i,a=[];if(t.length<1)return[new N(n,t,`filter array must have at least 1 element`)];switch(a=a.concat(Fs({key:`${n}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),H(t[0])){case`<`:case`<=`:case`>`:case`>=`:t.length>=2&&H(t[1])===`$type`&&a.push(new N(n,t,`"$type" cannot be use with operator "${t[0]}"`));case`==`:case`!=`:t.length!==3&&a.push(new N(n,t,`filter array for operator "${t[0]}" must have 3 elements`));case`in`:case`!in`:t.length>=2&&(i=V(t[1]),i!==`string`&&a.push(new N(`${n}[1]`,t[1],`string expected, ${i} found`)));for(let o=2;o{e in n&&t.push(new N(r,n[e],`"${e}" is prohibited for ref layers`))});let e;i.layers.forEach(t=>{H(t.id)===s&&(e=t)}),e?e.ref?t.push(new N(r,n.ref,`ref cannot reference another ref layer`)):o=H(e.type):t.push(new N(r,n.ref,`ref layer "${s}" not found`))}else if(o!==`background`)if(!n.source)t.push(new N(r,n,`missing required property "source"`));else{let e=i.sources&&i.sources[n.source],a=e&&H(e.type);e?a===`vector`&&o===`raster`?t.push(new N(r,n.source,`layer "${n.id}" requires a raster source`)):a!==`raster-dem`&&o===`hillshade`||a!==`raster-dem`&&o===`color-relief`?t.push(new N(r,n.source,`layer "${n.id}" requires a raster-dem source`)):a===`raster`&&o!==`raster`?t.push(new N(r,n.source,`layer "${n.id}" requires a vector source`)):a===`vector`&&!n[`source-layer`]?t.push(new N(r,n,`layer "${n.id}" must specify a "source-layer"`)):a===`raster-dem`&&o!==`hillshade`&&o!==`color-relief`?t.push(new N(r,n.source,`raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.`)):o===`line`&&n.paint&&n.paint[`line-gradient`]&&(a!==`geojson`||!e.lineMetrics)&&t.push(new N(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new N(r,n.source,`source "${n.source}" not found`))}return o===`raster`&&n.paint?.resampling&&n.paint?.[`raster-resampling`]&&t.push(new N(r,n.paint,`layer "${n.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(Os({key:r,value:n,valueSpec:a.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(){return[]},type(){return e.validateSpec({key:`${r}.type`,value:n.type,valueSpec:a.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:n,objectKey:`type`})},filter:Rs,layout(e){return Os({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(e){return Hs(ko({layerType:o},e))}}})},paint(e){return Os({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(e){return Vs(ko({layerType:o},e))}}})}}})),t}function Ws(e){let t=e.value,n=e.key,r=V(t);return r===`string`?[]:[new N(n,t,`string expected, ${r} found`)]}function Gs(e){let t=e.sourceName??``,n=e.value,r=e.styleSpec,i=r.source_raster_dem,a=e.style,o=[],s=V(n);if(n===void 0)return o;if(s!==`object`)return o.push(new N(`source_raster_dem`,n,`object expected, ${s} found`)),o;let c=H(n.encoding)===`custom`,l=[`redFactor`,`greenFactor`,`blueFactor`,`baseShift`],u=e.value.encoding?`"${e.value.encoding}"`:`Default`;for(let s in n)!c&&l.includes(s)?o.push(new N(s,n[s],`In "${t}": "${s}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):i[s]?o=o.concat(e.validateSpec({key:s,value:n[s],valueSpec:i[s],validateSpec:e.validateSpec,style:a,styleSpec:r})):o.push(new N(s,n[s],`unknown property "${s}"`));return o}const Ks={promoteId:Js};function qs(e){let t=e.value,n=e.key,r=e.styleSpec,i=e.style,a=e.validateSpec;if(!t.type)return[new N(n,t,`"type" is required`)];let o=H(t.type),s;switch(o){case`vector`:case`raster`:return s=Os({key:n,value:t,valueSpec:r[`source_${o.replace(`-`,`_`)}`],style:e.style,styleSpec:r,objectElementValidators:Ks,validateSpec:a}),s;case`raster-dem`:return s=Gs({sourceName:n,value:t,style:e.style,styleSpec:r,validateSpec:a}),s;case`geojson`:if(s=Os({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,validateSpec:a,objectElementValidators:Ks}),t.cluster)for(let e in t.clusterProperties){let[r,i]=t.clusterProperties[e],o=typeof r==`string`?[r,[`accumulated`],[`get`,e]]:r;s.push(...Ms({key:`${n}.${e}.map`,value:i,validateSpec:a,expressionContext:`cluster-map`})),s.push(...Ms({key:`${n}.${e}.reduce`,value:o,validateSpec:a,expressionContext:`cluster-reduce`}))}return s;case`video`:return Os({key:n,value:t,valueSpec:r.source_video,style:i,validateSpec:a,styleSpec:r});case`image`:return Os({key:n,value:t,valueSpec:r.source_image,style:i,validateSpec:a,styleSpec:r});case`canvas`:return[new N(n,null,`Please use runtime APIs to add canvas sources, rather than including them in stylesheets.`,`source.canvas`)];default:return Fs({key:`${n}.type`,value:t.type,valueSpec:{values:[`vector`,`raster`,`raster-dem`,`geojson`,`video`,`image`]},style:i,validateSpec:a,styleSpec:r})}}function Js({key:e,value:t}){if(V(t)===`string`)return Ws({key:e,value:t});{let n=[];for(let r in t)n.push(...Ws({key:`${e}.${r}`,value:t[r]}));return n}}function Ys(e){let t=e.value,n=e.styleSpec,r=n.light,i=e.style,a=[],o=V(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new N(`light`,t,`object expected, ${o} found`)]),a;for(let o in t){let s=o.match(/^(.*)-transition$/);a=s&&r[s[1]]&&r[s[1]].transition?a.concat(e.validateSpec({key:o,value:t[o],valueSpec:n.transition,validateSpec:e.validateSpec,style:i,styleSpec:n})):r[o]?a.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n})):a.concat([new N(o,t[o],`unknown property "${o}"`)])}return a}function Xs(e){let t=e.value,n=e.styleSpec,r=n.sky,i=e.style,a=V(t);if(t===void 0)return[];if(a!==`object`)return[new N(`sky`,t,`object expected, ${a} found`)];let o=[];for(let a in t)o=r[a]?o.concat(e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:i,styleSpec:n})):o.concat([new N(a,t[a],`unknown property "${a}"`)]);return o}function Zs(e){let t=e.value,n=e.styleSpec,r=n.terrain,i=e.style,a=[],o=V(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new N(`terrain`,t,`object expected, ${o} found`)]),a;for(let o in t)a=r[o]?a.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n})):a.concat([new N(o,t[o],`unknown property "${o}"`)]);return a}function Qs(e){return Ws(e).length===0?[]:Ms(e)}function $s(e){return Ws(e).length===0?[]:Ms(e)}function ec(e){let t=e.key,n=e.value;if(V(n)===`array`){if(n.length<1||n.length>4)return[new N(t,n,`padding requires 1 to 4 values; ${n.length} values found`)];let r={type:`number`},i=[];for(let a=0;ae.line-t.line)}function vc(e){return function(...t){return _c(e.apply(this,t))}}const yc={type:`enum`,"property-type":`data-constant`,expression:{interpolated:!1,parameters:[`global-state`]},values:{visible:{},none:{}},transition:!1,default:`visible`};var bc=class{constructor(e,t,n){this._rootKey=t,this._globalState=n,this.setValue(e)}evaluate(){return this._literalValue??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=Go(e,this._rootKey,yc,this._globalState);if(t.result===`error`)throw this._literalValue=`visible`,this._compiledValue=void 0,Error(t.value.map(e=>`${e.key}: ${e.message}`).join(`, `));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=$o(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function xc(e,t,n){return new bc(e,t,n)}const Sc=hc,Cc=new Set(Object.keys(j).filter(e=>e.startsWith(`source_`)).map(e=>e.slice(7).replaceAll(`_`,`-`)));function wc(e){return Object.entries(e.sources??{}).filter(([,e])=>!Cc.has(e.type)).map(([e])=>`sources.${e}`)}function Tc(e,t){let n=wc(t);return Ec(e,Sc(t).filter(({message:e})=>!n.some(t=>e.startsWith(`${t}:`)||e.startsWith(`${t}.`))))}function Ec(e,t){let n=!1;for(let r of t){if(r.severity===`warning`){Ft(r.message);continue}e.fire(new Fn(Error(r.message))),n=!0}return n}function Dc(e,t,n,r){return r?.validate!==!1&&Ec(e,t({styleSpec:j,...n}))}var Oc=class e{constructor(e,t,n){let r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let i=new Int32Array(this.arrayBuffer);e=i[0],t=i[1],n=i[2],this.d=t+2*n;for(let e=0;e=l[c+0]&&r>=l[c+1])?(o[u]=!0,a.push(i[u])):o[u]=!1}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToCellCoord(e),l=this._convertToCellCoord(t),u=this._convertToCellCoord(n),d=this._convertToCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++){let l=this.d*c+f;if(!(s&&!s(this._convertFromCellCoord(f),this._convertFromCellCoord(c),this._convertFromCellCoord(f+1),this._convertFromCellCoord(c+1)))&&i.call(this,e,t,n,r,l,a,o,s))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,t=3+this.cells.length+1+1,n=0;for(let e of this.cells)n+=e.length;let r=new Int32Array(t+n+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let i=t;for(let t=0;tn?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=t):this.lastFloorZoom{try{return RegExp(`\\p{sc=${e}}`,`u`).source}catch{return null}}).filter(e=>e);return new RegExp(t.join(`|`),`u`)}const Kc=Gc([`Arab`,`Dupl`,`Mong`,`Ougr`,`Syrc`]);function qc(e){return!Kc.test(String.fromCodePoint(e))}function Jc(e){return!(zc(e)||Bc(e))}function Yc(e){return/\p{sc=Arab}/u.test(String.fromCodePoint(e))}const Xc=Gc(`Adlm.Arab.Armi.Avst.Chrs.Cprt.Egyp.Elym.Gara.Hatr.Hebr.Hung.Khar.Lydi.Mand.Mani.Mend.Merc.Mero.Narb.Nbat.Nkoo.Orkh.Palm.Phli.Phlp.Phnx.Prti.Rohg.Samr.Sarb.Sogo.Syrc.Thaa.Todr.Yezi`.split(`.`));function Zc(e){return Xc.test(String.fromCodePoint(e))}function Qc(e,t){return!t&&Zc(e)?!1:!Vc(e)}function $c(e){for(let t of e)if(Zc(t.codePointAt(0)))return!0;return!1}function el(e,t){for(let n of e)if(!Qc(n.codePointAt(0),t))return!1;return!0}const tl=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus=`unavailable`,this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(tl.isParsed())throw Error(`RTL text plugin already registered.`);this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(e,t){if(this.isParsed())return this.getState();if(e.pluginStatus!==`loading`)return this.setState(e),e;let n=e.pluginURL,r=new Promise(e=>{this.loadScriptResolve=e}),i=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(await t(n),await Promise.race([r,i]),this.isParsed()){let e={pluginStatus:`loaded`,pluginURL:n};return this.setState(e),e}throw this.setState({pluginStatus:`error`,pluginURL:``}),Error(`RTL Text Plugin failed to import scripts from ${n}`)}};var W=class{constructor(e,t){this.isSupportedScript=nl,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new Ic,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ic,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),n=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*t}}};function nl(e){return el(e,tl.getRTLTextPluginStatus()===`loaded`)}const rl=`-transition`;var il=class{constructor(e,t,n,r){this.property=e,this.value=t,this.expression=Zo(t===void 0?e.specification.default:t,n,e.specification,r)}isDataDriven(){return this.expression.kind===`source`||this.expression.kind===`composite`}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}},al=class{constructor(e,t,n){this.property=e,this.value=new il(e,void 0,t,n)}transitioned(e,t){return new sl(this.property,this.value,t,xt({},e.transition,this.transition),e.now)}untransitioned(){return new sl(this.property,this.value,null,{},0)}},ol=class{constructor(e,t,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=n,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return Nt(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new al(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].value=new il(this._values[e].property,t===null?void 0:Nt(t),this._propertyRootKey(e),this._globalState)}getTransition(e){return Nt(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new al(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].transition=Nt(t)||void 0}serialize(){let e={};for(let t of Object.keys(this._values)){let n=this.getValue(t);n!==void 0&&(e[t]=n);let r=this.getTransition(t);r!==void 0&&(e[`${t}${rl}`]=r)}return e}transitioned(e,t){let n=new cl(this._properties);for(let r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){let e=new cl(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}},sl=class{constructor(e,t,n,r,i){this.property=e,this.value=t,this.begin=i+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){let r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),a=this.prior;if(!a)return i;if(r>this.end||this.value.isDataDriven())return this.prior=null,i;if(rr.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}},hl=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,n,r){if(e.value!==void 0)if(e.expression.kind===`constant`){let i=e.expression.evaluate(t,null,{},n,r);return this._calculate(i,i,i,t)}else return this._calculate(e.expression.evaluate(new W(Math.floor(t.zoom-1),t)),e.expression.evaluate(new W(Math.floor(t.zoom),t)),e.expression.evaluate(new W(Math.floor(t.zoom+1),t)),t)}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}},gl=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,n,r){return!!e.expression.evaluate(t,null,{},n,r)}interpolate(){return!1}},_l=class{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let n=e[t];n.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new il(n,void 0,n.name,void 0),i=this.defaultTransitionablePropertyValues[t]=new al(n,n.name,void 0);this.defaultTransitioningPropertyValues[t]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}};U(`DataDrivenProperty`,K),U(`DataConstantProperty`,G),U(`CrossFadedDataDrivenProperty`,ml),U(`CrossFadedProperty`,hl),U(`ColorRampProperty`,gl);const vl=` is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?`,yl=` is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?`;var bl=class extends In{constructor(e,t,n){if(super(),this.id=e.id,this.type=e.type,this._globalState=n,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=xc(this.visibility,`layers[${this.id}].layout.visibility`,n),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=ps(e.filter,`layers[${this.id}].filter`,n)),t.layout&&(this._unevaluatedLayout=new ll(t.layout,`layers[${this.id}].layout`,n)),t.paint)){this._transitionablePaint=new ol(t.paint,`layers[${this.id}].paint`,n);for(let t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(let t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new dl(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=ps(e,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){if(e===`visibility`)return this.visibility;if(this._transitionablePaint?.hasProperty(e))throw Error(e+vl);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 n=this._unevaluatedLayout._values[t];for(let t of n.getGlobalStateRefs())e.add(t)}for(let t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){let e=new globalThis.Map;if(this._transitionablePaint)for(let t in this._transitionablePaint._values){let n=this._transitionablePaint._values[t].value;for(let r of n.getGlobalStateRefs()){let i=e.get(r)??[];i.push({name:t,value:n.value}),e.set(r,i)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,n={}){if(e===`visibility`){this.visibility=t,this._visibilityExpression.setValue(t),this.recalculateVisibility();return}if(this._transitionablePaint?.hasProperty(e)){this.fire(new Fn(Error(e+vl)));return}t!=null&&this._validate(Sc.layoutProperty,`layers.${this.id}.layout.${e}`,e,t,n)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){if(e.endsWith(`-transition`)){let t=e.slice(0,-11);if(t===`visibility`||this._unevaluatedLayout?.hasProperty(t))throw Error(e+yl);return this._transitionablePaint.getTransition(t)}else{if(e===`visibility`||this._unevaluatedLayout?.hasProperty(e))throw Error(e+yl);return this._transitionablePaint.getValue(e)}}setPaintProperty(e,t,n={}){if(e===`visibility`||this._unevaluatedLayout?.hasProperty(e))return this.fire(new Fn(Error(e+yl))),!1;if(t!=null&&this._validate(Sc.paintProperty,`layers.${this.id}.paint.${e}`,e,t,n))return!1;if(e.endsWith(`-transition`))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let n=this._transitionablePaint._values[e],r=n.property.specification[`property-type`]===`cross-faded-data-driven`,i=n.value.isDataDriven(),a=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let o=this._transitionablePaint._values[e].value;return o.isDataDriven()||i||r||this._handleOverridablePaintPropertyUpdate(e,a,o)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,n){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)}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(){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:this._unevaluatedLayout?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(e.layout||={},e.layout.visibility=this.visibility),jt(e,(e,t)=>e!==void 0&&!(t===`layout`&&!Object.keys(e).length)&&!(t===`paint`&&!Object.keys(e).length))}_validate(e,t,n,r,i={}){return Dc(this,e,{key:t,layerType:this.type,objectKey:n,value:r},i)}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 ul)||!Eo(t.property.specification))&&(t.value.kind===`source`||t.value.kind===`composite`)&&t.value.isStateDependent)return!0}return!1}};let xl;const Sl=()=>xl||=new _l({"raster-opacity":new G(j.paint_raster[`raster-opacity`],`raster-opacity`),"raster-hue-rotate":new G(j.paint_raster[`raster-hue-rotate`],`raster-hue-rotate`),"raster-brightness-min":new G(j.paint_raster[`raster-brightness-min`],`raster-brightness-min`),"raster-brightness-max":new G(j.paint_raster[`raster-brightness-max`],`raster-brightness-max`),"raster-saturation":new G(j.paint_raster[`raster-saturation`],`raster-saturation`),"raster-contrast":new G(j.paint_raster[`raster-contrast`],`raster-contrast`),resampling:new G(j.paint_raster.resampling,`resampling`),"raster-resampling":new G(j.paint_raster[`raster-resampling`],`raster-resampling`),"raster-fade-duration":new G(j.paint_raster[`raster-fade-duration`],`raster-fade-duration`)});var Cl={get paint(){return Sl()}};const wl=e=>e.type===`raster`;var Tl=class extends bl{constructor(e,t){super(e,Cl,t)}};const El={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var Dl=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}},q=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 J(e,t=1){let n=0,r=0;return{members:e.map(e=>{let i=Ol(e.type),a=n=kl(n,Math.max(t,i)),o=e.components||1;return r=Math.max(r,i),n+=i*o,{name:e.name,type:e.type,components:o,offset:a}}),size:kl(n,Math.max(r,t)),alignment:t}}function Ol(e){return El[e].BYTES_PER_ELEMENT}function kl(e,t){return Math.ceil(e/t)*t}var Al=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=e*2;return this.int16[r+0]=t,this.int16[r+1]=n,e}};Al.prototype.bytesPerElement=4,U(`StructArrayLayout2i4`,Al);var jl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*3;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}};jl.prototype.bytesPerElement=6,U(`StructArrayLayout3i6`,jl);var Ml=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=e*4;return this.int16[a+0]=t,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,e}};Ml.prototype.bytesPerElement=8,U(`StructArrayLayout4i8`,Ml);var Nl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=e*6;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}};Nl.prototype.bytesPerElement=12,U(`StructArrayLayout2i4i12`,Nl);var Pl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=e*4,c=e*8;return this.int16[s+0]=t,this.int16[s+1]=n,this.uint8[c+4]=r,this.uint8[c+5]=i,this.uint8[c+6]=a,this.uint8[c+7]=o,e}};Pl.prototype.bytesPerElement=8,U(`StructArrayLayout2i4ub8`,Pl);var Fl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=e*2;return this.float32[r+0]=t,this.float32[r+1]=n,e}};Fl.prototype.bytesPerElement=8,U(`StructArrayLayout2f8`,Fl);var Il=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,n,r,i,a,o,s,c,l)}emplace(e,t,n,r,i,a,o,s,c,l,u){let d=e*10;return this.uint16[d+0]=t,this.uint16[d+1]=n,this.uint16[d+2]=r,this.uint16[d+3]=i,this.uint16[d+4]=a,this.uint16[d+5]=o,this.uint16[d+6]=s,this.uint16[d+7]=c,this.uint16[d+8]=l,this.uint16[d+9]=u,e}};Il.prototype.bytesPerElement=20,U(`StructArrayLayout10ui20`,Il);var Ll=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,r,i,a,o,s)}emplace(e,t,n,r,i,a,o,s,c){let l=e*8;return this.uint16[l+0]=t,this.uint16[l+1]=n,this.uint16[l+2]=r,this.uint16[l+3]=i,this.uint16[l+4]=a,this.uint16[l+5]=o,this.uint16[l+6]=s,this.uint16[l+7]=c,e}};Ll.prototype.bytesPerElement=16,U(`StructArrayLayout8ui16`,Ll);var Rl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,a,o,s,c,l,u,d)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=e*12;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.uint16[p+4]=a,this.uint16[p+5]=o,this.uint16[p+6]=s,this.uint16[p+7]=c,this.int16[p+8]=l,this.int16[p+9]=u,this.int16[p+10]=d,this.int16[p+11]=f,e}};Rl.prototype.bytesPerElement=24,U(`StructArrayLayout4i4ui4i24`,Rl);var zl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*3;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}};zl.prototype.bytesPerElement=12,U(`StructArrayLayout3f12`,zl);var Bl=class extends q{_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 n=e*1;return this.uint32[n+0]=t,e}};Bl.prototype.bytesPerElement=4,U(`StructArrayLayout1ul4`,Bl);var Vl=class extends q{_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,n,r,i,a,o,s,c){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,r,i,a,o,s,c)}emplace(e,t,n,r,i,a,o,s,c,l){let u=e*10,d=e*5;return this.int16[u+0]=t,this.int16[u+1]=n,this.int16[u+2]=r,this.int16[u+3]=i,this.int16[u+4]=a,this.int16[u+5]=o,this.uint32[d+3]=s,this.uint16[u+8]=c,this.uint16[u+9]=l,e}};Vl.prototype.bytesPerElement=20,U(`StructArrayLayout6i1ul2ui20`,Vl);var Hl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=e*6;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}};Hl.prototype.bytesPerElement=12,U(`StructArrayLayout2i2i2i12`,Hl);var Ul=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i)}emplace(e,t,n,r,i,a){let o=e*4,s=e*8;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.int16[s+6]=i,this.int16[s+7]=a,e}};Ul.prototype.bytesPerElement=16,U(`StructArrayLayout2f1f2i16`,Ul);var Wl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=e*16,c=e*4,l=e*8;return this.uint8[s+0]=t,this.uint8[s+1]=n,this.float32[c+1]=r,this.float32[c+2]=i,this.int16[l+6]=a,this.int16[l+7]=o,e}};Wl.prototype.bytesPerElement=16,U(`StructArrayLayout2ub2f2i16`,Wl);var Gl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*3;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}};Gl.prototype.bytesPerElement=6,U(`StructArrayLayout3ui6`,Gl);var Kl=class extends q{_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,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){let _=this.length;return this.resize(_+1),this.emplace(_,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=e*24,y=e*12,b=e*48;return this.int16[v+0]=t,this.int16[v+1]=n,this.uint16[v+2]=r,this.uint16[v+3]=i,this.uint32[y+2]=a,this.uint32[y+3]=o,this.uint32[y+4]=s,this.uint16[v+10]=c,this.uint16[v+11]=l,this.uint16[v+12]=u,this.float32[y+7]=d,this.float32[y+8]=f,this.uint8[b+36]=p,this.uint8[b+37]=m,this.uint8[b+38]=h,this.uint32[y+10]=g,this.int16[v+22]=_,e}};Kl.prototype.bytesPerElement=48,U(`StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48`,Kl);var ql=class extends q{_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,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D){let O=this.length;return this.resize(O+1),this.emplace(O,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O){let k=e*32,A=e*16;return this.int16[k+0]=t,this.int16[k+1]=n,this.int16[k+2]=r,this.int16[k+3]=i,this.int16[k+4]=a,this.int16[k+5]=o,this.int16[k+6]=s,this.int16[k+7]=c,this.uint16[k+8]=l,this.uint16[k+9]=u,this.uint16[k+10]=d,this.uint16[k+11]=f,this.uint16[k+12]=p,this.uint16[k+13]=m,this.uint16[k+14]=h,this.uint16[k+15]=g,this.uint16[k+16]=_,this.uint16[k+17]=v,this.uint16[k+18]=y,this.uint16[k+19]=b,this.uint16[k+20]=x,this.uint16[k+21]=S,this.uint16[k+22]=C,this.uint32[A+12]=w,this.float32[A+13]=T,this.float32[A+14]=E,this.uint16[k+30]=D,this.uint16[k+31]=O,e}};ql.prototype.bytesPerElement=64,U(`StructArrayLayout8i15ui1ul2f2ui64`,ql);var Jl=class extends q{_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 n=e*1;return this.float32[n+0]=t,e}};Jl.prototype.bytesPerElement=4,U(`StructArrayLayout1f4`,Jl);var Yl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*6,a=e*3;return this.uint16[i+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,e}};Yl.prototype.bytesPerElement=12,U(`StructArrayLayout1ui2f12`,Yl);var Xl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*2,a=e*4;return this.uint32[i+0]=t,this.uint16[a+2]=n,this.uint16[a+3]=r,e}};Xl.prototype.bytesPerElement=8,U(`StructArrayLayout1ul2ui8`,Xl);var Zl=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=e*2;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}};Zl.prototype.bytesPerElement=4,U(`StructArrayLayout2ui4`,Zl);var Ql=class extends q{_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 n=e*1;return this.uint16[n+0]=t,e}};Ql.prototype.bytesPerElement=2,U(`StructArrayLayout1ui2`,Ql);var $l=class extends q{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=e*4;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,e}};$l.prototype.bytesPerElement=16,U(`StructArrayLayout4f16`,$l);var eu=class extends Dl{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 l(this.anchorPointX,this.anchorPointY)}};eu.prototype.size=20;var tu=class extends Vl{get(e){return new eu(this,e)}};U(`CollisionBoxArray`,tu);var nu=class extends Dl{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]}};nu.prototype.size=48;var ru=class extends Kl{get(e){return new nu(this,e)}};U(`PlacedSymbolArray`,ru);var iu=class extends Dl{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]}};iu.prototype.size=64;var au=class extends ql{get(e){return new iu(this,e)}};U(`SymbolInstanceArray`,au);var ou=class extends Jl{getoffsetX(e){return this.float32[e*1+0]}};U(`GlyphOffsetArray`,ou);var su=class extends jl{getx(e){return this.int16[e*3+0]}gety(e){return this.int16[e*3+1]}gettileUnitDistanceFromAnchor(e){return this.int16[e*3+2]}};U(`SymbolLineVertexArray`,su);var cu=class extends Dl{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]}};cu.prototype.size=12;var lu=class extends Yl{get(e){return new cu(this,e)}};U(`TextAnchorOffsetArray`,lu);var uu=class extends Dl{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]}};uu.prototype.size=8;var du=class extends Xl{get(e){return new uu(this,e)}};U(`FeatureIndexArray`,du);var fu=class extends Al{},pu=class extends jl{},mu=class extends Ml{},hu=class extends Al{},gu=class extends Al{},_u=class extends Nl{},vu=class extends Pl{},yu=class extends Fl{},bu=class extends Il{},xu=class extends Ll{},Su=class extends Rl{},Cu=class extends zl{},wu=class extends Bl{},Tu=class extends Hl{},Eu=class extends Ul{},Du=class extends Wl{},Ou=class extends Gl{},ku=class extends Gl{},Au=class extends Zl{},ju=class extends Ql{};const Mu=J([{name:`a_pos`,components:2,type:`Int16`}],4),Nu=Mu.members;Mu.size,Mu.alignment;var Pu=class e{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(t,n,r,i){let a=this.segments[this.segments.length-1];return t>e.MAX_VERTEX_ARRAY_LENGTH&&Ft(`Max vertices per segment is ${e.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${e.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!a||a.vertexLength+t>e.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==i?this.createNewSegment(n,r,i):a}createNewSegment(e,t,n){let r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return n!==void 0&&(r.sortKey=n),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,n){return this.prepareSegment(0,e,t,n)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let e of this.segments)for(let t in e.vaos)e.vaos[t].destroy()}static simpleSegment(t,n,r,i){return new e([{vertexOffset:t,primitiveOffset:n,vertexLength:r,primitiveLength:i,vaos:{},sortKey:0}])}};Pu.MAX_VERTEX_ARRAY_LENGTH=2**16-1,U(`SegmentVector`,Pu);function Fu(e,t){return e=yt(Math.floor(e),0,255),t=yt(Math.floor(t),0,255),256*e+t}const Iu=J([{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`}]),Lu=J([{name:`a_dasharray_from`,components:4,type:`Uint16`},{name:`a_dasharray_to`,components:4,type:`Uint16`}]);var Ru=o(((e,t)=>{function n(e,t){for(var n=e.length&3,r=e.length-n,i=t,a,o=3432918353,s=461845907,c,l=0;l>>16)*o&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*s+(((c>>>16)*s&65535)<<16)&4294967295,i^=c,i=i<<13|i>>>19,a=(i&65535)*5+(((i>>>16)*5&65535)<<16)&4294967295,i=(a&65535)+27492+(((a>>>16)+58964&65535)<<16);switch(c=0,n){case 3:c^=(e.charCodeAt(l+2)&255)<<16;case 2:c^=(e.charCodeAt(l+1)&255)<<8;case 1:c^=e.charCodeAt(l)&255,c=(c&65535)*o+(((c>>>16)*o&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*s+(((c>>>16)*s&65535)<<16)&4294967295,i^=c}return i^=e.length,i^=i>>>16,i=(i&65535)*2246822507+(((i>>>16)*2246822507&65535)<<16)&4294967295,i^=i>>>13,i=(i&65535)*3266489909+(((i>>>16)*3266489909&65535)<<16)&4294967295,i^=i>>>16,i>>>0}t!==void 0&&(t.exports=n)})),zu=o(((e,t)=>{function n(e,t){for(var n=e.length,r=t^n,i=0,a;n>=4;)a=e.charCodeAt(i)&255|(e.charCodeAt(++i)&255)<<8|(e.charCodeAt(++i)&255)<<16|(e.charCodeAt(++i)&255)<<24,a=(a&65535)*1540483477+(((a>>>16)*1540483477&65535)<<16),a^=a>>>24,a=(a&65535)*1540483477+(((a>>>16)*1540483477&65535)<<16),r=(r&65535)*1540483477+(((r>>>16)*1540483477&65535)<<16)^a,n-=4,++i;switch(n){case 3:r^=(e.charCodeAt(i+2)&255)<<16;case 2:r^=(e.charCodeAt(i+1)&255)<<8;case 1:r^=e.charCodeAt(i)&255,r=(r&65535)*1540483477+(((r>>>16)*1540483477&65535)<<16)}return r^=r>>>13,r=(r&65535)*1540483477+(((r>>>16)*1540483477&65535)<<16),r^=r>>>15,r>>>0}t.exports=n})),Bu=c(o(((e,t)=>{var n=Ru(),r=zu();t.exports=n,t.exports.murmur3=n,t.exports.murmur2=r}))(),1),Vu=class e{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(Hu(e)),this.positions.push(t,n,r)}getPositions(e){if(!this.indexed)throw Error(`Trying to get index, but feature positions are not indexed`);let t=Hu(e),n=0,r=this.ids.length-1;for(;n>1;this.ids[e]>=t?r=e:n=e+1}let i=[];for(;this.ids[n]===t;){let e=this.positions[3*n],t=this.positions[3*n+1],r=this.positions[3*n+2];i.push({index:e,start:t,end:r}),n++}return i}static serialize(e,t){let n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Uu(n,r,0,n.length-1),t&&t.push(n.buffer,r.buffer),{ids:n,positions:r}}static deserialize(t){let n=new e;return n.ids=t.ids,n.positions=t.positions,n.indexed=!0,n}};function Hu(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,Bu.default)(String(e))}function Uu(e,t,n,r){for(;n>1],a=n-1,o=r+1;for(;;){do a++;while(e[a]i);if(a>=o)break;Wu(e,a,o),Wu(t,3*a,3*o),Wu(t,3*a+1,3*o+1),Wu(t,3*a+2,3*o+2)}o-n`u_${e}`),this.type=n}setUniform(e,t,n){e.set(n.constantOr(this.value))}getBinding(e,t,n){return this.type===`color`?new Zu(e,t):new qu(e,t)}},id=class{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),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,n,r){let i=null;r===`u_pattern_to`?i=this.patternTo:r===`u_pattern_from`?i=this.patternFrom:r===`u_dasharray_to`?i=this.dashTo:r===`u_dasharray_from`?i=this.dashFrom:r===`u_pixel_ratio_to`?i=this.pixelRatioTo:r===`u_pixel_ratio_from`&&(i=this.pixelRatioFrom),i!==null&&e.set(i)}getBinding(e,t,n){return n.startsWith(`u_pattern`)||n.startsWith(`u_dasharray_`)?new Xu(e,t):new qu(e,t)}},ad=class{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,n){let r=this.paintVertexArray.length,i=this.expression.evaluate(new W(0,n),t,{},n.canonical,[],n.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new W(0,i),n,r);this._setPaintValue(e,t,a)}_setPaintValue(e,t,n){if(this.type===`color`){let r=nd(n);for(let n=e;n`u_${e}_t`),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(e,t,n){let r=this.expression.evaluate(new W(this.zoom,n),t,{},n.canonical,[],n.formattedSection),i=this.expression.evaluate(new W(this.zoom+1,n),t,{},n.canonical,[],n.formattedSection),a=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(a,e,r,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new W(this.zoom,i),n,r),o=this.expression.evaluate(new W(this.zoom+1,i),n,r);this._setPaintValue(e,t,a,o)}_setPaintValue(e,t,n,r){if(this.type===`color`){let i=nd(n),a=nd(r);for(let n=e;n`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof ad||n instanceof od)for(let t of n.paintVertexAttributes)e.push(t.name);else if(n instanceof sd){let t=n.getVertexAttributes();for(let n of t)e.push(n.name)}}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof rd||n instanceof id||n instanceof od)for(let t of n.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let n=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof rd||i instanceof id||i instanceof od){for(let a of i.uniformNames)if(t[a]){let o=i.getBinding(e,t[a],a);n.push({name:a,property:r,binding:o})}}}return n}setUniforms(e,t,n,r){for(let{name:e,property:i,binding:a}of t)this.binders[i].setUniform(a,r,n.get(i),e)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let n=this.binders[t];if(e&&n instanceof sd){let t=e.fromScale===2?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(n instanceof ad||n instanceof od)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer)}}upload(e){for(let t in this.binders){let n=this.binders[t];(n instanceof ad||n instanceof od||n instanceof sd)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof ad||t instanceof od||t instanceof sd)&&t.destroy()}}},dd=class{constructor(e,t,n=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new ud(r,t,n);this.needsUpload=!1,this._featureMap=new Vu,this._bufferOffset=0}populatePaintArrays(e,t,n,r){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r);t.id!==void 0&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r){for(let i of n)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(e,this._featureMap,t,i,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 fd(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 pd(e){return{"line-pattern":{source:bu,composite:bu},"fill-pattern":{source:bu,composite:bu},"fill-extrusion-pattern":{source:bu,composite:bu},"line-dasharray":{source:xu,composite:xu}}[e]}function md(e,t,n){let r={color:{source:Fl,composite:$l},number:{source:Jl,composite:Fl}};return pd(e)?.[n]||r[t][n]}U(`ConstantBinder`,rd),U(`CrossFadedConstantBinder`,id),U(`SourceExpressionBinder`,ad),U(`CrossFadedPatternBinder`,cd),U(`CrossFadedDasharrayBinder`,ld),U(`CompositeExpressionBinder`,od),U(`ProgramConfiguration`,ud,{omit:[`_buffers`]}),U(`ProgramConfigurationSet`,dd);const hd=2**14-1,gd=-hd-1;function _d(e){let t=Ye/e.extent,n=e.loadGeometry();for(let e of n)for(let n of e){let e=Math.round(n.x*t),r=Math.round(n.y*t);n.x=yt(e,gd,hd),n.y=yt(r,gd,hd),(en.x+1||rn.y+1)&&Ft(`Geometry exceeds allowed extent, reduce your vector tile buffer size`)}return n}function vd(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?_d(e):[]}}const yd=-32768;function bd(e,t,n,r,i){e.emplaceBack(yd+t*8+r,yd+n*8+i)}var xd=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new hu,this.indexArray=new ku,this.segments=new Pu,this.programConfigurations=new dd(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n){let r=this.layers[0],i=[],a=null,o=!1,s=r.type===`heatmap`;if(r.type===`circle`){let e=r;a=e.layout.get(`circle-sort-key`),o=!a.isConstant(),s||=e.paint.get(`circle-pitch-alignment`)===`map`}let c=s?t.subdivisionGranularity.circle:1,l=new W(this.zoom),u=this.layers[0]._featureFilter.needGeometry;for(let{feature:t,id:r,index:s,sourceLayerIndex:c}of e){let e=vd(t,u);if(!this.layers[0]._featureFilter.filter(l,e,n))continue;let d=o?a.evaluate(e,{},n):void 0,f={id:r,properties:t.properties,type:t.type,sourceLayerIndex:c,index:s,geometry:u?e.geometry:_d(t),patterns:{},sortKey:d};i.push(f)}o&&i.sort((e,t)=>e.sortKey-t.sortKey);for(let r of i){let{geometry:i,index:a,sourceLayerIndex:o}=r,s=e[a].feature;this.addFeature(r,i,a,n,c),t.featureIndex.insert(s,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Nu),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,n,r,i=1){let a;switch(i){case 1:a=[0,7];break;case 3:a=[0,2,5,7];break;case 5:a=[0,1,3,4,6,7];break;case 7:a=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}let o=a.length;for(let n of t)for(let t of n){let n=t.x,r=t.y;if(n<0||n>=8192||r<0||r>=8192)continue;let i=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),s=i.vertexLength;for(let e=0;e=3){for(let t of r)if(Md(e,t))return!0}if(Ed(e,r,n))return!0}return!1}function Ed(e,t,n){if(e.length>1){if(Dd(e,t))return!0;for(let r of t)if(kd(r,e,n))return!0}for(let r of e)if(kd(r,t,n))return!0;return!1}function Dd(e,t){if(e.length===0||t.length===0)return!1;for(let n=0;n1?e.distSqr(n):e.distSqr(n.sub(t)._mult(i)._add(t))}function jd(e,t){let n=!1,r,i,a;for(let o of e){r=o;for(let e=0,o=r.length-1;et.y!=a.y>t.y&&t.x<(a.x-i.x)*(t.y-i.y)/(a.y-i.y)+i.x&&(n=!n)}return n}function Md(e,t){let n=!1;for(let r=0,i=e.length-1;rt.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function Nd(e,t,n,r,i){for(let a of e)if(t<=a.x&&n<=a.y&&r>=a.x&&i>=a.y)return!0;let a=[new l(t,n),new l(t,i),new l(r,i),new l(r,n)];if(e.length>2){for(let t of a)if(Md(e,t))return!0}for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;let a=It(e,t,n[0]);return a!==It(e,t,n[1])||a!==It(e,t,n[2])||a!==It(e,t,n[3])}function Fd(e,t,n){let r=t.paint.get(e).value;return r.kind===`constant`?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function Id(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Ld(e,t,n,r,i){if(!t[0]&&!t[1])return e;let a=l.convert(t)._mult(i);n===`viewport`&&a._rotate(-r);let o=[];for(let t of e)o.push(t.sub(a));return o}function Rd(e){let t=[];for(let n=0;nGd(e,t,n,r))}let qd;const Jd=()=>qd||=new _l({"circle-sort-key":new K(j.layout_circle[`circle-sort-key`],`circle-sort-key`)});let Yd;const Xd=()=>Yd||=new _l({"circle-radius":new K(j.paint_circle[`circle-radius`],`circle-radius`),"circle-color":new K(j.paint_circle[`circle-color`],`circle-color`),"circle-blur":new K(j.paint_circle[`circle-blur`],`circle-blur`),"circle-opacity":new K(j.paint_circle[`circle-opacity`],`circle-opacity`),"circle-translate":new G(j.paint_circle[`circle-translate`],`circle-translate`),"circle-translate-anchor":new G(j.paint_circle[`circle-translate-anchor`],`circle-translate-anchor`),"circle-pitch-scale":new G(j.paint_circle[`circle-pitch-scale`],`circle-pitch-scale`),"circle-pitch-alignment":new G(j.paint_circle[`circle-pitch-alignment`],`circle-pitch-alignment`),"circle-stroke-width":new K(j.paint_circle[`circle-stroke-width`],`circle-stroke-width`),"circle-stroke-color":new K(j.paint_circle[`circle-stroke-color`],`circle-stroke-color`),"circle-stroke-opacity":new K(j.paint_circle[`circle-stroke-opacity`],`circle-stroke-opacity`)});var Zd={get paint(){return Xd()},get layout(){return Jd()}};const Qd=e=>e.type===`circle`;var $d=class extends bl{constructor(e,t){super(e,Zd,t)}createBucket(e){return new xd(e)}queryRadius(e){let t=e;return Fd(`circle-radius`,this,t)+Fd(`circle-stroke-width`,this,t)+Id(this.paint.get(`circle-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){let c=Ld(e,this.paint.get(`circle-translate`),this.paint.get(`circle-translate-anchor`),-i.bearingInRadians,a),l=this.paint.get(`circle-radius`).evaluate(t,n)+this.paint.get(`circle-stroke-width`).evaluate(t,n),u=this.paint.get(`circle-pitch-scale`),d=this.paint.get(`circle-pitch-alignment`),f,p;return d===`map`?(f=c,p=l*a):(f=Kd(c,i,o,s),p=l),Wd({queryGeometry:f,size:p,transform:i,unwrappedTileID:o,getElevation:s,pitchAlignment:d,pitchScale:u},r)}},ef=class extends xd{};U(`HeatmapBucket`,ef,{omit:[`layers`]});let tf;const nf=()=>tf||=new _l({"heatmap-radius":new K(j.paint_heatmap[`heatmap-radius`],`heatmap-radius`),"heatmap-weight":new K(j.paint_heatmap[`heatmap-weight`],`heatmap-weight`),"heatmap-intensity":new G(j.paint_heatmap[`heatmap-intensity`],`heatmap-intensity`),"heatmap-color":new gl(j.paint_heatmap[`heatmap-color`],`heatmap-color`),"heatmap-opacity":new G(j.paint_heatmap[`heatmap-opacity`],`heatmap-opacity`)});var rf={get paint(){return nf()}};function af(e,{width:t,height:n},r,i){if(!i)i=new Uint8Array(t*n*r);else if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*n*r)throw RangeError(`mismatched image size. expected: ${i.length} but got: ${t*n*r}`);return e.width=t,e.height=n,e.data=i,e}function of(e,{width:t,height:n},r){if(t===e.width&&n===e.height)return;let i=af({},{width:t,height:n},r);sf(e,i,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,n)},r),e.width=t,e.height=n,e.data=i.data}function sf(e,t,n,r,i,a){if(i.width===0||i.height===0)return t;if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw RangeError(`out of range source coordinates for image copy`);if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.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 c=0;c{t[e.evaluationKey]=o;let s=e.expression.evaluate(t);i.setPixel(r/4/n,a/4,s)};if(e.clips)for(let t=0,i=0;te.type===`heatmap`;var mf=class extends bl{createBucket(e){return new ef(e)}constructor(e,t){super(e,rf,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=df({expression:e,evaluationKey:`heatmapDensity`,image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(`big-fb`)&&this.heatmapFbos.delete(ff)}queryRadius(e){return Fd(`heatmap-radius`,this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){return Wd({queryGeometry:e,size:this.paint.get(`heatmap-radius`).evaluate(t,n)*a,transform:i,unwrappedTileID:o,getElevation:s},r)}hasOffscreenPass(){return this.paint.get(`heatmap-opacity`)!==0&&!this.isHidden()}};let hf;const gf=()=>hf||=new _l({"hillshade-illumination-direction":new G(j.paint_hillshade[`hillshade-illumination-direction`],`hillshade-illumination-direction`),"hillshade-illumination-altitude":new G(j.paint_hillshade[`hillshade-illumination-altitude`],`hillshade-illumination-altitude`),"hillshade-illumination-anchor":new G(j.paint_hillshade[`hillshade-illumination-anchor`],`hillshade-illumination-anchor`),"hillshade-exaggeration":new G(j.paint_hillshade[`hillshade-exaggeration`],`hillshade-exaggeration`),"hillshade-shadow-color":new G(j.paint_hillshade[`hillshade-shadow-color`],`hillshade-shadow-color`),"hillshade-highlight-color":new G(j.paint_hillshade[`hillshade-highlight-color`],`hillshade-highlight-color`),"hillshade-accent-color":new G(j.paint_hillshade[`hillshade-accent-color`],`hillshade-accent-color`),"hillshade-method":new G(j.paint_hillshade[`hillshade-method`],`hillshade-method`),resampling:new G(j.paint_hillshade.resampling,`resampling`)});var _f={get paint(){return gf()}};const vf=e=>e.type===`hillshade`;var yf=class extends bl{constructor(e,t){super(e,_f,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,n=this.paint.get(`hillshade-highlight-color`).values,r=this.paint.get(`hillshade-shadow-color`).values,i=Math.max(e.length,t.length,n.length,r.length);e=e.concat(Array(i-e.length).fill(e.at(-1))),t=t.concat(Array(i-t.length).fill(t.at(-1))),n=n.concat(Array(i-n.length).fill(n.at(-1))),r=r.concat(Array(i-r.length).fill(r.at(-1)));let a=t.map(en);return{directionRadians:e.map(en),altitudeRadians:a,shadowColor:r,highlightColor:n}}hasOffscreenPass(){return this.paint.get(`hillshade-exaggeration`)!==0&&!this.isHidden()}};let bf;const xf=()=>bf||=new _l({"color-relief-opacity":new G(j[`paint_color-relief`][`color-relief-opacity`],`color-relief-opacity`),"color-relief-color":new gl(j[`paint_color-relief`][`color-relief-color`],`color-relief-color`),resampling:new G(j[`paint_color-relief`].resampling,`resampling`)});var Sf={get paint(){return xf()}};function Cf(e){return`data`in e}var wf=class{constructor(e,t,n,r){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,n){let{width:r,height:i}=e,a=(this.size?.[0]!==r||this.size[1]!==i)&&!n,{context:o}=this,{gl:s}=o;this.useMipmap=!!t?.useMipmap,a&&this.size&&this.format===s.RGBA&&(s.deleteTexture(this.texture),this.texture=s.createTexture(),this._ownedHandle=this.texture),s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let c=this.format===s.RGBA&&t?.premultiply!==!1;if(a)if(this.size=[r,i],this.format===s.RGBA&&r>0&&i>0){let t=this.useMipmap?Math.floor(Math.log2(Math.max(r,i)))+1:1;if(s.texStorage2D(s.TEXTURE_2D,t,s.RGBA8,r,i),Cf(e)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:t}=e;c&&t&&(t=uf(t)),t&&s.texSubImage2D(s.TEXTURE_2D,0,0,0,r,i,s.RGBA,s.UNSIGNED_BYTE,t)}else o.pixelStoreUnpackPremultiplyAlpha.set(c),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,e)}else Cf(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,c,r,i,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(c),this._uploadDomImage(e,s));else{let{x:t,y:a}=n||{x:0,y:0};Cf(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,c,t,a,r,i,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(c),this._updateDomImage(e,t,a,s))}this.useMipmap&&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,n,r,i){let{data:a}=e;t&&a&&(a=uf(a)),i.texImage2D(i.TEXTURE_2D,0,this.format,n,r,0,this.format,i.UNSIGNED_BYTE,a)}_updateDomImage(e,t,n,r){r.texSubImage2D(r.TEXTURE_2D,0,t,n,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,n,r,i,a,o){let{data:s}=e;t&&s&&(s=uf(s)),o.texSubImage2D(o.TEXTURE_2D,0,n,r,i,a,o.RGBA,o.UNSIGNED_BYTE,s)}bind(e,t,n){let{context:r}=this,{gl:i}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),i.bindTexture(i.TEXTURE_2D,this.texture),n===i.LINEAR_MIPMAP_NEAREST&&!this.useMipmap&&(n=i.LINEAR),e!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,n||e),this.filter=e),t!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrap=t)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},Tf=class e{static{this.byteViewCache=new WeakMap}constructor(t,n,r,i=1,a=1,o=1,s=0){if(this.uid=t,n.height!==n.width)throw RangeError(`DEM tiles must be square`);if(r&&![`mapbox`,`terrarium`,`custom`].includes(r)){Ft(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=n.height;let c=this.dim=n.height-2;switch(this.data=new Uint32Array(n.data.buffer),e.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=i,this.greenFactor=a,this.blueFactor=o,this.baseShift=s;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4;break}for(let e=0;ethis.max&&(this.max=r),r=this.dim||r<-1||r>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);let i=this._getByteView(),a=((r+1)*this.stride+n+1)*4,o=this.stride*4,s=e-n,c=t-r,l=this._unpackAtIndex(i,a),u=this._unpackAtIndex(i,a+4),d=this._unpackAtIndex(i,a+o),f=this._unpackAtIndex(i,a+o+4);return l*(1-s)*(1-c)+u*s*(1-c)+d*(1-s)*c+f*s*c}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+1)*this.stride+(e+1)}unpack(e,t,n){return e*this.redFactor+t*this.greenFactor+n*this.blueFactor-this.baseShift}pack(e){return Ef(e,this.getUnpackVector())}getPixels(){return new lf({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(e,t,n){if(this.dim!==e.dim)throw Error(`dem dimension mismatch`);let r=t*this.dim,i=t*this.dim+this.dim,a=n*this.dim,o=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1;break}switch(n){case-1:a=o-1;break;case 1:o=a+1;break}let s=-t*this.dim,c=-n*this.dim;for(let t=a;te.type===`color-relief`;var Of=class extends bl{constructor(e,t){super(e,Sf,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},n=this._transitionablePaint._values[`color-relief-color`].value.expression;if(n instanceof Ko&&n._styleExpression.expression instanceof Ti){this.colorRampExpression=n;let e=n._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(let n of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:n}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[z.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:[]},i=(t.elevationStops.length-1)/(e-1);for(let e=0;e80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Rf(a,o,s,c,l),o}function If(e,t,n,r,i){let a=null;if(i===Dp(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=wp(i/r|0,e[i],e[i+1],a);return a&&_p(a,a.next)&&(Tp(a),a=a.next),a}function Lf(e,t=e){let n=t===e,r=e,i;do i=!1,r!==r.next&&(Nf.size===0||!Nf.has(r))&&(_p(r,r.next)||gp(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),Pf=!0,Tp(r),r=r.prev,i=!0):(n||r!==t)&&(r=r.next,i=!n);while(i||r!==t);return t}function Rf(e,t,n,r,i){i&&lp(e,n,r,i);let a=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,c=e.next;if(gp(s,e,c)<0&&(i?Bf(e,n,r,i):zf(e))){t.push(s.i,e.i,c.i),Tp(e),e=c,a=c;continue}if(e=c,e===a){if(Pf=!1,e=Lf(e),Pf){a=e;continue}if(!o){e=Vf(e,t),a=e,o=!0;continue}Hf(e,t,n,r,i);break}}}function zf(e){let t=e.prev,n=e,r=e.next,i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&(i!==m.x||s!==m.y)&&mp(i,s,a,c,o,l,m.x,m.y)&&gp(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Bf(e,t,n,r){let i=e.prev,a=e,o=e.next,s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=fp(p,m,t,n,r),v=fp(h,g,t,n,r),y=e.prevZ;for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==o&&(s!==y.x||u!==y.y)&&mp(s,u,c,d,l,f,y.x,y.y)&&gp(y.prev,y,y.next)>=0)return!1;y=y.prevZ}let b=e.nextZ;for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==o&&(s!==b.x||u!==b.y)&&mp(s,u,c,d,l,f,b.x,b.y)&&gp(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Vf(e,t){let n=e,r=!1;do{let i=n.prev,a=n.next.next;vp(i,n,n.next,a,!1)&&xp(i,a)&&xp(a,i)&&(t.push(i.i,n.i,a.i),Tp(n),Tp(n.next),n=e=a,r=!0),n=n.next}while(n!==e);return r?Lf(n):n}function Hf(e,t,n,r,i){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&hp(a,e)){let o=Cp(a,e);a=Lf(a,a.next),o=Lf(o,o.next),Rf(a,t,n,r,i),Rf(o,t,n,r,i);return}e=e.next}a=a.next}while(a!==e)}let Uf=!1;function Wf(e,t,n,r){let i=[];for(let n=0,a=t.length;na&&(a=n.x),n.yo&&(o=n.y),t.xa&&(a=t.x),t.yo&&(o=t.y),n=t}while(++s<16&&n!==t);Xf[e]=n;let c=e*4;qf[c]=r,qf[c+1]=i,qf[c+2]=a,qf[c+3]=o}while(n!==t)}function $f(e,t){let n=e.z*4;t.xqf[n+2]&&(qf[n+2]=t.x),t.y>qf[n+3]&&(qf[n+3]=t.y)}function ep(e){let t=Xf[e];for(;t.prev.next!==t;)t=t.next;return Xf[e]=t,t}function tp(e){let t=Yf[e];for(;t.prev.next!==t;)t=t.next;return Yf[e]=t,t}function np(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(_p(e,n))return n;for(let t=0,s=0;tqf[s+3]||qf[s]>r||qf[s+2]<=a)continue;let c=ep(t);n=tp(t);do{if(n.prev.next===n){if(_p(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.xr||qf[f+3]u)continue;let p=ep(t);n=tp(t);do{if(n.prev.next===n&&r>=n.x&&n.x>=s&&r!==n.x&&mp(ir)&&(to.x||n.x===o.x&&rp(o,n)))&&(o=n,d=t)}n=n.next}while(n!==p)}return o}function rp(e,t){return gp(e.prev,e,t.prev)<0&&gp(t.next,e,e.next)<0}const ip=[];let ap=[],op=new Uint32Array,sp=new Uint32Array;const cp=new Uint32Array(256);function lp(e,t,n,r){let i=e,a=0;do i.z=fp(i.x,i.y,t,n,r),ip[a++]=i,i=i.next;while(i!==e);up(a);let o=null;for(let e=0;e=0&&ip[r].z>n;)ip[r+1]=ip[r],r--;ip[r+1]=e}return}op.length>>a&255]++;let o=0;for(let e=0;e<256;e++){let t=cp[e];cp[e]=o,o+=t}for(let o=0;o>>a&255]++;r[s]=t[o],i[s]=e}}function fp(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|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 pp(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function hp(e,t){let n=_p(e,t)&&gp(e.prev,e,e.next)>0&&gp(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||xp(e,t)&&xp(t,e)&&(gp(e.prev,e,t.prev)!==0||gp(e,t.prev,t)!==0))&&!bp(e,t)&&(n||Sp(e,t))}function gp(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function _p(e,t){return e.x===t.x&&e.y===t.y}function vp(e,t,n,r,i=!0){let a=gp(e,t,n),o=gp(e,t,r),s=gp(n,r,e),c=gp(n,r,t);return(a>0&&o<0||a<0&&o>0)&&(s>0&&c<0||s<0&&c>0)?!0:i?!!(a===0&&yp(e,n,t)||o===0&&yp(e,r,t)||s===0&&yp(n,e,r)||c===0&&yp(n,t,r)):!1}function yp(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function bp(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),i=Math.min(e.y,t.y),a=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.xa&&s.y>a||o.y=0&&gp(e,e.prev,t)>=0:gp(e,t,e.prev)<0||gp(e,e.next,t)<0}function Sp(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{let e=n.next;n.y>a!=e.y>a&&i<(e.x-n.x)*(a-n.y)/(e.y-n.y)+n.x&&(r=!r),n=e}while(n!==e);return r}function Cp(e,t){let n=Ep(e.i,e.x,e.y),r=Ep(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function wp(e,t,n,r){let i=Ep(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Tp(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),Uf&&$f(e.prev,e.next)}function Ep(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function Dp(e,t,n,r){let i=0;for(let a=t,o=n-r;ae)throw Error(`Min granularity must not be greater than base granularity.`);this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){let t=1<32767||t>32767)throw Error(`Vertex coordinates are out of signed 16 bit integer range.`);let n=Math.round(e)|0,r=Math.round(t)|0,i=this._getKey(n,r);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);let a=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,a),this._vertexBuffer.push(n,r),a}_subdivideTrianglesScanline(e){if(this._granularity<2)return Ip(this._vertexBuffer,e);let t=[],n=e.length;for(let r=0;r=1||y<=0)||h&&(si)){l>=r&&l<=i&&a.push(n[(e+1)%3]);continue}if(!h&&v>0){let e=o+f*v,t=s+p*v;a.push(this._vertexToIndex(e,t))}let b=o+f*Math.max(v,0),x=o+f*Math.min(y,1);if(m||this._generateIntraEdgeVertices(a,o,s,c,l,b,x),!h&&y<1){let e=o+f*y,t=s+p*y;a.push(this._vertexToIndex(e,t))}(h||l>=r&&l<=i)&&a.push(n[(e+1)%3]),!h&&(l<=r||l>=i)&&this._generateInterEdgeVertices(a,o,s,c,l,u,d,x,r,i)}return a}_generateIntraEdgeVertices(e,t,n,r,i,a,o){let s=r-t,c=i-n,l=c===0,u=l?Math.min(t,r):Math.min(a,o),d=l?Math.max(t,r):Math.max(a,o),f=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(d/this._granularityCellSize)-1;if(l?t=f;r--){let i=r*this._granularityCellSize,a=n+c*(i-t)/s;e.push(this._vertexToIndex(i,a))}}_generateInterEdgeVertices(e,t,n,r,i,a,o,s,c,l){let u=i-n,d=a-r,f=o-i,p=(c-i)/f,m=(l-i)/f,h=Math.min(p,m),g=Math.max(p,m),_=r+d*h,v=Math.floor(Math.min(_,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,s)/this._granularityCellSize)-1,b=s<_,x=f===0;if(x&&(o===c||o===l))return;if(x||h>=1||g<=0){let e=t-a,r=n-o,i=(c-o)/r,u=(l-o)/r,d=a+e*Math.min(i,u);v=Math.floor(Math.min(d,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(d,s)/this._granularityCellSize)-1,b=s0?l:c;if(b)for(let t=v;t<=y;t++){let n=t*this._granularityCellSize;e.push(this._vertexToIndex(n,S))}else for(let t=y;t>=v;t--){let n=t*this._granularityCellSize;e.push(this._vertexToIndex(n,S))}}_generateOutline(e){let t=[];for(let n of e){let e=Pp(n,this._granularity,!0),r=this._pointArrayToIndices(e),i=[];for(let e=1;ei==(a===-32768)?(e.push(n),e.push(t),e.push(this._vertexToIndex(r,a)),e.push(this._vertexToIndex(i,a)),e.push(n),e.push(this._vertexToIndex(r,a))):(e.push(t),e.push(n),e.push(this._vertexToIndex(r,a)),e.push(n),e.push(this._vertexToIndex(i,a)),e.push(this._vertexToIndex(r,a)))}_fillPoles(e,t,n){let r=this._vertexBuffer,i=Ye,a=e.length;for(let o=2;o=2&&this._canonical?.z===0&&(i=this._removeTrianglesOutsideTileX(i),a=a.map(e=>this._removeLinesOutsideTileX(e))),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:a}}_vertexOutsideTileX(e){let t=this._vertexBuffer[e*2];return t<0||t>8192}_removeTrianglesOutsideTileX(e){let t=[];for(let n=0;n0?(Math.floor(v/o)+1)*o:(Math.ceil(v/o)-1)*o,t=h>0?(Math.floor(y/o)+1)*o:(Math.ceil(y/o)-1)*o,n=Math.abs(v-e),r=Math.abs(y-t),i=Math.abs(v-u),a=Math.abs(y-d),c=f?n/g:1/0,b=p?r/_:1/0;if((i<=n||!f)&&(a<=r||!p))break;if(c0?(n.push(i),n.push(o),n.push(a)):(n.push(i),n.push(a),n.push(o))}return n}function Lp(e,t,n){if(t.length===0)throw Error(`Subdivision vertex ring is empty.`);let r=0,i=e[t[0]*2];for(let n=1;n=0?o-1:a-1,i=(s+1)%a,c=e[t[r]*2],l=e[t[r]*2+1],u=e[t[i]*2],d=e[t[i]*2+1],f=e[t[o]*2],p=e[t[o]*2+1],m=e[t[s]*2],h=e[t[s]*2+1],g=!1;if(cu)g=!1;else{let e=h-p,t=-(m-f),n=p((u-f)*e+(d-p)*t)*n&&(g=!0)}if(g){let e=t[r],i=t[o],c=t[s];e!==i&&e!==c&&i!==c&&n.push(c,i,e),o--,o<0&&(o=a-1)}else{let e=t[i],r=t[o],c=t[s];e!==r&&e!==c&&r!==c&&n.push(c,r,e),s++,s>=a&&(s=0)}if(r===i)break}}function Rp(e,t,n,r,i,a,o,s,c){let l=i.length/2,u=o&&s&&c;if(lPu.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,h=!0,g=!0,_=!0,u=0);let y=zp(o,r,a,s,f,h,l),b=zp(o,r,a,s,p,g,l),x=zp(o,r,a,s,m,_,l);n.emplaceBack(u+y-c,u+b-c,u+x-c),l.primitiveLength++}}function Vp(e,t,n,r,i,a){let o=[];for(let e=0;ePu.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,m=!0,h=!0,u=0);let _=zp(o,r,a,s,f,m,l),v=zp(o,r,a,s,p,h,l);n.emplaceBack(u+_-c,u+v-c),l.primitiveLength++}}var Hp=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new gu,this.indexArray=new ku,this.indexArray2=new Au,this.programConfigurations=new dd(e.layers,e.zoom),this.segments=new Pu,this.segments2=new Pu,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n){this.hasDependencies=jf(`fill`,this.layers,t);let r=this.layers[0].layout.get(`fill-sort-key`),i=!r.isConstant(),a=[],o=new W(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:c,id:l,index:u,sourceLayerIndex:d}of e){let e=vd(c,s);if(!this.layers[0]._featureFilter.filter(o,e,n))continue;let f=i?r.evaluate(e,{},n,t.availableImages):void 0,p={id:l,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:s?e.geometry:_d(c),patterns:{},sortKey:f};a.push(p)}i&&a.sort((e,t)=>e.sortKey-t.sortKey);for(let r of a){let{geometry:i,index:a,sourceLayerIndex:o}=r;if(this.hasDependencies){let e=Mf(`fill`,this.layers,r,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(r,i,a,n,{},t.subdivisionGranularity);let s=e[a].feature;t.featureIndex.insert(s,i,a,o,this.index)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}addFeatures(e,t,n){for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,n,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Af),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,n,r,i,a){for(let e of Ma(t,500)){let t=Np(e,r,a.fill.getGranularityForZoomLevel(r.z)),n=this.layoutVertexArray;Rp((e,t)=>{n.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r})}};U(`FillBucket`,Hp,{omit:[`layers`,`patternFeatures`]});let Up;const Wp=()=>Up||=new _l({"fill-sort-key":new K(j.layout_fill[`fill-sort-key`],`fill-sort-key`)});let Gp;const Kp=()=>Gp||=new _l({"fill-antialias":new G(j.paint_fill[`fill-antialias`],`fill-antialias`),"fill-opacity":new K(j.paint_fill[`fill-opacity`],`fill-opacity`),"fill-layer-opacity":new G(j.paint_fill[`fill-layer-opacity`],`fill-layer-opacity`),"fill-color":new K(j.paint_fill[`fill-color`],`fill-color`),"fill-outline-color":new K(j.paint_fill[`fill-outline-color`],`fill-outline-color`),"fill-translate":new G(j.paint_fill[`fill-translate`],`fill-translate`),"fill-translate-anchor":new G(j.paint_fill[`fill-translate-anchor`],`fill-translate-anchor`),"fill-pattern":new ml(j.paint_fill[`fill-pattern`],`fill-pattern`)});var qp={get paint(){return Kp()},get layout(){return Wp()}};const Jp=e=>e.type===`fill`;var Yp=class extends bl{constructor(e,t){super(e,qp,t)}recalculate(e,t){super.recalculate(e,t);let n=this.paint._values[`fill-outline-color`];n.value.kind===`constant`&&n.value.value===void 0&&(this.paint._values[`fill-outline-color`]=this.paint._values[`fill-color`])}createBucket(e){return new Hp(e)}queryRadius(){return Id(this.paint.get(`fill-translate`))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:n,pixelsToTileUnits:r}){return wd(Ld(e,this.paint.get(`fill-translate`),this.paint.get(`fill-translate-anchor`),-n.bearingInRadians,r),t)}isTileClipped(){return!0}};const Xp=J([{name:`a_pos`,components:2,type:`Int16`},{name:`a_normal_ed`,components:4,type:`Int16`}],4),Zp=J([{name:`a_centroid`,components:2,type:`Int16`}],4),Qp=Xp.members;Xp.size,Xp.alignment;var $p=class{constructor(e,t,n,r,i){for(this.properties=Object.create(null),this.extent=n,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=i;e.pos>3,a===0)continue}if(a--,i===1)o+=e.readSVarint(),s+=e.readSVarint(),r&&n.push(r),r=[new l(o,s)];else if(i===2)o+=e.readSVarint(),s+=e.readSVarint(),r&&r.push(new l(o,s));else if(i===7)r&&r.push(r[0].clone());else throw Error(`unknown command ${i}`)}return r&&n.push(r),n}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,n=1,r=0,i=0,a=0,o=1/0,s=-1/0,c=1/0,l=-1/0;for(;e.pos>3,r===0)continue}if(r--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),is&&(s=i),al&&(l=a);else if(n!==7)throw Error(`unknown command ${n}`)}return[o,c,s,l]}toGeoJSON(e,t,n){let r=this.extent*2**n,i=this.extent*e,a=this.extent*t,o=this.loadGeometry();function s(e){return[(e.x+i)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(e.y+a)*2/r)*Math.PI))-90]}function c(e){return e.map(s)}let l;if(this.type===1){let e=[];for(let t of o)e.push(t[0]);let t=c(e);l=e.length===1?{type:`Point`,coordinates:t[0]}:{type:`MultiPoint`,coordinates:t}}else if(this.type===2){let e=o.map(c);l=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e}}else if(this.type===3){let e=em(o),t=[];for(let n of e)t.push(n.map(c));l=t.length===1?{type:`Polygon`,coordinates:t[0]}:{type:`MultiPolygon`,coordinates:t}}else throw Error(`unknown feature type`);let u={type:`Feature`,geometry:l,properties:this.properties};return this.id!=null&&(u.id=this.id),u}};$p.types=[`Unknown`,`Point`,`LineString`,`Polygon`];function em(e){let t=e.length;if(t<=1)return[e];let n=[],r,i;for(let a=0;a=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 $p(this._pbf,t,this.extent,this._keys,this._values)}};function rm(e){let t=null,n=e.readVarint()+e.pos;for(;e.pose.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new _u,this.centroidVertexArray=new fu,this.indexArray=new ku,this.programConfigurations=new dd(e.layers,e.zoom),this.segments=new Pu,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n){this.features=[],this.hasDependencies=jf(`fill-extrusion`,this.layers,t);let r=new W(this.zoom),i=this.layers[0]._featureFilter.needGeometry;for(let{feature:a,id:o,index:s,sourceLayerIndex:c}of e){let e=vd(a,i);if(!this.layers[0]._featureFilter.filter(r,e,n))continue;let l={id:o,sourceLayerIndex:c,index:s,geometry:i?e.geometry:_d(a),properties:a.properties,type:a.type,patterns:{}};this.hasDependencies?this.features.push(Mf(`fill-extrusion`,this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,s,n,{},t.subdivisionGranularity),t.featureIndex.insert(a,l.geometry,s,c,this.index,!0)}}addFeatures(e,t,n){for(let r of this.features){let{geometry:i}=r;this.addFeature(r,i,r.index,t,n,e.subdivisionGranularity)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}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,Qp),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Zp.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,n,r,i,a){for(let n of Ma(t,500)){let t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,r,e,n,a);let o=this.layoutVertexArray.length-i,s=Math.floor(t.x/t.sampleCount),c=Math.floor(t.y/t.sampleCount);for(let e=0;e{om(l,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,c.verticesFlattened,c.indicesTriangles)}_generateSideFaces(e,t){let n=0;for(let r=1;rPu.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=i.sub(a)._perp()._unit(),s=a.dist(i);n+s>32768&&(n=0),om(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,0,n),om(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,1,n),n+=s,om(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,0,n),om(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,1,n);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 cm(e,t){for(let n=0;n8192)||e.y===t.y&&(e.y<0||e.y>8192)}function um(e){return e.every(e=>e.x<0)||e.every(e=>e.x>8192)||e.every(e=>e.y<0)||e.every(e=>e.y>8192)}let dm;const fm=()=>dm||=new _l({"fill-extrusion-rounded-corner-distance":new G(j[`layout_fill-extrusion`][`fill-extrusion-rounded-corner-distance`],`fill-extrusion-rounded-corner-distance`)});let pm;const mm=()=>pm||=new _l({"fill-extrusion-opacity":new G(j[`paint_fill-extrusion`][`fill-extrusion-opacity`],`fill-extrusion-opacity`),"fill-extrusion-color":new K(j[`paint_fill-extrusion`][`fill-extrusion-color`],`fill-extrusion-color`),"fill-extrusion-translate":new G(j[`paint_fill-extrusion`][`fill-extrusion-translate`],`fill-extrusion-translate`),"fill-extrusion-translate-anchor":new G(j[`paint_fill-extrusion`][`fill-extrusion-translate-anchor`],`fill-extrusion-translate-anchor`),"fill-extrusion-pattern":new ml(j[`paint_fill-extrusion`][`fill-extrusion-pattern`],`fill-extrusion-pattern`),"fill-extrusion-height":new K(j[`paint_fill-extrusion`][`fill-extrusion-height`],`fill-extrusion-height`),"fill-extrusion-base":new K(j[`paint_fill-extrusion`][`fill-extrusion-base`],`fill-extrusion-base`),"fill-extrusion-vertical-gradient":new G(j[`paint_fill-extrusion`][`fill-extrusion-vertical-gradient`],`fill-extrusion-vertical-gradient`)});var hm={get paint(){return mm()},get layout(){return fm()}};const gm=e=>e.type===`fill-extrusion`;var _m=class extends bl{constructor(e,t){super(e,hm,t)}createBucket(e){return new sm(e)}queryRadius(){return Id(this.paint.get(`fill-extrusion-translate`))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a,pixelPosMatrix:o}){let s=Ld(e,this.paint.get(`fill-extrusion-translate`),this.paint.get(`fill-extrusion-translate-anchor`),-i.bearingInRadians,a),c=this.paint.get(`fill-extrusion-height`).evaluate(t,n),l=this.paint.get(`fill-extrusion-base`).evaluate(t,n),u=Sm(s,o,0),d=xm(r,l,c,o),f=d[0],p=d[1];return bm(f,p,u)}};function vm(e,t){return e.x*t.x+e.y*t.y}function ym(e,t){if(e.length===1){let n=0,r=t[n++],i;for(;!i||r.equals(i);)if(i=t[n++],!i)return 1/0;for(;n>1),o=n-t,s,c=e[t],l=e[t+1],u=e[n],d=e[n+1];for(let r=t+3;ri){s=r,i=t;continue}if(t===i){let e=Math.abs(r-a);er&&(s-t>3&&Cm(e,t,s,r),e[s+2]=i,n-s>3&&Cm(e,s,n,r))}function wm(e,t,n,r,i,a){let o=i-n,s=a-r;if(o!==0||s!==0){let c=((e-n)*o+(t-r)*s)/(o*o+s*s);c>1?(n=i,r=a):c>0&&(n+=o*c,r+=s*c)}return o=e-n,s=t-r,o*o+s*s}function Tm(e,t,n,r){let i={type:t,geom:n},a={id:e??null,type:i.type,geometry:i.geom,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(i.type){case`Point`:case`MultiPoint`:Dm(a,i.geom);break;case`LineString`:Dm(a,i.geom.points);break;case`Polygon`:Dm(a,i.geom[0].points);break;case`MultiLineString`:for(let e of i.geom)Dm(a,e.points);break;case`MultiPolygon`:for(let e of i.geom)Dm(a,e[0].points);break}return a}function Em(e){let t=e;e.points.length>64&&(t.points=new Float64Array(e.points))}function Dm(e,t){for(let n=0;n1024)throw Error(`GeometryCollection nesting exceeds supported depth: 1024`);if(t.geometry.type===`GeometryCollection`){jm(e,t,t.geometry,n,r,i+1);return}if(!t.geometry.coordinates?.length)return;let a=Am(t,n,r),o=(n.tolerance/((1<0&&(r?o+=(i*c-s*a)/2:o+=Math.sqrt((s-i)**2+(c-a)**2)),i=s,a=c}let s=t.points.length-3;t.points[2]=1,n>0&&Cm(t.points,0,s,n),t.points[s+2]=1,Em(t),t.size=Math.abs(o),t.start=0,t.end=t.size}function zm(e,t,n,r){for(let i=0;i1?1:n}function Hm(e){return{type:`FeatureCollection`,features:e.map(e=>Um(e))}}function Um(e){let t={type:`Feature`,geometry:Wm(e),properties:e.tags};return e.id!=null&&(t.id=e.id),t}function Wm(e){let{type:t,geometry:n}=e;switch(t){case`Point`:return{type:t,coordinates:Km(n[0],n[1])};case`MultiPoint`:return{type:t,coordinates:Gm(n)};case`LineString`:return{type:t,coordinates:Gm(n.points)};case`MultiLineString`:case`Polygon`:return{type:t,coordinates:n.map(e=>Gm(e.points))};case`MultiPolygon`:return{type:t,coordinates:n.map(e=>e.map(e=>Gm(e.points)))}}}function Gm(e){let t=[];for(let n=0;n=n&&o=r)return null;let c=[];for(let t of e){let e=i===0?t.minX:t.minY,a=i===0?t.maxX:t.maxY;if(e>=n&&a=r))switch(t.type){case`Point`:case`MultiPoint`:Xm(t,c,n,r,i);continue;case`LineString`:Zm(t,c,n,r,i,s);continue;case`MultiLineString`:Qm(t,c,n,r,i);continue;case`Polygon`:$m(t,c,n,r,i);continue;case`MultiPolygon`:eh(t,c,n,r,i);continue}}return c.length?c:null}function Xm(e,t,n,r,i){let a=[];if(th(e.geometry,a,n,r,i),!a.length)return;let o=a.length===3?`Point`:`MultiPoint`;t.push(Tm(e.id,o,a,e.tags))}function Zm(e,t,n,r,i,a){let o=[];if(nh(e.geometry,o,n,r,i,!1,a.lineMetrics),o.length){if(a.lineMetrics){for(let n of o)t.push(Tm(e.id,`LineString`,n,e.tags));return}if(o.length>1){t.push(Tm(e.id,`MultiLineString`,o,e.tags));return}t.push(Tm(e.id,`LineString`,o[0],e.tags))}}function Qm(e,t,n,r,i){let a=[];if(ih(e.geometry,a,n,r,i,!1),a.length){if(a.length===1){t.push(Tm(e.id,`LineString`,a[0],e.tags));return}t.push(Tm(e.id,`MultiLineString`,a,e.tags))}}function $m(e,t,n,r,i){let a=[];ih(e.geometry,a,n,r,i,!0),a.length&&t.push(Tm(e.id,`Polygon`,a,e.tags))}function eh(e,t,n,r,i){let a=[];for(let t of e.geometry){let e=[];ih(t,e,n,r,i,!0),e.length&&a.push(e)}a.length&&t.push(Tm(e.id,`MultiPolygon`,a,e.tags))}function th(e,t,n,r,i){for(let a=0;a=n&&o<=r&&ah(t,e[a],e[a+1],e[a+2])}}function nh(e,t,n,r,i,a,o){let s=rh(e),c=i===0?oh:sh,l=e.start,u,d;for(let f=0;fn&&(d=c(s,p,m,g,_,n),o&&(s.start=l+u*d)):v>r?y=n&&(d=c(s,p,m,g,_,n),b=!0),y>r&&v<=r&&(d=c(s,p,m,g,_,r),b=!0),!a&&b&&(o&&(s.end=l+u*d),t.push(s),s=rh(e)),o&&(l+=u)}let f=e.points.length-3,p=e.points[f],m=e.points[f+1],h=e.points[f+2],g=i===0?p:m;g>=n&&g<=r&&ah(s.points,p,m,h),f=s.points.length-3,a&&f>=3&&(s.points[f]!==s.points[0]||s.points[f+1]!==s.points[1])&&ah(s.points,s.points[0],s.points[1],s.points[2]),s.points.length&&(Em(s),t.push(s))}function rh(e){return{points:[],size:e.size,start:e.start,end:e.end}}function ih(e,t,n,r,i,a){for(let o of e)nh(o,t,n,r,i,a,!1)}function ah(e,t,n,r){e.push(t,n,r)}function oh(e,t,n,r,i,a){let o=(a-t)/(r-t);return ah(e.points,a,n+(i-n)*o,1),o}function sh(e,t,n,r,i,a){let o=(a-n)/(i-n);return ah(e.points,t+(r-t)*o,a,1),o}function ch(e,t){let n=t.buffer/t.extent,r=e,i=Ym(e,1,-1-n,n,0,-1,2,t),a=Ym(e,1,1-n,2+n,0,-1,2,t);return!i&&!a?r:(r=Ym(e,1,-n,1+n,0,-1,2,t)||[],i&&(r=lh(i,1).concat(r)),a&&(r=r.concat(lh(a,-1))),r)}function lh(e,t){let n=[];for(let r of e)switch(r.type){case`Point`:case`MultiPoint`:{let e=uh(r.geometry,t);n.push(Tm(r.id,r.type,e,r.tags));continue}case`LineString`:{let e=dh(r.geometry,t);n.push(Tm(r.id,r.type,e,r.tags));continue}case`MultiLineString`:case`Polygon`:{let e=[];for(let n of r.geometry)e.push(dh(n,t));n.push(Tm(r.id,r.type,e,r.tags));continue}case`MultiPolygon`:{let e=[];for(let n of r.geometry){let r=[];for(let e of n)r.push(dh(e,t));e.push(r)}n.push(Tm(r.id,r.type,e,r.tags));continue}}return n}function uh(e,t){let n=[];for(let r=0;re.id));e=e.filter(e=>!n.has(e.id))}if(r.add.size){let t=Om({type:`FeatureCollection`,features:Array.from(r.add.values())},n);t=ch(t,n),i=i.concat(t),e=e.concat(t)}}if(r.update.size){let t=new Map,a=[];for(let n of e)r.update.has(n.id)?t.set(n.id,[...t.get(n.id)||[],n]):a.push(n);for(let[e,o]of r.update){let r=t.get(e);if(!r||r.length===0)continue;let s=ph(r,o,n);i=i.concat(r,s),a=a.concat(s)}e=a}return{affected:i,source:e}}function ph(e,t,n){let r=!!t.newGeometry,i=t.removeAllProperties||t.removeProperties?.length>0||t.addOrUpdateProperties?.length>0;if(r){let r=e[0],a=Om({type:`FeatureCollection`,features:[{type:`Feature`,id:r.id,geometry:t.newGeometry,properties:i?mh(r.tags,t):r.tags}]},n);return a=ch(a,n),a}if(i){let n=[];for(let r of e){let e={...r};e.tags=mh(e.tags,t),n.push(e)}return n}return e}function mh(e,t){if(t.removeAllProperties)return{};let n={...e||{}};if(t.removeProperties)for(let e of t.removeProperties)delete n[e];if(t.addOrUpdateProperties)for(let{key:e,value:r}of t.addOrUpdateProperties)n[e]=r;return n}function hh(e,t){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map(e=>[t.promoteId?e.properties[t.promoteId]:e.id,e])),update:new Map(e.update?.map(e=>[e.id,e]))}:{remove:new Set,add:new Map,update:new Map}}const gh=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Y=new Uint32Array(96);var _h=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=gh[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,void 0,t)}constructor(e,t=64,n=Float64Array,r=ArrayBuffer,i){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let a=gh.indexOf(this.ArrayType),o=e*2*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,c=(8-s%8)%8;if(a<0)throw Error(`Unexpected typed array class: ${n}.`);if(i)this.data=i,this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=e*2,this._finished=!0;else{let i=this.data=new r(8+o+s+c);this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=0,this._finished=!1,new Uint8Array(i,0,2).set([219,16+a]),new Uint16Array(i,2,1)[0]=t,new Uint32Array(i,4,1)[0]=e}}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return vh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;Y[0]=0,Y[1]=i.length-1,Y[2]=0;let s=3,c=[];for(;s>0;){let l=Y[--s],u=Y[--s],d=Y[--s];if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(Y[s++]=d,Y[s++]=f-1,Y[s++]=1-l),(l===0?n>=p:r>=m)&&(Y[s++]=f+1,Y[s++]=u,Y[s++]=1-l)}return c}within(e,t,n){let r=[];return this.withinInto(e,t,n,r),r}withinInto(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;Y[0]=0,Y[1]=i.length-1,Y[2]=0;let s=3,c=0,l=n*n;for(;s>0;){let u=Y[--s],d=Y[--s],f=Y[--s];if(d-f<=o){for(let n=f;n<=d;n++)Sh(a[2*n],a[2*n+1],e,t)<=l&&(r[c++]=i[n]);continue}let p=f+d>>1,m=a[2*p],h=a[2*p+1];Sh(m,h,e,t)<=l&&(r[c++]=i[p]),(u===0?e-n<=m:t-n<=h)&&(Y[s++]=f,Y[s++]=p-1,Y[s++]=1-u),(u===0?e+n>=m:t+n>=h)&&(Y[s++]=p+1,Y[s++]=d,Y[s++]=1-u)}return c}};function vh(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;yh(e,t,o,r,i,a),vh(e,t,n,r,o-1,1-a),vh(e,t,n,o+1,i,1-a)}function yh(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);yh(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(bh(e,t,r,n),t[2*i+a]>o&&bh(e,t,r,i);so;)c--}t[2*r+a]===o?bh(e,t,r,c):(c++,bh(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function bh(e,t,n,r){xh(e,n,r),xh(t,2*n,2*r),xh(t,2*n+1,2*r+1)}function xh(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function Sh(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}const Ch={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e};var wh=class{constructor(e){this.options=Object.assign(Object.create(Ch),e),this.trees=Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(e){let t=[];for(let n of e){if(!n.geometry)continue;let[e,r]=n.geometry.coordinates,[i,a]=[Bm(e),Vm(r)],o={id:n.id,type:`Point`,geometry:[i,a],tags:n.properties};t.push(o)}this.createIndex(t)}initialize(e){let t=[];for(let n of e)n.type===`Point`&&t.push(n);this.createIndex(t)}updateIndex(e,t,n){this.options=Object.assign(Object.create(Ch),n.clusterOptions),this.initialize(e)}createIndex(e){let{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time(`total time`);let i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;let a=[];for(let t=0;t=n;e--){let n=Date.now();o=this.trees[e]=this.createTree(this.cluster(o,e)),t&&console.log(`z%d: %d clusters in %dms`,e,o.numItems,Date.now()-n)}t&&console.timeEnd(`total time`)}getClusters(e,t){return this.getClustersInternal(e,t).map(e=>Um(e))}getClustersInternal(e,t){let n=((e[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,e[1])),i=e[2]===180?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){let e=this.getClustersInternal([n,r,180,a],t),o=this.getClustersInternal([-180,r,i,a],t);return e.concat(o)}let o=this.trees[this.limitZoom(t)],s=o.range(Bm(n),Vm(a),Bm(i),Vm(r)),c=o.flatData,l=[];for(let e of s){let t=this.stride*e;l.push(c[t+5]>1?Th(c,t,this.clusterProps):this.points[c[t+3]])}return l}getChildren(e){let t=this.getOriginId(e),n=this.getOriginZoom(e),r=Error(`No cluster with the specified id: `+e),i=this.trees[n];if(!i)throw r;let a=i.flatData;if(t*this.stride>=a.length)throw r;let o=this.options.radius/(this.options.extent*2**(n-1)),s=a[t*this.stride],c=a[t*this.stride+1],l=i.within(s,c,o),u=[];for(let t of l){let n=t*this.stride;a[n+4]===e&&u.push(a[n+5]>1?Eh(a,n,this.clusterProps):Um(this.points[a[n+3]]))}if(u.length===0)throw r;return u}getLeaves(e,t,n){t||=10,n||=0;let r=[];return this.appendLeaves(r,e,t,n,0),r}getTile(e,t,n){let r=this.trees[this.limitZoom(e)];if(!r)return null;let i=2**e,{extent:a,radius:o}=this.options,s=o/a,c=(n-s)/i,l=(n+1+s)/i,u={transformed:!0,features:[],source:null,x:t,y:n,z:e};return this.addTileFeatures(r.range((t-s)/i,c,(t+1+s)/i,l),r.flatData,t,n,i,u),t===0&&this.addTileFeatures(r.range(1-s/i,c,1,l),r.flatData,i,n,i,u),t===i-1&&this.addTileFeatures(r.range(0,c,s/i,l),r.flatData,-1,n,i,u),u}getClusterExpansionZoom(e){return this.getOriginZoom(e)}appendLeaves(e,t,n,r,i){let a=this.getChildren(t);for(let t of a){let a=t.properties;if(a?.cluster?i+a.point_count<=r?i+=a.point_count:i=this.appendLeaves(e,a.cluster_id,n,r,i):i1,c,l,u;if(s)c=Dh(t,e,this.clusterProps),l=t[e],u=t[e+1];else{let n=this.points[t[e+3]];c=n.tags,[l,u]=n.geometry}let d={type:1,geometry:[[Math.round(this.options.extent*(l*i-n)),Math.round(this.options.extent*(u*i-r))]],tags:c},f;f=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,f!==void 0&&(d.id=f),a.features.push(d)}}limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}cluster(e,t){let{radius:n,extent:r,reduce:i,minPoints:a}=this.options,o=n/(r*2**t),s=e.flatData,c=[],l=this.stride;for(let n=0;nt&&(p+=s[n+5])}if(p>f&&p>=a){let e=r*f,a=u*f,o,m=-1,h=((n/l|0)<<5)+(t+1)+this.points.length;for(let r of d){let c=r*l;if(s[c+2]<=t)continue;s[c+2]=t;let u=s[c+5];e+=s[c]*u,a+=s[c+1]*u,s[c+4]=h,i&&(o||(o=this.map(s,n,!0),m=this.clusterProps.length,this.clusterProps.push(o)),i(o,this.map(s,c)))}s[n+4]=h,c.push(e/p,a/p,1/0,h,-1,p),i&&c.push(m)}else{for(let e=0;e1)for(let e of d){let n=e*l;if(!(s[n+2]<=t)){s[n+2]=t;for(let e=0;e>5}getOriginZoom(e){return(e-this.points.length)%32}map(e,t,n){if(e[t+5]>1){let r=this.clusterProps[e[t+6]];return n?Object.assign({},r):r}let r=this.points[e[t+3]].tags,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}};function Th(e,t,n){return{id:e[t+3],type:`Point`,tags:Dh(e,t,n),geometry:[e[t],e[t+1]]}}function Eh(e,t,n){return{type:`Feature`,id:e[t+3],properties:Dh(e,t,n),geometry:{type:`Point`,coordinates:[qm(e[t]),Jm(e[t+1])]}}}function Dh(e,t,n){let r=e[t+5],i=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?`${Math.round(r/100)/10}k`:r,a=e[t+6],o=a===-1?{}:Object.assign({},n[a]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:i})}const Oh=`geojsonvt_clip_start`,kh=`geojsonvt_clip_end`;function Ah(e,t,n,r,i){let a=t===i.maxZoom?0:i.tolerance/((1<0&&t.size<(i?o:r)){n.numPoints+=t.points.length/3;return}let s=[];for(let e=0;eo)&&(n.numSimplified++,s.push(t.points[e],t.points[e+1])),n.numPoints++;i&&Lh(s,a),e.push(s)}function Lh(e,t){let n=0;for(let t=0,r=e.length,i=r-2;t0===t)for(let t=0,n=e.length;t1&&(console.log(`invalidating tiles`),console.time(`invalidating`)),this.invalidateTiles(t),n.debug>1&&console.timeEnd(`invalidating`);let[r,i,a]=[0,0,0],o=Ah(e,r,i,a,n);o.source=e;let s=Uh(r,i,a);if(this.tiles[s]=o,this.tileCoords.push({z:r,x:i,y:a,id:s}),n.debug){let e=`z${r}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}getClusterExpansionZoom(e){return null}getChildren(e){return null}getLeaves(e,t,n){return null}getTile(e,t,n){let{extent:r,debug:i}=this.options,a=1<1&&console.log(`drilling down to z%d-%d-%d`,e,t,n);let s=e,c=t,l=n,u;for(;!u&&s>0;)s--,c>>=1,l>>=1,u=this.tiles[Uh(s,c,l)];return!u?.source||(i>1&&(console.log(`found parent tile z%d-%d-%d`,s,c,l),console.time(`drilling down`)),this.splitTile(u.source,s,c,l,e,t,n),i>1&&console.timeEnd(`drilling down`),!this.tiles[o])?null:Rh(this.tiles[o],r)}splitTile(e,t,n,r,i,a,o){let s=[e,t,n,r],c=this.options,l=c.debug;for(;s.length;){r=s.pop(),n=s.pop(),t=s.pop(),e=s.pop();let u=1<1&&console.time(`creation`),f=this.tiles[d]=Ah(e,t,n,r,c),this.tileCoords.push({z:t,x:n,y:r,id:d}),l)){l>1&&(console.log(`tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,t,n,r,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd(`creation`));let e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(f.source=e,i==null){if(t===c.indexMaxZoom||f.numPoints<=c.indexMaxPoints)continue}else if(t===c.maxZoom||t===i)continue;else if(i!=null){let e=i-t;if(n!==a>>e||r!==o>>e)continue}if(f.source=null,!e.length)continue;l>1&&console.time(`clipping`);let p=.5*c.buffer/c.extent,m=.5-p,h=.5+p,g=1+p,_=null,v=null,y=null,b=null,x=Ym(e,u,n-p,n+h,0,f.minX,f.maxX,c),S=Ym(e,u,n+m,n+g,0,f.minX,f.maxX,c);x&&(_=Ym(x,u,r-p,r+h,1,f.minY,f.maxY,c),v=Ym(x,u,r+m,r+g,1,f.minY,f.maxY,c)),S&&(y=Ym(S,u,r-p,r+h,1,f.minY,f.maxY,c),b=Ym(S,u,r+m,r+g,1,f.minY,f.maxY,c)),l>1&&console.timeEnd(`clipping`),s.push(_||[],t+1,n*2,r*2),s.push(v||[],t+1,n*2,r*2+1),s.push(y||[],t+1,n*2+1,r*2),s.push(b||[],t+1,n*2+1,r*2+1)}}invalidateTiles(e){if(!e.length)return;let t=this.options,{debug:n}=t,r=1/0,i=-1/0,a=1/0,o=-1/0;for(let t of e)r=Math.min(r,t.minX),i=Math.max(i,t.maxX),a=Math.min(a,t.minY),o=Math.max(o,t.maxY);let s=t.buffer/t.extent,c=new Set;for(let t in this.tiles){let l=this.tiles[t],u=1<=f||o=m)continue;let h=!1;for(let t of e)if(t.maxX>=d&&t.minX=p&&t.minY1&&console.log(`invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)`,l.z,l.x,l.y,l.numFeatures,l.numPoints,l.numSimplified);let e=`z${l.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[t],c.add(t)}}c.size&&(this.tileCoords=this.tileCoords.filter(e=>!c.has(e.id)))}};function Uh(e,t,n){return((1<24)throw Error(`maxZoom should be in the 0-24 range`);if(t.promoteId&&t.generateId)throw Error(`promoteId and generateId cannot be used together.`);let r=Om(e,t);n&&(console.timeEnd(`preprocess data`),console.log(`index: maxZoom: %d, maxPoints: %d`,t.indexMaxZoom,t.indexMaxPoints),console.time(`generate tiles`)),r=ch(r,t),t.updateable&&(this.source=r),this.initializeIndex(r,t)}initializeIndex(e,t){this.tileIndex=t.cluster?new wh(t.clusterOptions):new Hh(t),e.length&&this.tileIndex.initialize(e)}getTile(e,t,n){return e=+e,t=+t,n=+n,e<0||e>24?null:this.tileIndex.getTile(e,t,n)}updateData(e,t){let n=this.options;if(!n.updateable)throw Error("to update tile geojson `updateable` option must be set to true");let{affected:r,source:i}=fh(this.source,e,n);t&&({affected:r,source:i}=this.filterUpdate(i,r,t)),r.length&&(this.source=i,this.tileIndex.updateIndex(i,r,n))}filterUpdate(e,t,n){let r=new Set;for(let i of e)i.id!=null&&(n(Um(i))||(t.push(i),r.add(i.id)));return e=e.filter(e=>!r.has(e.id)),{affected:t,source:e}}getData(){if(!this.options.updateable)throw Error("to retrieve data the `updateable` option must be set to true");return Hm(this.source)}updateClusterOptions(e,t){let n=this.options.cluster;if(this.options.cluster=e,this.options.clusterOptions=t,n==e){this.tileIndex.updateIndex(this.source,[],this.options);return}this.initializeIndex(this.source,this.options)}getClusterExpansionZoom(e){return this.tileIndex.getClusterExpansionZoom(e)}getClusterChildren(e){return this.tileIndex.getChildren(e)}getClusterLeaves(e,t,n){return this.tileIndex.getLeaves(e,t,n)}};const Kh=J([{name:`a_pos_normal`,components:2,type:`Int16`},{name:`a_data`,components:4,type:`Uint8`}],4),qh=Kh.members;Kh.size,Kh.alignment;const Jh=J([{name:`a_uv_x`,components:1,type:`Float32`},{name:`a_split_index`,components:1,type:`Float32`}]),Yh=Jh.members;Jh.size,Jh.alignment;const Xh=Math.cos(75/2*(Math.PI/180)),Zh=1/2,Qh=2**14/Zh;var $h=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let e of this.layers)this.gradients[e.id]={};this.layoutVertexArray=new vu,this.layoutVertexArray2=new yu,this.indexArray=new ku,this.programConfigurations=new dd(e.layers,e.zoom),this.segments=new Pu,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n){this.hasDependencies=jf(`line`,this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get(`line-sort-key`),i=!r.isConstant(),a=[],o=new W(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:t,id:c,index:l,sourceLayerIndex:u}of e){let e=vd(t,s);if(!this.layers[0]._featureFilter.filter(o,e,n))continue;let d=i?r.evaluate(e,{},n):void 0,f={id:c,properties:t.properties,type:t.type,sourceLayerIndex:u,index:l,geometry:s?e.geometry:_d(t),patterns:{},dashes:{},sortKey:d};a.push(f)}i&&a.sort((e,t)=>e.sortKey-t.sortKey);for(let r of a){let{geometry:i,index:a,sourceLayerIndex:o}=r;this.hasDependencies?(jf(`line`,this.layers,t)?Mf(`line`,this.layers,r,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,r,this.zoom,t),this.patternFeatures.push(r)):this.addFeature(r,i,a,n,{},{},t.subdivisionGranularity);let s=e[a].feature;t.featureIndex.insert(s,i,a,o,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n,dashPositions:r})}addFeatures(e,t,n,r){for(let i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,n,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,Yh)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,qh),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[Oh],end:+e.properties[kh]}}addFeature(e,t,n,r,i,a,o){let s=this.layers[0].layout,c=s.get(`line-join`).evaluate(e,{}),l=s.get(`line-cap`).evaluate(e,{}),u=s.get(`line-miter-limit`).evaluate(e,{}),d=s.get(`line-round-limit`).evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let n of t)this.addLine(n,e,c,l,u,d,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,dashPositions:a,canonical:r})}addLine(e,t,n,r,i,a,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let c=o?s.line.getGranularityForZoomLevel(o.z):1;if(e=Pp(e,c),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[u-1].equals(e[u-2]);)u--;let d=0;for(;d0;if(x&&t>d){let e=m.dist(h);if(e>2*f){let t=m.sub(m.sub(h)._mult(f/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,_,0,0,p),h=t}}let C=h&&g,w=C?n:l?`butt`:r;if(C&&w===`round`&&(yi&&(w=`bevel`),w===`bevel`&&(y>2&&(w=`flipbevel`),y100)o=v.mult(-1);else{let e=y*_.add(v).mag()/_.sub(v).mag();o._perp()._mult(e*(S?-1:1))}this.addCurrentVertex(m,o,0,0,p),this.addCurrentVertex(m,o.mult(-1),0,0,p)}else if(w===`bevel`||w===`fakeround`){let e=-Math.sqrt(y*y-1),t=S?e:0,n=S?0:e;if(h&&this.addCurrentVertex(m,_,t,n,p),w===`fakeround`){let e=Math.round(b*180/Math.PI/20);for(let t=1;t2*f){let t=m.add(g.sub(m)._mult(f/e)._round());this.updateDistance(m,t),this.addCurrentVertex(t,v,0,0,p),m=t}}}}addCurrentVertex(e,t,n,r,i,a=!1){let o=t.x+t.y*n,s=t.y-t.x*n,c=-t.x+t.y*r,l=-t.y-t.x*r;this.addHalfVertex(e,o,s,a,!1,n,i),this.addHalfVertex(e,c,l,a,!0,-r,i),this.distance>Qh/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,n,r,i,a))}addHalfVertex({x:e,y:t},n,r,i,a,o,s){let c=(this.lineClips?this.scaledDistance*(Qh-1):this.scaledDistance)*Zh;if(this.layoutVertexArray.emplaceBack((e<<1)+ +!!i,(t<<1)+ +!!a,Math.round(63*n)+128,Math.round(63*r)+128,(o===0?0:o<0?-1:1)+1|(c&63)<<2,c>>6),this.lineClips){let e=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(e,this.lineClipsArray.length)}let l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,l,this.e2),s.primitiveLength++),a?this.e2=l:this.e1=l}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 e=t.paint.get(`line-dasharray`);if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,n,r){for(let i of e){let e=i.paint.get(`line-dasharray`);if(!e||e.value.kind===`constant`)continue;let a=i.layout.get(`line-cap`).evaluate(t,{})===`round`,o={dasharray:e.value.evaluate({zoom:n-1},t,{}),round:a},s={dasharray:e.value.evaluate({zoom:n},t,{}),round:a},c={dasharray:e.value.evaluate({zoom:n+1},t,{}),round:a},l=`${o.dasharray.join(`,`)},${o.round}`,u=`${s.dasharray.join(`,`)},${s.round}`,d=`${c.dasharray.join(`,`)},${c.round}`;r.dashDependencies[l]=o,r.dashDependencies[u]=s,r.dashDependencies[d]=c,t.dashes[i.id]={min:l,mid:u,max:d}}}};U(`LineBucket`,$h,{omit:[`layers`,`patternFeatures`]});let eg;const tg=()=>eg||=new _l({"line-cap":new K(j.layout_line[`line-cap`],`line-cap`),"line-join":new K(j.layout_line[`line-join`],`line-join`),"line-miter-limit":new K(j.layout_line[`line-miter-limit`],`line-miter-limit`),"line-round-limit":new K(j.layout_line[`line-round-limit`],`line-round-limit`),"line-sort-key":new K(j.layout_line[`line-sort-key`],`line-sort-key`)});let ng;const rg=()=>ng||=new _l({"line-opacity":new K(j.paint_line[`line-opacity`],`line-opacity`),"line-layer-opacity":new G(j.paint_line[`line-layer-opacity`],`line-layer-opacity`),"line-color":new K(j.paint_line[`line-color`],`line-color`),"line-translate":new G(j.paint_line[`line-translate`],`line-translate`),"line-translate-anchor":new G(j.paint_line[`line-translate-anchor`],`line-translate-anchor`),"line-width":new K(j.paint_line[`line-width`],`line-width`),"line-gap-width":new K(j.paint_line[`line-gap-width`],`line-gap-width`),"line-offset":new K(j.paint_line[`line-offset`],`line-offset`),"line-blur":new K(j.paint_line[`line-blur`],`line-blur`),"line-dasharray":new ml(j.paint_line[`line-dasharray`],`line-dasharray`),"line-pattern":new ml(j.paint_line[`line-pattern`],`line-pattern`),"line-gradient":new gl(j.paint_line[`line-gradient`],`line-gradient`)});var ig={get paint(){return rg()},get layout(){return tg()}},ag=class extends K{possiblyEvaluate(e,t){return t=new W(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=xt({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}};let og;const sg=e=>e.type===`line`;var cg=class extends bl{constructor(e,t){super(e,ig,t),this.gradientVersion=0,og||(og=new ag(ig.paint.properties[`line-width`].specification,`line-floorwidth`),og.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e===`line-gradient`){let e=this.gradientExpression();Jo(e)?this.stepInterpolant=e._styleExpression.expression instanceof Ci:this.stepInterpolant=!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`]=og.possiblyEvaluate(this._transitioningPaint._values[`line-width`].value,e)}createBucket(e){return new $h(e)}queryRadius(e){let t=e,n=lg(Fd(`line-width`,this,t),Fd(`line-gap-width`,this,t)),r=Fd(`line-offset`,this,t);return n/2+Math.abs(r)+Id(this.paint.get(`line-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:i,pixelsToTileUnits:a}){let o=Ld(e,this.paint.get(`line-translate`),this.paint.get(`line-translate-anchor`),-i.bearingInRadians,a),s=a/2*lg(this.paint.get(`line-width`).evaluate(t,n),this.paint.get(`line-gap-width`).evaluate(t,n)),c=this.paint.get(`line-offset`).evaluate(t,n);return c&&(r=zd(r,c*a)),Td(o,r,s)}isTileClipped(){return!0}};function lg(e,t){return t>0?t+2*e:e}const ug=J([{name:`a_pos_offset`,components:4,type:`Int16`},{name:`a_data`,components:4,type:`Uint16`},{name:`a_pixeloffset`,components:4,type:`Int16`}],4),dg=J([{name:`a_projected_pos`,components:3,type:`Float32`}],4);J([{name:`a_fade_opacity`,components:1,type:`Uint32`}],4);const fg=J([{name:`a_placed`,components:2,type:`Uint8`},{name:`a_shift`,components:2,type:`Float32`},{name:`a_box_real`,components:2,type:`Int16`}]);J([{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 pg=J([{name:`a_pos`,components:2,type:`Int16`},{name:`a_anchor_pos`,components:2,type:`Int16`},{name:`a_extrude`,components:2,type:`Int16`}],4),mg=J([{name:`a_pos`,components:2,type:`Float32`},{name:`a_radius`,components:1,type:`Float32`},{name:`a_flags`,components:2,type:`Int16`}],4);J([{name:`triangle`,components:3,type:`Uint16`}]),J([{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`}]),J([{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`}]),J([{type:`Float32`,name:`offsetX`}]),J([{type:`Int16`,name:`x`},{type:`Int16`,name:`y`},{type:`Int16`,name:`tileUnitDistanceFromAnchor`}]),J([{type:`Uint16`,name:`textAnchor`},{type:`Float32`,components:2,name:`textOffset`}]);function hg(e,t,n){let r=t.layout.get(`text-transform`).evaluate(n,{});return r===`uppercase`?e=e.toLocaleUpperCase():r===`lowercase`&&(e=e.toLocaleLowerCase()),tl.applyArabicShaping&&(e=tl.applyArabicShaping(e)),e}function gg(e,t,n){for(let r of e.sections)r.text=hg(r.text,t,n);return e}function _g(e){let t={},n={},r=[],i=0;function a(t){r.push(e[t]),i++}function o(e,t,i){let a=n[e];return delete n[e],n[t]=a,r[a].geometry[0].pop(),r[a].geometry[0]=r[a].geometry[0].concat(i[0]),a}function s(e,n,i){let a=t[n];return delete t[n],t[e]=a,r[a].geometry[0].shift(),r[a].geometry[0]=i[0].concat(r[a].geometry[0]),a}function c(e,t,n){let r=n?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let l=0;le.geometry)}const vg={"!":`︕`,"#":`#`,$:`$`,"%":`%`,"&":`&`,"(":`︵`,")":`︶`,"*":`*`,"+":`+`,",":`︐`,"-":`︲`,".":`・`,"/":`/`,":":`︓`,";":`︔`,"<":`︿`,"=":`=`,">":`﹀`,"?":`︖`,"@":`@`,"[":`﹇`,"\\":`\`,"]":`﹈`,"^":`^`,_:`︳`,"`":```,"{":`︷`,"|":`―`,"}":`︸`,"~":`~`,"¢":`¢`,"£":`£`,"¥":`¥`,"¦":`¦`,"¬":`¬`,"¯":` ̄`,"–":`︲`,"—":`︱`,"‘":`﹃`,"’":`﹄`,"“":`﹁`,"”":`﹂`,"…":`︙`,"⋯":`︙`,"‧":`・`,"₩":`₩`,"、":`︑`,"。":`︒`,"〈":`︿`,"〉":`﹀`,"《":`︽`,"》":`︾`,"「":`﹁`,"」":`﹂`,"『":`﹃`,"』":`﹄`,"【":`︻`,"】":`︼`,"〔":`︹`,"〕":`︺`,"〖":`︗`,"〗":`︘`,"!":`︕`,"(":`︵`,")":`︶`,",":`︐`,"-":`︲`,".":`・`,":":`︓`,";":`︔`,"<":`︿`,">":`﹀`,"?":`︖`,"[":`﹇`,"]":`﹈`,"_":`︳`,"{":`︷`,"|":`―`,"}":`︸`,"⦅":`︵`,"⦆":`︶`,"。":`︒`,"「":`﹁`,"」":`﹂`};function yg(e){let t=``,n={premature:!0,value:void 0},r=e[Symbol.iterator](),i=r.next(),a=e[Symbol.iterator]();a.next();let o=a.next();for(;!i.done;)(o.done||!Jc(o.value.codePointAt(0))||vg[o.value])&&(n.premature||!Jc(n.value.codePointAt(0))||vg[n.value])&&vg[i.value]?t+=vg[i.value]:t+=i.value,n={value:i.value,premature:!1},i=r.next(),o=a.next();return t}const bg={10:!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},xg={40:!0};function Sg(e,t,n,r,i,a){if(`fontStack`in t){let r=n[t.fontStack]?.[e];return r?r.metrics.advance*t.scale+i:0}else{let e=r[t.imageName];return e?e.displaySize[0]*t.scale*24/a+i:0}}function Cg(e,t,n,r){let i=(e-t)**2;return r?eMath.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,n=0;for(let r=0;rn))}addImageSection(e){let t=e.image?e.image.name:``;if(t.length===0){Ft(`Can't add FormattedSection with an empty image.`);return}let n=this.getNextImageSectionCharCode();if(!n){Ft(`Reached maximum number of images 6401`);return}this.text+=String.fromCharCode(n),this.sections.push({scale:1,verticalAlign:e.verticalAlign||`bottom`,imageName:t}),this.sectionIndex.push(this.sections.length-1)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,n,r,i){let a=[],o=this.determineAverageLineWidth(e,t,n,r,i),s=this.hasZeroWidthSpaces(),c=0,l=0,u=this.text[Symbol.iterator](),d=u.next(),f=this.text[Symbol.iterator]();f.next();let p=f.next(),m=this.text[Symbol.iterator]();m.next(),m.next();let h=m.next();for(;!d.done;){let t=this.getSection(l),g=d.value.codePointAt(0);if(Hc(g)||(c+=Sg(g,t,n,r,e,i)),!p.done){let e=Rc(g),n=p.value.codePointAt(0);(bg[g]||e||`imageName`in t||!h.done&&xg[n])&&a.push(Tg(l+1,c,o,a,wg(g,n,e&&s),!1))}l++,d=u.next(),p=f.next(),h=m.next()}return Eg(Tg(this.length(),c,o,a,0,!0))}determineAverageLineWidth(e,t,n,r,i){let a=0,o=0;for(let t of this.text){let s=this.getSection(o);a+=Sg(t.codePointAt(0),s,n,r,e,i),o++}let s=Math.max(1,Math.ceil(a/t));return a/s}};const Og=65536*65536,kg=1/Og,Ag=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`);var jg=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,n=this.length){let r;for(;r=this.nextField(n);)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)*Og;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Og;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,n=t[this.pos++];if(n<128)return n;let r=n&127,i;return i=t[this.pos++],r|=(i&127)<<7,i<128||(i=t[this.pos++],r|=(i&127)<<14,i<128)||(i=t[this.pos++],r|=(i&127)<<21,i<128)?r:(i=t[this.pos],r|=(i&15)<<28,Ng(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&&Ag?Ag.decode(this.buf.subarray(t,e)):Jg(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 n=this.readPackedEnd();for(;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}`)}},Mg=class{constructor(e=new Uint8Array(16)){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.length=this.buf.length}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t=0&&e<128){this.pos>=this.length&&this.realloc(1),this.buf[this.pos++]=e;return}if(e>268435455||e<0){Fg(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))}writeSVarint(e){this.writeVarint(e<0?-e*2-1:e*2)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(e.length*4),this.pos++;let t=this.pos;this.pos=Yg(this.buf,e,this.pos);let n=this.pos-t;n>=128&&Rg(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let t=e.length;this.writeVarint(t),this.realloc(t),this.buf.set(e,this.pos),this.pos+=t}writeRawMessage(e,t){this.pos++;let n=this.pos;e(t,this);let r=this.pos-n;r>=128&&Rg(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,n){this.writeTag(e,2),this.writeRawMessage(t,n)}writePackedVarint(e,t){t.length&&this.writeMessage(e,zg,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Bg,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Ug,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Vg,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Hg,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Wg,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Gg,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Kg,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,qg,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function Ng(e,t,n){let r=n.buf,i,a;if(a=r[n.pos++],i=(a&112)>>4,a<128||(a=r[n.pos++],i|=(a&127)<<3,a<128)||(a=r[n.pos++],i|=(a&127)<<10,a<128)||(a=r[n.pos++],i|=(a&127)<<17,a<128)||(a=r[n.pos++],i|=(a&127)<<24,a<128)||(a=r[n.pos++],i|=(a&1)<<31,a<128))return Pg(e,i,t);throw Error(`Expected varint not more than 10 bytes`)}function Pg(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function Fg(e,t){let n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw Error(`Given varint doesn't fit into 10 bytes`);t.realloc(10),Ig(n,r,t),Lg(r,t)}function Ig(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function Lg(e,t){let n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function Rg(e,t,n){let r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(r),n.buf.copyWithin(e+r,e,n.pos)}function zg(e,t){let n=e.length,r=t.buf,i=t.pos,a=t.length;for(let o=0;oa){t.pos=i,t.writeVarint(n),r=t.buf,i=t.pos,a=t.length;continue}for(;n>127;)r[i++]=n%128|128,n=Math.floor(n/128);r[i++]=n}t.pos=i}function Bg(e,t){for(let n=0;n239?4:t>223?3:t>191?2:1;if(i+o>n)break;let s,c,l;o===1?t<128&&(a=t):o===2?(s=e[i+1],(s&192)==128&&(a=(t&31)<<6|s&63,a<=127&&(a=null))):o===3?(s=e[i+1],c=e[i+2],(s&192)==128&&(c&192)==128&&(a=(t&15)<<12|(s&63)<<6|c&63,(a<=2047||a>=55296&&a<=57343)&&(a=null))):o===4&&(s=e[i+1],c=e[i+2],l=e[i+3],(s&192)==128&&(c&192)==128&&(l&192)==128&&(a=(t&15)<<18|(s&63)<<12|(c&63)<<6|l&63,(a<=65535||a>=1114112)&&(a=null))),a===null?(a=65533,o=1):a>65535&&(a-=65536,r+=String.fromCharCode(a>>>10&1023|55296),a=56320|a&1023),r+=String.fromCharCode(a),i+=o}return r}function Yg(e,t,n){for(let r=0,i,a;r55295&&i<57344)if(a)if(i<56320){e[n++]=239,e[n++]=191,e[n++]=189,a=i;continue}else i=a-55296<<10|i-56320|65536,a=null;else{i>56319||r+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):a=i;continue}else a&&=(e[n++]=239,e[n++]=191,e[n++]=189,null);i<128?e[n++]=i:(i<2048?e[n++]=i>>6|192:(i<65536?e[n++]=i>>12|224:(e[n++]=i>>18|240,e[n++]=i>>12&63|128),e[n++]=i>>6&63|128),e[n++]=i&63|128)}return n}function Xg(e,t,n){e===1&&n.readMessage(Zg,t)}function Zg(e,t,n){if(e===3){let{id:e,bitmap:r,width:i,height:a,left:o,top:s,advance:c}=n.readMessage(Qg,{});t.push({id:e,bitmap:new cf({width:i+6,height:a+6},r),metrics:{width:i,height:a,left:o,top:s,advance:c}})}}function Qg(e,t,n){e===1?t.id=n.readVarint():e===2?t.bitmap=n.readBytes():e===3?t.width=n.readVarint():e===4?t.height=n.readVarint():e===5?t.left=n.readSVarint():e===6?t.top=n.readSVarint():e===7&&(t.advance=n.readVarint())}function $g(e){return new jg(e).readFields(Xg,[])}function e_(e){let{userImage:t}=e;return t?.render&&t.render()?(e.data.replace(new Uint8Array(t.data.buffer)),!0):!1}function t_(e){let t=0,n=0;for(let r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort((e,t)=>t.h-e.h);let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}],i=0,a=0;for(let t of e)for(let e=r.length-1;e>=0;e--){let n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,a=Math.max(a,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){let t=r.pop();t&&eh.toCodeUnitIndex(e));let e=v(h.toString(),_);for(let t of e){let e=[...t].map(()=>0);g.push(new Dg(t,h.sections,e))}}else if(y){g=[],_=_.map(e=>h.toCodeUnitIndex(e));let e=0,t=[];for(let n of h.text)t.push(...Array(n.length).fill(h.sectionIndex[e])),e++;let n=y(h.text,t,_);for(let e of n){let t=[],n=``;for(let r of e[0])t.push(e[1][n.length]),n+=r;g.push(new Dg(e[0],h.sections,t))}}else g=o_(h,_);let b=[],x={positionedLines:b,text:h.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:d,iconsInText:!1,verticalizable:!1};return p_(x,t,n,r,g,o,s,c,d,l,f,m),!a_(b)&&x}function c_(e){let t=.5,n=.5;switch(e){case`right`:case`top-right`:case`bottom-right`:t=1;break;case`left`:case`top-left`:case`bottom-left`:t=0;break}switch(e){case`bottom`:case`bottom-right`:case`bottom-left`:n=1;break;case`top`:case`top-right`:case`top-left`:n=0;break}return{horizontalAlign:t,verticalAlign:n}}function l_(e,t,n){let r=t.getMaxScale()*24,{maxImageWidth:i,maxImageHeight:a}=t.getMaxImageSize(e),o=Math.max(r,a*n);return{verticalLineContentWidth:Math.max(r,i*n),horizontalLineContentHeight:o}}function u_(e){switch(e){case`top`:return 0;case`center`:return .5;default:return 1}}function d_(e,t,n,r){if(e?.rect)return e;let i=t[n.fontStack]?.[r];return i?{rect:null,metrics:i.metrics}:null}function f_(e,t,n){return!(e===1||!t&&!zc(n)||t&&(Hc(n)||Yc(n)))}function p_(e,t,n,r,i,a,o,s,c,l,u,d){let f=0,p=0,m=0,h=0,g=s===`right`?1:s===`left`?0:.5,_=24/d,v=0;for(let o of i){o.trim();let i=o.getMaxScale(),s={positionedGlyphs:[],lineOffset:0};e.positionedLines[v]=s;let d=s.positionedGlyphs,y=0;if(!o.length()){p+=a,++v;continue}let b=l_(r,o,_),x=0;for(let a of o.text){let s=o.getSection(x),m=a.codePointAt(0),h=f_(c,u,m),g={glyph:m,imageName:null,x:f,y:p+-17,vertical:h,scale:1,fontStack:``,sectionIndex:o.getSectionIndex(x),metrics:null,rect:null},v;if(`fontStack`in s){if(v=m_(s,m,h,b,t,n),!v)continue;g.fontStack=s.fontStack}else{if(e.iconsInText=!0,s.scale*=_,v=h_(s,h,i,b,r),!v)continue;y=Math.max(y,v.imageOffset),g.imageName=s.imageName}let{rect:S,metrics:C,baselineOffset:w}=v;if(g.y+=w,g.scale=s.scale,g.metrics=C,g.rect=S,d.push(g),!h)f+=C.advance*s.scale+l;else{e.verticalizable=!0;let t=`imageName`in s?C.advance:24;f+=t*s.scale+l}x++}if(d.length!==0){let e=f-l;m=Math.max(e,m),g_(d,0,d.length-1,g)}f=0;let S=(i-1)*24;s.lineOffset=Math.max(y,S);let C=a*i+y;p+=C,h=Math.max(C,h),++v}let{horizontalAlign:y,verticalAlign:b}=c_(o);__(e.positionedLines,g,y,b,m,h,a,p,i.length),e.top+=-b*p,e.bottom=e.top+p,e.left+=-y*m,e.right=e.left+m}function m_(e,t,n,r,i,a){let o=a[e.fontStack]?.[t],s=d_(o,i,e,t);if(s===null)return null;let c;if(n)c=r.verticalLineContentWidth-e.scale*24;else{let t=u_(e.verticalAlign);c=(r.horizontalLineContentHeight-e.scale*24)*t}return{rect:s.rect,metrics:s.metrics,baselineOffset:c}}function h_(e,t,n,r,i){let a=i[e.imageName];if(!a)return null;let o=a.paddedRect,s=a.displaySize,c={width:s[0],height:s[1],left:1,top:-3,advance:t?s[1]:s[0]},l;if(t)l=r.verticalLineContentWidth-s[1]*e.scale;else{let t=u_(e.verticalAlign);l=(r.horizontalLineContentHeight-s[1]*e.scale)*t}let u=(t?s[0]:s[1])*e.scale-24*n;return{rect:o,metrics:c,baselineOffset:l,imageOffset:u}}function g_(e,t,n,r){if(r===0)return;let i=e[n],a=i.metrics.advance*i.scale,o=(e[n].x+a)*r;for(let r=t;r<=n;r++)e[r].x-=o}function __(e,t,n,r,i,a,o,s,c){let l=(t-n)*i,u=0;u=a===o?-r*c*o+.5*o:-s*r- -17;for(let t of e)for(let e of t.positionedGlyphs)e.x+=l,e.y+=u}function v_(e,t,n){let{horizontalAlign:r,verticalAlign:i}=c_(n),a=t[0],o=t[1],s=a-e.displaySize[0]*r,c=s+e.displaySize[0],l=o-e.displaySize[1]*i;return{image:e,top:l,bottom:l+e.displaySize[1],left:s,right:c}}function y_(e){let t=e.left,n=e.top,r=e.right-t,i=e.bottom-n,a=e.image.content[2]-e.image.content[0],o=e.image.content[3]-e.image.content[1],s=e.image.textFitWidth??`stretchOrShrink`,c=e.image.textFitHeight??`stretchOrShrink`,l=a/o;if(c===`proportional`){if(s===`stretchOnly`&&r/il){let e=Math.ceil(r/l);n*=e/i,i=e}return{x1:t,y1:n,x2:t+r,y2:n+i}}function b_(e,t,n,r,i,a){let o=e.image,s;if(o.content){let e=o.content,t=o.pixelRatio||1;s=[e[0]/t,e[1]/t,o.displaySize[0]-e[2]/t,o.displaySize[1]-e[3]/t]}let c=t.left*a,l=t.right*a,u,d,f,p;n===`width`||n===`both`?(p=i[0]+c-r[3],d=i[0]+l+r[1]):(p=i[0]+(c+l-o.displaySize[0])/2,d=p+o.displaySize[0]);let m=t.top*a,h=t.bottom*a;return n===`height`||n===`both`?(u=i[1]+m-r[0],f=i[1]+h+r[2]):(u=i[1]+(m+h-o.displaySize[1])/2,f=u+o.displaySize[1]),{image:o,top:u,right:d,bottom:f,left:p,collisionPadding:s}}const x_=32640;function S_(e,t){let{expression:n}=t;if(n.kind===`constant`)return{kind:`constant`,layoutSize:n.evaluate(new W(e+1))};if(n.kind===`source`)return{kind:`source`};{let{zoomStops:t,interpolationType:r}=n,i=0;for(;ie.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];let t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=S_(this.zoom,t[`text-size`]),this.iconSizeData=S_(this.zoom,t[`icon-size`]);let n=this.layers[0].layout,r=n.get(`symbol-sort-key`),i=n.get(`symbol-z-order`);this.canOverlap=T_(n,`text-overlap`,`text-allow-overlap`)!==`never`||T_(n,`icon-overlap`,`icon-allow-overlap`)!==`never`||n.get(`text-ignore-placement`)||n.get(`icon-ignore-placement`),this.sortFeaturesByKey=i!==`viewport-y`&&!r.isConstant();let a=i===`viewport-y`||i===`auto`&&!this.sortFeaturesByKey;this.sortFeaturesByY=a&&this.canOverlap,n.get(`symbol-placement`)===`point`&&(this.writingModes=n.get(`text-writing-mode`).map(e=>i_[e])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID}createArrays(){this.text=new A_(new dd(this.layers,this.zoom,e=>e.startsWith(`text`))),this.icon=new A_(new dd(this.layers,this.zoom,e=>e.startsWith(`icon`))),this.glyphOffsetArray=new ou,this.lineVertexArray=new su,this.symbolInstances=new au,this.textAnchorOffsets=new lu}calculateGlyphDependencies(e,t,n,r,i){for(let a of e)if(t[a.codePointAt(0)]=!0,(n||r)&&i){let e=vg[a];e&&(t[e.codePointAt(0)]=!0)}}populate(e,t,n){let r=this.layers[0],i=r.layout,a=i.get(`text-font`),o=i.get(`text-field`),s=i.get(`icon-image`),c=(o.value.kind!==`constant`||o.value.value instanceof Jr&&!o.value.value.isEmpty()||o.value.value.toString().length>0)&&(a.value.kind!==`constant`||a.value.value.length>0),l=s.value.kind!==`constant`||!!s.value.value||Object.keys(s.parameters).length>0,u=i.get(`symbol-sort-key`);if(this.features=[],!c&&!l)return;let d=t.iconDependencies,f=t.glyphDependencies,p=t.availableImages,m=new W(this.zoom);for(let{feature:t,id:o,index:s,sourceLayerIndex:h}of e){let e=r._featureFilter.needGeometry,g=vd(t,e);if(!r._featureFilter.filter(m,g,n))continue;e||(g.geometry=_d(t));let _;if(c){let e=r.getValueAndResolveTokens(`text-field`,g,n,p),t=Jr.factory(e);this.hasRTLText||=k_(t),(!this.hasRTLText||tl.getRTLTextPluginStatus()===`unavailable`||this.hasRTLText&&tl.isParsed())&&(_=gg(t,r,g))}let v;if(l){let e=r.getValueAndResolveTokens(`icon-image`,g,n,p);v=e instanceof ei?e:ei.fromString(e)}if(!_&&!v)continue;let y=this.sortFeaturesByKey?u.evaluate(g,{},n):void 0,b={id:o,text:_,icon:v,index:s,sourceLayerIndex:h,geometry:g.geometry,properties:t.properties,type:$p.types[t.type],sortKey:y};if(this.features.push(b),v&&(d[v.name]=!0),_){let e=a.evaluate(g,{},n).join(`,`),t=i.get(`text-rotation-alignment`)!==`viewport`&&i.get(`symbol-placement`)!==`point`;this.allowVerticalPlacement=this.writingModes?.includes(2);for(let n of _.sections)if(n.image)d[n.image.name]=!0;else{let r=Uc(_.toString()),i=n.fontStack||e;f[i]||={},this.calculateGlyphDependencies(n.text,f[i],t,this.allowVerticalPlacement,r)}}}i.get(`symbol-placement`)===`line`&&(this.features=_g(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}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 n=this.lineVertexArray.length;if(e.segment!==void 0){let n=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]),i={};for(let r=e.segment+1;r=0;n--)i[n]={x:t[n].x,y:t[n].y,tileUnitDistanceFromAnchor:r},n>0&&(r+=t[n-1].dist(t[n]));for(let e=0;e0}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 n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+n.numGlyphs*4;for(let t=n.vertexStartIndex;tr[e]-r[t]||i[t]-i[e]),a}addToSortKeyRanges(e,t){let n=this.sortKeyRanges[this.sortKeyRanges.length-1];n?.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(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 e of this.symbolInstanceIndexes){let t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);let n=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let e=0;e=0&&n.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)}t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};U(`SymbolBucket`,M_,{omit:[`layers`,`collisionBoxArray`,`features`,`compareText`]}),M_.MAX_GLYPHS=65535,M_.addDynamicAttributes=O_;function N_(e,t){return t.replace(/{([^{}]+)}/g,(t,n)=>e&&n in e?String(e[n]):``)}let P_;const F_=()=>P_||=new _l({"symbol-placement":new G(j.layout_symbol[`symbol-placement`],`symbol-placement`),"symbol-spacing":new G(j.layout_symbol[`symbol-spacing`],`symbol-spacing`),"symbol-avoid-edges":new G(j.layout_symbol[`symbol-avoid-edges`],`symbol-avoid-edges`),"symbol-sort-key":new K(j.layout_symbol[`symbol-sort-key`],`symbol-sort-key`),"symbol-z-order":new G(j.layout_symbol[`symbol-z-order`],`symbol-z-order`),"icon-allow-overlap":new G(j.layout_symbol[`icon-allow-overlap`],`icon-allow-overlap`),"icon-overlap":new G(j.layout_symbol[`icon-overlap`],`icon-overlap`),"icon-ignore-placement":new G(j.layout_symbol[`icon-ignore-placement`],`icon-ignore-placement`),"icon-optional":new G(j.layout_symbol[`icon-optional`],`icon-optional`),"icon-rotation-alignment":new G(j.layout_symbol[`icon-rotation-alignment`],`icon-rotation-alignment`),"icon-size":new K(j.layout_symbol[`icon-size`],`icon-size`),"icon-text-fit":new G(j.layout_symbol[`icon-text-fit`],`icon-text-fit`),"icon-text-fit-padding":new G(j.layout_symbol[`icon-text-fit-padding`],`icon-text-fit-padding`),"icon-image":new K(j.layout_symbol[`icon-image`],`icon-image`),"icon-rotate":new K(j.layout_symbol[`icon-rotate`],`icon-rotate`),"icon-padding":new K(j.layout_symbol[`icon-padding`],`icon-padding`),"icon-keep-upright":new G(j.layout_symbol[`icon-keep-upright`],`icon-keep-upright`),"icon-offset":new K(j.layout_symbol[`icon-offset`],`icon-offset`),"icon-anchor":new K(j.layout_symbol[`icon-anchor`],`icon-anchor`),"icon-pitch-alignment":new G(j.layout_symbol[`icon-pitch-alignment`],`icon-pitch-alignment`),"text-pitch-alignment":new G(j.layout_symbol[`text-pitch-alignment`],`text-pitch-alignment`),"text-rotation-alignment":new G(j.layout_symbol[`text-rotation-alignment`],`text-rotation-alignment`),"text-field":new K(j.layout_symbol[`text-field`],`text-field`),"text-font":new K(j.layout_symbol[`text-font`],`text-font`),"text-size":new K(j.layout_symbol[`text-size`],`text-size`),"text-max-width":new K(j.layout_symbol[`text-max-width`],`text-max-width`),"text-line-height":new G(j.layout_symbol[`text-line-height`],`text-line-height`),"text-letter-spacing":new K(j.layout_symbol[`text-letter-spacing`],`text-letter-spacing`),"text-justify":new K(j.layout_symbol[`text-justify`],`text-justify`),"text-radial-offset":new K(j.layout_symbol[`text-radial-offset`],`text-radial-offset`),"text-variable-anchor":new G(j.layout_symbol[`text-variable-anchor`],`text-variable-anchor`),"text-variable-anchor-offset":new K(j.layout_symbol[`text-variable-anchor-offset`],`text-variable-anchor-offset`),"text-anchor":new K(j.layout_symbol[`text-anchor`],`text-anchor`),"text-max-angle":new G(j.layout_symbol[`text-max-angle`],`text-max-angle`),"text-writing-mode":new G(j.layout_symbol[`text-writing-mode`],`text-writing-mode`),"text-rotate":new K(j.layout_symbol[`text-rotate`],`text-rotate`),"text-padding":new G(j.layout_symbol[`text-padding`],`text-padding`),"text-keep-upright":new G(j.layout_symbol[`text-keep-upright`],`text-keep-upright`),"text-transform":new K(j.layout_symbol[`text-transform`],`text-transform`),"text-offset":new K(j.layout_symbol[`text-offset`],`text-offset`),"text-allow-overlap":new G(j.layout_symbol[`text-allow-overlap`],`text-allow-overlap`),"text-overlap":new G(j.layout_symbol[`text-overlap`],`text-overlap`),"text-ignore-placement":new G(j.layout_symbol[`text-ignore-placement`],`text-ignore-placement`),"text-optional":new G(j.layout_symbol[`text-optional`],`text-optional`)});let I_;const L_=()=>I_||=new _l({"icon-opacity":new K(j.paint_symbol[`icon-opacity`],`icon-opacity`),"icon-color":new K(j.paint_symbol[`icon-color`],`icon-color`),"icon-halo-color":new K(j.paint_symbol[`icon-halo-color`],`icon-halo-color`),"icon-halo-width":new K(j.paint_symbol[`icon-halo-width`],`icon-halo-width`),"icon-halo-blur":new K(j.paint_symbol[`icon-halo-blur`],`icon-halo-blur`),"icon-translate":new G(j.paint_symbol[`icon-translate`],`icon-translate`),"icon-translate-anchor":new G(j.paint_symbol[`icon-translate-anchor`],`icon-translate-anchor`),"text-opacity":new K(j.paint_symbol[`text-opacity`],`text-opacity`),"text-color":new K(j.paint_symbol[`text-color`],`text-color`,{runtimeType:er,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new K(j.paint_symbol[`text-halo-color`],`text-halo-color`),"text-halo-width":new K(j.paint_symbol[`text-halo-width`],`text-halo-width`),"text-halo-blur":new K(j.paint_symbol[`text-halo-blur`],`text-halo-blur`),"text-translate":new G(j.paint_symbol[`text-translate`],`text-translate`),"text-translate-anchor":new G(j.paint_symbol[`text-translate-anchor`],`text-translate-anchor`)});var R_={get paint(){return L_()},get layout(){return F_()}},z_=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:$n,this.defaultValue=e}evaluate(e){if(e.formattedSection){let t=this.defaultValue.property.overrides;if(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}};U(`FormatSectionOverride`,z_,{omit:[`defaultValue`]});const B_=e=>e.type===`symbol`;var V_=class e extends bl{constructor(e,t){super(e,R_,t)}recalculate(e,t){if(super.recalculate(e,t),this.layout.get(`icon-rotation-alignment`)===`auto`&&(this.layout.get(`symbol-placement`)===`point`?this.layout._values[`icon-rotation-alignment`]=`viewport`:this.layout._values[`icon-rotation-alignment`]=`map`),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`)),this.layout.get(`symbol-placement`)===`point`){let e=this.layout.get(`text-writing-mode`);if(e){let t=[];for(let n of e)t.includes(n)||t.push(n);this.layout._values[`text-writing-mode`]=t}else this.layout._values[`text-writing-mode`]=[`horizontal`]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){let i=this.layout.get(e).evaluate(t,{},n,r),a=this._unevaluatedLayout._values[e];return!a.isDataDriven()&&!Wo(a.value)&&i?N_(t.properties,i):i}createBucket(e){return new M_(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error(`Should take a different path in FeatureIndex`)}_setPaintOverrides(){for(let t of R_.paint.overridableProperties){if(!e.hasPaintOverride(this.layout,t))continue;let n=this.paint.get(t),r=new Vo(new z_(n),`layers[${this.id}].paint.${n.property.name}`,n.property.specification),i=null;i=n.value.kind===`constant`||n.value.kind===`source`?new Ko(`source`,r):new qo(`composite`,r,n.value.zoomStops),this.paint._values[t]=new ul(n.property,i,n.parameters)}}_handleOverridablePaintPropertyUpdate(t,n,r){return!this.layout||n.isDataDriven()||r.isDataDriven()?!1:e.hasPaintOverride(this.layout,t)}static hasPaintOverride(e,t){let n=e.get(`text-field`),r=R_.paint.properties[t],i=!1,a=e=>{for(let t of e)if(r.overrides?.hasOverride(t)){i=!0;return}};if(n.value.kind===`constant`&&n.value.value instanceof Jr)a(n.value.value.sections);else if(n.value.kind===`source`||n.value.kind===`composite`){let e=t=>{if(!i)if(t instanceof oi&&ii(t.value)===ar){let e=t.value;a(e.sections)}else t instanceof Zi?a(t.sections):t.eachChild(e)},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}};function H_(e,t,n,r=1){let i=e.get(`icon-padding`).evaluate(t,{},n)?.values;return[i[0]*r,i[1]*r,i[2]*r,i[3]*r]}let U_;const W_=()=>U_||=new _l({"background-color":new G(j.paint_background[`background-color`],`background-color`),"background-pattern":new hl(j.paint_background[`background-pattern`],`background-pattern`),"background-opacity":new G(j.paint_background[`background-opacity`],`background-opacity`)});var G_={get paint(){return W_()}};const K_=e=>e.type===`background`;var q_=class extends bl{constructor(e,t){super(e,G_,t)}};function J_(e){let t=[],n=e.id;return n===void 0&&t.push(new N(`layers.${n}`,null,`missing required property "id"`)),e.render===void 0&&t.push(new N(`layers.${n}`,null,`missing required method "render"`)),e.renderingMode&&e.renderingMode!==`2d`&&e.renderingMode!==`3d`&&t.push(new N(`layers.${n}`,null,`property "renderingMode" must be either "2d" or "3d"`)),t}const Y_=e=>e.type===`custom`;var X_=class extends bl{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.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 Z_(e,t){if(e.type===`custom`)return new X_(e,t);switch(e.type){case`background`:return new q_(e,t);case`circle`:return new $d(e,t);case`color-relief`:return new Of(e,t);case`fill`:return new Yp(e,t);case`fill-extrusion`:return new _m(e,t);case`heatmap`:return new mf(e,t);case`hillshade`:return new yf(e,t);case`line`:return new cg(e,t);case`raster`:return new Tl(e,t);case`symbol`:return new V_(e,t)}}var Q_=class{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}};const $_={once:!0};var ev=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Q_(()=>this.process()),this.subscription=$t(this.target,`message`,e=>this.receive(e),!1),this.globalScope=zt(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((n,r)=>{let i=Math.round(Math.random()*0xde0b6b3a7640000).toString(36).substring(0,10),a=t?$t(t.signal,`abort`,()=>{a?.unsubscribe(),delete this.resolveRejects[i];let n={id:i,type:``,origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(n),r(new mn(t.signal.reason))},$_):null;this.resolveRejects[i]={resolve:e=>{a?.unsubscribe(),n(e)},reject:e=>{a?.unsubscribe(),r(e)}};let o=[],s={...e,id:i,sourceMapId:this.mapId,origin:location.origin,data:Pc(e.data,o)};this.target.postMessage(s,{transfer:o})})}receive(e){let t=e.data,n=t.id,r=[`file://`,`resource://android`,`null`],i=[t.origin,location.origin],a=t.origin===location.origin,o=i.some(e=>r.includes(e));if(!(!a&&!o)&&!(t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type===``){delete this.tasks[n];let e=this.abortControllers[n];delete this.abortControllers[n],e&&e.abort();return}if(zt(self)||t.mustQueue){this.tasks[n]=t,this.taskQueue.push(n),this.invoker.trigger();return}this.processTask(n,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===``){let n=this.resolveRejects[e];if(delete this.resolveRejects[e],!n)return;t.error?n.reject(Qe(Fc(t.error))):n.resolve(Fc(t.data));return}if(!this.messageHandlers[t.type]){this.completeTask(e,null,null);return}let n=Fc(t.data),r=new AbortController;this.abortControllers[e]=r;try{let i=await this.messageHandlers[t.type](t.sourceMapId,n,r);this.completeTask(e,null,i)}catch(t){this.completeTask(e,Qe(t))}}completeTask(e,t,n){let r=[];delete this.abortControllers[e];let i={id:e,type:``,sourceMapId:this.mapId,origin:location.origin,error:t?Pc(t):null,data:Pc(n,r)};this.target.postMessage(i,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};const tv=6371008.8;var nv=class e{constructor(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw Error(`Invalid LngLat latitude value: must be between -90 and 90`)}wrap(){return new e(bt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let t=Math.PI/180,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return tv*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof e)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new e(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t==`object`&&t)return new e(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}};const rv=2*Math.PI*tv;function iv(e){return rv*Math.cos(e*Math.PI/180)}function av(e){return(180+e)/360}function ov(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function sv(e,t){return e/iv(t)}function cv(e){return e*360-180}function lv(e){let t=180-e*360;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function uv(e,t){return e*iv(lv(t))}function dv(e){return 1/Math.cos(e*Math.PI/180)}var fv=class e{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(t,n=0){let r=nv.convert(t);return new e(av(r.lng),ov(r.lat),sv(n,r.lat))}toLngLat(){return new nv(cv(this.x),lv(this.y))}toAltitude(){return uv(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/rv*dv(lv(this.y))}};function pv(e,t,n){return!(e<0||e>25||n<0||n>=2**e||t<0||t>=2**e)}function mv(e,t){let{x:n,y:r}=fv.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||n<0||n>=1)}var hv=class{constructor(e,t,n){if(!pv(e,t,n))throw Error(`x=${t}, y=${n}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=n,this.key=vv(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,n){let r=bv(this.x,this.y,this.z),i=Sv(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(n===`tms`?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?`@2x`:``).replace(/{quadkey}/g,i).replace(/{bbox-epsg-3857}/g,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 l((e.x*t-this.x)*Ye,(e.y*t-this.y)*Ye)}toString(){return`${this.z}/${this.x}/${this.y}`}},gv=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=vv(e,t.z,t.z,t.x,t.y)}},_v=class e{constructor(e,t,n,r,i){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${n}`);this.overscaledZ=e,this.wrap=t,this.canonical=new hv(n,+r,+i),this.key=vv(t,e,n,r,i)}clone(){return new e(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(t){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let n=this.canonical.z-t;return t>this.canonical.z?new e(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new e(t,this.wrap,t,this.canonical.x>>n,this.canonical.y>>n)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let n=this.canonical.z-e;return e>this.canonical.z?vv(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):vv(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;let t=this.canonical.z-e.canonical.z;return t<0?!1:e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(t){if(this.overscaledZ>=t)return[new e(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let n=this.canonical.z+1,r=this.canonical.x*2,i=this.canonical.y*2;return[new e(n,this.wrap,n,r,i),new e(n,this.wrap,n,r+1,i),new e(n,this.wrap,n,r,i+1),new e(n,this.wrap,n,r+1,i+1)]}isLessThan(e){return this.wrape.wrap?!1:this.overscaledZe.overscaledZ?!1:this.canonical.xe.canonical.x?!1:this.canonical.y=0&&t=0&&n=l)return null;let d=this.canonical.x+i,f=this.wrap;return d<0?(f-=Math.ceil(-d/l),d=(d%l+l)%l):d>=l&&(f+=Math.floor(d/l),d%=l),{tileID:new e(this.overscaledZ,f,c,d,u),x:o,y:s}}};function vv(e,t,n,r,i){e*=2,e<0&&(e=e*-1-1);let a=1<0;i--){let e=1<this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(t){let n=new e;return n.extend(t(new l(this.minX,this.minY))),n.extend(t(new l(this.maxX,this.minY))),n.extend(t(new l(this.minX,this.maxY))),n.extend(t(new l(this.maxX,this.maxY))),n}static fromPoints(t){let n=new e;for(let e of t)n.extend(e);return n}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}},Tv=class{constructor(e,t){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=t,`id`in e&&(typeof e.id==`string`?this.id=parseInt(e.id,10):typeof e.id==`number`&&!isNaN(e.id)&&(this.id=e.id))}loadGeometry(){let e=[],t=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(let n of t){let t=[];for(let e of n)t.push(new l(e[0],e[1]));e.push(t)}return e}};const Ev=`_geojsonTileLayer`;var Dv=class{constructor(e,t){this.layers={[Ev]:this},this.name=Ev,this.version=t?t.version:1,this.extent=t?t.extent:4096,this.length=e.length,this.features=e}feature(e){return new Tv(this.features[e],this.extent)}};function Ov(e,t=``){let n=new Mg;return kv(e,n,t),n.finish()}function kv(e,t,n=``){for(let r in e.layers)t.writeMessage(3,(e,t)=>Av(e,t,n),e.layers[r])}function Av(e,t,n=``){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||``),t.writeVarintField(5,e.extent||4096);let r={jsonPrefix:n,keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n>31}function Fv(e,t){let n=e.loadGeometry(),r=e.type,i=0,a=0;for(let o of n){let n=1;r===1&&(n=o.length),t.writeVarint(Nv(1,n));let s=r===3?o.length-1:o.length;for(let e=0;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]}},Rv=class{constructor(e,t,n,r,i){this.type=`Feature`,this._vectorTileFeature=e,this._x=n,this._y=r,this._z=t;for(let t in e.properties)typeof e.properties[t]!=`string`||!e.properties[t].startsWith(`__$json__:`)||(e.properties[t]=JSON.parse(e.properties[t].slice(10)));this.properties=e.properties,this.id=i}projectPoint(e,t,n,r){return[(e.x+t)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(e.y+n)*2/r)*Math.PI))-90]}projectLine(e,t,n,r){return e.map(e=>this.projectPoint(e,t,n,r))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,n=e.extent*this._x,r=e.extent*this._y,i=e.loadGeometry();switch(e.type){case 1:{let e=[];for(let t of i)e.push(t[0]);let a=this.projectLine(e,n,r,t);this._geometry=e.length===1?{type:`Point`,coordinates:a[0]}:{type:`MultiPoint`,coordinates:a};break}case 2:{let e=i.map(e=>this.projectLine(e,n,r,t));this._geometry=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e};break}case 3:{let e=em(i),a=[];for(let i of e)a.push(i.map(e=>this.projectLine(e,n,r,t)));this._geometry=a.length===1?{type:`Polygon`,coordinates:a[0]}:{type:`MultiPolygon`,coordinates:a};break}default:throw Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let t in this)t!==`_geometry`&&t!==`_vectorTileFeature`&&t!==`_x`&&t!==`_y`&&t!==`_z`&&(e[t]=this[t]);return e}},zv=class{constructor(e,t,n){this._name=e,this.dataBuffer=t,typeof n==`number`?this._size=n:(this.nullabilityBuffer=n,this._size=n.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},Bv=class extends zv{},Vv=class extends Bv{getValueFromBuffer(e){return this.dataBuffer[e]}},Hv=class extends Bv{getValueFromBuffer(e){return this.dataBuffer[e]}},Uv=class extends zv{constructor(e,t,n,r){super(e,t,r),this.delta=n}},Wv=class extends Uv{constructor(e,t,n,r){super(e,Int32Array.of(t),n,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},Gv=class extends zv{constructor(e,t,n,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),n)}getValueFromBuffer(e){return this.dataBuffer[0]}},Kv=class{constructor(e,t,n,r,i=4096){if(this._name=e,this._geometryVector=t,this._idVector=n,this._propertyVectors=r,this._extent=i,e.length===0)throw Error(`Missing layer name`)}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||=new Map(this._propertyVectors.map(e=>[e.name,e])),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],t=this.geometryVector.getGeometries();for(let n=0;n>>32-e;const $v=Qv,ey=65536;function ty(e,t){return e-e%t}function ny(e){return ty(e+31,32)}function ry(e){if(!Number.isFinite(e)||e<=0)return ey;let t=ty(Math.floor(e),256);return t===0?256:t}function iy(e){let t=e>>>0;return((t&255)<<24|(t&65280)<<8|t>>>8&65280|t>>>24&255)>>>0}function ay(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0;n[i++]=a>>>0&3,n[i++]=a>>>2&3,n[i++]=a>>>4&3,n[i++]=a>>>6&3,n[i++]=a>>>8&3,n[i++]=a>>>10&3,n[i++]=a>>>12&3,n[i++]=a>>>14&3,n[i++]=a>>>16&3,n[i++]=a>>>18&3,n[i++]=a>>>20&3,n[i++]=a>>>22&3,n[i++]=a>>>24&3,n[i++]=a>>>26&3,n[i++]=a>>>28&3,n[i++]=a>>>30&3,n[i++]=o>>>0&3,n[i++]=o>>>2&3,n[i++]=o>>>4&3,n[i++]=o>>>6&3,n[i++]=o>>>8&3,n[i++]=o>>>10&3,n[i++]=o>>>12&3,n[i++]=o>>>14&3,n[i++]=o>>>16&3,n[i++]=o>>>18&3,n[i++]=o>>>20&3,n[i++]=o>>>22&3,n[i++]=o>>>24&3,n[i++]=o>>>26&3,n[i++]=o>>>28&3,n[i]=o>>>30&3}function oy(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0;n[i++]=a>>>0&7,n[i++]=a>>>3&7,n[i++]=a>>>6&7,n[i++]=a>>>9&7,n[i++]=a>>>12&7,n[i++]=a>>>15&7,n[i++]=a>>>18&7,n[i++]=a>>>21&7,n[i++]=a>>>24&7,n[i++]=a>>>27&7,n[i++]=(a>>>30|(o&1)<<2)&7,n[i++]=o>>>1&7,n[i++]=o>>>4&7,n[i++]=o>>>7&7,n[i++]=o>>>10&7,n[i++]=o>>>13&7,n[i++]=o>>>16&7,n[i++]=o>>>19&7,n[i++]=o>>>22&7,n[i++]=o>>>25&7,n[i++]=o>>>28&7,n[i++]=(o>>>31|(s&3)<<1)&7,n[i++]=s>>>2&7,n[i++]=s>>>5&7,n[i++]=s>>>8&7,n[i++]=s>>>11&7,n[i++]=s>>>14&7,n[i++]=s>>>17&7,n[i++]=s>>>20&7,n[i++]=s>>>23&7,n[i++]=s>>>26&7,n[i]=s>>>29&7}function sy(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0;n[i++]=a>>>0&15,n[i++]=a>>>4&15,n[i++]=a>>>8&15,n[i++]=a>>>12&15,n[i++]=a>>>16&15,n[i++]=a>>>20&15,n[i++]=a>>>24&15,n[i++]=a>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15,n[i++]=c>>>0&15,n[i++]=c>>>4&15,n[i++]=c>>>8&15,n[i++]=c>>>12&15,n[i++]=c>>>16&15,n[i++]=c>>>20&15,n[i++]=c>>>24&15,n[i]=c>>>28&15}function cy(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0;n[i++]=a>>>0&31,n[i++]=a>>>5&31,n[i++]=a>>>10&31,n[i++]=a>>>15&31,n[i++]=a>>>20&31,n[i++]=a>>>25&31,n[i++]=(a>>>30|(o&7)<<2)&31,n[i++]=o>>>3&31,n[i++]=o>>>8&31,n[i++]=o>>>13&31,n[i++]=o>>>18&31,n[i++]=o>>>23&31,n[i++]=(o>>>28|(s&1)<<4)&31,n[i++]=s>>>1&31,n[i++]=s>>>6&31,n[i++]=s>>>11&31,n[i++]=s>>>16&31,n[i++]=s>>>21&31,n[i++]=s>>>26&31,n[i++]=(s>>>31|(c&15)<<1)&31,n[i++]=c>>>4&31,n[i++]=c>>>9&31,n[i++]=c>>>14&31,n[i++]=c>>>19&31,n[i++]=c>>>24&31,n[i++]=(c>>>29|(l&3)<<3)&31,n[i++]=l>>>2&31,n[i++]=l>>>7&31,n[i++]=l>>>12&31,n[i++]=l>>>17&31,n[i++]=l>>>22&31,n[i]=l>>>27&31}function ly(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0;n[i++]=a>>>0&63,n[i++]=a>>>6&63,n[i++]=a>>>12&63,n[i++]=a>>>18&63,n[i++]=a>>>24&63,n[i++]=(a>>>30|(o&15)<<2)&63,n[i++]=o>>>4&63,n[i++]=o>>>10&63,n[i++]=o>>>16&63,n[i++]=o>>>22&63,n[i++]=(o>>>28|(s&3)<<4)&63,n[i++]=s>>>2&63,n[i++]=s>>>8&63,n[i++]=s>>>14&63,n[i++]=s>>>20&63,n[i++]=s>>>26&63,n[i++]=c>>>0&63,n[i++]=c>>>6&63,n[i++]=c>>>12&63,n[i++]=c>>>18&63,n[i++]=c>>>24&63,n[i++]=(c>>>30|(l&15)<<2)&63,n[i++]=l>>>4&63,n[i++]=l>>>10&63,n[i++]=l>>>16&63,n[i++]=l>>>22&63,n[i++]=(l>>>28|(u&3)<<4)&63,n[i++]=u>>>2&63,n[i++]=u>>>8&63,n[i++]=u>>>14&63,n[i++]=u>>>20&63,n[i]=u>>>26&63}function uy(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0;n[i++]=a>>>0&127,n[i++]=a>>>7&127,n[i++]=a>>>14&127,n[i++]=a>>>21&127,n[i++]=(a>>>28|(o&7)<<4)&127,n[i++]=o>>>3&127,n[i++]=o>>>10&127,n[i++]=o>>>17&127,n[i++]=o>>>24&127,n[i++]=(o>>>31|(s&63)<<1)&127,n[i++]=s>>>6&127,n[i++]=s>>>13&127,n[i++]=s>>>20&127,n[i++]=(s>>>27|(c&3)<<5)&127,n[i++]=c>>>2&127,n[i++]=c>>>9&127,n[i++]=c>>>16&127,n[i++]=c>>>23&127,n[i++]=(c>>>30|(l&31)<<2)&127,n[i++]=l>>>5&127,n[i++]=l>>>12&127,n[i++]=l>>>19&127,n[i++]=(l>>>26|(u&1)<<6)&127,n[i++]=u>>>1&127,n[i++]=u>>>8&127,n[i++]=u>>>15&127,n[i++]=u>>>22&127,n[i++]=(u>>>29|(d&15)<<3)&127,n[i++]=d>>>4&127,n[i++]=d>>>11&127,n[i++]=d>>>18&127,n[i]=d>>>25&127}function dy(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0;n[i++]=a>>>0&255,n[i++]=a>>>8&255,n[i++]=a>>>16&255,n[i++]=a>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=d>>>0&255,n[i++]=d>>>8&255,n[i++]=d>>>16&255,n[i++]=d>>>24&255,n[i++]=f>>>0&255,n[i++]=f>>>8&255,n[i++]=f>>>16&255,n[i]=f>>>24&255}function fy(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0;n[i++]=a>>>0&511,n[i++]=a>>>9&511,n[i++]=a>>>18&511,n[i++]=(a>>>27|(o&15)<<5)&511,n[i++]=o>>>4&511,n[i++]=o>>>13&511,n[i++]=o>>>22&511,n[i++]=(o>>>31|(s&255)<<1)&511,n[i++]=s>>>8&511,n[i++]=s>>>17&511,n[i++]=(s>>>26|(c&7)<<6)&511,n[i++]=c>>>3&511,n[i++]=c>>>12&511,n[i++]=c>>>21&511,n[i++]=(c>>>30|(l&127)<<2)&511,n[i++]=l>>>7&511,n[i++]=l>>>16&511,n[i++]=(l>>>25|(u&3)<<7)&511,n[i++]=u>>>2&511,n[i++]=u>>>11&511,n[i++]=u>>>20&511,n[i++]=(u>>>29|(d&63)<<3)&511,n[i++]=d>>>6&511,n[i++]=d>>>15&511,n[i++]=(d>>>24|(f&1)<<8)&511,n[i++]=f>>>1&511,n[i++]=f>>>10&511,n[i++]=f>>>19&511,n[i++]=(f>>>28|(p&31)<<4)&511,n[i++]=p>>>5&511,n[i++]=p>>>14&511,n[i]=p>>>23&511}function py(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0;n[i++]=a>>>0&1023,n[i++]=a>>>10&1023,n[i++]=a>>>20&1023,n[i++]=(a>>>30|(o&255)<<2)&1023,n[i++]=o>>>8&1023,n[i++]=o>>>18&1023,n[i++]=(o>>>28|(s&63)<<4)&1023,n[i++]=s>>>6&1023,n[i++]=s>>>16&1023,n[i++]=(s>>>26|(c&15)<<6)&1023,n[i++]=c>>>4&1023,n[i++]=c>>>14&1023,n[i++]=(c>>>24|(l&3)<<8)&1023,n[i++]=l>>>2&1023,n[i++]=l>>>12&1023,n[i++]=l>>>22&1023,n[i++]=u>>>0&1023,n[i++]=u>>>10&1023,n[i++]=u>>>20&1023,n[i++]=(u>>>30|(d&255)<<2)&1023,n[i++]=d>>>8&1023,n[i++]=d>>>18&1023,n[i++]=(d>>>28|(f&63)<<4)&1023,n[i++]=f>>>6&1023,n[i++]=f>>>16&1023,n[i++]=(f>>>26|(p&15)<<6)&1023,n[i++]=p>>>4&1023,n[i++]=p>>>14&1023,n[i++]=(p>>>24|(m&3)<<8)&1023,n[i++]=m>>>2&1023,n[i++]=m>>>12&1023,n[i]=m>>>22&1023}function my(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0;n[i++]=a>>>0&2047,n[i++]=a>>>11&2047,n[i++]=(a>>>22|(o&1)<<10)&2047,n[i++]=o>>>1&2047,n[i++]=o>>>12&2047,n[i++]=(o>>>23|(s&3)<<9)&2047,n[i++]=s>>>2&2047,n[i++]=s>>>13&2047,n[i++]=(s>>>24|(c&7)<<8)&2047,n[i++]=c>>>3&2047,n[i++]=c>>>14&2047,n[i++]=(c>>>25|(l&15)<<7)&2047,n[i++]=l>>>4&2047,n[i++]=l>>>15&2047,n[i++]=(l>>>26|(u&31)<<6)&2047,n[i++]=u>>>5&2047,n[i++]=u>>>16&2047,n[i++]=(u>>>27|(d&63)<<5)&2047,n[i++]=d>>>6&2047,n[i++]=d>>>17&2047,n[i++]=(d>>>28|(f&127)<<4)&2047,n[i++]=f>>>7&2047,n[i++]=f>>>18&2047,n[i++]=(f>>>29|(p&255)<<3)&2047,n[i++]=p>>>8&2047,n[i++]=p>>>19&2047,n[i++]=(p>>>30|(m&511)<<2)&2047,n[i++]=m>>>9&2047,n[i++]=m>>>20&2047,n[i++]=(m>>>31|(h&1023)<<1)&2047,n[i++]=h>>>10&2047,n[i]=h>>>21&2047}function hy(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0,g=e[t+11]>>>0;n[i++]=a>>>0&4095,n[i++]=a>>>12&4095,n[i++]=(a>>>24|(o&15)<<8)&4095,n[i++]=o>>>4&4095,n[i++]=o>>>16&4095,n[i++]=(o>>>28|(s&255)<<4)&4095,n[i++]=s>>>8&4095,n[i++]=s>>>20&4095,n[i++]=c>>>0&4095,n[i++]=c>>>12&4095,n[i++]=(c>>>24|(l&15)<<8)&4095,n[i++]=l>>>4&4095,n[i++]=l>>>16&4095,n[i++]=(l>>>28|(u&255)<<4)&4095,n[i++]=u>>>8&4095,n[i++]=u>>>20&4095,n[i++]=d>>>0&4095,n[i++]=d>>>12&4095,n[i++]=(d>>>24|(f&15)<<8)&4095,n[i++]=f>>>4&4095,n[i++]=f>>>16&4095,n[i++]=(f>>>28|(p&255)<<4)&4095,n[i++]=p>>>8&4095,n[i++]=p>>>20&4095,n[i++]=m>>>0&4095,n[i++]=m>>>12&4095,n[i++]=(m>>>24|(h&15)<<8)&4095,n[i++]=h>>>4&4095,n[i++]=h>>>16&4095,n[i++]=(h>>>28|(g&255)<<4)&4095,n[i++]=g>>>8&4095,n[i]=g>>>20&4095}function gy(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0,g=e[t+11]>>>0,_=e[t+12]>>>0,v=e[t+13]>>>0,y=e[t+14]>>>0,b=e[t+15]>>>0;n[i++]=a>>>0&65535,n[i++]=a>>>16&65535,n[i++]=o>>>0&65535,n[i++]=o>>>16&65535,n[i++]=s>>>0&65535,n[i++]=s>>>16&65535,n[i++]=c>>>0&65535,n[i++]=c>>>16&65535,n[i++]=l>>>0&65535,n[i++]=l>>>16&65535,n[i++]=u>>>0&65535,n[i++]=u>>>16&65535,n[i++]=d>>>0&65535,n[i++]=d>>>16&65535,n[i++]=f>>>0&65535,n[i++]=f>>>16&65535,n[i++]=p>>>0&65535,n[i++]=p>>>16&65535,n[i++]=m>>>0&65535,n[i++]=m>>>16&65535,n[i++]=h>>>0&65535,n[i++]=h>>>16&65535,n[i++]=g>>>0&65535,n[i++]=g>>>16&65535,n[i++]=_>>>0&65535,n[i++]=_>>>16&65535,n[i++]=v>>>0&65535,n[i++]=v>>>16&65535,n[i++]=y>>>0&65535,n[i++]=y>>>16&65535,n[i++]=b>>>0&65535,n[i]=b>>>16&65535}function _y(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0;n[i++]=t>>>0&1,n[i++]=t>>>1&1,n[i++]=t>>>2&1,n[i++]=t>>>3&1,n[i++]=t>>>4&1,n[i++]=t>>>5&1,n[i++]=t>>>6&1,n[i++]=t>>>7&1,n[i++]=t>>>8&1,n[i++]=t>>>9&1,n[i++]=t>>>10&1,n[i++]=t>>>11&1,n[i++]=t>>>12&1,n[i++]=t>>>13&1,n[i++]=t>>>14&1,n[i++]=t>>>15&1,n[i++]=t>>>16&1,n[i++]=t>>>17&1,n[i++]=t>>>18&1,n[i++]=t>>>19&1,n[i++]=t>>>20&1,n[i++]=t>>>21&1,n[i++]=t>>>22&1,n[i++]=t>>>23&1,n[i++]=t>>>24&1,n[i++]=t>>>25&1,n[i++]=t>>>26&1,n[i++]=t>>>27&1,n[i++]=t>>>28&1,n[i++]=t>>>29&1,n[i++]=t>>>30&1,n[i++]=t>>>31&1}}function vy(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0;n[i++]=t>>>0&3,n[i++]=t>>>2&3,n[i++]=t>>>4&3,n[i++]=t>>>6&3,n[i++]=t>>>8&3,n[i++]=t>>>10&3,n[i++]=t>>>12&3,n[i++]=t>>>14&3,n[i++]=t>>>16&3,n[i++]=t>>>18&3,n[i++]=t>>>20&3,n[i++]=t>>>22&3,n[i++]=t>>>24&3,n[i++]=t>>>26&3,n[i++]=t>>>28&3,n[i++]=t>>>30&3,n[i++]=r>>>0&3,n[i++]=r>>>2&3,n[i++]=r>>>4&3,n[i++]=r>>>6&3,n[i++]=r>>>8&3,n[i++]=r>>>10&3,n[i++]=r>>>12&3,n[i++]=r>>>14&3,n[i++]=r>>>16&3,n[i++]=r>>>18&3,n[i++]=r>>>20&3,n[i++]=r>>>22&3,n[i++]=r>>>24&3,n[i++]=r>>>26&3,n[i++]=r>>>28&3,n[i++]=r>>>30&3}}function yy(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0;n[i++]=t>>>0&7,n[i++]=t>>>3&7,n[i++]=t>>>6&7,n[i++]=t>>>9&7,n[i++]=t>>>12&7,n[i++]=t>>>15&7,n[i++]=t>>>18&7,n[i++]=t>>>21&7,n[i++]=t>>>24&7,n[i++]=t>>>27&7,n[i++]=(t>>>30|(r&1)<<2)&7,n[i++]=r>>>1&7,n[i++]=r>>>4&7,n[i++]=r>>>7&7,n[i++]=r>>>10&7,n[i++]=r>>>13&7,n[i++]=r>>>16&7,n[i++]=r>>>19&7,n[i++]=r>>>22&7,n[i++]=r>>>25&7,n[i++]=r>>>28&7,n[i++]=(r>>>31|(o&3)<<1)&7,n[i++]=o>>>2&7,n[i++]=o>>>5&7,n[i++]=o>>>8&7,n[i++]=o>>>11&7,n[i++]=o>>>14&7,n[i++]=o>>>17&7,n[i++]=o>>>20&7,n[i++]=o>>>23&7,n[i++]=o>>>26&7,n[i++]=o>>>29&7}}function by(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0;n[i++]=t>>>0&15,n[i++]=t>>>4&15,n[i++]=t>>>8&15,n[i++]=t>>>12&15,n[i++]=t>>>16&15,n[i++]=t>>>20&15,n[i++]=t>>>24&15,n[i++]=t>>>28&15,n[i++]=r>>>0&15,n[i++]=r>>>4&15,n[i++]=r>>>8&15,n[i++]=r>>>12&15,n[i++]=r>>>16&15,n[i++]=r>>>20&15,n[i++]=r>>>24&15,n[i++]=r>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15}}function xy(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0;n[i++]=t>>>0&31,n[i++]=t>>>5&31,n[i++]=t>>>10&31,n[i++]=t>>>15&31,n[i++]=t>>>20&31,n[i++]=t>>>25&31,n[i++]=(t>>>30|(r&7)<<2)&31,n[i++]=r>>>3&31,n[i++]=r>>>8&31,n[i++]=r>>>13&31,n[i++]=r>>>18&31,n[i++]=r>>>23&31,n[i++]=(r>>>28|(o&1)<<4)&31,n[i++]=o>>>1&31,n[i++]=o>>>6&31,n[i++]=o>>>11&31,n[i++]=o>>>16&31,n[i++]=o>>>21&31,n[i++]=o>>>26&31,n[i++]=(o>>>31|(s&15)<<1)&31,n[i++]=s>>>4&31,n[i++]=s>>>9&31,n[i++]=s>>>14&31,n[i++]=s>>>19&31,n[i++]=s>>>24&31,n[i++]=(s>>>29|(c&3)<<3)&31,n[i++]=c>>>2&31,n[i++]=c>>>7&31,n[i++]=c>>>12&31,n[i++]=c>>>17&31,n[i++]=c>>>22&31,n[i++]=c>>>27&31}}function Sy(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0;n[i++]=t>>>0&63,n[i++]=t>>>6&63,n[i++]=t>>>12&63,n[i++]=t>>>18&63,n[i++]=t>>>24&63,n[i++]=(t>>>30|(r&15)<<2)&63,n[i++]=r>>>4&63,n[i++]=r>>>10&63,n[i++]=r>>>16&63,n[i++]=r>>>22&63,n[i++]=(r>>>28|(o&3)<<4)&63,n[i++]=o>>>2&63,n[i++]=o>>>8&63,n[i++]=o>>>14&63,n[i++]=o>>>20&63,n[i++]=o>>>26&63,n[i++]=s>>>0&63,n[i++]=s>>>6&63,n[i++]=s>>>12&63,n[i++]=s>>>18&63,n[i++]=s>>>24&63,n[i++]=(s>>>30|(c&15)<<2)&63,n[i++]=c>>>4&63,n[i++]=c>>>10&63,n[i++]=c>>>16&63,n[i++]=c>>>22&63,n[i++]=(c>>>28|(l&3)<<4)&63,n[i++]=l>>>2&63,n[i++]=l>>>8&63,n[i++]=l>>>14&63,n[i++]=l>>>20&63,n[i++]=l>>>26&63}}function Cy(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0,u=e[a++]>>>0;n[i++]=t>>>0&127,n[i++]=t>>>7&127,n[i++]=t>>>14&127,n[i++]=t>>>21&127,n[i++]=(t>>>28|(r&7)<<4)&127,n[i++]=r>>>3&127,n[i++]=r>>>10&127,n[i++]=r>>>17&127,n[i++]=r>>>24&127,n[i++]=(r>>>31|(o&63)<<1)&127,n[i++]=o>>>6&127,n[i++]=o>>>13&127,n[i++]=o>>>20&127,n[i++]=(o>>>27|(s&3)<<5)&127,n[i++]=s>>>2&127,n[i++]=s>>>9&127,n[i++]=s>>>16&127,n[i++]=s>>>23&127,n[i++]=(s>>>30|(c&31)<<2)&127,n[i++]=c>>>5&127,n[i++]=c>>>12&127,n[i++]=c>>>19&127,n[i++]=(c>>>26|(l&1)<<6)&127,n[i++]=l>>>1&127,n[i++]=l>>>8&127,n[i++]=l>>>15&127,n[i++]=l>>>22&127,n[i++]=(l>>>29|(u&15)<<3)&127,n[i++]=u>>>4&127,n[i++]=u>>>11&127,n[i++]=u>>>18&127,n[i++]=u>>>25&127}}function wy(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0,u=e[a++]>>>0,d=e[a++]>>>0;n[i++]=t>>>0&255,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=r>>>0&255,n[i++]=r>>>8&255,n[i++]=r>>>16&255,n[i++]=r>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=d>>>0&255,n[i++]=d>>>8&255,n[i++]=d>>>16&255,n[i++]=d>>>24&255}}function Ty(e,t,n,r){let i=r,a=t;for(let t=0;t<128;t++){let t=e[a++]>>>0;n[i++]=t&65535,n[i++]=t>>>16&65535}}function Ey(e,t,n,r,i){let a=$v[i]>>>0,o=t,s=0,c=e[o]>>>0,l=r;for(let t=0;t<8;t++){for(let t=0;t<32;t++)if(s+i<=32){let r=c>>>s&a;n[l+t]=r|0,s+=i,s===32&&(s=0,o++,t!==31&&(c=e[o]>>>0))}else{let r=32-s,u=c>>>s;o++,c=e[o]>>>0;let d=i-r,f=-1>>>32-d>>>0,p=(u|(c&f)<>>0)}}const Dy=ry(ey),Oy=3*Dy/256+Dy|0;function ky(){let e=new Uint8Array(Oy);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 Ay(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:ky()}}function jy(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let n=new Uint32Array(Math.max(16,t*2));return e.encodedWords=n,n}function My(e,t,n,r){r.byteContainer.length>>2;if(i.byteOffset&3)for(let n=0;n>>8&255,i[a+2|0]=r>>>16&255,i[a+3|0]=r>>>24&255}else{let n=r.byteContainerI32;(!n||n.buffer!==i.buffer||n.byteOffset!==i.byteOffset||n.length>>2)),n.set(e.subarray(t,t+a))}let o=n&3;if(o>0){let n=e[t+a|0]|0,r=a<<2;for(let e=0;e>>(e<<3)&255}return i}function Ny(e,t,n){let r=e[t++]|0,i=n.dataToBePacked;for(let a=2;a<=32;a=a+1|0){if(!(r>>>a-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${a}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let o=e[t++]>>>0,s=ny(o),c=o*a+31>>>5;if(t+c>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${a}, size=${o}, streamWordIndex=${t}, needWords=${c}, availableWords=${e.length-t}, encodedWords=${e.length})`);let l=i[a];(!l||l.length>>5)|0,n.exceptionSizes[a]=o}return t}function Py(e,t,n,r,i){switch(i){case 1:_y(e,t,n,r);break;case 2:vy(e,t,n,r);break;case 3:yy(e,t,n,r);break;case 4:by(e,t,n,r);break;case 5:xy(e,t,n,r);break;case 6:Sy(e,t,n,r);break;case 7:Cy(e,t,n,r);break;case 8:wy(e,t,n,r);break;case 16:Ty(e,t,n,r);break;default:Ey(e,t,n,r,i);break}return t+(i<<3)|0}function Fy(e,t,n,r){if(n+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${n}, byteSize=${t})`);let i=e[n++],a=e[n++];if(i>32)throw Error(`FastPFOR decode: invalid bitWidth=${i} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:i,exceptionCount:a,bytePosIn:n}}function Iy(e,t,n,r,i,a){if(n+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${a} (need 1 byte for maxBits, bytePos=${n}, byteSize=${t})`);let o=e[n++];if(o32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${a} (bitWidth=${r}, expected ${r}..32)`);let s=o-r|0;if(s<1||s>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${s} at block=${a} (bitWidth=${r}, maxBits=${o})`);if(n+i>t)throw Error(`FastPFOR decode: exception positions underflow at block=${a} (need=${i}, have=${t-n})`);return{maxBits:o,exceptionBitWidth:s,bytePosIn:n}}function Ly(e,t,n,r,i,a,o,s,c){let{maxBits:l,exceptionBitWidth:u,bytePosIn:d}=Iy(i,a,o,n,r,c);if(o=d,u===1){let a=1<h)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${m}, need ${r}, size=${h}) at block ${c}`);for(let a=0;a0&&(d=Ly(i,f,r,o,s,c,d,l,t))}if(u!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${n}, consumedPackedEnd=${u}, expectedPackedEnd=${r}, packedWords=${r-n}, encoded.length=${e.length})`)}function zy(e,t,n,r,i,a){let o=n|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 c=o+1|0,l=o+s|0,u=e[l]>>>0,d=u+3>>>2,f=l+1,p=f+d;if(p>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${u} (metaInts=${d}, pageStart=${o}, packedEnd=${l}, byteContainerStart=${f}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let m=My(e,f,u,a),h=u,g=Ny(e,p,a);return a.dataPointers.fill(0),Ry(e,o,c,l,t,r|0,i/256|0,m,h,a),g}function By(e,t,n,r,i,a){let o=r+ty(i,256),s=r,c=n;for(;s!==o;){let n=Math.min(Dy,o-s);c=zy(e,t,c,s,n,a),s=s+n|0}return c}function Vy(e,t,n,r,i,a){if(a===0)return t;let o=0,s=t,c=t+n,l=i,u=i,d=i+a,f=0,p=0;for(;s>>o&255;if(o+=8,s+=o>>>5,o&=31,f|=(t&127)<28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${f}, decoded=${u-l}/${a}, inPos=${s}, inEnd=${c})`)}if(u!==d)throw Error(`FastPFOR VByte: truncated stream (decoded=${u-l}, expected=${a}, consumedWords=${s-t}/${n}, vbyteStart=${t}, vbyteEnd=${c})`);return s}function Hy(e,t,n){let r=0,i=0,a=new Uint32Array(t),o=n??ky();if(e.length>0){let t=e[r]|0;if(r=r+1|0,t&255)throw Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(i+t>a.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${i}, alignedLength=${t}, out.length=${a.length})`);r=By(e,a,r,i,t,o),i=i+t|0}let s=e.length-r|0,c=t-i|0;return Vy(e,r,s,a,i,c),a}function Uy(e,t,n,r,i){switch(i){case 2:ay(e,t,n,r);return;case 3:oy(e,t,n,r);return;case 4:sy(e,t,n,r);return;case 5:cy(e,t,n,r);return;case 6:ly(e,t,n,r);return;case 7:uy(e,t,n,r);return;case 8:dy(e,t,n,r);return;case 9:fy(e,t,n,r);return;case 10:py(e,t,n,r);return;case 11:my(e,t,n,r);return;case 12:hy(e,t,n,r);return;case 16:gy(e,t,n,r);return;case 32:for(let i=0;i<32;i=i+1|0)n[r+i|0]=e[t+i|0]|0;return;default:break}let a=$v[i]>>>0,o=t,s=0,c=e[o]>>>0;for(let t=0;t<32;t++)if(s+i<=32){let l=c>>>s&a;n[r+t]=l|0,s+=i,s===32&&(s=0,o++,t!==31&&(c=e[o]>>>0))}else{let l=32-s,u=c>>>s;o++,c=e[o]>>>0;let d=$v[i-l]>>>0,f=(u|(c&d)<e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${n}, bytes.length=${e.length})`);let i=Math.floor(n/4),a=n%4!=0,o=a?i+1:i;if(r.length0){let n=e.byteOffset+t;if(n&3)for(let n=0;n=64)throw Error(`Varint too long`)}return t.set(i),n}function Jy(e,t,n){let r=new Float64Array(n);for(let i=0;i>4,i<128||(i=t[n.get()],n.increment(),r|=(i&127)<<3,i<128)||(i=t[n.get()],n.increment(),r|=(i&127)<<10,i<128)||(i=t[n.get()],n.increment(),r|=(i&127)<<17,i<128)||(i=t[n.get()],n.increment(),r|=(i&127)<<24,i<128)||(i=t[n.get()],n.increment(),r|=(i&1)<<31,i<128))return r*4294967296+(e>>>0);throw Error(`Expected varint not more than 10 bytes`)}function Zy(e,t,n,r){return Qy(e,t,n,r,Ay(n>>>2))}function Qy(e,t,n,r,i){let a=r.get();if(n&3)throw Error(`FastPFOR: invalid encodedByteLength=${n} at offset=${a} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=n>>>2,s=jy(i,o);Wy(e,a,n,s);let c=Hy(s.subarray(0,o),t,i.decoderWorkspace);return r.add(n),c}function Q(e){return e>>>1^-(e&1)}function $y(e){return e>>1n^-(e&1n)}function eb(e){return e%2==1?(e+1)/-2:e/2}function tb(e){let t=new Int32Array(e.length);for(let n=0;n=4)for(;r=4)for(;r=4)for(;n=4)for(let r=e[0];n=4)for(;r=4)for(;c>>0;for(let n=1;n>>0;return t}function wb(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,$y(e[0]));for(let n=1;n>>0,t[1]=Q(e[1])>>>0;for(let n=2;n>>0,t[n+1]=t[n-1]+Q(e[n+1])>>>0;return t}function Eb(e,t,n,r){let i=gb(e,t,n,r);return new Uint32Array(i)}function Db(e){return e[1]}function Ob(e){return Q(e[1])}function kb(e){if(e.length===2){let t=Q(e[1]);return[t,t]}return[Q(e[2]),Q(e[3])]}function Ab(e){return e[1]}function jb(e){return $y(e[1])}function Mb(e){if(e.length===2){let t=$y(e[1]);return[t,t]}return[$y(e[2]),$y(e[3])]}var Nb;(function(e){e.PRESENT=`PRESENT`,e.DATA=`DATA`,e.OFFSET=`OFFSET`,e.LENGTH=`LENGTH`})(Nb||={});var Pb;(function(e){e.NONE=`NONE`,e.SINGLE=`SINGLE`,e.SHARED=`SHARED`,e.VERTEX=`VERTEX`,e.MORTON=`MORTON`,e.FSST=`FSST`})(Pb||={});var Fb;(function(e){e.VERTEX=`VERTEX`,e.INDEX=`INDEX`,e.STRING=`STRING`,e.KEY=`KEY`})(Fb||={});var Ib;(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`})(Ib||={});const Lb=[Nb.PRESENT,Nb.DATA,Nb.OFFSET,Nb.LENGTH],Rb=[Z.NONE,Z.DELTA,Z.COMPONENTWISE_DELTA,Z.RLE,Z.MORTON,Z.PDE],zb=[Zv.NONE,Zv.FAST_PFOR,Zv.VARINT],Bb=[Pb.NONE,Pb.SINGLE,Pb.SHARED,Pb.VERTEX,Pb.MORTON,Pb.FSST],Vb=[Fb.VERTEX,Fb.INDEX,Fb.STRING,Fb.KEY],Hb=[Ib.VAR_BINARY,Ib.GEOMETRIES,Ib.PARTS,Ib.RINGS,Ib.TRIANGLES,Ib.SYMBOL,Ib.DICTIONARY];function Ub(e,t){let n=Kb(e,t);return n.logicalLevelTechnique1===Z.MORTON?Wb(n,e,t):(Z.RLE===n.logicalLevelTechnique1||Z.RLE===n.logicalLevelTechnique2)&&Zv.NONE!==n.physicalLevelTechnique?Gb(n,e,t):n}function Wb(e,t,n){let r=Gy(t,n,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 Gb(e,t,n){let r=Gy(t,n,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 Kb(e,t){let n=e[t.get()],r=Lb[n>>4],i={};switch(r){case Nb.DATA:i={dictionaryType:Bb[n&15]};break;case Nb.OFFSET:i={offsetType:Vb[n&15]};break;case Nb.LENGTH:i={lengthType:Hb[n&15]};break}t.increment();let a=e[t.get()],o=Rb[a>>5],s=Rb[a>>2&7],c=zb[a&3];t.increment();let l=Gy(e,t,2),u=l[0],d=l[1];return{physicalStreamType:r,logicalStreamType:i,logicalLevelTechnique1:o,logicalLevelTechnique2:s,physicalLevelTechnique:c,numValues:u,byteLength:d,decompressedCount:u}}var $;(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`})($||={});var qb=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),n=e%8;return(this.values[t]>>n&1)==1}set(e,t){let n=Math.floor(e/8),r=e%8;this.values[n]=this.values[n]|+!!t<>n&1}size(){return this._size}getBuffer(){return this.values}};function Jb(e,t,n){if(!t)return e;let r=t.size(),i=e.constructor,a=new i(r),o=0;for(let i=0;i>1,t)-n}}function xx(e,t){let n=0;for(let r=0;r>r;return n}var Sx;(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`})(Sx||={});var Cx;(function(e){e[e.POINT=0]=`POINT`,e[e.LINESTRING=1]=`LINESTRING`,e[e.POLYGON=2]=`POLYGON`})(Cx||={});var wx;(function(e){e[e.MORTON=0]=`MORTON`,e[e.VEC_2=1]=`VEC_2`,e[e.VEC_3=2]=`VEC_3`})(wx||={});function Tx(e){let t=Array(e.numGeometries),n=1,r=1,i=1,a=0,o=0,s=0,c=e.mortonSettings,u=e.topologyVector,d=u.geometryOffsets,f=u.partOffsets,p=u.ringOffsets,m=e.vertexOffsets,h=!m||m.length===0,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let u=0;u[e]),n+=e,r+=e}break;case Sx.LINESTRING:{let l;g?(l=p[r]-p[r-1],r++):l=f[n]-f[n-1],n++;let u;h?(u=Dx(_,o,l,!1),o+=l*2):(u=Ex(e.vertexBufferType,_,m,s,l,!1,c),s+=l),t[a++]=[u],d&&i++}break;case Sx.POLYGON:{let l=f[n]-f[n-1];n++;let u=Array(l-1),g,v=p[r]-p[r-1];if(r++,h){g=Dx(_,o,v,!0),o+=v*2;for(let e=0;e0&&t.push(t[0]),d.push(t)}e[t]=d,i&&c++}break;case Sx.MULTIPOLYGON:{let u=i[c]-i[c-1];c++;let d=[];for(let e=0;e0&&t.push(t[0]),d.push(t)}}e[t]=d}break}return e}[Symbol.iterator](){return null}};function Rx(e,t,n,r,i,a){return new zx(e,t,n,r,i,a)}var zx=class extends Lx{constructor(e,t,n,r,i,a){super(n,r,i,a),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function Bx(e,t,n,r,i){return new Vx(e,t,n,r,i)}var Vx=class extends Lx{constructor(e,t,n,r,i){super(t,n,r,i),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function Hx(e,t,n,r,i){let a=Ub(e,n),o=hx(a,r,e,n),s,c,l,u;if(o===$.CONST){let o=tx(e,n,a),d,f,p,m;for(let r=0;rn?t[a++]:1);return r}function Wx(e,t,n,r){let i=new Uint32Array(t[t.length-1]+1),a=0;i[0]=a;let o=1,s=0;for(let c=0;c=o);){let n=e[r.increment()];if(n<=127){let o=n+3,s=e[r.increment()],c=Math.min(a+o,t);i.fill(s,a,c),a=c}else{let o=256-n;for(let n=0;n=12?tS.decode(e.subarray(t,n)):rS(e,t,n)}function rS(e,t,n){let r=``,i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+o>n)break;let s,c,l;o===1?t<128&&(a=t):o===2?(s=e[i+1],(s&192)==128&&(a=(t&31)<<6|s&63,a<=127&&(a=null))):o===3?(s=e[i+1],c=e[i+2],(s&192)==128&&(c&192)==128&&(a=(t&15)<<12|(s&63)<<6|c&63,(a<=2047||a>=55296&&a<=57343)&&(a=null))):o===4&&(s=e[i+1],c=e[i+2],l=e[i+3],(s&192)==128&&(c&192)==128&&(l&192)==128&&(a=(t&15)<<18|(s&63)<<12|(c&63)<<6|l&63,(a<=65535||a>=1114112)&&(a=null))),a===null?(a=65533,o=1):a>65535&&(a-=65536,r+=String.fromCharCode(a>>>10&1023|55296),a=56320|a&1023),r+=String.fromCharCode(a),i+=o}return r}var iS=class extends zv{constructor(e,t,n,r){super(e,n,r),this.offsetBuffer=t}},aS=class extends iS{constructor(e,t,n,r){super(e,t,n,r??t.length-1)}getValueFromBuffer(e){let t=this.offsetBuffer[e],n=this.offsetBuffer[e+1];return nS(this.dataBuffer,t,n)}},oS=class extends iS{constructor(e,t,n,r,i){super(e,n,r,i??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e],n=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return nS(this.dataBuffer,n,r)}};function sS(e,t,n){let r=[],i=Array(t.length).fill(0);for(let e=1;e1&&!c.nullable||l===1&&c.nullable)throw Error(`The number of streams for the child field ${c.name} does not match its nullability. nullibilty: ${c.nullable}, numStreams: ${l}`);let p;if(c.nullable){let n=Ub(e,t);p=new qb(Zx(e,n.numValues,n.byteLength,t),n.numValues)}let m=Zb(e,t,Ub(e,t),void 0,p);u[d++]=s?new cS(f,m,i,a,o,s,p):new oS(f,m,i,a,p)}return u}function mS(e,t,n,r,i,a){return n.type===`scalarType`?a&&!a.has(n.name)?(Xx(r,e,t),null):hS(r,e,t,i,n.scalarType,n):r===0?null:pS(e,t,n,a)}function hS(e,t,n,r,i,a){let o=null;if(e===0)return null;if(a.nullable){let e=Ub(t,n),r=e.numValues,i=n.get(),a=Zx(t,r,e.byteLength,n);n.set(i+e.byteLength),o=new qb(a,e.numValues)}let s=o??r;switch(i.physicalType){case X.UINT_32:case X.INT_32:return bS(t,n,a,i,s);case X.STRING:{let r=a.nullable?e-1:e;return lS(a.name,t,n,r,o)}case X.BOOLEAN:return gS(t,n,a,r,s);case X.UINT_64:case X.INT_64:return yS(t,n,a,s,i);case X.FLOAT:return _S(t,n,a,s);case X.DOUBLE:return vS(t,n,a,s);default:throw Error(`The specified data type for the field is currently not supported: ${i}`)}}function gS(e,t,n,r,i){let a=Ub(e,t),o=a.numValues,s=t.get(),c=xS(i)?i:void 0,l=Zx(e,o,a.byteLength,t,c);t.set(s+a.byteLength);let u=new qb(l,o);return new qx(n.name,u,i)}function _S(e,t,n,r){let i=Ub(e,t),a=xS(r)?r:void 0,o=$x(e,t,i.numValues,a);return new Jx(n.name,o,r)}function vS(e,t,n,r){let i=Ub(e,t),a=xS(r)?r:void 0,o=eS(e,t,i.numValues,a);return new Hv(n.name,o,r)}function yS(e,t,n,r,i){let a=Ub(e,t),o=hx(a,r,e,t,`int64`),s=i.physicalType===X.INT_64;if(o===$.FLAT){let i=xS(r)?r:void 0,o=s?ix(e,t,a,i):ax(e,t,a,i);return new vx(n.name,o,r)}if(o===$.SEQUENCE){let r=rx(e,t,a);return new yx(n.name,r[0],r[1],a.numRleValues)}let c=s?sx(e,t,a):cx(e,t,a);return new Yx(n.name,c,r,s)}function bS(e,t,n,r,i){let a=Ub(e,t),o=hx(a,i,e,t),s=r.physicalType===X.INT_32;if(o===$.FLAT){let r=xS(i)?i:void 0,o=s?Xb(e,t,a,void 0,r):Zb(e,t,a,void 0,r);return new Vv(n.name,o,i)}if(o===$.SEQUENCE){let r=nx(e,t,a);return new Wv(n.name,r[0],r[1],a.numRleValues)}let c=s?ex(e,t,a):tx(e,t,a);return new Gv(n.name,c,i,s)}function xS(e){return e instanceof qb}function SS(e){switch(e){case 0:case 1:case 2:case 3:{let t={};t.nullable=(e&1)!=0,t.columnScope=qv.FEATURE;let n={};return n.type=`logicalType`,n.logicalType=Yv.ID,n.longID=(e&2)!=0,t.scalarType=n,t.type=`scalarType`,t}case 4:{let e={};e.nullable=!1,e.columnScope=qv.FEATURE;let t={};return t.type=`physicalType`,t.physicalType=Jv.GEOMETRY,e.type=`complexType`,e.complexType=t,e}case 30:{let e={};e.nullable=!1,e.columnScope=qv.FEATURE;let t={};return t.type=`physicalType`,t.physicalType=Jv.STRUCT,e.type=`complexType`,e.complexType=t,e}default:return OS(e)}}function CS(e){return e>=10}function wS(e){return e===30}function TS(e){if(e.type===`scalarType`){let t=e.scalarType;if(t.type===`physicalType`)switch(t.physicalType){case X.BOOLEAN:case X.INT_8:case X.UINT_8:case X.INT_32:case X.UINT_32:case X.INT_64:case X.UINT_64:case X.FLOAT:case X.DOUBLE:return!1;case X.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 Jv.GEOMETRY:case Jv.STRUCT:return!0;default:return!1}}return console.warn(`Unexpected column type in hasStreamCount`,e),!1}function ES(e){return e.type===`scalarType`&&e.scalarType?.type===`logicalType`&&e.scalarType.logicalType===Yv.ID}function DS(e){return e.type===`complexType`&&e.complexType?.type===`physicalType`&&e.complexType.physicalType===Jv.GEOMETRY}function OS(e){let t;switch(e){case 10:case 11:t=X.BOOLEAN;break;case 12:case 13:t=X.INT_8;break;case 14:case 15:t=X.UINT_8;break;case 16:case 17:t=X.INT_32;break;case 18:case 19:t=X.UINT_32;break;case 20:case 21:t=X.INT_64;break;case 22:case 23:t=X.UINT_64;break;case 24:case 25:t=X.FLOAT;break;case 26:case 27:t=X.DOUBLE;break;case 28:case 29:t=X.STRING;break;default:return null}let n={};n.nullable=(e&1)!=0,n.columnScope=qv.FEATURE;let r={};return r.type=`physicalType`,r.physicalType=t,n.type=`scalarType`,n.scalarType=r,n}const kS=new TextDecoder;function AS(e,t){let n=Gy(e,t,1)[0];if(n===0)return``;let r=t.get(),i=r+n,a=e.subarray(r,i);return t.add(n),kS.decode(a)}function jS(e){return{name:e.name,nullable:e.nullable,scalarField:e.scalarType,complexField:e.complexType,type:e.type===`scalarType`?`scalarField`:`complexField`}}function MS(e,t){let n=Gy(e,t,1)[0]>>>0;if(n<10||n>30)throw Error(`Unsupported field type code ${n}. Supported: 10-29(scalars), 30(STRUCT)`);let r=SS(n);if(CS(n)&&(r.name=AS(e,t)),wS(n)){let n=Gy(e,t,1)[0]>>>0;r.complexType.children=Array(n);for(let i=0;i>>0,r=SS(n);if(!r)throw Error(`Unsupported column type code ${n}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(CS(n)?r.name=AS(e,t):n>=0&&n<=3?r.name=`id`:n===4&&(r.name=`geometry`),wS(n)){let n=Gy(e,t,1)[0]>>>0,i=r.complexType;i.children=Array(n);for(let r=0;r>>0,a=Gy(e,t,1)[0]>>>0;r.columns=Array(a);for(let n=0;n>>0,o=r.get()+a;if(o>e.length)throw Error(`Block overruns tile: ${o} > ${e.length}`);if(Gy(e,r,1)[0]>>>0!=1){r.set(o);continue}let[s,c]=PS(e,r),l=s.featureTables[0],u=null,d=null,f=[],p=0;for(let i of l.columns){let a=i.name;if(ES(i)){let t=null;if(i.nullable){let n=Ub(e,r),i=r.get(),a=Zx(e,n.numValues,n.byteLength,r);r.set(i+n.byteLength),t=new qb(a,n.numValues)}let o=Ub(e,r);p=t?t.size():o.decompressedCount,u=IS(e,i,r,a,o,t??p,n)}else if(DS(i)){let n=Gy(e,r,1)[0];if(p===0){let t=r.get();p=Ub(e,r).decompressedCount,r.set(t)}t&&(t.scale=t.extent/c),d=Hx(e,n,r,p,t)}else{let t=TS(i)?Gy(e,r,1)[0]:1;if(t===0)continue;let n=mS(e,r,i,t,p,void 0);if(n)if(Array.isArray(n))for(let e of n)f.push(e);else f.push(n)}}let m=new Kv(l.name,d,u,f,c);i.push(m),r.set(o)}return i}function IS(e,t,n,r,i,a,o=!1){let s=t.scalarType;if(s?.type!==`logicalType`||s.logicalType!==Yv.ID)throw Error(`ID column must be a logical ID scalar type: ${r}`);let c=s.longID?X.UINT_64:X.UINT_32,l=typeof a==`number`?void 0:a,u=hx(i,a,e,n,c===X.UINT_64?`int64`:`int32`);if(c===X.UINT_32)switch(u){case $.FLAT:return new Vv(r,Zb(e,n,i,void 0,l),a);case $.SEQUENCE:{let t=nx(e,n,i);return new Wv(r,t[0],t[1],i.numRleValues)}case $.CONST:return new Gv(r,tx(e,n,i),a,!1)}switch(u){case $.FLAT:return o?new Hv(r,ox(e,n,i),a):new vx(r,ax(e,n,i,l),a);case $.SEQUENCE:{let t=rx(e,n,i);return new yx(r,t[0],t[1],i.numRleValues)}case $.CONST:return new Yx(r,cx(e,n,i),a,!1)}throw Error(`Vector type not supported for id column.`)}var LS=class{constructor(e,t){switch(this._featureData=e,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Sx.POINT:case Sx.MULTIPOINT:this.type=1;break;case Sx.LINESTRING:case Sx.MULTILINESTRING:this.type=2;break;case Sx.POLYGON:case Sx.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 n=[];for(let e of t)n.push(new l(e.x,e.y));e.push(n)}return e}},RS=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 LS(this.features[e],this.extent)}},zS=class{constructor(e){this.layers={};let t=FS(new Uint8Array(e));this.layers=t.reduce((e,t)=>({...e,[t.name]:new RS(t)}),{})}},BS=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 Oc(Ye,16,0),this.grid3D=new Oc(Ye,16,0),this.featureIndexArray=new du,this.promoteId=t}insert(e,t,n,r,i,a){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,r,i);let s=a?this.grid3D:this.grid;for(let e of t){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)t[0]=Math.min(t[0],n.x),t[1]=Math.min(t[1],n.y),t[2]=Math.max(t[2],n.x),t[3]=Math.max(t[3],n.y);t[0]<8192&&t[1]<8192&&t[2]>=0&&t[3]>=0&&s.insert(o,t[0],t[1],t[2],t[3])}}loadVTLayers(){if(!this.vtLayers){switch(this.encoding){case`mlt`:this.vtLayers=new zS(this.rawTileData).layers;break;default:this.vtLayers=new im(new jg(this.rawTileData)).layers}this.sourceLayerCoder=new Lv(this.vtLayers?Object.keys(this.vtLayers).sort():[Ev])}return this.vtLayers}query(e,t,n,r){this.loadVTLayers();let i=e.params,a=Ye/e.tileSize/e.scale,o=ps(i.filter,`queryRenderedFeatures filter`,i.globalState),s=e.queryGeometry,c=e.queryPadding*a,l=wv.fromPoints(s),u=this.grid.query(l.minX-c,l.minY-c,l.maxX+c,l.maxY+c),d=wv.fromPoints(e.cameraQueryGeometry).expandBy(c),f=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,n,r,i)=>Nd(e.cameraQueryGeometry,t-c,n-c,r+c,i+c));for(let e of f)u.push(e);u.sort(HS);let p={},m;for(let c of u){if(c===m)continue;m=c;let l=this.featureIndexArray.get(c),u=null;this.loadMatchingFeature(p,l.bucketIndex,l.sourceLayerIndex,l.featureIndex,o,i.layers,i.availableImages,t,n,r,(t,n,r)=>(u||=_d(t),n.queryIntersectsFeature({queryGeometry:s,feature:t,featureState:r,geometry:u,zoom:this.z,transform:e.transform,pixelsToTileUnits:a,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return p}loadMatchingFeature(e,t,n,r,i,a,o,s,c,l,u){let d=this.bucketLayerIDs[t];if(a&&!d.some(e=>a.has(e)))return;let f=this.sourceLayerCoder.decode(n),p=this.vtLayers[f].feature(r);if(i.needGeometry){let e=vd(p,!0);if(!i.filter(new W(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new W(this.tileID.overscaledZ),p))return;let m=this.getId(p,f);for(let t of d){if(a&&!a.has(t))continue;let n=s[t];if(!n)continue;let i={};m&&l&&(i=l.getState(n.sourceLayer||`_geojsonTileLayer`,m));let d=xt({},c[t]);d.paint=VS(d.paint,n.paint,p,i,o),d.layout=VS(d.layout,n.layout,p,i,o);let f=!u||u(p,n,i);if(!f)continue;let h=new Rv(p,this.z,this.x,this.y,m);h.layer=d;let g=e[t];g===void 0&&(g=e[t]=[]),g.push({featureIndex:r,feature:h,intersectionZ:f})}}lookupSymbolFeatures(e,t,n,r,i,a,o,s){let c={};this.loadVTLayers();let l=ps(i.filterSpec,`queryRenderedFeatures symbol filter`,i.globalState);for(let i of e)this.loadMatchingFeature(c,n,r,i,l,a,o,s,t);return c}hasLayer(e){for(let t of this.bucketLayerIDs)for(let n of t)if(e===n)return!0;return!1}getId(e,t){let n=e.id;if(this.promoteId){let r=typeof this.promoteId==`string`?this.promoteId:this.promoteId[t];n=e.properties[r],typeof n==`boolean`&&(n=Number(n)),n===void 0&&e.properties?.cluster&&this.promoteId&&(n=Number(e.properties.cluster_id))}return n}};U(`FeatureIndex`,BS,{omit:[`rawTileData`,`sourceLayerCoder`]});function VS(e,t,n,r,i){return At(e,(e,a)=>{let o=t instanceof dl?t.get(a):null;return o?.evaluate?o.evaluate(n,r,i):o})}function HS(e,t){return t-e}var US=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,n){let r=e.wrapped().key;this.data[r]===void 0&&(this.data[r]=[]);let i={value:t,timeout:void 0};if(n!==void 0&&(i.timeout=setTimeout(()=>{this.remove(e,i)},n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}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 n=e.wrapped().key,r=t===void 0?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let t=[];for(let n in this.data)for(let r of this.data[n])e(r.value)||t.push(r);for(let e of t)this.remove(e.value.tileID,e)}},WS=class{constructor(e){this.maxEntries=e,this.map=new Map}get(e){let t=this.map.get(e);return t!==void 0&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxEntries){let e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}};function GS(e,t,n,r,i){let a=[];for(let o of e){let e;for(let s=0;s=r&&u.x>=r)&&(c.x>=r?c=new l(r,c.y+(u.y-c.y)*((r-c.x)/(u.x-c.x)))._round():u.x>=r&&(u=new l(r,c.y+(u.y-c.y)*((r-c.x)/(u.x-c.x)))._round()),!(c.y>=i&&u.y>=i)&&(c.y>=i?c=new l(c.x+(u.x-c.x)*((i-c.y)/(u.y-c.y)),i)._round():u.y>=i&&(u=new l(c.x+(u.x-c.x)*((i-c.y)/(u.y-c.y)),i)._round()),(!e||!c.equals(e[e.length-1]))&&(e=[c],a.push(e)),e.push(u)))))}}return a}function KS(e,t,n,r,i,a){let o=qS(e,t,n,i,0);return o=qS(o,t,r,a,1),o}function qS(e,t,n,r,i){switch(t){case 1:return JS(e,n,r,i);case 2:return XS(e,n,r,i,!1);case 3:return XS(e,n,r,i,!0)}return[]}function JS(e,t,n,r){let i=[];for(let a of e)for(let e of a){let a=r===0?e.x:e.y;a>=t&&a<=n&&i.push([e])}return i}function YS(e,t,n,r,i){let a=r===0?ZS:QS,o=[],s=[];for(let c=0;ct&&o.push(a(l,u,t)):d>n?f=t&&(o.push(a(l,u,t)),p=!0),f>n&&d<=n&&(o.push(a(l,u,n)),p=!0),!i&&p&&(s.push(o),o=[])}let c=e.length-1,u=r===0?e[c].x:e[c].y;return u>=t&&u<=n&&o.push(e[c]),i&&o.length>0&&!o[0].equals(o[o.length-1])&&o.push(new l(o[0].x,o[0].y)),o.length>0&&s.push(o),s}function XS(e,t,n,r,i){let a=[];for(let o of e){let e=YS(o,t,n,r,i);e.length>0&&a.push(...e)}return a}function ZS(e,t,n){let r=(n-e.x)/(t.x-e.x);return new l(n,e.y+(t.y-e.y)*r)}function QS(e,t,n){let r=(n-e.y)/(t.y-e.y);return new l(e.x+(t.x-e.x)*r,n)}var $S=class e extends l{constructor(e,t,n,r){super(e,t),this.angle=n,r!==void 0&&(this.segment=r)}clone(){return new e(this.x,this.y,this.angle,this.segment)}};U(`Anchor`,$S);function eC(e,t,n,r,i){if(t.segment===void 0||n===0)return!0;let a=t,o=t.segment+1,s=0;for(;s>-n/2;){if(o--,o<0)return!1;s-=e[o].dist(a),a=e[o]}s+=e[o].dist(e[o+1]),o++;let c=[],l=0;for(;sr;)l-=c.shift().angleDelta;if(l>i)return!1;o++,s+=n.dist(a)}return!0}function tC(e){let t=0;for(let n=0;nl){let u=(l-c)/a,d=new $S(Di.number(r.x,i.x,u),Di.number(r.y,i.y,u),i.angleTo(r),n);return d._round(),!o||eC(e,d,s,o,t)?d:void 0}c+=a}}function aC(e,t,n,r,i,a,o,s,c){let l=nC(r,a,o),u=rC(r,i),d=u*o,f=e[0].x===0||e[0].x===c||e[0].y===0||e[0].y===c;t-d=0&&_=0&&v=0&&f+l<=u){let n=new $S(_,v,h,t);n._round(),(!r||eC(e,n,a,r,i))&&p.push(n)}}d+=m}return!s&&!p.length&&!o&&(p=oC(e,d/2,n,r,i,a,o,!0,c)),p}function sC(e,t,n,r){let i=[],a=e.image,o=a.pixelRatio,s=a.paddedRect.w-2,c=a.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},d=a.stretchX||[[0,s]],f=a.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],m=d.reduce(p,0),h=f.reduce(p,0),g=s-m,_=c-h,v=0,y=m,b=0,x=h,S=0,C=g,w=0,T=_;if(a.content&&r){let t=a.content,n=t[2]-t[0],r=t[3]-t[1];(a.textFitWidth||a.textFitHeight)&&(u=y_(e)),v=cC(d,0,t[0]),b=cC(f,0,t[1]),y=cC(d,t[0],t[2]),x=cC(f,t[1],t[3]),S=t[0]-v,w=t[1]-b,C=n-y,T=r-x}let E=u.x1,D=u.y1,O=u.x2-E,k=u.y2-D,A=(e,r,i,s)=>{let c=uC(e.stretch-v,y,O,E),u=dC(e.fixed-S,C,e.stretch,m),d=uC(r.stretch-b,x,k,D),f=dC(r.fixed-w,T,r.stretch,h),p=uC(i.stretch-v,y,O,E),g=dC(i.fixed-S,C,i.stretch,m),_=uC(s.stretch-b,x,k,D),A=dC(s.fixed-w,T,s.stretch,h),ee=new l(c,d),te=new l(p,d),ne=new l(p,_),re=new l(c,_),ie=new l(u/o,f/o),ae=new l(g/o,A/o),oe=t*Math.PI/180;if(oe){let e=Math.sin(oe),t=Math.cos(oe),n=[t,-e,e,t];ee._matMult(n),te._matMult(n),re._matMult(n),ne._matMult(n)}let se=e.stretch+e.fixed,ce=i.stretch+i.fixed,le=r.stretch+r.fixed,ue=s.stretch+s.fixed;return{tl:ee,tr:te,bl:re,br:ne,tex:{x:a.paddedRect.x+1+se,y:a.paddedRect.y+1+le,w:ce-se,h:ue-le},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ie,pixelOffsetBR:ae,minFontScaleX:C/o/O,minFontScaleY:T/o/k,isSDF:n}};if(!r||!a.stretchX&&!a.stretchY)i.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:s+1},{fixed:0,stretch:c+1}));else{let e=lC(d,g,m),t=lC(f,_,h);for(let n=0;n0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let c=a.image?.content&&(a.image.textFitWidth||a.image.textFitHeight)?y_(a):{x1:a.left,y1:a.top,x2:a.right,y2:a.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=a.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 e=new l(c.x1,c.y1),t=new l(c.x2,c.y1),n=new l(c.x1,c.y2),r=new l(c.x2,c.y2),i=u*Math.PI/180;e._rotate(i),t._rotate(i),n._rotate(i),r._rotate(i),c.x1=Math.min(e.x,t.x,n.x,r.x),c.x2=Math.max(e.x,t.x,n.x,r.x),c.y1=Math.min(e.y,t.y,n.y,r.y),c.y2=Math.max(e.y,t.y,n.y,r.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,n,r,i)}this.boxEndIndex=e.length}},mC=class{constructor(e=[],t=(e,t)=>et)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}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:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[r],e=r}t[e]=i}};function hC(e,t=1){let n=wv.fromPoints(e[0]),r=Math.min(n.width(),n.height()),i=r/2,a=new mC([],gC),{minX:o,minY:s,maxX:c,maxY:u}=n;if(r===0)return new l(o,s);for(let t=o;tf.d||!f.d)&&(f=n),!(n.max-f.d<=t)&&(i=n.h/2,a.push(new _C(n.p.x-i,n.p.y-i,i,e)),a.push(new _C(n.p.x+i,n.p.y-i,i,e)),a.push(new _C(n.p.x-i,n.p.y+i,i,e)),a.push(new _C(n.p.x+i,n.p.y+i,i,e)))}return d.d>0&&f.d-d.d<=t?d.p:f.p}function gC(e,t){return t.max-e.max}var _C=class{constructor(e,t,n,r){this.p=new l(e,t),this.h=n,this.d=vC(this.p,r),this.max=this.d+this.h*Math.SQRT2}};function vC(e,t){let n=!1,r=1/0;for(let i of t)for(let t=0,a=i.length,o=a-1;te.y!=s.y>e.y&&e.x<(s.x-a.x)*(e.y-a.y)/(s.y-a.y)+a.x&&(n=!n),r=Math.min(r,Ad(e,a,s))}return(n?1:-1)*Math.sqrt(r)}function yC(e){let t=0,n=0,r=0,i=e[0];for(let e=0,a=i.length,o=a-1;ee*24);r.startsWith(`top`)?i[1]-=7:r.startsWith(`bottom`)&&(i[1]+=7),t[n+1]=i}return new $r(t)}let a=r.get(`text-variable-anchor`);if(a){let i;i=e._unevaluatedLayout.getValue(`text-radial-offset`)===void 0?r.get(`text-offset`).evaluate(t,{},n).map(e=>e*24):[r.get(`text-radial-offset`).evaluate(t,{},n)*24,xC];let o=[];for(let e of a)o.push(e,SC(e,i));return new $r(o)}return null}function wC(e){e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=Ye/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let n=e.bucket.layers[0],r=n.layout,i=n._unevaluatedLayout._values,a={layoutIconSize:i[`icon-size`].possiblyEvaluate(new W(e.bucket.zoom+1),e.canonical),layoutTextSize:i[`text-size`].possiblyEvaluate(new W(e.bucket.zoom+1),e.canonical),textMaxSize:i[`text-size`].possiblyEvaluate(new W(18))};if(e.bucket.textSizeData.kind===`composite`){let{minZoom:t,maxZoom:n}=e.bucket.textSizeData;a.compositeTextSizes=[i[`text-size`].possiblyEvaluate(new W(t),e.canonical),i[`text-size`].possiblyEvaluate(new W(n),e.canonical)]}if(e.bucket.iconSizeData.kind===`composite`){let{minZoom:t,maxZoom:n}=e.bucket.iconSizeData;a.compositeIconSizes=[i[`icon-size`].possiblyEvaluate(new W(t),e.canonical),i[`icon-size`].possiblyEvaluate(new W(n),e.canonical)]}let o=r.get(`text-line-height`)*24,s=r.get(`text-rotation-alignment`)!==`viewport`&&r.get(`symbol-placement`)!==`point`,c=r.get(`text-keep-upright`),l=r.get(`text-size`);for(let t of e.bucket.features){let i=r.get(`text-font`).evaluate(t,{},e.canonical).join(`,`),u=l.evaluate(t,{},e.canonical),d=a.layoutTextSize.evaluate(t,{},e.canonical),f=a.layoutIconSize.evaluate(t,{},e.canonical),p={horizontal:{},vertical:void 0},m=t.text,h=[0,0];if(m){let a=m.toString(),l=r.get(`text-letter-spacing`).evaluate(t,{},e.canonical)*24,f=Wc(a)?l:0,g=r.get(`text-anchor`).evaluate(t,{},e.canonical),_=CC(n,t,e.canonical);if(!_){let n=r.get(`text-radial-offset`).evaluate(t,{},e.canonical);h=n?SC(g,[n*24,xC]):r.get(`text-offset`).evaluate(t,{},e.canonical).map(e=>e*24)}let v=s?`center`:r.get(`text-justify`).evaluate(t,{},e.canonical),y=r.get(`symbol-placement`)===`point`?r.get(`text-max-width`).evaluate(t,{},e.canonical)*24:1/0,b=()=>{e.bucket.allowVerticalPlacement&&Uc(a)&&(p.vertical=s_(m,e.glyphMap,e.glyphPositions,e.imagePositions,i,y,o,g,`left`,f,h,2,!0,d,u))};if(!s&&_){let t=new Set;if(v===`auto`)for(let e=0;e<_.values.length;e+=2)t.add(TC(_.values[e]));else t.add(v);let n=!1;for(let r of t)if(!p.horizontal[r])if(n)p.horizontal[r]=p.horizontal[0];else{let t=s_(m,e.glyphMap,e.glyphPositions,e.imagePositions,i,y,o,`center`,r,f,h,1,!1,d,u);t&&(p.horizontal[r]=t,n=t.positionedLines.length===1)}b()}else{v===`auto`&&(v=TC(g));let t=s_(m,e.glyphMap,e.glyphPositions,e.imagePositions,i,y,o,g,v,f,h,1,!1,d,u);t&&(p.horizontal[v]=t),b(),Uc(a)&&s&&c&&(p.vertical=s_(m,e.glyphMap,e.glyphPositions,e.imagePositions,i,y,o,g,v,f,h,2,!1,d,u))}}let g,_=!1;if(t.icon?.name){let n=e.imageMap[t.icon.name];n&&(g=v_(e.imagePositions[t.icon.name],r.get(`icon-offset`).evaluate(t,{},e.canonical),r.get(`icon-anchor`).evaluate(t,{},e.canonical)),_=!!n.sdf,e.bucket.sdfIcons===void 0?e.bucket.sdfIcons=_:e.bucket.sdfIcons!==_&&Ft(`Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer`),n.pixelRatio===e.bucket.pixelRatio?r.get(`icon-rotate`).constantOr(1)!==0&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let v=kC(p.horizontal)||p.vertical;e.bucket.iconsInText||=v?v.iconsInText:!1,(v||g)&&EC(e.bucket,t,p,g,e.imageMap,a,d,f,h,_,e.canonical,e.subdivisionGranularity)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}function TC(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 EC(e,t,n,r,i,a,o,s,c,l,u,d){let f=a.textMaxSize.evaluate(t,{});f===void 0&&(f=o);let p=e.layers[0].layout,m=p.get(`icon-offset`).evaluate(t,{},u),h=kC(n.horizontal),g=o/24,_=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,y=e.tilePixelRatio*s,b=e.tilePixelRatio*p.get(`symbol-spacing`),x=p.get(`text-padding`)*e.tilePixelRatio,S=H_(p,t,u,e.tilePixelRatio),C=p.get(`text-max-angle`)/180*Math.PI,w=p.get(`text-rotation-alignment`)!==`viewport`&&p.get(`symbol-placement`)!==`point`,T=p.get(`icon-rotation-alignment`)===`map`&&p.get(`symbol-placement`)!==`point`,E=p.get(`symbol-placement`),D=b/2,O=p.get(`icon-text-fit`),k;r&&O!==`none`&&(e.allowVerticalPlacement&&n.vertical&&(k=b_(r,n.vertical,O,p.get(`icon-text-fit-padding`),m,g)),h&&(r=b_(r,h,O,p.get(`icon-text-fit-padding`),m,g)));let A=u?d.line.getGranularityForZoomLevel(u.z):1,ee=(s,d)=>{d.x<0||d.x>=8192||d.y<0||d.y>=8192||AC(e,d,s,n,r,i,k,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,_,[x,x,x,x],w,c,y,S,T,m,t,a,l,u,o)};if(E===`line`)for(let i of GS(t.geometry,0,0,Ye,Ye)){let t=Pp(i,A),a=aC(t,b,C,n.vertical||h,r,24,v,e.overscaling,Ye);for(let n of a){let r=h;(!r||!jC(e,r.text,D,n))&&ee(t,n)}}else if(E===`line-center`){for(let e of t.geometry)if(e.length>1){let t=Pp(e,A),i=iC(t,C,n.vertical||h,r,24,v);i&&ee(t,i)}}else if(t.type===`Polygon`)for(let e of Ma(t.geometry,0)){let t=hC(e,16);ee(Pp(e[0],A,!0),new $S(t.x,t.y,0))}else if(t.type===`LineString`)for(let e of t.geometry){let t=Pp(e,A);ee(t,new $S(t[0].x,t[0].y,0))}else if(t.type===`Point`)for(let e of t.geometry)for(let t of e)ee([t],new $S(t.x,t.y,0))}function DC(e,t){let n=e.length,r=t?.values;if(r?.length>0)for(let t=0;t32640&&Ft(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):g.kind===`composite`&&(_=[128*p.compositeTextSizes[0].evaluate(o,{},m),128*p.compositeTextSizes[1].evaluate(o,{},m)],(_[0]>32640||_[1]>32640)&&Ft(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,h,_,s,a,o,l,t,c.lineStartIndex,c.lineLength,f,m);for(let t of u)d[t]=e.text.placedSymbolArray.length-1;return h.length*4}function kC(e){for(let t in e)return e[t];return null}function AC(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w){let T=e.addToLineVertexArray(t,n),E,D,O,k,A=0,ee=0,te=0,ne=0,re=-1,ie=-1,ae={},oe=(0,Bu.default)(``);if(e.allowVerticalPlacement&&r.vertical){let e=s.layout.get(`text-rotate`).evaluate(b,{},C)+90,n=r.vertical;O=new pC(c,t,l,u,d,n,f,p,m,e),o&&(k=new pC(c,t,l,u,d,o,g,_,m,e))}if(i){let n=s.layout.get(`icon-rotate`).evaluate(b,{}),r=s.layout.get(`icon-text-fit`)!==`none`,a=sC(i,n,S,r),f=o?sC(o,n,S,r):void 0;D=new pC(c,t,l,u,d,i,g,_,!1,n),A=a.length*4;let p=e.iconSizeData,m=null;p.kind===`source`?(m=[128*s.layout.get(`icon-size`).evaluate(b,{})],m[0]>32640&&Ft(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):p.kind===`composite`&&(m=[128*x.compositeIconSizes[0].evaluate(b,{},C),128*x.compositeIconSizes[1].evaluate(b,{},C)],(m[0]>32640||m[1]>32640)&&Ft(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,m,y,v,b,0,t,T.lineStartIndex,T.lineLength,-1,C),re=e.icon.placedSymbolArray.length-1,f&&(ee=f.length*4,e.addSymbols(e.icon,f,m,y,v,b,2,t,T.lineStartIndex,T.lineLength,-1,C),ie=e.icon.placedSymbolArray.length-1)}let se=Object.keys(r.horizontal);for(let n of se){let i=r.horizontal[n];E||=(oe=(0,Bu.default)(i.text),new pC(c,t,l,u,d,i,f,p,m,s.layout.get(`text-rotate`).evaluate(b,{},C)));let o=i.positionedLines.length===1;if(te+=OC(e,t,i,a,s,m,b,h,T,r.vertical?1:3,o?se:[n],ae,re,x,C),o)break}r.vertical&&(ne+=OC(e,t,r.vertical,a,s,m,b,h,T,2,[`vertical`],ae,ie,x,C));let ce=E?E.boxStartIndex:e.collisionBoxArray.length,le=E?E.boxEndIndex:e.collisionBoxArray.length,ue=O?O.boxStartIndex:e.collisionBoxArray.length,de=O?O.boxEndIndex:e.collisionBoxArray.length,fe=D?D.boxStartIndex:e.collisionBoxArray.length,pe=D?D.boxEndIndex:e.collisionBoxArray.length,me=k?k.boxStartIndex:e.collisionBoxArray.length,he=k?k.boxEndIndex:e.collisionBoxArray.length,ge=-1,_e=(e,t)=>e?.circleDiameter?Math.max(e.circleDiameter,t):t;ge=_e(E,ge),ge=_e(O,ge),ge=_e(D,ge),ge=_e(k,ge);let ve=+(ge>-1);ve&&(ge*=w/24),e.glyphOffsetArray.length>=M_.MAX_GLYPHS&&Ft(`Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907`),b.sortKey!==void 0&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);let ye=CC(s,b,C),[be,xe]=DC(e.textAnchorOffsets,ye);e.symbolInstances.emplaceBack(t.x,t.y,ae.right>=0?ae.right:-1,ae.center>=0?ae.center:-1,ae.left>=0?ae.left:-1,ae.vertical||-1,re,ie,oe,ce,le,ue,de,fe,pe,me,he,l,te,ne,A,ee,ve,0,f,ge,be,xe)}function jC(e,t,n,r){let i=e.compareText;if(!(t in i))i[t]=[];else{let e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])this._layers[e.id]),n=t[0];if(n.isHidden())continue;let r=n.source||``,i=this.familiesBySource[r];i||=this.familiesBySource[r]={};let a=n.sourceLayer||`_geojsonTileLayer`,o=i[a];o||=i[a]=[],o.push(t)}}},W=class{constructor(e){let t={},n=[];for(let r in e){let i=e[r],a=t[r]={};for(let e in i){let t=i[+e];if(!t||t.bitmap.width===0||t.bitmap.height===0)continue;let r={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(r),a[e]={rect:r,metrics:t.metrics}}}let{w:a,h:o}=r(n),s=new i({width:a||1,height:o||1});for(let n in e){let r=e[n];for(let e in r){let a=r[+e];if(!a||a.bitmap.width===0||a.bitmap.height===0)continue;let o=t[n][e].rect;i.copy(a.bitmap,s,{x:0,y:0},{x:o.x+1,y:o.y+1},a.bitmap)}}this.image=s,this.positions=t}};a(`GlyphAtlas`,W);var G=class{constructor(e){this.tileID=new o(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}async parse(e,t,n,r,i){this.status=`parsing`,this.data=e,this.collisionBoxArray=new s;let a=new c(Object.keys(e.layers).sort()),o=new l(this.tileID,this.promoteId);o.bucketLayerIDs=[];let v={},y={featureIndex:o,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:n,subdivisionGranularity:i},b=t.familiesBySource[this.source];for(let t in b){let r=e.layers[t];if(!r)continue;r.version===1&&u(`Vector tile source "${this.source}" layer "${t}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let i=a.encode(t),s=[];for(let e=0;ee.id)))}}let x=d(y.glyphDependencies,e=>Object.keys(e).map(Number));for(let e of this.inFlightDependencies)e?.abort();this.inFlightDependencies=[];let S=Promise.resolve({});if(Object.keys(x).length){let e=new AbortController;this.inFlightDependencies.push(e),S=r.sendAsync({type:`GG`,data:{stacks:x,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let C=Object.keys(y.iconDependencies),w=Promise.resolve({});if(C.length){let e=new AbortController;this.inFlightDependencies.push(e),w=r.sendAsync({type:`GI`,data:{icons:C,source:this.source,tileID:this.tileID,type:`icons`}},e)}let T=Object.keys(y.patternDependencies),E=Promise.resolve({});if(T.length){let e=new AbortController;this.inFlightDependencies.push(e),E=r.sendAsync({type:`GI`,data:{icons:T,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let D=y.dashDependencies,O=Promise.resolve({});if(Object.keys(D).length){let e=new AbortController;this.inFlightDependencies.push(e),O=r.sendAsync({type:`GDA`,data:{dashes:D}},e)}let[k,A,j,M]=await Promise.all([S,w,E,O]),N=new W(k),P=new f(A,j);for(let e in v){let t=v[e];t instanceof p?(K(t.layers,this.zoom,n),m({bucket:t,glyphMap:k,glyphPositions:N.positions,imageMap:A,imagePositions:P.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:y.subdivisionGranularity})):t.hasDependencies&&(t instanceof h||t instanceof g||t instanceof _)&&(K(t.layers,this.zoom,n),t.addFeatures(y,this.tileID.canonical,P.patternPositions,M))}return this.status=`done`,{buckets:Object.values(v).filter(e=>!e.isEmpty()),featureIndex:o,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:N.image,imageAtlas:P,dashPositions:M,glyphMap:this.returnDependencies?k:null,iconMap:this.returnDependencies?A:null,glyphPositions:this.returnDependencies?N.positions:null}}};function K(e,t,n){let r=new v(t);for(let t of e)t.recalculate(r,n)}var q=class{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,t){this.loading[e]=t}finishLoading(e){delete this.loading[e]}abort(e){let t=this.loading[e];t?.abort&&(t.abort.abort(),delete this.loading[e])}getParsing(e){return this.parsing[e]}setParsing(e,t){this.parsing[e]=t}removeParsing(e){delete this.parsing[e]}markLoaded(e,t){this.loaded[e]=t}getLoaded(e){let t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}},J=class{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return e.length===0&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}},Y=class{constructor(e,t,n,r,i){this.type=e,this.properties=n||{},this.extent=i,this.pointsArray=t,this.id=r}loadGeometry(){return this.pointsArray.map(e=>e.map(e=>new y(e.x,e.y)))}},X=class{constructor(e,t,n){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=n}feature(e){return this._myFeatures[e]}},re=class{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}};function ie(e,t,n){let{extent:r}=e,i=2**(n.z-t.z),a=(n.x-t.x*i)*r,o=(n.y-t.y*i)*r,s=[];for(let t=0;t0&&c.addLayer(i)}let u={vectorTile:c,rawData:O(c).buffer};return this.overzoomedTileResultCache.set(o,u),u}async reloadTile(e){let t=e.uid,n=this.tileState.getLoaded(t);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.showCollisionBoxes=e.showCollisionBoxes,n.status===`parsing`){let r=this.tileState.getParsing(t);try{return await this._parseWorkerTile(n,e,r)}finally{this.tileState.removeParsing(t)}}if(n.status===`done`&&n.vectorTile)return await this._parseWorkerTile(n,e)}async abortTile(e){this.tileState.abort(e.uid)}async removeTile(e){this.tileState.removeLoaded(e.uid)}},oe=class{constructor(){this.loaded={}}async loadTile(e){let{uid:t,encoding:n,rawImageData:r,redFactor:i,greenFactor:a,blueFactor:o,baseShift:s}=e,c=r.width+2,l=r.height+2,u=new k(t,A(r)?new j({width:c,height:l},await M(r,-1,-1,c,l)):r,n,i,a,o,s);return this.loaded||={},this.loaded[t]=u,u}removeTile(e){let t=this.loaded,n=e.uid;t?.[n]&&delete t[n]}},se=class{constructor(e,t,n,r=ce){this.actor=e,this.layerIndex=t,this.availableImages=n,this.tileState=new q,this._createGeoJSONIndex=r}loadVectorTile(e){if(!this._geoJSONIndex)throw Error(`Unable to parse the data into a cluster or geojson`);let{z:t,x:n,y:r}=e.tileID.canonical,i=this._geoJSONIndex.getTile(t,n,r);if(!i)return null;let a=new N(i.features,{version:2,extent:P});return{vectorTile:a,rawData:O(a,F).buffer}}async loadTile(e){let{uid:t}=e,n=new G(e);n.abort=new AbortController;try{let r=this.loadVectorTile(e);if(!r)return null;let{vectorTile:i,rawData:a}=r;n.vectorTile=i,this.tileState.markLoaded(t,n);let o={rawData:a};this.tileState.setParsing(t,o);try{return await this._parseWorkerTile(n,e,o)}finally{this.tileState.removeParsing(t)}}catch(e){throw n.status=`done`,this.tileState.markLoaded(t,n),e}}async _reloadLoadedTile(e){let t=e.uid,n=this.tileState.getLoaded(t);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.showCollisionBoxes=e.showCollisionBoxes,n.status===`parsing`){let r=this.tileState.getParsing(t);try{return await this._parseWorkerTile(n,e,r)}finally{this.tileState.removeParsing(t)}}if(n.status===`done`&&n.vectorTile)return await this._parseWorkerTile(n,e)}async _parseWorkerTile(e,t,n){let r=await e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);if(n){let{rawData:e}=n;r=D({rawTileData:e.slice(0),encoding:`mvt`},r)}return r}async abortTile(e){this.tileState.abort(e.uid)}async removeTile(e){this.tileState.removeLoaded(e.uid)}async loadData(e){this._pendingRequest?.abort();let t=this._startRequestTiming(e);this._pendingRequest=new AbortController;try{await this.loadAndProcessGeoJSON(e,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();let n={};return e.request&&(n.data=e.data),this._finishRequestTiming(t,e,n),n}catch(e){if(delete this._pendingRequest,!I(e))throw e;return{abandoned:!0}}}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new J(e.request.url)}_finishRequestTiming(e,t,n){let r=e?.finish();r&&(n.resourceTiming={[t.source]:JSON.parse(JSON.stringify(r))})}reloadTile(e){return this.tileState.getLoaded(e.uid)?this._reloadLoadedTile(e):this.loadTile(e)}async loadAndProcessGeoJSON(e,t){if(e.request&&(e.data=(await L(e.request,t)).data),e.data){e.data=this._filterGeoJSON(e.data,e.filter,e.source),this._geoJSONIndex=this._createGeoJSONIndex(e.data,e);return}if(e.dataDiff){this._geoJSONIndex??=this._createGeoJSONIndex({type:`FeatureCollection`,features:[]},e),this._geoJSONIndex.updateData(e.dataDiff,this._getFilterPredicate(e.filter,e.source));return}if(e.updateCluster&&this._geoJSONIndex.updateClusterOptions(e.geojsonVtOptions.cluster,Z(e)),this._geoJSONIndex==null)throw Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}_filterGeoJSON(e,t,n){if(e.type!==`FeatureCollection`)return e;let r=this._getFilterPredicate(t,n);return r?{type:`FeatureCollection`,features:e.features.filter(e=>r(e))}:e}_getFilterPredicate(e,t){if(typeof e!=`boolean`&&!e?.length)return;let n=R(e,`sources.${t}.filter`,{type:`boolean`,"property-type":`data-driven`,overridable:!1,transition:!1});if(n.result===`error`)throw Error(n.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return e=>n.value.evaluate({zoom:0},e)}async removeSource(e){this._pendingRequest?.abort()}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}};function ce(e,t){return new z(e,D(t.geojsonVtOptions||{},{updateable:!0,clusterOptions:Z(t)}))}function Z({geojsonVtOptions:e,clusterProperties:t,source:n}){if(!t||!e.clusterOptions)return e.clusterOptions;let r={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(t);for(let e of s){let[a,o]=t[e],s=R(o,`sources.${n}.clusterProperties.${e}[1]`),c=R(typeof a==`string`?[a,[`accumulated`],[`get`,e]]:a,`sources.${n}.clusterProperties.${e}[0]`);r[e]=s.value,i[e]=c.value}return e.clusterOptions.map=e=>{o.properties=e;let t={};for(let e of s)t[e]=r[e].evaluate(a,o);return t},e.clusterOptions.reduce=(e,t)=>{o.properties=t;for(let t of s)a.accumulated=e[t],e[t]=i[t].evaluate(a,o)},e.clusterOptions}async function Q(e){if(e.endsWith(`.mjs`)){await import(e);return}let t=await fetch(e,{credentials:`same-origin`});if(!t.ok)throw Error(`Failed to load ${e}: ${t.status}`);let n=await t.text();if(/^[ \t]*(import|export)\s/m.test(n)){let e=URL.createObjectURL(new Blob([n],{type:`text/javascript`}));try{await import(e)}finally{URL.revokeObjectURL(e)}return}globalThis.eval(n)}var $=class{constructor(e){this.self=e,this.actor=new B(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=/* @__PURE__ */ new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=V,this.self.removeProtocol=ee,this.self.registerRTLTextPlugin=e=>{H.setMethods(e)},this.self.makeRequest=te,this.actor.registerMessageHandler(`LDT`,(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler(`RDT`,async(e,t)=>{this._getDEMWorkerSource(e,t.source).removeTile(t)}),this.actor.registerMessageHandler(`GCEZ`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterExpansionZoom(t)),this.actor.registerMessageHandler(`GCC`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterChildren(t)),this.actor.registerMessageHandler(`GCL`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterLeaves(t)),this.actor.registerMessageHandler(`LD`,(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler(`LT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler(`RT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler(`AT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler(`RMT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler(`RS`,async(e,t)=>{if(!this.workerSources[e]?.[t.type]?.[t.source])return;let n=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],n.removeSource!==void 0&&n.removeSource(t)}),this.actor.registerMessageHandler(`RM`,async e=>{delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],this.globalStates.delete(e)}),this.actor.registerMessageHandler(`SR`,async(e,t)=>{this.referrer=t}),this.actor.registerMessageHandler(`SRPS`,(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler(`IS`,async(e,t)=>{await Q(t)}),this.actor.registerMessageHandler(`SI`,(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler(`UL`,async(e,t)=>{this._getLayerIndex(e).update(t.layers,t.removedIds,this._getGlobalState(e))}),this.actor.registerMessageHandler(`UGS`,async(e,t)=>{let n=this._getGlobalState(e);for(let e in t)n[e]=t[e]}),this.actor.registerMessageHandler(`SL`,async(e,t)=>{this._getLayerIndex(e).replace(t,this._getGlobalState(e))})}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}async _setImages(e,t){this.availableImages[e]=t;for(let n in this.workerSources[e]){let r=this.workerSources[e][n];for(let e in r)r[e].availableImages=t}}async _syncRTLPluginState(e,t){return await H.syncState(t,Q)}_getAvailableImages(e){let t=this.availableImages[e];return t||=[],t}_getLayerIndex(e){let t=this.layerIndexes[e];return t||=this.layerIndexes[e]=new U,t}_getWorkerSource(e,t,n){if(this.workerSources[e]||={},this.workerSources[e][t]||={},!this.workerSources[e][t][n]){let r={sendAsync:(t,n)=>(t.targetMapId=e,this.actor.sendAsync(t,n))};switch(t){case`vector`:this.workerSources[e][t][n]=new ae(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case`geojson`:this.workerSources[e][t][n]=new se(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][n]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e));break}}return this.workerSources[e][t][n]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||={},this.demWorkerSources[e][t]||=new oe,this.demWorkerSources[e][t]}};ne(self)&&(self.worker=new $(self));export{$ as default}; -//# sourceMappingURL=maplibre-gl-worker.mjs.map +import{$ as e,Ai as t,An as n,Cn as r,Gt as i,Jn as a,K as o,Kt as s,L as c,M as l,Nr as u,On as d,Q as f,Tn as p,W as m,Xn as h,Y as g,Yt as _,_ as v,_n as y,_t as b,c as x,cn as S,d as C,dr as ee,gt as w,i as T,in as E,ir as D,it as O,j as k,jt as A,kr as j,l as te,ln as ne,lr as re,m as M,n as N,nr as P,nt as F,o as I,p as L,tt as R,ut as z,vn as B,xn as V}from"./maplibre-gl-shared.mjs";var H=class{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(e,t,n){for(let t of e){this._layerConfigs[t.id]=t;let e=this._layers[t.id]=l(t,n);e._featureFilter=S(e.filter,`layers[${t.id}].filter`,n),this.keyCache[t.id]&&delete this.keyCache[t.id]}for(let e of t)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};let r=ne(Object.values(this._layerConfigs),this.keyCache);for(let e of r){let t=e.map(e=>this._layers[e.id]),n=t[0];if(n.isHidden())continue;let r=n.source||``,i=this.familiesBySource[r];i||=this.familiesBySource[r]={};let a=n.sourceLayer||`_geojsonTileLayer`,o=i[a];o||=i[a]=[],o.push(t)}}},U=class{constructor(e){let t={},n=[];for(let r in e){let i=e[r],a=t[r]={};for(let e in i){let t=i[+e];if(!t||t.bitmap.width===0||t.bitmap.height===0)continue;let r={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(r),a[e]={rect:r,metrics:t.metrics}}}let{w:r,h:i}=o(n),a=new w({width:r||1,height:i||1});for(let n in e){let r=e[n];for(let e in r){let i=r[+e];if(!i||i.bitmap.width===0||i.bitmap.height===0)continue;let o=t[n][e].rect;w.copy(i.bitmap,a,{x:0,y:0},{x:o.x+1,y:o.y+1},i.bitmap)}}this.image=a,this.positions=t}};_(`GlyphAtlas`,U);var W=class{constructor(e){this.tileID=new v(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}async parse(e,t,n,r,i){this.status=`parsing`,this.data=e,this.collisionBoxArray=new A;let a=new C(Object.keys(e.layers).sort()),o=new x(this.tileID,this.promoteId);o.bucketLayerIDs=[];let s={},l={featureIndex:o,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:n,subdivisionGranularity:i},u=t.familiesBySource[this.source];for(let t in u){let r=e.layers[t];if(!r)continue;r.version===1&&j(`Vector tile source "${this.source}" layer "${t}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let i=a.encode(t),c=[];for(let e=0;ee.id)))}}let d=ee(l.glyphDependencies,e=>Object.keys(e).map(Number));for(let e of this.inFlightDependencies)e?.abort();this.inFlightDependencies=[];let p=Promise.resolve({});if(Object.keys(d).length){let e=new AbortController;this.inFlightDependencies.push(e),p=r.sendAsync({type:`GG`,data:{stacks:d,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let h=Object.keys(l.iconDependencies),g=Promise.resolve({});if(h.length){let e=new AbortController;this.inFlightDependencies.push(e),g=r.sendAsync({type:`GI`,data:{icons:h,source:this.source,tileID:this.tileID,type:`icons`}},e)}let _=Object.keys(l.patternDependencies),v=Promise.resolve({});if(_.length){let e=new AbortController;this.inFlightDependencies.push(e),v=r.sendAsync({type:`GI`,data:{icons:_,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let y=l.dashDependencies,b=Promise.resolve({});if(Object.keys(y).length){let e=new AbortController;this.inFlightDependencies.push(e),b=r.sendAsync({type:`GDA`,data:{dashes:y}},e)}let[S,w,T,E]=await Promise.all([p,g,v,b]),D=new U(S),k=new m(w,T);for(let e in s){let t=s[e];t instanceof c?(G(t.layers,this.zoom,n),N({bucket:t,glyphMap:S,glyphPositions:D.positions,imageMap:w,imagePositions:k.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:l.subdivisionGranularity})):t.hasDependencies&&(t instanceof O||t instanceof R||t instanceof f)&&(G(t.layers,this.zoom,n),t.addFeatures(l,this.tileID.canonical,k.patternPositions,E))}return this.status=`done`,{buckets:Object.values(s).filter(e=>!e.isEmpty()),featureIndex:o,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:D.image,imageAtlas:k,dashPositions:E,glyphMap:this.returnDependencies?S:null,iconMap:this.returnDependencies?w:null,glyphPositions:this.returnDependencies?D.positions:null}}};function G(e,t,n){let r=new i(t);for(let t of e)t.recalculate(r,n)}var K=class{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,t){this.loading[e]=t}finishLoading(e){delete this.loading[e]}abort(e){let t=this.loading[e];t?.abort&&(t.abort.abort(),delete this.loading[e])}getParsing(e){return this.parsing[e]}setParsing(e,t){this.parsing[e]=t}removeParsing(e){delete this.parsing[e]}markLoaded(e,t){this.loaded[e]=t}getLoaded(e){let t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}},q=class{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return e.length===0&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}},J=class{constructor(e,t,n,r,i){this.type=e,this.properties=n||{},this.extent=i,this.pointsArray=t,this.id=r}loadGeometry(){return this.pointsArray.map(e=>e.map(e=>new t(e.x,e.y)))}},Y=class{constructor(e,t,n){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=n}feature(e){return this._myFeatures[e]}},ie=class{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}};function ae(e,t,n){let{extent:r}=e,i=2**(n.z-t.z),a=(n.x-t.x*i)*r,o=(n.y-t.y*i)*r,s=[];for(let t=0;t0&&c.addLayer(i)}let u={vectorTile:c,rawData:M(c).buffer};return this.overzoomedTileResultCache.set(o,u),u}async reloadTile(e){let t=e.uid,n=this.tileState.getLoaded(t);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.showCollisionBoxes=e.showCollisionBoxes,n.status===`parsing`){let r=this.tileState.getParsing(t);try{return await this._parseWorkerTile(n,e,r)}finally{this.tileState.removeParsing(t)}}if(n.status===`done`&&n.vectorTile)return await this._parseWorkerTile(n,e)}async abortTile(e){this.tileState.abort(e.uid)}async removeTile(e){this.tileState.removeLoaded(e.uid)}},X=class{constructor(){this.loaded={}}async loadTile(e){let{uid:t,encoding:n,rawImageData:r,redFactor:i,greenFactor:a,blueFactor:o,baseShift:s}=e,c=r.width+2,l=r.height+2,u=new z(t,D(r)?new b({width:c,height:l},await P(r,-1,-1,c,l)):r,n,i,a,o,s);return this.loaded||={},this.loaded[t]=u,u}removeTile(e){let t=this.loaded,n=e.uid;t?.[n]&&delete t[n]}},se=class{constructor(e,t,n,r=ce){this.actor=e,this.layerIndex=t,this.availableImages=n,this.tileState=new K,this._createGeoJSONIndex=r}loadVectorTile(e){if(!this._geoJSONIndex)throw Error(`Unable to parse the data into a cluster or geojson`);let{z:t,x:r,y:i}=e.tileID.canonical,a=this._geoJSONIndex.getTile(t,r,i);if(!a)return null;let o=new L(a.features,{version:2,extent:u});return{vectorTile:o,rawData:M(o,n).buffer}}async loadTile(e){let{uid:t}=e,n=new W(e);n.abort=new AbortController;try{let r=this.loadVectorTile(e);if(!r)return null;let{vectorTile:i,rawData:a}=r;n.vectorTile=i,this.tileState.markLoaded(t,n);let o={rawData:a};this.tileState.setParsing(t,o);try{return await this._parseWorkerTile(n,e,o)}finally{this.tileState.removeParsing(t)}}catch(e){throw n.status=`done`,this.tileState.markLoaded(t,n),e}}async _reloadLoadedTile(e){let t=e.uid,n=this.tileState.getLoaded(t);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.showCollisionBoxes=e.showCollisionBoxes,n.status===`parsing`){let r=this.tileState.getParsing(t);try{return await this._parseWorkerTile(n,e,r)}finally{this.tileState.removeParsing(t)}}if(n.status===`done`&&n.vectorTile)return await this._parseWorkerTile(n,e)}async _parseWorkerTile(e,t,n){let r=await e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);if(n){let{rawData:e}=n;r=h({rawTileData:e.slice(0),encoding:`mvt`},r)}return r}async abortTile(e){this.tileState.abort(e.uid)}async removeTile(e){this.tileState.removeLoaded(e.uid)}async loadData(e){this._pendingRequest?.abort();let t=this._startRequestTiming(e);this._pendingRequest=new AbortController;try{await this.loadAndProcessGeoJSON(e,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();let n={};return e.request&&(n.data=e.data),this._finishRequestTiming(t,e,n),n}catch(e){if(delete this._pendingRequest,!d(e))throw e;return{abandoned:!0}}}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new q(e.request.url)}_finishRequestTiming(e,t,n){let r=e?.finish();r&&(n.resourceTiming={[t.source]:JSON.parse(JSON.stringify(r))})}reloadTile(e){return this.tileState.getLoaded(e.uid)?this._reloadLoadedTile(e):this.loadTile(e)}async loadAndProcessGeoJSON(e,t){if(e.request&&(e.data=(await B(e.request,t)).data),e.data){e.data=this._filterGeoJSON(e.data,e.filter,e.source),this._geoJSONIndex=this._createGeoJSONIndex(e.data,e);return}if(e.dataDiff){this._geoJSONIndex??=this._createGeoJSONIndex({type:`FeatureCollection`,features:[]},e),this._geoJSONIndex.updateData(e.dataDiff,this._getFilterPredicate(e.filter,e.source));return}if(e.updateCluster&&this._geoJSONIndex.updateClusterOptions(e.geojsonVtOptions.cluster,Z(e)),this._geoJSONIndex==null)throw Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}_filterGeoJSON(e,t,n){if(e.type!==`FeatureCollection`)return e;let r=this._getFilterPredicate(t,n);return r?{type:`FeatureCollection`,features:e.features.filter(e=>r(e))}:e}_getFilterPredicate(e,t){if(typeof e!=`boolean`&&!e?.length)return;let n=E(e,`sources.${t}.filter`,{type:`boolean`,"property-type":`data-driven`,overridable:!1,transition:!1});if(n.result===`error`)throw Error(n.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return e=>n.value.evaluate({zoom:0},e)}async removeSource(e){this._pendingRequest?.abort()}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}};function ce(t,n){return new e(t,h(n.geojsonVtOptions||{},{updateable:!0,clusterOptions:Z(n)}))}function Z({geojsonVtOptions:e,clusterProperties:t,source:n}){if(!t||!e.clusterOptions)return e.clusterOptions;let r={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(t);for(let e of s){let[a,o]=t[e],s=E(o,`sources.${n}.clusterProperties.${e}[1]`),c=E(typeof a==`string`?[a,[`accumulated`],[`get`,e]]:a,`sources.${n}.clusterProperties.${e}[0]`);r[e]=s.value,i[e]=c.value}return e.clusterOptions.map=e=>{o.properties=e;let t={};for(let e of s)t[e]=r[e].evaluate(a,o);return t},e.clusterOptions.reduce=(e,t)=>{o.properties=t;for(let t of s)a.accumulated=e[t],e[t]=i[t].evaluate(a,o)},e.clusterOptions}async function Q(e){if(e.endsWith(`.mjs`)){await import(e);return}let t=await fetch(e,{credentials:`same-origin`});if(!t.ok)throw Error(`Failed to load ${e}: ${t.status}`);let n=await t.text();if(/^[ \t]*(import|export)\s/m.test(n)){let e=URL.createObjectURL(new Blob([n],{type:`text/javascript`}));try{await import(e)}finally{URL.revokeObjectURL(e)}return}globalThis.eval(n)}var $=class{constructor(e){this.self=e,this.actor=new k(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=r,this.self.removeProtocol=p,this.self.registerRTLTextPlugin=e=>{s.setMethods(e)},this.self.makeRequest=V,this.actor.registerMessageHandler(`LDT`,(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler(`RDT`,async(e,t)=>{this._getDEMWorkerSource(e,t.source).removeTile(t)}),this.actor.registerMessageHandler(`GCEZ`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterExpansionZoom(t)),this.actor.registerMessageHandler(`GCC`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterChildren(t)),this.actor.registerMessageHandler(`GCL`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterLeaves(t)),this.actor.registerMessageHandler(`LD`,(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler(`LT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler(`RT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler(`AT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler(`RMT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler(`RS`,async(e,t)=>{if(!this.workerSources[e]?.[t.type]?.[t.source])return;let n=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],n.removeSource!==void 0&&n.removeSource(t)}),this.actor.registerMessageHandler(`RM`,async e=>{delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],this.globalStates.delete(e)}),this.actor.registerMessageHandler(`SR`,async(e,t)=>{this.referrer=t}),this.actor.registerMessageHandler(`SRPS`,(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler(`IS`,async(e,t)=>{await Q(t)}),this.actor.registerMessageHandler(`SI`,(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler(`UL`,async(e,t)=>{this._getLayerIndex(e).update(t.layers,t.removedIds,this._getGlobalState(e))}),this.actor.registerMessageHandler(`UGS`,async(e,t)=>{let n=this._getGlobalState(e);for(let e in t)n[e]=t[e]}),this.actor.registerMessageHandler(`SL`,async(e,t)=>{this._getLayerIndex(e).replace(t,this._getGlobalState(e))})}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}async _setImages(e,t){this.availableImages[e]=t;for(let n in this.workerSources[e]){let r=this.workerSources[e][n];for(let e in r)r[e].availableImages=t}}async _syncRTLPluginState(e,t){return await s.syncState(t,Q)}_getAvailableImages(e){let t=this.availableImages[e];return t||=[],t}_getLayerIndex(e){let t=this.layerIndexes[e];return t||=this.layerIndexes[e]=new H,t}_getWorkerSource(e,t,n){if(this.workerSources[e]||={},this.workerSources[e][t]||={},!this.workerSources[e][t][n]){let r={sendAsync:(t,n)=>(t.targetMapId=e,this.actor.sendAsync(t,n))};switch(t){case`vector`:this.workerSources[e][t][n]=new oe(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case`geojson`:this.workerSources[e][t][n]=new se(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][n]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e));break}}return this.workerSources[e][t][n]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||={},this.demWorkerSources[e][t]||=new X,this.demWorkerSources[e][t]}};re(self)&&(self.worker=new $(self));export{$ as default}; +//# sourceMappingURL=maplibre-gl-worker.mjs.map \ No newline at end of file diff --git a/vendor/javascript/maplibre-gl.js b/vendor/javascript/maplibre-gl.js index 8cfea747..bfb18cdf 100644 --- a/vendor/javascript/maplibre-gl.js +++ b/vendor/javascript/maplibre-gl.js @@ -1,11 +1,9 @@ -// maplibre-gl@6.0.0 downloaded from https://ga.jspm.io/npm:maplibre-gl@6.0.0/dist/maplibre-gl.mjs - -import{Oi as t,Er as n,Dn as r,ji as i,Zn as a,Pn as o,Nn as s,ur as c,wn as l,xn as u,ar as d,Yn as f,En as p,Sn as m,pn as h,vn as g,mn as _,_t as v,fn as y,Ar as b,G as x,dt as S,K as C,q as w,_n as T,J as E,dn as D,qt as O,gt as k,Ht as A,Vt as j,Wt as ee,Tr as te,$t as M,Ut as ne,Qt as re,Gt as ie,sr as ae,j as oe,gn as se,fi as ce,Ti as N,wi as P,vi as le,gr as ue,k as F,jr as de,D as fe,E as pe,On as me,Ai as he,ki as ge,br as _e,_ as ve,T as ye,w as be,Pr as I,S as L,h as xe,g as Se,bn as Ce,rn as we,kr as Te,jt as Ee,L as De,cn as Oe,bt as ke,u as Ae,hr as je,In as R,jn as Me,Gn as Ne,Mr as Pe,gi as Fe,O as Ie,wr as Le,Rr as Re,nr as ze,b as Be,s as Ve,f as He,Fr as Ue,Ir as We,Br as Ge,Lr as Ke,Gr as qe,V as Je,B as Ye,R as Xe,$n as Ze,a as Qe,yt as $e,er as et,U as tt,Nr as nt,Or as rt,r as it,z as at,t as ot,I as st,zt as ct,ct as lt,Ft as ut,At as dt,Rt as ft,un as pt,vr as mt,C as ht,ri as gt,Kr as _t,qr as vt,$r as yt,Jr as bt,ai as xt,Yr as St,Ur as Ct,Zr as wt,yr as Tt,Wr as Et,Xr as Dt,_r as Ot,v as kt,y as At,bi as jt,ui as Mt,Ci as Nt,xi as Pt,_i as Ft,Rn as It,Bn as Lt,Cr as Rt,Hr as zt,ir as Bt,Sr as Vt,tn as z,xt as B,at as Ht,ot as Ut,st as Wt,dr as Gt,Jn as Kt,nn as qt,pr as Jt,Vn as Yt,ii as Xt,xr as Zt,Vr as Qt,ci as $t,A as en,Dr as tn,Hn as nn,zn as rn,ni as an,ei as on,ti as sn,Si as cn,Kn as ln,li as un,Mn as dn,qn as fn,sn as pn,yn as mn,Jt as hn,Un as gn,kn as _n,en as vn,an as yn,M as bn,Bt as xn,Ln as Sn,on as Cn,Xt as wn,Zt as Tn,P as En,fr as Dn,Qn as On,Tt as kn,kt as An,St as V,Et as jn,Ct as H,wt as Mn,Ei as Nn,Di as Pn,oi as Fn,yi as In,Dt as Ln,Ot as Rn,Mt as zn,X as Bn,It as Vn,pt as Hn,mr as Un,ht as Wn,Qr as Gn,si as Kn,Lt as qn,Nt as Jn,mi as Yn,pi as Xn,di as Zn,vt as Qn,mt as $n,Z as er,rt as tr,et as nr,ft as rr,lt as ir,F as ar,N as or,Fn as sr,Xn as cr,tr as lr,Wn as ur,or as dr,cr as fr,lr as pr,zr as mr,x as hr,hi as gr,Pt as _r}from"./maplibre-gl-shared.mjs";export{hn as AJAXError,Cn as addProtocol,Tn as removeProtocol}from"./maplibre-gl-shared.mjs"; +import{Di as t,Tr as n,Dn as r,Ai as i,Xn as a,Pn as o,Nn as s,lr as c,wn as l,xn as u,ir as d,Jn as f,En as p,Sn as m,pn as h,vn as g,mn as _,_t as v,fn as y,kr as b,G as x,dt as S,K as C,q as w,_n as T,J as E,dn as D,qt as O,gt as k,Ht as A,Vt as j,Wt as ee,wr as te,$t as M,Ut as ne,Qt as re,Gt as ie,or as ae,j as oe,gn as se,di as ce,wi as N,Ci as le,_i as ue,hr as de,k as P,Ar as fe,D as pe,E as me,On as he,ki as ge,Oi as _e,yr as ve,_ as ye,T as be,w as xe,Nr as F,S as I,h as Se,g as Ce,bn as we,rn as Te,Or as Ee,jt as De,L as Oe,cn as ke,bt as Ae,u as je,mr as Me,In as L,jn as Ne,Gn as Pe,jr as Fe,hi as Ie,O as Le,Cr as Re,Lr as ze,tr as Be,b as Ve,s as He,f as Ue,Pr as We,Fr as Ge,zr as Ke,Ir as qe,Wr as Je,V as Ye,B as Xe,R as Ze,Qn as Qe,a as $e,yt as et,$n as tt,U as nt,Mr as rt,Dr as it,r as at,z as ot,t as st,I as ct,zt as lt,ct as ut,Ft as dt,At as ft,Rt as pt,un as mt,_r as ht,C as gt,ni as _t,Gr as vt,Kr as yt,Qr as bt,qr as xt,ii as St,Jr as Ct,Hr as wt,Xr as Tt,vr as Et,Ur as Dt,Yr as Ot,gr as kt,v as At,y as jt,yi as Mt,li as Nt,Si as Pt,bi as Ft,gi as It,Rn as Lt,Bn as Rt,Sr as zt,Vr as Bt,rr as Vt,xr as Ht,at as Ut,ot as Wt,st as Gt,nn as Kt,fr as qt,Vn as R,ri as Jt,ur as Yt,br as Xt,Br as Zt,si as Qt,A as $t,Er as en,Hn as tn,zn as nn,ti as rn,$r as an,ei as on,xi as sn,Kn as cn,ci as ln,Mn as un,qn as dn,sn as fn,yn as pn,Jt as mn,Un as hn,kn as gn,en as _n,an as vn,M as yn,Bt as bn,Ln as xn,on as Sn,Xt as Cn,Zt as wn,P as Tn,dr as En,Zn as Dn,xt as z,Tt as On,kt as kn,St as B,Et as An,tn as V,Ct as H,wt as jn,Ti as Mn,Ei as Nn,ai as Pn,vi as Fn,Dt as In,Ot as Ln,Mt as Rn,X as zn,It as Bn,pt as Vn,pr as Hn,ht as Un,Zr as Wn,oi as Gn,Lt as Kn,Nt as qn,pi as Jn,fi as Yn,ui as Xn,vt as Zn,mt as Qn,Z as $n,rt as er,et as tr,ft as nr,lt as rr,F as ir,N as ar,Fn as or,Yn as sr,er as cr,Wn as lr,ar as ur,sr as dr,cr as fr,Rr as pr,x as mr,mi as hr,Pt as gr}from"./maplibre-gl-shared.mjs";export{hn as AJAXError,Cn as addProtocol,Tn as removeProtocol}from"./maplibre-gl-shared.mjs"; /** * MapLibre GL JS -* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.0.0/LICENSE.txt +* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.1.0/LICENSE.txt */ -var vr=`6.0.0`;function yr(){var n=new t(4);return t!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n}function br(t,n){var r=n[0],i=n[1],a=n[2],o=n[3],s=r*o-a*i;return s?(s=1/s,t[0]=o*s,t[1]=-i*s,t[2]=-a*s,t[3]=r*s,t):null}function xr(t,n,r){var i=n[0],a=n[1],o=n[2],s=n[3],c=Math.sin(r),l=Math.cos(r);return t[0]=i*l+o*c,t[1]=a*l+s*c,t[2]=i*-c+o*l,t[3]=a*-c+s*l,t}let Sr,Cr,wr;const Tr={frame(t,i,a,o){let s=o||window,c=s.requestAnimationFrame(t=>{l(),i(t)}),{unsubscribe:l}=n(t.signal,`abort`,()=>{l(),s.cancelAnimationFrame(c),a(new r(t.signal.reason))},!1)},frameAsync(t,n){return new Promise((r,i)=>{this.frame(t,r,i,n)})},getImageData(t,n=0){return this.getImageCanvasContext(t).getImageData(-n,-n,t.width+2*n,t.height+2*n)},getImageCanvasContext(t){let n=window.document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)throw Error(`failed to create canvas 2d context`);return n.width=t.width,n.height=t.height,r.drawImage(t,0,0,t.width,t.height),r},resolveURL(t){return Sr||=document.createElement(`a`),Sr.href=t,Sr.href},get hardwareConcurrency(){return typeof navigator<`u`&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return wr===void 0?matchMedia?(Cr??=matchMedia(`(prefers-reduced-motion: reduce)`),Cr.matches):!1:wr},set prefersReducedMotion(t){wr=t}},Er=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(t){this._frozenAt=t}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function U(){return Er.getCurrentTime()}function Dr(t){Er.setNow(t)}function Or(){Er.restoreNow()}function kr(){return Er.isFrozen()}var W=class e{static{this.docStyle=typeof window<`u`&&window.document?.documentElement.style}static{this.selectProp=!e.docStyle||`userSelect`in e.docStyle?`userSelect`:`webkitUserSelect`}static create(t,n,r){let i=window.document.createElement(t);return n!==void 0&&(i.className=n),r&&r.appendChild(i),i}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){e.docStyle&&e.selectProp&&(e.userSelect=e.docStyle[e.selectProp],e.docStyle[e.selectProp]=`none`)}static enableDrag(){e.docStyle&&e.selectProp&&(e.docStyle[e.selectProp]=e.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener(`click`,e.suppressClickInternal,!0)}static suppressClick(){window.addEventListener(`click`,e.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener(`click`,e.suppressClickInternal,!0)},0)}static getScale(t){let n=t.getBoundingClientRect();return{x:n.width/t.offsetWidth||1,y:n.height/t.offsetHeight||1,boundingClientRect:n}}static getPoint(t,n,r){let a=n.boundingClientRect;return new i((r.clientX-a.left)/n.x-t.clientLeft,(r.clientY-a.top)/n.y-t.clientTop)}static mousePos(t,n){let r=e.getScale(t);return e.getPoint(t,r,n)}static touchPos(t,n){let r=[],i=e.getScale(t);for(let a of n)r.push(e.getPoint(t,i,a));return r}static sanitize(t){let n=new DOMParser().parseFromString(t,`text/html`).body||document.createElement(`body`),r=n.querySelectorAll(`script`);for(let t of r)t.remove();return e.clean(n),n.innerHTML}static isPossiblyDangerous(t,n){let r=n.replace(/\s+/g,``).toLowerCase();if([`src`,`href`,`xlink:href`].includes(t)&&(r.includes(`javascript:`)||r.includes(`data:`))||t.startsWith(`on`))return!0}static clean(t){let n=t.children;for(let t of n)e.removeAttributes(t),e.clean(t)}static removeAttributes(t){for(let{name:n,value:r}of t.attributes)e.isPossiblyDangerous(n,r)&&t.removeAttribute(n)}};let Ar;(function(t){let n,i,h,g;t.resetRequestQueue=()=>{n=[],i=0,h=0,g={}},t.addThrottleControl=t=>{let n=h++;return g[n]=t,n},t.removeThrottleControl=t=>{delete g[t],b()};let _=()=>{for(let t of Object.keys(g))if(g[t]())return!0;return!1};t.getImage=(t,r,i=!0,o)=>new Promise((s,c)=>{t.headers||={},t.headers.accept=`image/webp,*/*`,a(t,{type:`image`});let l={abortController:r,requestParameters:t,supportImageRefresh:i,imageBitmapOptions:o,state:`queued`,onError:t=>{c(t)},onSuccess:t=>{s(t)}};n.push(l),b()});let v=(t,n)=>typeof createImageBitmap==`function`?o(t,n):s(t),y=async t=>{t.state=`running`;let{requestParameters:n,supportImageRefresh:r,imageBitmapOptions:a,onError:o,onSuccess:s,abortController:p}=t,m=r===!1&&!a&&!c(self)&&!l(n.url)&&(!n.headers||Object.keys(n.headers).reduce((t,n)=>t&&n===`accept`,!0));i++;let h=m?x(n,p):u(n,p);try{let n=await h;delete t.abortController,t.state=`completed`,n.data instanceof HTMLImageElement||d(n.data)?s(n):n.data&&s({data:await v(n.data,a),cacheControl:n.cacheControl,expires:n.expires})}catch(n){delete t.abortController,o(f(n))}finally{i--,b()}},b=()=>{let t=_()?p.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:p.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r0;r++){let t=n.shift();if(t.abortController.signal.aborted){r--;continue}y(t)}},x=(t,n)=>new Promise((i,a)=>{let o=new Image,s=t.url,c=t.credentials;c&&c===`include`?o.crossOrigin=`use-credentials`:(c&&c===`same-origin`||!m(s))&&(o.crossOrigin=`anonymous`),n.signal.addEventListener(`abort`,()=>{o.src=``,a(new r(n.signal.reason))}),o.fetchPriority=`high`,o.onload=()=>{o.onerror=o.onload=null,i({data:o})},o.onerror=()=>{o.onerror=o.onload=null,!n.signal.aborted&&a(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.`))},o.src=s})})(Ar||={}),Ar.resetRequestQueue();var Nr=class{constructor(t){this._transformRequestFn=t??null}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}},Pr=class extends h{},G=class extends Pr{},Fr=class extends Pr{constructor(t={}){super(`style.load`,t)}},Ir=class extends Pr{constructor(t,n={}){super(t,n),this.dataType=`style`}},K=class extends Pr{constructor(t,n={}){super(t,n),this.dataType=`source`}},Lr=class extends Pr{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(t,r);let o=W.mousePos(n.getCanvas(),r),s=n.unproject(o);super(t,a({point:o,lngLat:s,originalEvent:r},i)),this._defaultPrevented=!1,this.target=n}},Rr=class extends Pr{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,r){let a=t===`touchend`?r.changedTouches:r.touches,o=W.touchPos(n.getCanvasContainer(),a),s=o.map(t=>n.unproject(t)),c=o.reduce((t,n,r,i)=>t.add(n.div(i.length)),new i(0,0)),l=n.unproject(c);super(t,{points:o,point:c,lngLats:s,lngLat:l,originalEvent:r}),this._defaultPrevented=!1}},zr=class extends Pr{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n){super(`wheel`,{originalEvent:n}),this._defaultPrevented=!1}},Br=class extends Pr{},Vr=class extends Pr{constructor(t={}){super(`terrain`,t)}},Hr=class extends Pr{constructor(t={}){super(`projectiontransition`,t)}},Ur=class extends Pr{},Wr=class extends Pr{constructor(t={}){super(`styleimagemissing`,t)}};function jr(t){let n=[];if(typeof t==`string`)n.push({id:`default`,url:t});else if(t&&t.length>0){let r=[];for(let{id:i,url:a}of t){let t=`${i}${a}`;r.includes(t)||(r.push(t),n.push({id:i,url:a}))}}return n}function Mr(t,n,r){try{let i=new URL(t);return i.pathname+=`${n}${r}`,i.toString()}catch{throw Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function Gr(t,n,r,i){let a=jr(t),o=r>1?`@2x`:``,s={},c={};for(let{id:t,url:r}of a){s[t]=g(await n.transformRequest(Mr(r,o,`.json`),`SpriteJSON`),i);let a=await n.transformRequest(Mr(r,o,`.png`),`SpriteImage`);c[t]=Ar.getImage(a,i)}return await Promise.all([...Object.values(s),...Object.values(c)]),Kr(s,c)}async function Kr(t,n){let r={};for(let i in t){r[i]={};let a=Tr.getImageCanvasContext((await n[i]).data),o=(await t[i]).data;for(let t in o){let{width:n,height:s,x:c,y:l,sdf:u,pixelRatio:d,stretchX:f,stretchY:p,content:m,textFitWidth:h,textFitHeight:g}=o[t],_={width:n,height:s,x:c,y:l,context:a};r[i][t]={data:null,pixelRatio:d,sdf:u,stretchX:f,stretchY:p,content:m,textFitWidth:h,textFitHeight:g,spriteData:_}}}return r}var Yr=class extends _{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this.patterns={},this.atlasImage=new v({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&=(this.atlasTexture.destroy(),null);for(let t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new v({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(let{ids:t,promiseResolve:n}of this.requestors)n(this._getImagesForIds(t));this.requestors=[]}}getImage(t){let n=this.images[t];if(n&&!n.data&&n.spriteData){let t=n.spriteData;n.data=new v({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let r=!0,i=n.data||n.spriteData;return this._validateStretch(n.stretchX,i?.width)||(this.fire(new y(Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,i?.height)||(this.fire(new y(Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new y(Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(t,n){if(!t)return!0;let r=0;for(let i of t){if(i[0]=t[1]}updateImage(t,n,r=!0){let i=this.getImage(t);if(r&&(i.data.width!==n.data.width||i.data.height!==n.data.height))throw Error(`size mismatch between old image (${i.data.width}x${i.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=i.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){let n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage?.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}setMissingImageResolver(t){this.missingImageResolver=t}getImages(t){return new Promise((n,r)=>{let i=!0;if(!this.isLoaded())for(let n of t)this.images[n]||(i=!1);this.isLoaded()||i?n(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:n})})}async _getImagesForIds(t){let n=new Set(t.filter(t=>!this.getImage(t))),r=this.missingImageResolver;r&&await Promise.all(Array.from(n,t=>r(t)));let i={};for(let r of t){let t=this.getImage(r);t&&(n.delete(r),i[r]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:!!t.userImage?.render})}for(let t of n)this.fire(new Wr({id:t})),b(`Image "${t}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return i}getPixelSize(){let{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){let n=this.patterns[t],r=this.getImage(t);if(!r)return null;if(n&&n.position.version===r.version)return n.position;if(n)n.position.version=r.version;else{let n={w:r.data.width+2,h:r.data.height+2,x:0,y:0},i=new x(n,r);this.patterns[t]={bin:n,position:i}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){let n=t.gl;this.atlasTexture?this.dirty&&=(this.atlasTexture.update(this.atlasImage),!1):this.atlasTexture=new S(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){let t=[];for(let n in this.patterns)t.push(this.patterns[n].bin);let{w:n,h:r}=C(t),i=this.atlasImage;i.resize({width:n||1,height:r||1});for(let t in this.patterns){let{bin:n}=this.patterns[t],r=n.x+1,a=n.y+1,o=this.getImage(t).data,s=o.width,c=o.height;v.copy(o,i,{x:0,y:0},{x:r,y:a},{width:s,height:c}),v.copy(o,i,{x:0,y:c-1},{x:r,y:a-1},{width:s,height:1}),v.copy(o,i,{x:0,y:0},{x:r,y:a+c},{width:s,height:1}),v.copy(o,i,{x:s-1,y:0},{x:r-1,y:a},{width:1,height:c}),v.copy(o,i,{x:0,y:0},{x:r+s,y:a},{width:1,height:c})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(let n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;let t=this.getImage(n);t||b(`Image with ID: "${n}" was not found`),w(t)&&this.updateImage(n,t)}}cloneImages(){let t={};for(let n in this.images){let r=this.images[n];t[n]={...r,data:r.data?r.data.clone():null}}return t}};async function qr(t,n,r,i){let a=n*256,o=a+255,s=await T(await i.transformRequest(r.replace(`{fontstack}`,t).replace(`{range}`,`${a}-${o}`),`Glyphs`),new AbortController);if(!s?.data)throw Error(`Could not load glyph range. range: ${n}, ${a}-${o}`);let c={};for(let t of E(s.data))c[t.id]=t;return c}const Jr=0x56bc75e2d63100000,Xr=new Float64Array(256);for(let t=0;t<256;t++){let n=.5-(t/255)**(1/2.2);Xr[t]=n*Math.abs(n)}Xr[255]=-0x56bc75e2d63100000;var $r=class{constructor({fontSize:t=24,buffer:n=3,radius:r=8,cutoff:i=.25,fontFamily:a=`sans-serif`,fontWeight:o=`normal`,fontStyle:s=`normal`,lang:c=null}={}){this.buffer=n,this.radius=r,this.cutoff=i,this.lang=c;let l=this.size=t+n*4,u=this._createCanvas(l),d=this.ctx=u.getContext(`2d`,{willReadFrequently:!0});d.font=`${s} ${o} ${t}px ${a}`,d.textBaseline=`alphabetic`,d.textAlign=`left`,d.fillStyle=`black`,this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(t){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(t,t);let n=document.createElement(`canvas`);return n.width=n.height=t,n}draw(t){let{width:n,actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:a,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(r),c=Math.floor(-a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o)-c)),u=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(i))),d=l+2*this.buffer,f=u+2*this.buffer,p=Math.max(d*f,0),m=new Uint8ClampedArray(p),h={data:m,width:d,height:f,glyphWidth:l,glyphHeight:u,glyphTop:s,glyphLeft:c,glyphAdvance:n};if(l===0||u===0)return h;let{ctx:g,buffer:_,gridInner:v,gridOuter:y}=this;this.lang&&(g.lang=this.lang),g.clearRect(_,_,l,u),g.fillText(t,_-c,_+s);let b=g.getImageData(_,_,l,u);y.fill(Jr,0,p),v.fill(0,0,p);let x=3;for(let t=0;t-1);l++,o[l]=c,s[l]=u,s[l+1]=Jr}for(let c=0,l=0;c/[-\w]+/.test(t)?t:`'${CSS.escape(t)}'`).join(`,`),i=this._fontWeight(n[0]),a=this._fontStyle(n[0]);if(typeof document<`u`&&document.fonts?.load)try{await document.fonts.load(`${a} ${i||`normal`} 48px ${r}`)}catch(t){b(`Failed to load font "${r}": ${f(t).message}`)}return new e.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:r,fontWeight:i,fontStyle:a,lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?`italic`:/oblique/i.test(t)?`oblique`:`normal`}_fontWeight(t){let n={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950},r;for(let[i,a]of Object.entries(n))RegExp(`\\b${i}\\b`,`i`).test(t)&&(r=`${a}`);return r}destroy(){for(let t in this.entries){let n=this.entries[t];n.tinySDF=null,n.ideographTinySDF=null,n.glyphs={},n.requests={},n.ranges={}}this.entries={}}};let ni;const ri=()=>ni||=new A({anchor:new j(D.light.anchor,`anchor`),position:new j(D.light.position,`position`),color:new j(D.light.color,`color`),intensity:new j(D.light.intensity,`intensity`)});var oi=class extends _{constructor(t){super(),this._transitionable=new ee(ri(),`light`,void 0),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return te(this.properties.get(`position`))}setLight(t,n={}){if(!this._validate(M.light,t,n))for(let n in t){let r=t[n];n.endsWith(`-transition`)?this._transitionable.setTransition(n.slice(0,-ne.length),r):this._transitionable.setValue(n,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,r){return re(this,t,{value:n},r)}};let ii;const ai=()=>ii||=new A({"sky-color":new j(D.sky[`sky-color`],`sky-color`),"horizon-color":new j(D.sky[`horizon-color`],`horizon-color`),"fog-color":new j(D.sky[`fog-color`],`fog-color`),"fog-ground-blend":new j(D.sky[`fog-ground-blend`],`fog-ground-blend`),"horizon-fog-blend":new j(D.sky[`horizon-fog-blend`],`horizon-fog-blend`),"sky-horizon-blend":new j(D.sky[`sky-horizon-blend`],`sky-horizon-blend`),"atmosphere-blend":new j(D.sky[`atmosphere-blend`],`atmosphere-blend`)});var li=class extends _{constructor(t){super(),this._transitionable=new ee(ai(),`sky`,void 0),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new ie(0))}setSky(t,n={}){if(!this._validate(M.sky,t,n)){t||={"sky-color":`transparent`,"horizon-color":`transparent`,"fog-color":`transparent`,"fog-ground-blend":1,"atmosphere-blend":0};for(let n in t){let r=t[n];n.endsWith(`-transition`)?this._transitionable.setTransition(n.slice(0,-ne.length),r):this._transitionable.setValue(n,r)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,r={}){return re(this,t,{value:n},r)}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}},ui=class{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){let r=t.join(`,`)+String(n);return this.dashEntry[r]||=this.addDash(t,n),this.dashEntry[r]}getDashRanges(t,n,r){let i=t.length%2==1,a=[],o=i?-t[t.length-1]*r:0,s=t[0]*r,c=!0;a.push({left:o,right:s,isDash:c,zeroLength:t[0]===0});let l=t[0];for(let n=1;n1&&(c=t[++s]);let l=Math.abs(a-c.left),u=Math.abs(a-c.right),d=Math.min(l,u),f,p=n/r*(i+1);if(c.isDash){let t=i-Math.abs(p);f=Math.sqrt(d*d+t*t)}else f=i-Math.sqrt(d*d+p*p);this.data[o+a]=Math.max(0,Math.min(255,f+128))}}}addRegularDash(t){for(let n=t.length-1;n>=0;--n){let r=t[n],i=t[n+1];r.zeroLength?t.splice(n,1):i?.isDash===r.isDash&&(i.left=r.left,t.splice(n,1))}let n=t[0],r=t[t.length-1];n.isDash===r.isDash&&(n.left=r.left-this.width,r.right=n.right+this.width);let i=this.width*this.nextRow,a=0,o=t[a];for(let n=0;n1&&(o=t[++a]);let r=Math.abs(n-o.left),s=Math.abs(n-o.right),c=Math.min(r,s),l=o.isDash?c:-c;this.data[i+n]=Math.max(0,Math.min(255,l+128))}}addDash(t,n){let r=n?7:0,i=2*r+1;if(this.nextRow+i>this.height)return b(`LineAtlas out of space`),null;let a=0;for(let n of t)a+=n;if(a!==0){let i=this.width/a,o=this.getDashRanges(t,this.width,i);n?this.addRoundDash(o,i,r):this.addRegularDash(o)}let o={y:this.nextRow+r,height:2*r,width:a};return this.nextRow+=i,this.dirty=!0,o}bind(t){let n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}};function si(t){if(!t)return!1;let n=globalThis.location;if(!n)return!1;try{return new URL(t,n.href).origin!==n.origin}catch{return!1}}function ci(){let t=import.meta.url;if(!/^https?:/.test(t))return``;let n=t.endsWith(`-dev.mjs`)?`maplibre-gl-worker-dev.mjs`:`maplibre-gl-worker.mjs`;return new URL(`./${n}`,t).href}function di(t,n){if(n)try{return new Worker(t,{type:`module`})}catch(t){console.warn(`Module worker not supported, falling back to classic worker`,t)}return new Worker(t)}async function fi(t){let n=await fetch(t);if(!n.ok)throw Error(`Failed to fetch worker script (${n.status}): ${t}`);let r=await n.text(),i=new Blob([r],{type:`text/javascript`});return URL.createObjectURL(i)}function pi(t){let n=new Blob([`import ${JSON.stringify(new URL(t,import.meta.url).href)}`],{type:`text/javascript`});return URL.createObjectURL(n)}async function mi(){let t=p.WORKER_URL||ci(),n=!t?.endsWith(`.cjs`);if(!si(t))return di(t,n);if(n){let r=pi(t);try{return di(r,n)}finally{URL.revokeObjectURL(r)}}let r=await fi(t);try{return di(r,n)}finally{URL.revokeObjectURL(r)}}const hi=`maplibre_preloaded_worker_pool`;var gi=class e{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let t=[];for(;t.length{for(let n of t)n.terminate()})}}isPreloaded(){return!!this.active[hi]}numActive(){return Object.keys(this.active).length}};const _i=Math.floor(Tr.hardwareConcurrency/2);gi.workerCount=ae(globalThis)?Math.max(Math.min(_i,3),1):1;let vi;function yi(){return vi||=new gi,vi}function bi(){yi().acquire(hi)}function xi(){let t=vi;t&&(t.isPreloaded()&&t.numActive()===1?(t.release(hi),vi=null):console.warn(`Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()`))}var wi=class{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n,this.removed=!1,this.actorsPromise=this.initActors(n)}async initActors(t){let n=await this.workerPool.acquire(t);if(this.removed)return[];if(this.actors=n.map((n,r)=>{let i=new oe(n,t);return i.name=`Worker ${r}`,i}),!this.actors.length)throw Error(`No actors found`);return this.actors}async broadcast(t,n){let r=await this.actorsPromise;return Promise.all(r.map(r=>r.sendAsync({type:t,data:n})))}async getActor(){let t=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%t.length,t[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(t=!0){this.removed=!0;for(let t of this.actors)t.remove();this.actors=[],t&&this.workerPool.release(this.id)}async registerMessageHandler(t,n){let r=await this.actorsPromise;for(let i of r)i.registerMessageHandler(t,n)}async unregisterMessageHandler(t){let n=await this.actorsPromise;for(let r of n)r.unregisterMessageHandler(t)}};let Si;function Ci(){return Si||(Si=new wi(yi(),se),Si.registerMessageHandler(`GR`,(t,n,r)=>u(n,r))),Si}function Ti(t,n){let r=ce();return N(r,r,[1,1,0]),P(r,r,[t.width*.5,t.height*.5,1]),t.calculatePosMatrix?le(r,r,t.calculatePosMatrix(n.toUnwrapped())):r}function Ei(t,n,r){if(t)for(let i of t){let t=n[i];if(t?.source===r&&t.type===`fill-extrusion`)return!0}else for(let t in n){let i=n[t];if(i.source===r&&i.type===`fill-extrusion`)return!0}return!1}function Di(t,n,r,i,a,o,s){let c=Ei(a?.layers??null,n,t.id),l=o.maxPitchScaleFactor(),u=t.tilesIn(i,l,c);u.sort(Ai);let d=[];for(let i of u)d.push({wrappedTileID:i.tileID.wrapped().key,queryResults:i.tile.queryRenderedFeatures(n,r,t.getState(),i.queryGeometry,i.cameraQueryGeometry,i.scale,a,o,l,Ti(o,i.tileID),s?(t,n)=>s(i.tileID,t,n):void 0)});return Mi(ji(d),t)}function Oi(t,n,r,i,a,o,s){let c={},l=o.queryRenderedSymbols(i),u=[];for(let t of Object.keys(l).map(Number))u.push(s[t]);u.sort(Ai);for(let r of u){let i=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],n,r.bucketIndex,r.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState},a.layers,a.availableImages,t);for(let t in i){c[t]||=[];let n=i[t];n.sort((t,n)=>{let i=r.featureSortOrder;if(i){let r=i.indexOf(t.featureIndex);return i.indexOf(n.featureIndex)-r}else return n.featureIndex-t.featureIndex});for(let r of n)c[t].push(r)}}return Ni(c,t,r)}function ki(t,n){let r=t.getRenderableIds().map(n=>t.getTileByID(n)),i=[],a={};for(let t of r){let r=t.tileID.canonical.key;a[r]||(a[r]=!0,t.querySourceFeatures(i,n))}return i}function Ai(t,n){let r=t.tileID,i=n.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}function ji(t){let n={},r={};for(let{queryResults:i,wrappedTileID:a}of t){r[a]||={};let t=r[a];for(let r in i){let a=i[r];t[r]||={};let o=t[r];n[r]||=[];for(let t of a)o[t.featureIndex]||(o[t.featureIndex]=!0,n[r].push(t))}}return n}function Mi(t,n){for(let r in t)for(let i of t[r])Pi(i,n);return t}function Ni(t,n,r){for(let i in t)for(let a of t[i]){let t=r[n[i].source];Pi(a,t)}return t}function Pi(t,n){let r=t.feature,i=n.getFeatureState(r.layer[`source-layer`],r.id);r.source=r.layer.source,r.layer[`source-layer`]&&(r.sourceLayer=r.layer[`source-layer`]),r.state=i}async function Fi(t,n,r,i){let o=t;if(t.url?o=(await g(await n.transformRequest(t.url,`Source`),r)).data:await Tr.frameAsync(r,i),!o)return null;let s=ue(a(o,t),[`tiles`,`minzoom`,`maxzoom`,`attribution`,`bounds`,`scheme`,`tileSize`,`encoding`]);return`vector_layers`in o&&o.vector_layers&&(s.vectorLayerIds=o.vector_layers.map(t=>t.id)),s}var Ii=class e{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):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 F?new F(t.lng,t.lat):F.convert(t),this}setSouthWest(t){return this._sw=t instanceof F?new F(t.lng,t.lat):F.convert(t),this}extend(t){let n=this._sw,r=this._ne,i,a;if(t instanceof F)i=t,a=t;else if(t instanceof e){if(i=t._sw,a=t._ne,!i||!a)return this}else{if(Array.isArray(t))if(t.length===4||t.every(Array.isArray)){let n=t;return this.extend(e.convert(n))}else{let n=t;return this.extend(F.convert(n))}else if(t&&(`lng`in t||`lon`in t)&&`lat`in t)return this.extend(F.convert(t));return this}return!n&&!r?(this._sw=new F(i.lng,i.lat),this._ne=new F(a.lng,a.lat)):(n.lng=Math.min(i.lng,n.lng),n.lat=Math.min(i.lat,n.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)),this}getCenter(){return new F((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new F(this.getWest(),this.getNorth())}getSouthEast(){return new F(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){let{lng:n,lat:r}=F.convert(t),i=this._sw.lat<=r&&r<=this._ne.lat,a=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=n&&n>=this._ne.lng),i&&a}intersects(t){if(t=e.convert(t),!(t.getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let n=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(n>=360||r>=360)return!0;let i=de(this.getWest(),-180,180),a=de(this.getEast(),-180,180),o=de(t.getWest(),-180,180),s=de(t.getEast(),-180,180),c=i>a,l=o>s;return c&&l?!0:c?s>=i||o<=a:l?a>=o||i<=s:o<=a&&s>=i}static convert(t){return t instanceof e||!t?t:new e(t)}static fromLngLat(t,n=0){let r=360*n/40075017,i=r/Math.cos(Math.PI/180*t.lat);return new e(new F(t.lng-i,t.lat-r),new F(t.lng+i,t.lat+r))}adjustAntiMeridian(){let t=new F(this._sw.lng,this._sw.lat),n=new F(this._ne.lng,this._ne.lat);return t.lng>n.lng?new e(t,new F(n.lng+360,n.lat)):new e(t,n)}},zi=class{constructor(t,n,r){this.bounds=Ii.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=r||24}validateBounds(t){return!Array.isArray(t)||t.length!==4?[-180,-90,180,90]:[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]}contains(t){let n=2**t.z,r={minX:Math.floor(pe(this.bounds.getWest())*n),minY:Math.floor(fe(this.bounds.getNorth())*n),maxX:Math.ceil(pe(this.bounds.getEast())*n),maxY:Math.ceil(fe(this.bounds.getSouth())*n)};return t.x>=r.minX&&t.x=r.minY&&t.y{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return a({},this._options)}async loadTile(t){let n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:await this.map._requestManager.transformRequest(n,`Tile`),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.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(t),etag:t.etag};r.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();let i=`RT`;if(!t.actor||t.state===`expired`)t.actor=this.dispatcher.getReadyActor(),i=`LT`;else if(t.state===`loading`)return new Promise((n,r)=>{t.reloadPromise={resolve:n,reject:r}});t.abortController=new AbortController;try{let n=await t.actor.sendAsync({type:i,data:r},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,n);let a={};return n?.etagUnmodified&&(a.unmodified=!0),a}catch(n){if(delete t.abortController,t.aborted||me(n))return;if(n&&n.status!==404)throw n;this._afterTileLoadWorkerResponse(t,null)}}async _getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let n=t.tileID.scaledTo(this.maxzoom).canonical,r=n.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:n,overzoomRequest:await this.map._requestManager.transformRequest(r,`Tile`)}}_afterTileLoadWorkerResponse(t,n){if(n?.resourceTiming&&(t.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&t.setExpiryData(n),t.etag=n?.etag,t.loadVectorData(n,this.map.painter),t.reloadPromise){let n=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(n.resolve).catch(n.reject)}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&await t.actor.sendAsync({type:`AT`,data:{uid:t.uid,type:this.type,source:this.id}})}async unloadTile(t){t.unloadVectorData(),t.actor&&await t.actor.sendAsync({type:`RMT`,data:{uid:t.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},Vi=class extends _{constructor(t,n,r,i){super(),this.id=t,this.dispatcher=r,this.setEventedParent(i),this.type=`raster`,this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme=`xyz`,this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=a({type:`raster`},n),a(this,ue(n,[`url`,`scheme`,`tileSize`]))}async load(t=!1){this._loaded=!1,this.fire(new K(`dataloading`)),this._tileJSONRequest=new AbortController;try{let n=await Fi(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,n&&(a(this,n),n.bounds&&(this.tileBounds=new zi(n.bounds,this.minzoom,this.maxzoom)),this.fire(new K(`data`,{sourceDataType:`metadata`})),this.fire(new K(`data`,{sourceDataType:`content`,sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,me(t)||this.fire(new y(f(t)))}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(t){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}serialize(){return a({},this._options)}setPremultiplyAlpha(t){return this._premultiplyAlpha===t||this.setSourceProperty(()=>{this._premultiplyAlpha=t}),this}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}async loadTile(t){let n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this._premultiplyAlpha,i=r?void 0:{premultiplyAlpha:`none`};t.abortController=new AbortController;try{let a=await Ar.getImage(await this.map._requestManager.transformRequest(n,`Tile`),t.abortController,this.map._refreshExpiredTiles,i);if(delete t.abortController,t.aborted){t.state=`unloaded`;return}if(a?.data){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&t.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let n=this.map.painter.context,i=n.gl,o=a.data;t.texture=this.map.painter.getTileTexture(o.width),t.texture?t.texture.update(o,{useMipmap:!0,premultiply:r}):(t.texture=new S(n,o,i.RGBA,{useMipmap:!0,premultiply:r}),t.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_NEAREST)),t.state=`loaded`}}catch(n){if(delete t.abortController,t.aborted)t.state=`unloaded`;else if(n)throw t.state=`errored`,n}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController)}async unloadTile(t){t.texture&&this.map.painter.saveTileTexture(t.texture)}hasTransition(){return!1}},Hi=class extends Vi{constructor(t,n,r,i){super(t,n,r,i),this.type=`raster-dem`,this.maxzoom=22,this._options=a({type:`raster-dem`},n),this.encoding=n.encoding||`mapbox`,this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}async loadTile(t){let n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=await this.map._requestManager.transformRequest(n,`Tile`);t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{let n=await Ar.getImage(r,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted){t.state=`unloaded`;return}if(n?.data){let r=n.data;this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&t.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let i=d(r)&&he()?r:await this.readImageNow(r),a={type:this.type,uid:t.uid,source:this.id,rawImageData:i,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(t.actor&&t.state!==`expired`&&t.state!==`reloading`)return;await this.dispatcher.waitForInitComplete(),(!t.actor||t.state===`expired`)&&(t.actor=this.dispatcher.getReadyActor()),t.dem=await t.actor.sendAsync({type:`LDT`,data:a}),t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state=`loaded`}}catch(n){if(delete t.abortController,t.aborted)t.state=`unloaded`;else if(n)throw t.state=`errored`,n}}async readImageNow(t){if(typeof VideoFrame<`u`&&ge()){let n=t.width+2,r=t.height+2;try{return new v({width:n,height:r},await _e(t,-1,-1,n,r))}catch{}}return Tr.getImageData(t,1)}_getNeighboringTiles(t){let n=t.canonical,r=2**n.z,i=(n.x-1+r)%r,a=n.x===0?t.wrap-1:t.wrap,o=(n.x+1+r)%r,s=n.x+1===r?t.wrap+1:t.wrap,c={};return c[new ve(t.overscaledZ,a,n.z,i,n.y).key]={backfilled:!1},c[new ve(t.overscaledZ,s,n.z,o,n.y).key]={backfilled:!1},n.y>0&&(c[new ve(t.overscaledZ,a,n.z,i,n.y-1).key]={backfilled:!1},c[new ve(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},c[new ve(t.overscaledZ,s,n.z,o,n.y-1).key]={backfilled:!1}),n.y+10||r.addOrUpdateProperties?.length>0;if(!a&&!o)continue;i.push(n.geometry);let s={...n};if(t.set(r.id,s),a&&(i.push(r.newGeometry),s.geometry=r.newGeometry),o){if(r.removeAllProperties?s.properties={}:s.properties={...s.properties||{}},r.removeProperties)for(let t of r.removeProperties)delete s.properties[t];if(r.addOrUpdateProperties)for(let{key:t,value:n}of r.addOrUpdateProperties)s.properties[t]=n}}return i}function Wi(t,n,r){if(!t)return n||{};if(!n)return t||{};r&&(qi(t.add,r),qi(n.add,r));let i=Yi(t),a=Yi(n);Gi(i,a);let o={};if((i.removeAll||a.removeAll)&&(o.removeAll=!0),o.remove=new Set([...i.remove,...a.remove]),o.add=new Map([...i.add,...a.add]),o.update=new Map([...i.update,...a.update]),o.remove.size&&o.add.size)for(let t of o.add.keys())o.remove.delete(t);let s=Xi(o);return r&&Ji(s.add,r),s}function Gi(t,n){n.removeAll&&(t.add.clear(),t.update.clear(),t.remove.clear(),n.remove.clear());for(let r of n.remove)t.add.delete(r),t.update.delete(r);for(let[r,i]of n.update){let a=t.update.get(r);a&&(n.update.set(r,Ki(a,i)),t.update.delete(r))}}function Ki(t,n){let r={id:t.id};if(n.removeAllProperties&&(delete t.removeProperties,delete t.addOrUpdateProperties,delete n.removeProperties),n.removeProperties)for(let r of n.removeProperties){let n=t.addOrUpdateProperties.findIndex(t=>t.key===r);n>-1&&t.addOrUpdateProperties.splice(n,1)}return(t.removeAllProperties||n.removeAllProperties)&&(r.removeAllProperties=!0),(t.removeProperties||n.removeProperties)&&(r.removeProperties=[...t.removeProperties||[],...n.removeProperties||[]]),(t.addOrUpdateProperties||n.addOrUpdateProperties)&&(r.addOrUpdateProperties=[...t.addOrUpdateProperties||[],...n.addOrUpdateProperties||[]]),(t.newGeometry||n.newGeometry)&&(r.newGeometry=n.newGeometry||t.newGeometry),r}function qi(t,n){if(t)for(let r of t){let t=Li(r,n);t!=null&&(r.id=t)}}function Ji(t,n){if(t)for(let r of t)Li(r,n)!=null&&delete r.id}function Yi(t){if(!t)return{};let n={};return n.removeAll=t.removeAll,n.remove=new Set(t.remove||[]),n.add=new Map(t.add?.map(t=>[t.id,t])),n.update=new Map(t.update?.map(t=>[t.id,t])),n}function Xi(t){let n={};return t.removeAll&&(n.removeAll=t.removeAll),t.remove&&(n.remove=Array.from(t.remove)),t.add&&(n.add=Array.from(t.add.values())),t.update&&(n.update=Array.from(t.update.values())),n}function Zi(t){return!t||t.length===0?[]:typeof t[0]==`number`?[t]:t.flatMap(t=>Zi(t))}function Qi(t){return t.type===`GeometryCollection`?t.geometries.flatMap(t=>Qi(t)):Zi(t.coordinates)}function $i(t){let n=new Ii,r;switch(t.type){case`FeatureCollection`:r=t.features.flatMap(t=>Qi(t.geometry));break;case`Feature`:r=Qi(t.geometry);break;default:r=Qi(t);break}if(r.length===0)return n;for(let t of r){let[r,i]=t;n.extend([r,i])}return n}function ea({x:t,y:n,z:r},i=0){let a=ye((t-i)/2**r),o=be((n+1+i)/2**r),s=ye((t+1+i)/2**r),c=be((n-i)/2**r);return new Ii([a,o],[s,c])}var ra=class extends _{constructor(t,n,r,i){super(),this.id=t,this.type=`geojson`,this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actorPromise=r.getActor(),this.setEventedParent(i),this._data=typeof n.data==`string`?{url:n.data}:{geojson:n.data},this._options=a({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&b(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=a({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer===void 0?128:n.buffer),tolerance:this._pixelsToTileUnits(n.tolerance===void 0?.375:n.tolerance),extent:I,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1,promoteId:typeof n.promoteId==`string`?n.promoteId:void 0,cluster:n.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:I,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1}},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(t){return t*(I/this.tileSize)}_getClusterMaxZoom(t){let n=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||t===void 0||b(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${n}"`),n}async load(){await this._updateWorkerData()}onAdd(t){this.map=t,this.load()}setData(t){return this._data=typeof t==`string`?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t},this._updateWorkerData()}updateData(t){return this._pendingWorkerUpdate.diff=Wi(this._pendingWorkerUpdate.diff,t),this._updateWorkerData()}async getData(){return this._data.url&&await this.once(`data`),this._data.geojson?this._data.geojson:{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}}async getBounds(){return $i(await this.getData())}setClusterOptions(t){return this.workerOptions.geojsonVtOptions.cluster=t.cluster,t.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),t.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}async getClusterExpansionZoom(t){return(await this.actorPromise).sendAsync({type:`GCEZ`,data:{type:this.type,clusterId:t,source:this.id}})}async getClusterChildren(t){return(await this.actorPromise).sendAsync({type:`GCC`,data:{type:this.type,clusterId:t,source:this.id}})}async getClusterLeaves(t,n,r){return(await this.actorPromise).sendAsync({type:`GCL`,data:{type:this.type,source:this.id,clusterId:t,limit:n,offset:r}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate()){b(`No pending worker updates for GeoJSONSource ${this.id}.`);return}let{data:t,diff:n,updateCluster:r}=this._pendingWorkerUpdate,i=this._getLoadGeoJSONParameters(t,n,r);t===void 0?n?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(i),await this._updatePromise}async _getLoadGeoJSONParameters(t,n,r){let i=a({type:this.type,source:this.id},this.workerOptions);if(typeof t==`string`)return i.request=await this.map._requestManager.transformRequest(Tr.resolveURL(t),`Source`),i.request.collectResourceTiming=this._collectResourceTiming,i;if(t!==void 0)return i.data=t,i;if(n)return i.dataDiff=n,i;if(r)return i.updateCluster=!0,i}async _dispatchWorkerUpdate(t){this._isUpdatingWorker=!0,this.fire(new K(`dataloading`));try{let n=await t,r=await(await this.actorPromise).sendAsync({type:`LD`,data:n});if(this._isUpdatingWorker=!1,this._removed||r.abandoned){this.fire(new K(`dataabort`));return}r.data&&(this._data={geojson:r.data});let i=this._applyDiffToSource(n.dataDiff),a=this._getShouldReloadTileOptions(i),o={};this._applyResourceTiming(o,r),this.fire(new K(`data`,{...o,sourceDataType:`metadata`})),this.fire(new K(`data`,{...o,sourceDataType:`content`,shouldReloadTileOptions:a}))}catch(t){if(this._isUpdatingWorker=!1,this._removed){this.fire(new K(`dataabort`));return}this.fire(new y(f(t)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(t,n){if(!this._collectResourceTiming)return;let r=n.resourceTiming?.[this.id];if(!r)return;let i=r.slice(0);i?.length&&a(t,{resourceTiming:i})}_applyDiffToSource(t){if(!t)return;let n=typeof this.promoteId==`string`?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let t=Ri(this._data.geojson,n);if(!t)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:t}}if(!this._data.updateable)return;let r=Ui(this._data.updateable,t,n);if(!(t.removeAll||this._options.cluster))return r}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map(t=>$i(t))}}shouldReloadTile(t,{affectedBounds:n}){if(t.state===`loading`)return!0;if(t.state===`unloaded`)return!1;let{buffer:r,extent:i}=this.workerOptions.geojsonVtOptions,a=ea(t.tileID.canonical,r/i);for(let t of n)if(a.intersects(t))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(t){let n=t.actor?`RT`:`LT`;t.actor=await this.actorPromise;let r={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.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};t.abortController=new AbortController;try{let i=await(await this.actorPromise).sendAsync({type:n,data:r},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(i,this.map.painter,n===`RT`)}catch(n){if(delete t.abortController,t.aborted||me(n))return;throw n}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}async unloadTile(t){t.unloadVectorData(),await(await this.actorPromise).sendAsync({type:`RMT`,data:{uid:t.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then(t=>t.sendAsync({type:`RS`,data:{type:this.type,source:this.id}}))}serialize(){return a({},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}},ia=class extends _{constructor(t,n,r,i){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=r,this.coordinates=n.coordinates,this.type=`image`,this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=n}async load(t){this._loaded=!1,this.fire(new K(`dataloading`)),this.url=this.options.url,this._request=new AbortController;try{let n=await Ar.getImage(await this.map._requestManager.transformRequest(this.url,`Image`),this._request);this._request=null,this._loaded=!0,n?.data&&(this.image=n.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,me(t)||this.fire(new y(f(t)))}}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&=(this._request.abort(),null),this.options.url=t.url,this.load(t.coordinates).finally(()=>this.texture=null),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new K(`data`,{sourceDataType:`metadata`})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&=(this._request.abort(),null)}setCoordinates(t){this.coordinates=t;let n=t.map(L.fromLngLat);return this.tileID=ta(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map(t=>this.tileID.getTilePoint(t)._round()),this.flippedWindingOrder=na(this.tileCoords),this.fire(new K(`data`,{sourceDataType:`content`})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let t=this.map.painter.context,n=t.gl;this.texture||(this.texture=new S(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let t in this.tiles){let n=this.tiles[t];n.state!==`loaded`&&(n.state=`loaded`,n.texture=this.texture,r=!0)}r&&this.fire(new K(`data`,{sourceDataType:`idle`,sourceId:this.id}))}async loadTile(t){this.tileID?.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state=`errored`}serialize(){return{type:`image`,url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){let{minX:n,minY:r,maxX:i,maxY:a}=xe.fromPoints(t),o={};for(let t=0;t<=25;t++){let s=2**t,c=Math.floor(n*s),l=Math.floor(r*s),u=Math.floor(i*s),d=Math.floor(a*s),f=(c%s+s)%s,p=u%s;o[t]={minWrap:Math.floor(c/s),maxWrap:Math.floor(u/s),minTileXWrapped:f,maxTileXWrapped:p,minTileY:l,maxTileY:d}}return o}};function ta(t){let n=xe.fromPoints(t),r=n.width(),i=n.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(r,i))/Math.LN2)),o=2**a;return new Se(a,Math.floor((n.minX+n.maxX)/2*o),Math.floor((n.minY+n.maxY)/2*o))}function na(t){let n=t[1].x-t[0].x,r=t[1].y-t[0].y,i=t[2].x-t[0].x;return n*(t[2].y-t[0].y)-r*i<0}var sa=class extends ia{constructor(t,n,r,i){super(t,n,r,i),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type=`video`,this.options=n}async load(){this._loaded=!1;let t=this.options;this.urls=[];for(let n of t.urls)this.urls.push((await this.map._requestManager.transformRequest(n,`Source`)).url);try{let t=await Ce(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 y(f(t)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){let n=this.video.seekable;tn.end(0)?this.fire(new y(new we(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}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 t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new S(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let t in this.tiles){let n=this.tiles[t];n.state!==`loaded`&&(n.state=`loaded`,n.texture=this.texture,r=!0)}r&&this.fire(new K(`data`,{sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`video`,urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},ca=class extends ia{constructor(t,n,r,i){super(t,n,r,i),n.coordinates?(!Array.isArray(n.coordinates)||n.coordinates.length!==4||n.coordinates.some(t=>!Array.isArray(t)||t.length!==2||t.some(t=>typeof t!=`number`)))&&this.fire(new y(new we(`sources.${t}`,null,`"coordinates" property must be an array of 4 longitude/latitude array pairs`))):this.fire(new y(new we(`sources.${t}`,null,`missing required property "coordinates"`))),n.animate&&typeof n.animate!=`boolean`&&this.fire(new y(new we(`sources.${t}`,null,`optional "animate" property must be a boolean value`))),n.canvas?typeof n.canvas!=`string`&&!(n.canvas instanceof HTMLCanvasElement)&&this.fire(new y(new we(`sources.${t}`,null,`"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance`))):this.fire(new y(new we(`sources.${t}`,null,`missing required property "canvas"`))),this.options=n,this.animate=n.animate===void 0||n.animate}async load(){if(this._loaded=!0,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 y(Error(`Canvas dimensions cannot be less than or equal to zero.`)));return}this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&=(this.prepare(),!1)},this._finishLoading()}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let n=this.map.painter.context,r=n.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new S(n,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let i=!1;for(let t in this.tiles){let n=this.tiles[t];n.state!==`loaded`&&(n.state=`loaded`,n.texture=this.texture,i=!0)}i&&this.fire(new K(`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 t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}};const aa={},oa=(t,n,r,i)=>{let a=new(la(n.type))(t,n,r,i);if(a.id!==t)throw Error(`Expected Source id to be ${t} instead of ${a.id}`);return a},la=t=>{switch(t){case`geojson`:return ra;case`image`:return ia;case`raster`:return Vi;case`raster-dem`:return Hi;case`vector`:return Bi;case`video`:return sa;case`canvas`:return ca}return aa[t]},ua=(t,n)=>{aa[t]=n},da=async(t,n)=>{if(la(t))throw Error(`A source type called "${t}" already exists.`);ua(t,n)};function fa(t,n){let r={};if(!n)return r;for(let i of t){let t=i.layerIds.map(t=>n.getLayer(t)).filter(Boolean);if(t.length!==0){i.layers=t,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map(n=>t.filter(t=>t.id===n)[0]));for(let n of t)r[n.id]=i}}return r}const pa=`RTLPluginLoaded`;var ga=class extends _{constructor(...t){super(...t),this.status=`unavailable`,this.url=null,this.dispatcher=Ci()}_syncState(t){return this.status=t,this.dispatcher.broadcast(`SRPS`,{pluginStatus:t,pluginURL:this.url}).catch(t=>{throw this.status=`error`,t})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status=`unavailable`,this.url=null}async setRTLTextPlugin(t,n=!1){if(this.url)throw Error(`setRTLTextPlugin cannot be called multiple times.`);if(this.url=Tr.resolveURL(t),!this.url)throw Error(`requested url ${t} is invalid`);if(this.status===`unavailable`)if(n)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 h(pa))}lazyLoad(){this.status===`unavailable`?this.status=`requested`:this.status===`deferred`&&this._requestImport()}};let ma=null;function ha(){return ma||=new ga,ma}var ya=class{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=Te(),this.uses=0,this.tileSize=n,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(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:n,fadingParentID:r,fadeEndTime:i}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=n,this.fadingParentID=r,this.fadeEndTime=i}setSelfFadeLogic(t){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=t}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=U(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state===`errored`||this.state===`loaded`||this.state===`reloading`}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(t){return this.rttObjects[t]}acquireRTT(t,n,r){return this.rttObjects[n]=t.acquireRTT(r)}releaseRTT(t){if(this.rttObjects.length!==0){for(let n of this.rttObjects)n&&t.releaseRTT(n);this.rttObjects.length=0}}loadVectorData(t,n,r){if(t?.etagUnmodified===!0){this.state=`loaded`;return}if(this.hasData()&&this.unloadVectorData(),this.state=`loaded`,!t){this.collisionBoxArray=new Ee;return}t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestEncoding=t.encoding,this.latestFeatureIndex.rawTileData=t.rawTileData,this.latestFeatureIndex.encoding=t.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=fa(t.buckets,n?.style),this.hasSymbolBuckets=!1;for(let t in this.buckets){let n=this.buckets[t];if(n instanceof De)if(this.hasSymbolBuckets=!0,r)n.justReloaded=!0;else break}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let t in this.buckets){let n=this.buckets[t];if(n instanceof De&&n.hasRTLText){this.hasRTLText=!0,ha().lazyLoad();break}}this.queryPadding=0;for(let t in this.buckets){let r=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(t).queryRadius(r))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}unloadVectorData(){for(let t in this.buckets)this.buckets[t].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(t){return this.buckets[t.id]}upload(t){for(let n in this.buckets){let r=this.buckets[n];r.uploadPending()&&r.upload(t)}let n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new S(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new S(t,this.glyphAtlasImage,n.ALPHA),null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,r,i,a,o,s,c,l,u,d){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:i,cameraQueryGeometry:a,scale:o,tileSize:this.tileSize,pixelPosMatrix:u,transform:c,params:s,queryPadding:this.queryPadding*l,getElevation:d},t,n,r):{}}querySourceFeatures(t,n){let r=this.latestFeatureIndex;if(!r?.rawTileData)return;let i=r.loadVTLayers(),a=n?.sourceLayer?n.sourceLayer:``,o=i._geojsonTileLayer||i[a];if(!o)return;let s=Oe(n?.filter,`querySourceFeatures[${a}].filter`,n?.globalState),{z:c,x:l,y:u}=this.tileID.canonical,d={z:c,x:l,y:u};for(let n=0;nt)r=!1;else if(!n)r=!0;else if(this.expirationTime({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),b=[],x=[];if(t.renderWorldCopies&&s.allowWorldCopies())for(let t=1;t<=3;t++)b.push(y(-t)),b.push(y(t));for(b.push(y(0));b.length>0;){let p=b.pop(),g=p.x,y=p.y,S=p.fullyVisible,C={x:g,y,z:p.zoom},w=s.getTileBoundingVolume(C,p.wrap,t.elevation,n);if(!S){let t=Oa(r,w,i);if(t===0)continue;S=t===2}let T=s.distanceToTile2d(a.x,a.y,C,w),E=l;c&&(E=(n.calculateTileZoom||ja)(t.zoom+Le(t.tileSize/n.tileSize),T,_,v,t.fov)),E=(n.roundZoom?Math.round:Math.floor)(E),E=Math.max(0,E);let D=Math.min(E,d);if(p.wrap=s.getWrap(o,C,p.wrap),p.zoom>=D){if(p.zoom>1),i=p.zoom+1;b.push({zoom:i,x:n,y:r,wrap:p.wrap,fullyVisible:S})}}return x.sort((t,n)=>t.distanceSq-n.distanceSq).map(t=>t.tileID)}const Pa=xe.fromPoints([new i(0,0),new i(I,I)]);function Fa(t){return t===`raster`||t===`image`||t===`video`}function Ia(t,n,r,i,a,o,s){let c=U(),l=ze(n);for(let u of n){let n=t.getTileById(u.key);(n.fadingDirection===0||n.fadeOpacity===0)&&n.resetFadeLogic(),!La(t,n,r,c,i,a,s)&&(Ra(t,n,r,c,o,s)||Ba(n,l,c,s)||n.resetFadeLogic())}}function La(t,n,r,i,a,o,s){if(!n.hasData())return!1;let{tileID:c,fadingRole:l,fadingDirection:u,fadingParentID:d}=n;if(l===0&&u===1&&d)return r[d.key]=d,!0;let f=Math.max(c.overscaledZ-a,o);for(let a=c.overscaledZ-1;a>=f;a--){let o=c.scaledTo(a),l=t.getLoadedTile(o);if(l)return n.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:l.tileID,fadeEndTime:i+s}),l.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:i+s}),r[o.key]=o,!0}return!1}function Ra(t,n,r,i,a,o){if(!n.hasData())return!1;let s=n.tileID.children(a),c=za(t,n,s,r,i,a,o);if(c)return!0;for(let l of s)za(t,n,l.children(a),r,i,a,o)&&(c=!0);return c}function za(t,n,r,i,a,o,s){if(r[0].overscaledZ>=o)return!1;let c=!1;for(let o of r){let r=t.getLoadedTile(o);if(!r)continue;let{fadingRole:l,fadingDirection:u,fadingParentID:d}=r;(l!==0||u!==0||!d)&&(r.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:n.tileID,fadeEndTime:a+s}),n.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+s})),i[o.key]=o,c=!0}return c}function Ba(t,n,r,i){let a=t.tileID;if(t.selfFading)return!0;if(t.hasData())return!1;if(n.has(a)){let n=r+i;return t.setSelfFadeLogic(n),!0}return!1}function Va(t,n){if(n<=0)return!1;let r=U();for(let n of t.getAllTiles())if(n.fadeEndTime>=r)return!0;return!1}function Ha(t,n){let r=n.getRenderableIds();for(let i of r){if(!t.neighboringTiles?.[i])continue;let r=n.getTileById(i);t.neighboringTiles[i].backfilled||Ua(t,r),!r.neighboringTiles?.[t.tileID.key]?.backfilled&&Ua(r,t)}}function Ua(t,n){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let r=n.tileID.canonical.x-t.tileID.canonical.x,i=n.tileID.canonical.y-t.tileID.canonical.y,a=2**t.tileID.canonical.z,o=n.tileID.key;(r!==0||i!==0)&&(Math.abs(i)>1||(Math.abs(r)>1&&(Math.abs(r+a)===1?r+=a:Math.abs(r-a)===1&&(r-=a)),!(!n.dem||!t.dem)&&(t.dem.backfillBorder(n.dem,r,i),t.neighboringTiles?.[o]&&(t.neighboringTiles[o].backfilled=!0))))}var Ka=class{constructor(){this._tiles={}}handleWrapJump(t){let n={};for(let r in this._tiles){let i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),n[i.tileID.key]=i}this._tiles=n}setFeatureState(t,n,r){for(let i in this._tiles)this._tiles[i].setFeatureState(t,n,r)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map(t=>t.tileID).sort(Be).map(t=>t.key):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,n){this._tiles[t]=n}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){let n=this.getTileById(t.key);return n?.hasData()?n:null}isIdRenderable(t,n=!1){return this.getTileById(t)?.isRenderable(n)}getRenderableIds(t=0,n){let r=[];for(let t of this.getAllIds())this.isIdRenderable(t,n)&&r.push(this.getTileById(t));return n?r.sort((n,r)=>{let a=n.tileID,o=r.tileID,s=new i(a.canonical.x,a.canonical.y)._rotate(-t),c=new i(o.canonical.x,o.canonical.y)._rotate(-t);return a.overscaledZ-o.overscaledZ||c.y-s.y||c.x-s.x}).map(t=>t.tileID.key):r.map(t=>t.tileID).sort(Be).map(t=>t.key)}},Wa=class e extends _{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(t,n,r){super(),this.id=t,this.dispatcher=r,this.on(`data`,t=>{this._dataHandler(t)}),this.on(`dataloading`,()=>{this._sourceErrored=!1}),this.on(`error`,()=>{this._sourceErrored=this._source.loaded()}),this._source=oa(t,n,r,this),this._inViewTiles=new Ka,this._outOfViewCache=new Ve(0,t=>this._unloadTile(t)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new xa,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(t)}onRemove(t){for(let t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(t),this._inViewTiles=new Ka}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,n,r){try{let i=await this._source.loadTile(t);this._tileLoaded(t,n,r,i)}catch(n){t.state=`errored`,n.status===404?this.update(this.transform,this.terrain):this._source.fire(new y(f(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 K(`dataabort`,{tile:t,coord:t.tileID}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let n of this._inViewTiles.getAllTiles())n.upload(t),n.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,t)}hasRenderableParent(t){let n=t.overscaledZ-1;if(n>=this._source.minzoom){let r=this.getLoadedTile(t.scaledTo(n));if(r)return this._inViewTiles.isIdRenderable(r.tileID.key)}return!1}reload(t,n=void 0){if(this._paused){this._shouldReloadOnResume=!0;return}this._outOfViewCache.reset();for(let r of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(r);n&&!this._source.shouldReloadTile(i,n)||(t?this._reloadTile(r,`expired`):i.state!==`errored`&&this._reloadTile(r,`reloading`))}}async _reloadTile(t,n){let r=this._inViewTiles.getTileById(t);r&&(r.state!==`loading`&&(r.state=n),await this._loadTile(r,t,n))}_tileLoaded(t,n,r,i){t.timeAdded=U(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),r===`expired`&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),!i?.unmodified&&(this.getSource().type===`raster-dem`&&t.dem&&Ha(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new K(`data`,{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,n){let r=this._getLoadedDescendents(n),i=/* @__PURE__ */ new Set;for(let a of n){let n=r[a.key];if(!n?.length){i.add(a);continue}let o=a.overscaledZ+e.maxOverzooming,s=n.filter(t=>t.tileID.overscaledZ<=o);if(!s.length){i.add(a);continue}let c=Math.min(...s.map(t=>t.tileID.overscaledZ)),l=s.filter(t=>t.tileID.overscaledZ===c).map(t=>t.tileID);for(let n of l)t[n.key]=n;this._areDescendentsComplete(l,c,a.overscaledZ)||i.add(a)}return i}_getLoadedDescendents(t){let n={};for(let r of this._inViewTiles.getAllTiles().filter(t=>t.hasData()))for(let i of t)r.tileID.isChildOf(i)&&(n[i.key]||=[],n[i.key].push(r));return n}_areDescendentsComplete(t,n,r){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===n:4**(n-r)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let n=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),r=this._maxTileCacheZoomLevels===null?p.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,i=Math.floor(n*r),a=typeof this._maxTileCacheSize==`number`?Math.min(this._maxTileCacheSize,i):i;this._outOfViewCache.setMaxSize(a)}handleWrapJump(t){let n=(t-(this._prevLng===void 0?t:this._prevLng))/360,r=Math.round(n);this._prevLng=t,r&&(this._inViewTiles.handleWrapJump(r),this._resetTileReloadTimers())}update(t,n){if(!this._sourceLoaded||this._paused)return;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng);let r;!this.used&&!this.usedForTerrain?r=[]:this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new ve(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)):(r=Na(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:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter(t=>this._source.hasTile(t)))),this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let i=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,i&&this.fire(new K(`data`,{sourceDataType:`idle`,sourceId:this.id}));let a=Ma(t,this._source),o=this._updateRetainedTiles(r,a),s=Fa(this._source.type);s&&this._rasterFadeDuration>0&&!n&&Ia(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 n of this._inViewTiles.getAllIds())t[n]||this._removeTile(n)}_cleanUpVectorTiles(t){for(let n of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(n);if(t[n]){r.clearSymbolFadeHold();continue}if(!r.hasSymbolBuckets){this._removeTile(n);continue}r.holdingForSymbolFade()?r.symbolFadeFinished()&&this._removeTile(n):r.setSymbolHoldDuration(this.map._fadeDuration)}}_addTerrainIdealTiles(t){let n=[];for(let r of t)if(r.canonical.z>this._source.minzoom){let t=r.scaledTo(r.canonical.z-1);n.push(t);let i=r.scaledTo(Math.max(this._source.minzoom,Math.min(r.canonical.z,5)));n.push(i)}return t.concat(n)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){let r=/* @__PURE__ */ new Set;for(let n of t)this._addTile(n).hasData()||r.add(n);let i=t.reduce((t,n)=>(t[n.key]=n,t),{}),a=this._retainLoadedChildren(i,r),o={},s=Math.max(n-e.maxUnderzooming,this._source.minzoom);for(let t of a){let n=this._inViewTiles.getTileById(t.key),r=n?.wasRequested();for(let a=t.overscaledZ-1;a>=s;--a){let s=t.scaledTo(a);if(o[s.key])break;if(o[s.key]=!0,n=this.getTile(s),!n&&r&&(n=this._addTile(s)),n){let t=n.hasData();if((t||!this.map?.cancelPendingTileRequestsWhileZooming||r)&&(i[s.key]=s),r=n.wasRequested(),t)break}}}return i}_addTile(t){let n=this._inViewTiles.getTileById(t.key);if(n)return n;n=this._outOfViewCache.getAndRemove(t),n&&(n.resetFadeLogic(),this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null));let r=n;return n||(n=new ya(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._inViewTiles.setTile(t.key,n),r||this._source.fire(new K(`dataloading`,{tile:n,coord:n.tileID})),n}_setTileReloadTimer(t,n){this._clearTileReloadTimer(t);let r=n.getExpiryTimeout();if(r){let n=()=>{this._reloadTile(t,`expired`),delete this._timers[t]};this._timers[t]=setTimeout(n,r)}}_clearTileReloadTimer(t){let n=this._timers[t];n&&(clearTimeout(n),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 n=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,n)}}refreshTiles(t){for(let n of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(n);!this._inViewTiles.isIdRenderable(n)&&r.state!=`errored`||t.some(t=>t.equals(r.tileID.canonical))&&this._reloadTile(n,`expired`)}}_removeTile(t){let n=this._inViewTiles.getTileById(t);n&&(n.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),!(n.uses>0)&&(n.hasData()&&n.state!==`reloading`?this._outOfViewCache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(t){if(t.dataType===`source`){if(t.sourceDataType===`metadata`){this._sourceLoaded=!0;return}t.sourceDataType!==`content`||!this._sourceLoaded||this._paused||(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,n,r){let i=[],a=this.transform;if(!a)return i;let o=a.getCoveringTilesDetailsProvider().allowWorldCopies(),s=r?a.getCameraQueryGeometry(t):t,c=t=>a.screenPointToMercatorCoordinate(t,this.terrain),l=this.transformBbox(t,c,!o),u=this.transformBbox(s,c,!o),d=this.getIds(),f=xe.fromPoints(u);for(let t of d){let r=this._inViewTiles.getTileById(t);if(r.holdingForSymbolFade())continue;let s=o?[r.tileID]:[r.tileID.unwrapTo(-1),r.tileID.unwrapTo(0)],c=2**(a.zoom-r.tileID.overscaledZ),d=n*r.queryPadding*I/r.tileSize/c;for(let t of s){let n=f.map(n=>t.getTilePoint(new L(n.x,n.y)));if(n.expandBy(d),n.intersects(Pa)){let n=l.map(n=>t.getTilePoint(n)),a=u.map(n=>t.getTilePoint(n));i.push({tile:r,tileID:o?t:t.unwrapTo(0),queryGeometry:n,cameraQueryGeometry:a,scale:c})}}}return i}transformBbox(t,n,r){let i=t.map(n);if(r){let r=xe.fromPoints(t);r.shrinkBy(Math.min(r.width(),r.height())*.001);let a=r.map(n);xe.fromPoints(i).covers(a)||(i=i.map(t=>t.x>.5?new L(t.x-1,t.y,t.z):t))}return i}getVisibleCoordinates(t){let n=this.getRenderableIds(t).map(t=>this._inViewTiles.getTileById(t).tileID);return this.transform&&this.transform.populateCache(n),n}hasTransition(){return this._source.hasTransition()?!0:Fa(this._source.type)&&Va(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,n,r){t||=He,this._state.updateState(t,n,r)}removeFeatureState(t,n,r){t||=He,this._state.removeFeatureState(t,n,r)}getFeatureState(t,n){return t||=He,this._state.getState(t,n)}setDependencies(t,n,r){let i=this._inViewTiles.getTileById(t);i&&i.setDependencies(n,r)}reloadTilesForDependencies(t,n){for(let r of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(r).hasDependency(t,n)&&this._reloadTile(r,`reloading`);this._outOfViewCache.filter(r=>!r.hasDependency(t,n))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if(t.state!==`loaded`&&t.state!==`errored`)return!1;return!0}},Ja=class{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let t=1;t0?(i-o)/s:0;return this.points[a].mult(1-c).add(this.points[n].mult(c))}};function Ga(t,n){let r=!0;return t===`always`||(t===`never`||n===`never`)&&(r=!1),r}var Xa=class{constructor(t,n,r){let i=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(t/r),this.yCellCount=Math.ceil(n/r);for(let t=0;tthis.width||i<0||n>this.height)return[];let c=[];if(t<=0&&n<=0&&this.width<=r&&this.height<=i){if(a)return[{key:null,x1:t,y1:n,x2:r,y2:i}];for(let t=0;t0}hitTestCircle(t,n,r,i,a){let o=t-r,s=t+r,c=n-r,l=n+r;if(s<0||o>this.width||l<0||c>this.height)return!1;let u=[],d={hitTest:!0,overlapMode:i,circle:{x:t,y:n,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(o,c,s,l,this._queryCellCircle,u,d,a),u.length>0}_queryCell(t,n,r,i,a,o,s,c){let{seenUids:l,hitTest:u,overlapMode:d}=s,f=this.boxCells[a],p=1e-6;if(f!==null){let a=this.bboxes;for(let s of f)if(!l.box[s]){l.box[s]=!0;let f=s*4,m=this.boxKeys[s];if(t<=a[f+2]+p&&n<=a[f+3]+p&&r>=a[f+0]-p&&i>=a[f+1]-p&&(!c||c(m))&&(!u||!Ga(d,m.overlapMode))&&(o.push({key:m,x1:a[f],y1:a[f+1],x2:a[f+2],y2:a[f+3]}),u))return!0}}let m=this.circleCells[a];if(m!==null){let a=this.circles;for(let s of m)if(!l.circle[s]){l.circle[s]=!0;let f=s*3,p=this.circleKeys[s];if(this._circleAndRectCollide(a[f],a[f+1],a[f+2],t,n,r,i)&&(!c||c(p))&&(!u||!Ga(d,p.overlapMode))){let t=a[f],n=a[f+1],r=a[f+2];if(o.push({key:p,x1:t-r,y1:n-r,x2:t+r,y2:n+r}),u)return!0}}}return!1}_queryCellCircle(t,n,r,i,a,o,s,c){let{circle:l,seenUids:u,overlapMode:d}=s,f=this.boxCells[a];if(f!==null){let t=this.bboxes;for(let n of f)if(!u.box[n]){u.box[n]=!0;let r=n*4,i=this.boxKeys[n];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[r+0],t[r+1],t[r+2],t[r+3])&&(!c||c(i))&&!Ga(d,i.overlapMode))return o.push(!0),!0}}let p=this.circleCells[a];if(p!==null){let t=this.circles;for(let n of p)if(!u.circle[n]){u.circle[n]=!0;let r=n*3,i=this.circleKeys[n];if(this._circlesCollide(t[r],t[r+1],t[r+2],l.x,l.y,l.radius)&&(!c||c(i))&&!Ga(d,i.overlapMode))return o.push(!0),!0}}}_forEachCell(t,n,r,i,a,o,s,c){let l=this._convertToXCellCoord(t),u=this._convertToYCellCoord(n),d=this._convertToXCellCoord(r),f=this._convertToYCellCoord(i);for(let p=l;p<=d;p++)for(let l=u;l<=f;l++){let u=this.xCellCount*l+p;if(a.call(this,t,n,r,i,u,o,s,c))return}}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,r,i,a,o){let s=i-t,c=a-n,l=r+o;return l*l>s*s+c*c}_circleAndRectCollide(t,n,r,i,a,o,s){let c=(o-i)/2,l=Math.abs(t-(i+c));if(l>c+r)return!1;let u=(s-a)/2,d=Math.abs(n-(a+u));if(d>u+r)return!1;if(l<=c||d<=u)return!0;let f=l-c,p=d-u;return f*f+p*p<=r*r}};function qa(t,n){let r=1/(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]),i=1/(n[8]*n[8]+n[9]*n[9]+n[10]*n[10]),a=n[0]*r,o=n[4]*r,s=n[8]*i,c=n[1]*r,l=n[5]*r,u=n[9]*i,d=n[2]*r,f=n[6]*r,p=n[10]*i;t[0]=a,t[1]=o,t[2]=s,t[4]=c,t[5]=l,t[6]=u,t[8]=d,t[9]=f,t[10]=p;let m=n[12],h=n[13],g=n[14];return t[12]=-a*m-c*h-d*g,t[13]=-o*m-l*h-f*g,t[14]=-s*m-u*h-p*g,t[3]=0,t[7]=0,t[11]=0,t[15]=1,t}function Ya(t,n){return t[0]=1/n[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1/n[5],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=1/n[14],t[12]=0,t[13]=0,t[14]=-1,t[15]=n[10]/n[14],t}function Za(t,n){let r=1/(n[0]*n[5]-n[1]*n[4]);return t[0]=n[5]*r,t[1]=-n[1]*r,t[2]=0,t[3]=0,t[4]=-n[4]*r,t[5]=n[0]*r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1/n[10],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1/n[15],t}const Qa=ce();function $a(t,n,r){let i=ce();if(!t){let{vecSouth:t,vecEast:r}=to(n),a=yr();a[0]=r[0],a[1]=r[1],a[2]=t[0],a[3]=t[1],br(a,a),i[0]=a[0],i[1]=a[1],i[4]=a[2],i[5]=a[3]}return P(i,i,[1/r,1/r,1]),i}function eo(t,n,r,i){if(t){let t=ce();if(!n){let{vecSouth:n,vecEast:i}=to(r);t[0]=i[0],t[1]=i[1],t[4]=n[0],t[5]=n[1]}return P(t,t,[i,i,1]),t}else return r.pixelsToClipSpaceMatrix}function to(t){let n=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),i=Math.cos(t.pitchInRadians),a=Math.cos(t.bearingInRadians),o=Math.sin(t.bearingInRadians),s=Ue();s[0]=-a*i*r-o*n,s[1]=-o*i*r+a*n;let c=We(s);c<1e-9?Ge(s):Ke(s,s,1/c);let l=Ue();l[0]=a*i*n-o*r,l[1]=o*i*n+a*r;let u=We(l);return u<1e-9?Ge(l):Ke(l,l,1/u),{vecEast:l,vecSouth:s}}function no(t,n,r,a){let o;a?(o=[t,n,a(t,n),1],qe(o,o,r)):(o=[t,n,0,1],bo(o,o,r));let s=o[3];return{point:new i(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function ro(t,n){return .5+t/n*.5}function io(t,n){return t.x>=-n[0]&&t.x<=n[0]&&t.y>=-n[1]&&t.y<=n[1]}function ao(t,n,r,a,o,s,c,l,u,d,f,p,m){let h=r?t.textSizeData:t.iconSizeData,g=Je(h,n.transform.zoom),_=[256/n.width*2+1,256/n.height*2+1],v=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;v.clear();let y=t.lineVertexArray,b=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=n.transform.width/n.transform.height,S=!1;for(let r=0;rMath.abs(r.x-n.x)*i?{useVertical:!0}:(t===2?n.yr.x)?{needsFlipping:!0}:null}function co(t){let{projectionContext:n,pitchedLabelPlaneMatrixInverse:r,symbol:a,fontSize:o,flip:s,keepUpright:c,glyphOffsetArray:l,dynamicLayoutVertexArray:u,aspectRatio:d,rotateToLine:f}=t,p=o/24,m=a.lineOffsetX*p,h=a.lineOffsetY*p,g;if(a.numGlyphs>1){let t=a.glyphStartIndex+a.numGlyphs,i=a.lineStartIndex,o=a.lineStartIndex+a.lineLength,u=oo(p,l,m,h,s,a,f,n);if(!u)return{notEnoughRoom:!0};let _=po(u.first.point.x,u.first.point.y,n,r),v=po(u.last.point.x,u.last.point.y,n,r);if(c&&!s){let t=so(a.writingMode,_,v,d);if(t)return t}g=[u.first];for(let r=a.glyphStartIndex+1;r0?c.point:lo(n.tileAnchorPoint,s,t,1,n),u=po(t.x,t.y,n,r),f=po(l.x,l.y,n,r),p=so(a.writingMode,u,f,d);if(p)return p}let t=_o(p*l.getoffsetX(a.glyphStartIndex),m,h,s,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,n,f);if(!t||n.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};g=[t]}for(let t of g)Xe(u,t.point,t.angle);return{}}function lo(t,n,r,i,a){let o=t.add(t.sub(n)._unit()),s=fo(o.x,o.y,a).point,c=r.sub(s);return r.add(c._mult(i/c.mag()))}function uo(t,n,r){let a=n.projectionCache;if(a.projections[t])return a.projections[t];let o=new i(n.lineVertexArray.getx(t),n.lineVertexArray.gety(t)),s=fo(o.x,o.y,n);if(s.signedDistanceFromCamera>0)return a.projections[t]=s.point,a.anyProjectionOccluded||=s.isOccluded,s.point;let c=t-r.direction,l=r.distanceFromAnchor===0?n.tileAnchorPoint:new i(n.lineVertexArray.getx(c),n.lineVertexArray.gety(c)),u=r.absOffsetX-r.distanceFromAnchor+1;return lo(l,o,r.previousVertex,u,n)}function fo(t,n,r){let i=t+r.translation[0],a=n+r.translation[1],o;return r.pitchWithMap?(o=no(i,a,r.pitchedLabelPlaneMatrix,r.getElevation),o.isOccluded=!1):(o=r.transform.projectTileCoordinates(i,a,r.unwrappedTileID,r.getElevation),o.point.x=(o.point.x*.5+.5)*r.width,o.point.y=(-o.point.y*.5+.5)*r.height),o}function po(t,n,r,i){if(r.pitchWithMap){let a=[t,n,0,1];return qe(a,a,i),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}else return{x:t/r.width*2-1,y:1-n/r.height*2}}function mo(t,n,r){return r.transform.projectTileCoordinates(t,n,r.unwrappedTileID,r.getElevation)}function ho(t,n,r){return t._unit()._perp()._mult(n*r)}function go(t,n,r,i,a,o,s,c,l){if(c.projectionCache.offsets[t])return c.projectionCache.offsets[t];let u=r.add(n);if(t+l.direction=a)return c.projectionCache.offsets[t]=u,u;let d=uo(t+l.direction,c,l),f=ho(d.sub(r),s,l.direction),p=r.add(f),m=d.add(f);return c.projectionCache.offsets[t]=Ze(o,u,p,m)||u,c.projectionCache.offsets[t]}function _o(t,n,r,i,a,o,s,c,l){let u=i?t-n:t+n,d=u>0?1:-1,f=0;i&&(d*=-1,f=Math.PI),d<0&&(f+=Math.PI);let p=d>0?o+a:o+a+1,m;c.projectionCache.cachedAnchorPoint?m=c.projectionCache.cachedAnchorPoint:(m=fo(c.tileAnchorPoint.x,c.tileAnchorPoint.y,c).point,c.projectionCache.cachedAnchorPoint=m);let h=m,g=m,_,v,y=0,b=0,x=Math.abs(u),S=[],C;for(;y+b<=x;){if(p+=d,p=s)return null;y+=b,g=h,v=_;let t={absOffsetX:x,direction:d,distanceFromAnchor:y,previousVertex:g};if(h=uo(p,c,t),r===0)S.push(g),C=h.sub(g);else{let n,i=h.sub(g);n=i.mag()===0?ho(uo(p+d,c,t).sub(h),r,d):ho(i,r,d),v||=g.add(n),_=go(p,n,h,o,s,v,r,c,t),S.push(v),C=_.sub(v)}b=C.mag()}let w=(x-y)/b,T=C._mult(w)._add(v||g),E=f+Math.atan2(h.y-g.y,h.x-g.x);return S.push(T),{point:T,angle:l?E:0,path:S}}const vo=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function yo(t,n){for(let r=0;r{let i=no(t.x,t.y,r,n.getElevation),a=n.transform.projectTileCoordinates(i.point.x,i.point.y,n.unwrappedTileID,n.getElevation);return a.point.x=(a.point.x*.5+.5)*n.width,a.point.y=(-a.point.y*.5+.5)*n.height,a})}function So(t){let n=0,r=0,i=0,a=0;for(let o=0;or&&(r=a,n=i));return t.slice(n,n+r)}var To=class{constructor(t,n=new Xa(t.width+200,t.height+200,25),r=new Xa(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=r,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+100,this.screenBottomBoundary=t.height+100,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,r,i,a,o,s,c,l,u,d,f){let p=t.anchorPointX+c[0],m=t.anchorPointY+c[1],h=this.projectAndGetPerspectiveRatio(p,m,a,u,f),g=r*h.perspectiveRatio,_;if(!o&&!s){let n=h.x+(d?d.x*g:0),r=h.y+(d?d.y*g:0);_={allPointsOccluded:!1,box:[n+t.x1*g,r+t.y1*g,n+t.x2*g,r+t.y2*g]}}else _=this._projectCollisionBox(t,g,i,a,o,s,c,h,u,d,f);let[v,y,b,x]=_.box,S=o?_.allPointsOccluded:h.isOccluded,C=S;return C||=h.perspectiveRatio=1;t--)m.push(s.path[t]);for(let t=1;tt.signedDistanceFromCamera<=0)?[]:t.map(t=>t.point)}let _=[];if(m.length>0){let t=m[0].clone(),n=m[0].clone();for(let r=1;r=r.x&&n.x<=a.x&&t.y>=r.y&&n.y<=a.y?[m]:n.xa.x||n.ya.y?[]:Qe([m],r.x,r.y,a.x,a.y)}for(let r of _){o.reset(r,n*.25);let i=0;i=o.length<=.5*n?1:Math.ceil(o.paddedLength/h)+1;for(let r=0;r=this.screenRightBoundary||i<100||n>this.screenBottomBoundary}isInsideGrid(t,n,r,i){return r>=0&&t=0&&nthis.projectAndGetPerspectiveRatio(t.x,t.y,a,u,f));A=t.some(t=>!t.isOccluded),k=t.map(t=>new i(t.x,t.y))}else A=!0;return{box:et(k),allPointsOccluded:!A}}},Eo=class{constructor(t,n,r,i){t?this.opacity=Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):this.opacity=i&&r?1:0,this.placed=r}isHidden(){return this.opacity===0&&!this.placed}},Do=class{constructor(t,n,r,i,a){this.text=new Eo(t?t.text:null,n,r,a),this.icon=new Eo(t?t.icon:null,n,i,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Oo=class{constructor(t,n,r){this.text=t,this.icon=n,this.skipFade=r}},ko=class{constructor(t,n,r,i,a){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=r,this.bucketIndex=i,this.tileID=a}},Ao=class{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:t=>t.collisionGroupID===n}}return this.collisionGroups[t]}};function Co(t,n,r,a,o){let{horizontalAlign:s,verticalAlign:c}=tt(t),l=-(s-.5)*n,u=-(c-.5)*r;return new i(l+a[0]*o,u+a[1]*o)}var Mo=class{constructor(t,n,r,i,a){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new To(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new Ao(i),this.collisionCircleArrays={},this.collisionBoxArrays=/* @__PURE__ */ new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){let n=this.terrain;return n?(r,i)=>n.getElevation(t,r,i):null}getBucketParts(t,n,r,i){let a=r.getBucket(n),o=r.latestFeatureIndex;if(!a||!o||n.id!==a.layerIds[0])return;let s=r.collisionBoxArray,c=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-r.tileID.overscaledZ),d=r.tileSize/I,f=r.tileID.toUnwrapped(),p=c.get(`text-rotation-alignment`)===`map`,m=nt(r,1,this.transform.zoom),h=rt(this.collisionIndex.transform,r,l.get(`text-translate`),l.get(`text-translate-anchor`)),g=rt(this.collisionIndex.transform,r,l.get(`icon-translate`),l.get(`icon-translate-anchor`)),_=$a(p,this.transform,m);this.retainedQueryData[a.bucketInstanceId]=new ko(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,r.tileID);let v={bucket:a,layout:c,translationText:h,translationIcon:g,unwrappedTileID:f,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:d,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:Je(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(let n of a.sortKeyRanges){let{sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:a}=n;t.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:a,parameters:v})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v})}attemptAnchorPlacement(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b){let x=it[t.textAnchor],S=[t.textOffset0,t.textOffset1],C=Co(x,r,i,S,a),w=this.collisionIndex.placeCollisionBox(n,f,c,l,u,s,o,g,d.predicate,y,C,b);if(!(v&&!this.collisionIndex.placeCollisionBox(v,f,c,l,u,s,o,_,d.predicate,y,C,b).placeable)&&w.placeable){let t;if(this.prevPlacement?.variableOffsets[p.crossTileID]&&this.prevPlacement?.placements[p.crossTileID]?.text&&(t=this.prevPlacement.variableOffsets[p.crossTileID].anchor),p.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);return this.variableOffsets[p.crossTileID]={textOffset:S,width:r,height:i,anchor:x,textBoxScale:a,prevAnchor:t},this.markUsedJustification(m,x,p,h),m.allowVerticalPlacement&&(this.markUsedOrientation(m,h,p),this.placedOrientations[p.crossTileID]=h),{shift:C,placedGlyphBoxes:w}}}placeLayerBucketPart(t,n,r){let{bucket:i,layout:a,translationText:o,translationIcon:s,unwrappedTileID:c,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,collisionGroup:m}=t.parameters,h=a.get(`text-optional`),g=a.get(`icon-optional`),_=at(a,`text-overlap`,`text-allow-overlap`),v=_===`always`,y=at(a,`icon-overlap`,`icon-allow-overlap`),x=y===`always`,S=a.get(`text-rotation-alignment`)===`map`,C=a.get(`text-pitch-alignment`)===`map`,w=a.get(`icon-text-fit`)!==`none`,T=a.get(`symbol-z-order`)===`viewport-y`,E=v&&(x||!i.hasIconData()||g),D=x&&(v||!i.hasTextData()||h);!i.collisionArrays&&f&&i.deserializeCollisionBoxes(f);let O=this.retainedQueryData[i.bucketInstanceId].tileID,k=this._getTerrainElevationFunc(O),A=this.transform.getFastPathSimpleProjectionMatrix(O),j=(t,f,x)=>{if(n[t.crossTileID])return;if(d){this.placements[t.crossTileID]=new Oo(!1,!1,!1);return}let T=!1,j=!1,ee=!0,te=null,M={box:null,placeable:!1,offscreen:null,occluded:!1},ne={box:null,placeable:!1,offscreen:null},re=null,ie=null,ae=null,oe=0,se=0,ce=0;f.textFeatureIndex?oe=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(oe=t.featureIndex),f.verticalTextFeatureIndex&&(se=f.verticalTextFeatureIndex);let N=f.textBox;if(N){let n=n=>{let r=1;if(i.allowVerticalPlacement&&!n&&this.prevPlacement){let n=this.prevPlacement.placedOrientations[t.crossTileID];n&&(this.placedOrientations[t.crossTileID]=n,r=n,this.markUsedOrientation(i,r,t))}return r},a=(n,r)=>{if(i.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&f.verticalTextBox){for(let t of i.writingModes)if(t===2?(M=r(),ne=M):M=n(),M?.placeable)break}else M=n()},l=t.textAnchorOffsetStartIndex,d=t.textAnchorOffsetEndIndex;if(d===l){let r=(n,r)=>{let a=this.collisionIndex.placeCollisionBox(n,_,u,O,c,C,S,o,m.predicate,k,void 0,A);return a?.placeable&&(this.markUsedOrientation(i,r,t),this.placedOrientations[t.crossTileID]=r),a};a(()=>r(N,1),()=>{let n=f.verticalTextBox;return i.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&n?r(n,2):{box:null,offscreen:null}}),n(M?.placeable)}else{let p=it[this.prevPlacement?.variableOffsets[t.crossTileID]?.anchor],h=(n,a,f)=>{let h=n.x2-n.x1,g=n.y2-n.y1,v=t.textBoxScale,b=w&&y===`never`?a:null,x=null,E=_===`never`?1:2,D=`never`;p&&E++;for(let r=0;rh(N,f.iconBox,1),()=>{let n=f.verticalTextBox,r=M?.placeable;return i.allowVerticalPlacement&&!r&&t.numVerticalGlyphVertices>0&&n?h(n,f.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),M&&(T=M.placeable,ee=M.offscreen);let g=n(M?.placeable);if(!T&&this.prevPlacement){let n=this.prevPlacement.variableOffsets[t.crossTileID];n&&(this.variableOffsets[t.crossTileID]=n,this.markUsedJustification(i,n.anchor,t,g))}}}if(re=M,T=re?.placeable,ee=re?.offscreen,t.useRuntimeCollisionCircles&&t.centerJustifiedTextSymbolIndex>=0){let n=i.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),s=Ye(i.textSizeData,p,n),u=a.get(`text-padding`),d=t.collisionCircleDiameter;ie=this.collisionIndex.placeCollisionCircles(_,n,i.lineVertexArray,i.glyphOffsetArray,s,c,l,r,C,m.predicate,d,u,o,k),ie.circles.length&&ie.collisionDetected&&!r&&b(`Collisions detected, but collision boxes are not shown`),T=v||ie.circles.length>0&&!ie.collisionDetected,ee&&=ie.offscreen}if(f.iconFeatureIndex&&(ce=f.iconFeatureIndex),f.iconBox){let t=t=>this.collisionIndex.placeCollisionBox(t,y,u,O,c,C,S,s,m.predicate,k,w&&te?te:void 0,A);ne&&ne.placeable&&f.verticalIconBox?(ae=t(f.verticalIconBox),j=ae.placeable):(ae=t(f.iconBox),j=ae.placeable),ee&&=ae.offscreen}let P=h||t.numHorizontalGlyphVertices===0&&t.numVerticalGlyphVertices===0,le=g||t.numIconVertices===0;!P&&!le?j=T=j&&T:le?P||(j&&=T):T=j&&T;let ue=T&&re.placeable,F=j&&ae.placeable;if(ue&&(ne&&ne.placeable&&se?this.collisionIndex.insertCollisionBox(re.box,_,a.get(`text-ignore-placement`),i.bucketInstanceId,se,m.ID):this.collisionIndex.insertCollisionBox(re.box,_,a.get(`text-ignore-placement`),i.bucketInstanceId,oe,m.ID)),F&&this.collisionIndex.insertCollisionBox(ae.box,y,a.get(`icon-ignore-placement`),i.bucketInstanceId,ce,m.ID),ie&&T&&this.collisionIndex.insertCollisionCircles(ie.circles,_,a.get(`text-ignore-placement`),i.bucketInstanceId,oe,m.ID),r&&this.storeCollisionData(i.bucketInstanceId,x,f,re,ae,ie),t.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);if(i.bucketInstanceId===0)throw Error(`bucket.bucketInstanceId can't be 0`);let de=(T||E)&&!re?.occluded,fe=(j||D)&&!ae?.occluded;this.placements[t.crossTileID]=new Oo(de,fe,ee||i.justReloaded),n[t.crossTileID]=!0};if(T){if(t.symbolInstanceStart!==0)throw Error(`bucket.bucketInstanceId should be 0`);let n=i.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=n.length-1;t>=0;--t){let r=n[t];j(i.symbolInstances.get(r),i.collisionArrays[r],r)}}else for(let n=t.symbolInstanceStart;n=0&&(o>=0&&n!==o?t.text.placedSymbolArray.get(n).crossTileID=0:t.text.placedSymbolArray.get(n).crossTileID=r.crossTileID)}markUsedOrientation(t,n,r){let i=n===1||n===3?n:0,a=n===2?n:0,o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(let n of o)t.text.placedSymbolArray.get(n).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let n=this.prevPlacement,r=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;let i=n?n.symbolFadeChange(t):1,a=n?n.opacities:{},o=n?n.variableOffsets:{},s=n?n.placedOrientations:{};for(let t in this.placements){let n=this.placements[t],o=a[t];o?(this.opacities[t]=new Do(o,i,n.text,n.icon),r||=n.text!==o.text.placed,r||=n.icon!==o.icon.placed):(this.opacities[t]=new Do(null,i,n.text,n.icon,n.skipFade),r||=n.text||n.icon)}for(let t in a){let n=a[t];if(!this.opacities[t]){let a=new Do(n,i,!1,!1);a.isHidden()||(this.opacities[t]=a,r||=n.text.placed,r||=n.icon.placed)}}for(let t in o)!this.variableOffsets[t]&&this.opacities[t]&&!this.opacities[t].isHidden()&&(this.variableOffsets[t]=o[t]);for(let t in s)!this.placedOrientations[t]&&this.opacities[t]&&!this.opacities[t].isHidden()&&(this.placedOrientations[t]=s[t]);if(n&&n.lastPlacementChangeTime===void 0)throw Error(`Last placement time for previous placement is not defined`);r?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!=`number`&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){let r={};for(let i of n){let n=i.getBucket(t);n&&i.latestFeatureIndex&&t.id===n.layerIds[0]&&this.updateBucketOpacities(n,i.tileID,r,i.collisionBoxArray)}}updateBucketOpacities(t,n,r,a){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();let o=t.layers[0],s=o.layout,c=new Do(null,0,!1,!1,!0),l=s.get(`text-allow-overlap`),u=s.get(`icon-allow-overlap`),d=o._unevaluatedLayout.hasValue(`text-variable-anchor`)||o._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),f=s.get(`text-rotation-alignment`)===`map`,p=s.get(`text-pitch-alignment`)===`map`,m=s.get(`icon-text-fit`)!==`none`,h=new Do(null,0,l&&(u||!t.hasIconData()||s.get(`icon-optional`)),u&&(l||!t.hasTextData()||s.get(`text-optional`)),!0);!t.collisionArrays&&a&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(a);let g=(t,n,r)=>{for(let i=0;i0||s>0,b=a.numIconVertices>0,x=this.placedOrientations[a.crossTileID],S=x===2,C=x===1||x===3;if(y){let n=Io(v.text),r=S?Lo:n;g(t.text,o,r);let i=C?Lo:n;g(t.text,s,i);let c=v.text.isHidden(),l=[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex];for(let n of l)n>=0&&(t.text.placedSymbolArray.get(n).hidden=c||S?1:0);a.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).hidden=c||C?1:0);let u=this.variableOffsets[a.crossTileID];u&&this.markUsedJustification(t,u.anchor,a,x);let d=this.placedOrientations[a.crossTileID];d&&(this.markUsedJustification(t,`left`,a,d),this.markUsedOrientation(t,d,a))}if(b){let n=Io(v.icon),r=!(m&&a.verticalPlacedIconSymbolIndex&&S);if(a.placedIconSymbolIndex>=0){let i=r?n:Lo;g(t.icon,a.numIconVertices,i),t.icon.placedSymbolArray.get(a.placedIconSymbolIndex).hidden=v.icon.isHidden()}if(a.verticalPlacedIconSymbolIndex>=0){let i=r?Lo:n;g(t.icon,a.numVerticalIconVertices,i),t.icon.placedSymbolArray.get(a.verticalPlacedIconSymbolIndex).hidden=v.icon.isHidden()}}let w=_?.has(n)?_.get(n):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let r=t.collisionArrays[n];if(r){let n=new i(0,0);if(r.textBox||r.verticalTextBox){let i=!0;if(d){let t=this.variableOffsets[l];t?(n=Co(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),f&&n._rotate(p?-this.transform.bearingInRadians:this.transform.bearingInRadians)):i=!1}if(r.textBox||r.verticalTextBox){let a;r.textBox&&(a=S),r.verticalTextBox&&(a=C),wo(t.textCollisionBox.collisionVertexArray,v.text.placed,!i||a,w.text,n.x,n.y)}}if(r.iconBox||r.verticalIconBox){let i=!!(!C&&r.verticalIconBox),a;r.iconBox&&(a=i),r.verticalIconBox&&(a=!i),wo(t.iconCollisionBox.collisionVertexArray,v.icon.placed,a,w.icon,m?n.x:0,m?n.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}};function wo(t,n,r,i,a,o){(!i||i.length===0)&&(i=[0,0,0,0]);let s=i[0]-100,c=i[1]-100,l=i[2]-100,u=i[3]-100;t.emplaceBack(+!!n,+!!r,a||0,o||0,s,c),t.emplaceBack(+!!n,+!!r,a||0,o||0,l,c),t.emplaceBack(+!!n,+!!r,a||0,o||0,l,u),t.emplaceBack(+!!n,+!!r,a||0,o||0,s,u)}const jo=2**25,No=2**24,Po=2**17,Fo=2**16;function Io(t){if(t.opacity===0&&!t.placed)return 0;if(t.opacity===1&&t.placed)return 4294967295;let n=+!!t.placed,r=Math.floor(t.opacity*127);return r*jo+n*No+r*Po+n*Fo+r*512+n*256+r*2+n}const Lo=0;var Bo=class{constructor(t){this._sortAcrossTiles=t.layout.get(`symbol-z-order`)!==`viewport-y`&&!t.layout.get(`symbol-sort-key`).isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,r,i,a){let o=this._bucketParts;for(;this._currentTileIndext.sortKey-n.sortKey));this._currentPartIndex!this._forceFullPlacement&&U()-i>2;for(;this._currentPlacementIndex>=0;){let i=n[t[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(st(i)&&i.layout&&(!i.minzoom||i.minzoom<=o)&&(!i.maxzoom||i.maxzoom>o)){if(this._inProgressLayer||=new Bo(i),this._inProgressLayer.continuePlacement(r[i.source],this.placement,this._showCollisionBoxes,i,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}};const Ro=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],q=new Uint32Array(96);var zo=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=Ro[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,void 0,t)}constructor(t,n=64,r=Float64Array,i=ArrayBuffer,a){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let o=Ro.indexOf(this.ArrayType),s=t*2*this.ArrayType.BYTES_PER_ELEMENT,c=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-c%8)%8;if(o<0)throw Error(`Unexpected typed array class: ${r}.`);if(a)this.data=a,this.ids=new this.IndexArrayType(a,8,t),this.coords=new r(a,8+c+l,t*2),this._pos=t*2,this._finished=!0;else{let a=this.data=new i(8+s+c+l);this.ids=new this.IndexArrayType(a,8,t),this.coords=new r(a,8+c+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(a,0,2).set([219,16+o]),new Uint16Array(a,2,1)[0]=n,new Uint32Array(a,4,1)[0]=t}}add(t,n){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return Ho(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,i){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:a,coords:o,nodeSize:s}=this;q[0]=0,q[1]=a.length-1,q[2]=0;let c=3,l=[];for(;c>0;){let u=q[--c],d=q[--c],f=q[--c];if(d-f<=s){for(let s=f;s<=d;s++){let c=o[2*s],u=o[2*s+1];c>=t&&c<=r&&u>=n&&u<=i&&l.push(a[s])}continue}let p=f+d>>1,m=o[2*p],h=o[2*p+1];m>=t&&m<=r&&h>=n&&h<=i&&l.push(a[p]),(u===0?t<=m:n<=h)&&(q[c++]=f,q[c++]=p-1,q[c++]=1-u),(u===0?r>=m:i>=h)&&(q[c++]=p+1,q[c++]=d,q[c++]=1-u)}return l}within(t,n,r){let i=[];return this.withinInto(t,n,r,i),i}withinInto(t,n,r,i){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:a,coords:o,nodeSize:s}=this;q[0]=0,q[1]=a.length-1,q[2]=0;let c=3,l=0,u=r*r;for(;c>0;){let d=q[--c],f=q[--c],p=q[--c];if(f-p<=s){for(let r=p;r<=f;r++)Ko(o[2*r],o[2*r+1],t,n)<=u&&(i[l++]=a[r]);continue}let m=p+f>>1,h=o[2*m],g=o[2*m+1];Ko(h,g,t,n)<=u&&(i[l++]=a[m]),(d===0?t-r<=h:n-r<=g)&&(q[c++]=p,q[c++]=m-1,q[c++]=1-d),(d===0?t+r>=h:n+r>=g)&&(q[c++]=m+1,q[c++]=f,q[c++]=1-d)}return l}};function Ho(t,n,r,i,a,o){if(a-i<=r)return;let s=i+a>>1;Uo(t,n,s,i,a,o),Ho(t,n,r,i,s-1,1-o),Ho(t,n,r,s+1,a,1-o)}function Uo(t,n,r,i,a,o){for(;a>i;){if(a-i>600){let s=a-i+1,c=r-i+1,l=Math.log(s),u=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*u*(s-u)/s)*(c-s/2<0?-1:1);Uo(t,n,r,Math.max(i,Math.floor(r-c*u/s+d)),Math.min(a,Math.floor(r+(s-c)*u/s+d)),o)}let s=n[2*r+o],c=i,l=a;for(Wo(t,n,i,r),n[2*a+o]>s&&Wo(t,n,i,a);cs;)l--}n[2*i+o]===s?Wo(t,n,i,l):(l++,Wo(t,n,l,a)),l<=r&&(i=l+1),r<=l&&(a=l-1)}}function Wo(t,n,r,i){Go(t,r,i),Go(n,2*r,2*i),Go(n,2*r+1,2*i+1)}function Go(t,n,r){let i=t[n];t[n]=t[r],t[r]=i}function Ko(t,n,r,i){let a=t-r,o=n-i;return a*a+o*o}const qo=512/I/2;var Xo=class{constructor(t,n,r){this.tileID=t,this.bucketInstanceId=r,this._symbolsByKey={};let i=/* @__PURE__ */ new Map;for(let t=0;t({x:Math.floor(t.anchorX*qo),y:Math.floor(t.anchorY*qo)})),crossTileIDs:n.map(t=>t.crossTileID)};if(r.positions.length>128){let t=new zo(r.positions.length,16,Uint16Array);for(let{x:n,y:i}of r.positions)t.add(n,i);t.finish(),delete r.positions,r.index=t}this._symbolsByKey[t]=r}}getScaledCoordinates(t,n){let{x:r,y:i,z:a}=this.tileID.canonical,{x:o,y:s,z:c}=n.canonical,l=qo/2**(c-a),u=(o*I+t.anchorX)*l,d=(s*I+t.anchorY)*l,f=r*I*qo,p=i*I*qo;return{x:Math.floor(u-f),y:Math.floor(d-p)}}findMatches(t,n,r){let i=this.tileID.canonical.zt)}},Zo=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Qo=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let n=Math.round((t-this.lng)/360);if(n!==0)for(let t in this.indexes){let r=this.indexes[t],i={};for(let t in r){let a=r[t];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+n),i[a.tileID.key]=a}this.indexes[t]=i}this.lng=t}addBucket(t,n,r){if(this.indexes[t.overscaledZ]?.[t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;tt.overscaledZ)for(let r in a){let o=a[r];o.tileID.isChildOf(t)&&o.findMatches(n.symbolInstances,t,i)}else{let o=a[t.scaledTo(Number(r)).key];o&&o.findMatches(n.symbolInstances,t,i)}}for(let t=0;t{l(),i(t)}),{unsubscribe:l}=n(t.signal,`abort`,()=>{l(),s.cancelAnimationFrame(c),a(new r(t.signal.reason))},!1)},frameAsync(t,n){return new Promise((r,i)=>{this.frame(t,r,i,n)})},getImageData(t,n=0){return this.getImageCanvasContext(t).getImageData(-n,-n,t.width+2*n,t.height+2*n)},getImageCanvasContext(t){let n=window.document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});if(!r)throw Error(`failed to create canvas 2d context`);return n.width=t.width,n.height=t.height,r.drawImage(t,0,0,t.width,t.height),r},resolveURL(t){return xr||=document.createElement(`a`),xr.href=t,xr.href},get hardwareConcurrency(){return typeof navigator<`u`&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return Cr===void 0?matchMedia?(Sr??=matchMedia(`(prefers-reduced-motion: reduce)`),Sr.matches):!1:Cr},set prefersReducedMotion(t){Cr=t}},Tr=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(t){this._frozenAt=t}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function U(){return Tr.getCurrentTime()}function Er(t){Tr.setNow(t)}function Dr(){Tr.restoreNow()}function Or(){return Tr.isFrozen()}var W=class e{static{this.docStyle=typeof window<`u`&&window.document?.documentElement.style}static{this.selectProp=!e.docStyle||`userSelect`in e.docStyle?`userSelect`:`webkitUserSelect`}static create(t,n,r){let i=window.document.createElement(t);return n!==void 0&&(i.className=n),r&&r.appendChild(i),i}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){e.docStyle&&e.selectProp&&(e.userSelect=e.docStyle[e.selectProp],e.docStyle[e.selectProp]=`none`)}static enableDrag(){e.docStyle&&e.selectProp&&(e.docStyle[e.selectProp]=e.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener(`click`,e.suppressClickInternal,!0)}static suppressClick(){window.addEventListener(`click`,e.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener(`click`,e.suppressClickInternal,!0)},0)}static getScale(t){let n=t.getBoundingClientRect();return{x:n.width/t.offsetWidth||1,y:n.height/t.offsetHeight||1,boundingClientRect:n}}static getPoint(t,n,r){let a=n.boundingClientRect;return new i((r.clientX-a.left)/n.x-t.clientLeft,(r.clientY-a.top)/n.y-t.clientTop)}static mousePos(t,n){let r=e.getScale(t);return e.getPoint(t,r,n)}static touchPos(t,n){let r=[],i=e.getScale(t);for(let a of n)r.push(e.getPoint(t,i,a));return r}static sanitize(t){let n=new DOMParser().parseFromString(t,`text/html`).body||document.createElement(`body`),r=n.querySelectorAll(`script`);for(let t of r)t.remove();return e.clean(n),n.innerHTML}static isPossiblyDangerous(t,n){let r=n.replace(/\s+/g,``).toLowerCase();if([`src`,`href`,`xlink:href`].includes(t)&&(r.includes(`javascript:`)||r.includes(`data:`))||t.startsWith(`on`))return!0}static clean(t){let n=t.children;for(let t of n)e.removeAttributes(t),e.clean(t)}static removeAttributes(t){for(let{name:n,value:r}of t.attributes)e.isPossiblyDangerous(n,r)&&t.removeAttribute(n)}};let kr;(function(t){let n,i,h,g;t.resetRequestQueue=()=>{n=[],i=0,h=0,g={}},t.addThrottleControl=t=>{let n=h++;return g[n]=t,n},t.removeThrottleControl=t=>{delete g[t],b()};let _=()=>{for(let t of Object.keys(g))if(g[t]())return!0;return!1};t.getImage=(t,r,i=!0,o)=>new Promise((s,c)=>{t.headers||={},t.headers.accept=`image/webp,*/*`,a(t,{type:`image`});let l={abortController:r,requestParameters:t,supportImageRefresh:i,imageBitmapOptions:o,state:`queued`,onError:t=>{c(t)},onSuccess:t=>{s(t)}};n.push(l),b()});let v=(t,n)=>typeof createImageBitmap==`function`?o(t,n):s(t),y=async t=>{t.state=`running`;let{requestParameters:n,supportImageRefresh:r,imageBitmapOptions:a,onError:o,onSuccess:s,abortController:p}=t,m=r===!1&&!a&&!c(self)&&!l(n.url)&&(!n.headers||Object.keys(n.headers).reduce((t,n)=>t&&n===`accept`,!0));i++;let h=m?x(n,p):u(n,p);try{let n=await h;delete t.abortController,t.state=`completed`,n.data instanceof HTMLImageElement||d(n.data)?s(n):n.data&&s({data:await v(n.data,a),cacheControl:n.cacheControl,expires:n.expires})}catch(n){delete t.abortController,o(f(n))}finally{i--,b()}},b=()=>{let t=_()?p.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:p.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r0;r++){let t=n.shift();if(t.abortController.signal.aborted){r--;continue}y(t)}},x=(t,n)=>new Promise((i,a)=>{let o=new Image,s=t.url,c=t.credentials;c&&c===`include`?o.crossOrigin=`use-credentials`:(c&&c===`same-origin`||!m(s))&&(o.crossOrigin=`anonymous`),n.signal.addEventListener(`abort`,()=>{o.src=``,a(new r(n.signal.reason))}),o.fetchPriority=`high`,o.onload=()=>{o.onerror=o.onload=null,i({data:o})},o.onerror=()=>{o.onerror=o.onload=null,!n.signal.aborted&&a(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.`))},o.src=s})})(kr||={}),kr.resetRequestQueue();var Mr=class{constructor(t){this._transformRequestFn=t??null}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}},Nr=class extends h{},G=class extends Nr{},Pr=class extends Nr{constructor(t={}){super(`style.load`,t)}},Fr=class extends Nr{constructor(t,n={}){super(t,n),this.dataType=`style`}},K=class extends Nr{constructor(t,n={}){super(t,n),this.dataType=`source`}},Ir=class extends Nr{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(t,r);let o=W.mousePos(n.getCanvas(),r),s=n.unproject(o);super(t,a({point:o,lngLat:s,originalEvent:r},i)),this._defaultPrevented=!1,this.target=n}},Lr=class extends Nr{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,r){let a=t===`touchend`?r.changedTouches:r.touches,o=W.touchPos(n.getCanvasContainer(),a),s=o.map(t=>n.unproject(t)),c=o.reduce((t,n,r,i)=>t.add(n.div(i.length)),new i(0,0)),l=n.unproject(c);super(t,{points:o,point:c,lngLats:s,lngLat:l,originalEvent:r}),this._defaultPrevented=!1}},Rr=class extends Nr{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n){super(`wheel`,{originalEvent:n}),this._defaultPrevented=!1}},zr=class extends Nr{},Br=class extends Nr{constructor(t={}){super(`terrain`,t)}},Vr=class extends Nr{constructor(t={}){super(`projectiontransition`,t)}},Hr=class extends Nr{},Ur=class extends Nr{constructor(t={}){super(`styleimagemissing`,t)}};function Ar(t){let n=[];if(typeof t==`string`)n.push({id:`default`,url:t});else if(t&&t.length>0){let r=[];for(let{id:i,url:a}of t){let t=`${i}${a}`;r.includes(t)||(r.push(t),n.push({id:i,url:a}))}}return n}function jr(t,n,r){try{let i=new URL(t);return i.pathname+=`${n}${r}`,i.toString()}catch{throw Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function Wr(t,n,r,i){let a=Ar(t),o=r>1?`@2x`:``,s={},c={};for(let{id:t,url:r}of a){s[t]=g(await n.transformRequest(jr(r,o,`.json`),`SpriteJSON`),i);let a=await n.transformRequest(jr(r,o,`.png`),`SpriteImage`);c[t]=kr.getImage(a,i)}return await Promise.all([...Object.values(s),...Object.values(c)]),Gr(s,c)}async function Gr(t,n){let r={};for(let i in t){r[i]={};let a=wr.getImageCanvasContext((await n[i]).data),o=(await t[i]).data;for(let t in o){let{width:n,height:s,x:c,y:l,sdf:u,pixelRatio:d,stretchX:f,stretchY:p,content:m,textFitWidth:h,textFitHeight:g}=o[t],_={width:n,height:s,x:c,y:l,context:a};r[i][t]={data:null,pixelRatio:d,sdf:u,stretchX:f,stretchY:p,content:m,textFitWidth:h,textFitHeight:g,spriteData:_}}}return r}var Jr=class extends _{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this.patterns={},this.atlasImage=new v({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&=(this.atlasTexture.destroy(),null);for(let t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new v({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(let{ids:t,promiseResolve:n}of this.requestors)n(this._getImagesForIds(t));this.requestors=[]}}getImage(t){let n=this.images[t];if(n&&!n.data&&n.spriteData){let t=n.spriteData;n.data=new v({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let r=!0,i=n.data||n.spriteData;return this._validateStretch(n.stretchX,i?.width)||(this.fire(new y(Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,i?.height)||(this.fire(new y(Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new y(Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(t,n){if(!t)return!0;let r=0;for(let i of t){if(i[0]=t[1]}updateImage(t,n,r=!0){let i=this.getImage(t);if(r&&(i.data.width!==n.data.width||i.data.height!==n.data.height))throw Error(`size mismatch between old image (${i.data.width}x${i.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=i.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){let n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage?.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}setMissingImageResolver(t){this.missingImageResolver=t}getImages(t){return new Promise((n,r)=>{let i=!0;if(!this.isLoaded())for(let n of t)this.images[n]||(i=!1);this.isLoaded()||i?n(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:n})})}async _getImagesForIds(t){let n=new Set(t.filter(t=>!this.getImage(t))),r=this.missingImageResolver;r&&await Promise.all(Array.from(n,t=>r(t)));let i={};for(let r of t){let t=this.getImage(r);t&&(n.delete(r),i[r]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:!!t.userImage?.render})}for(let t of n)this.fire(new Ur({id:t})),b(`Image "${t}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return i}getPixelSize(){let{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){let n=this.patterns[t],r=this.getImage(t);if(!r)return null;if(n&&n.position.version===r.version)return n.position;if(n)n.position.version=r.version;else{let n={w:r.data.width+2,h:r.data.height+2,x:0,y:0},i=new x(n,r);this.patterns[t]={bin:n,position:i}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){let n=t.gl;this.atlasTexture?this.dirty&&=(this.atlasTexture.update(this.atlasImage),!1):this.atlasTexture=new S(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){let t=[];for(let n in this.patterns)t.push(this.patterns[n].bin);let{w:n,h:r}=C(t),i=this.atlasImage;i.resize({width:n||1,height:r||1});for(let t in this.patterns){let{bin:n}=this.patterns[t],r=n.x+1,a=n.y+1,o=this.getImage(t).data,s=o.width,c=o.height;v.copy(o,i,{x:0,y:0},{x:r,y:a},{width:s,height:c}),v.copy(o,i,{x:0,y:c-1},{x:r,y:a-1},{width:s,height:1}),v.copy(o,i,{x:0,y:0},{x:r,y:a+c},{width:s,height:1}),v.copy(o,i,{x:s-1,y:0},{x:r-1,y:a},{width:1,height:c}),v.copy(o,i,{x:0,y:0},{x:r+s,y:a},{width:1,height:c})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(let n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;let t=this.getImage(n);t||b(`Image with ID: "${n}" was not found`),w(t)&&this.updateImage(n,t)}}cloneImages(){let t={};for(let n in this.images){let r=this.images[n];t[n]={...r,data:r.data?r.data.clone():null}}return t}};async function Kr(t,n,r,i){let a=n*256,o=a+255,s=await T(await i.transformRequest(r.replace(`{fontstack}`,t).replace(`{range}`,`${a}-${o}`),`Glyphs`),new AbortController);if(!s?.data)throw Error(`Could not load glyph range. range: ${n}, ${a}-${o}`);let c={};for(let t of E(s.data))c[t.id]=t;return c}const qr=0x56bc75e2d63100000,Yr=new Float64Array(256);for(let t=0;t<256;t++){let n=.5-(t/255)**(1/2.2);Yr[t]=n*Math.abs(n)}Yr[255]=-0x56bc75e2d63100000;var Qr=class{constructor({fontSize:t=24,buffer:n=3,radius:r=8,cutoff:i=.25,fontFamily:a=`sans-serif`,fontWeight:o=`normal`,fontStyle:s=`normal`,lang:c=null}={}){this.buffer=n,this.radius=r,this.cutoff=i,this.lang=c;let l=this.size=t+n*4,u=this._createCanvas(l),d=this.ctx=u.getContext(`2d`,{willReadFrequently:!0});d.font=`${s} ${o} ${t}px ${a}`,d.textBaseline=`alphabetic`,d.textAlign=`left`,d.fillStyle=`black`,this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(t){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(t,t);let n=document.createElement(`canvas`);return n.width=n.height=t,n}draw(t){let{width:n,actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:a,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(r),c=Math.floor(-a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o)-c)),u=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(i))),d=l+2*this.buffer,f=u+2*this.buffer,p=Math.max(d*f,0),m=new Uint8ClampedArray(p),h={data:m,width:d,height:f,glyphWidth:l,glyphHeight:u,glyphTop:s,glyphLeft:c,glyphAdvance:n};if(l===0||u===0)return h;let{ctx:g,buffer:_,gridInner:v,gridOuter:y}=this;this.lang&&(g.lang=this.lang),g.clearRect(_,_,l,u),g.fillText(t,_-c,_+s);let b=g.getImageData(_,_,l,u);y.fill(qr,0,p),v.fill(0,0,p);let x=3;for(let t=0;t-1);l++,o[l]=c,s[l]=u,s[l+1]=qr}for(let c=0,l=0;c/[-\w]+/.test(t)?t:`'${CSS.escape(t)}'`).join(`,`),i=this._fontWeight(n[0]),a=this._fontStyle(n[0]);if(typeof document<`u`&&document.fonts?.load)try{await document.fonts.load(`${a} ${i||`normal`} 48px ${r}`)}catch(t){b(`Failed to load font "${r}": ${f(t).message}`)}return new e.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:r,fontWeight:i,fontStyle:a,lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?`italic`:/oblique/i.test(t)?`oblique`:`normal`}_fontWeight(t){let n={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950},r;for(let[i,a]of Object.entries(n))RegExp(`\\b${i}\\b`,`i`).test(t)&&(r=`${a}`);return r}destroy(){for(let t in this.entries){let n=this.entries[t];n.tinySDF=null,n.ideographTinySDF=null,n.glyphs={},n.requests={},n.ranges={}}this.entries={}}};let ti;const ni=()=>ti||=new A({anchor:new j(D.light.anchor,`anchor`),position:new j(D.light.position,`position`),color:new j(D.light.color,`color`),intensity:new j(D.light.intensity,`intensity`)});var ai=class extends _{constructor(t,n){super(),this._transitionable=new ee(ni(),`light`,n),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return te(this.properties.get(`position`))}setLight(t,n={}){if(!this._validate(M.light,t,n))for(let n in t){let r=t[n];n.endsWith(`-transition`)?this._transitionable.setTransition(n.slice(0,-ne.length),r):this._transitionable.setValue(n,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,r){return re(this,t,{value:n},r)}};let ri;const ii=()=>ri||=new A({"sky-color":new j(D.sky[`sky-color`],`sky-color`),"horizon-color":new j(D.sky[`horizon-color`],`horizon-color`),"fog-color":new j(D.sky[`fog-color`],`fog-color`),"fog-ground-blend":new j(D.sky[`fog-ground-blend`],`fog-ground-blend`),"horizon-fog-blend":new j(D.sky[`horizon-fog-blend`],`horizon-fog-blend`),"sky-horizon-blend":new j(D.sky[`sky-horizon-blend`],`sky-horizon-blend`),"atmosphere-blend":new j(D.sky[`atmosphere-blend`],`atmosphere-blend`)});var ci=class extends _{constructor(t,n){super(),this._transitionable=new ee(ii(),`sky`,n),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new ie(0))}setSky(t,n={}){if(!this._validate(M.sky,t,n)){t||={"sky-color":`transparent`,"horizon-color":`transparent`,"fog-color":`transparent`,"fog-ground-blend":1,"atmosphere-blend":0};for(let n in t){let r=t[n];n.endsWith(`-transition`)?this._transitionable.setTransition(n.slice(0,-ne.length),r):this._transitionable.setValue(n,r)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,r={}){return re(this,t,{value:n},r)}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}},li=class{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){let r=t.join(`,`)+String(n);return this.dashEntry[r]||=this.addDash(t,n),this.dashEntry[r]}getDashRanges(t,n,r){let i=t.length%2==1,a=[],o=i?-t[t.length-1]*r:0,s=t[0]*r,c=!0;a.push({left:o,right:s,isDash:c,zeroLength:t[0]===0});let l=t[0];for(let n=1;n1&&(c=t[++s]);let l=Math.abs(a-c.left),u=Math.abs(a-c.right),d=Math.min(l,u),f,p=n/r*(i+1);if(c.isDash){let t=i-Math.abs(p);f=Math.sqrt(d*d+t*t)}else f=i-Math.sqrt(d*d+p*p);this.data[o+a]=Math.max(0,Math.min(255,f+128))}}}addRegularDash(t){for(let n=t.length-1;n>=0;--n){let r=t[n],i=t[n+1];r.zeroLength?t.splice(n,1):i?.isDash===r.isDash&&(i.left=r.left,t.splice(n,1))}let n=t[0],r=t[t.length-1];n.isDash===r.isDash&&(n.left=r.left-this.width,r.right=n.right+this.width);let i=this.width*this.nextRow,a=0,o=t[a];for(let n=0;n1&&(o=t[++a]);let r=Math.abs(n-o.left),s=Math.abs(n-o.right),c=Math.min(r,s),l=o.isDash?c:-c;this.data[i+n]=Math.max(0,Math.min(255,l+128))}}addDash(t,n){let r=n?7:0,i=2*r+1;if(this.nextRow+i>this.height)return b(`LineAtlas out of space`),null;let a=0;for(let n of t)a+=n;if(a!==0){let i=this.width/a,o=this.getDashRanges(t,this.width,i);n?this.addRoundDash(o,i,r):this.addRegularDash(o)}let o={y:this.nextRow+r,height:2*r,width:a};return this.nextRow+=i,this.dirty=!0,o}bind(t){let n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}};function oi(t){if(!t)return!1;let n=globalThis.location;if(!n)return!1;try{return new URL(t,n.href).origin!==n.origin}catch{return!1}}function si(){let t=import.meta.url;if(!/^https?:/.test(t))return``;let n=t.endsWith(`-dev.mjs`)?`maplibre-gl-worker-dev.mjs`:`maplibre-gl-worker.mjs`;return new URL(`./${n}`,t).href}function ui(t,n){if(n)try{return new Worker(t,{type:`module`})}catch(t){console.warn(`Module worker not supported, falling back to classic worker`,t)}return new Worker(t)}async function di(t){let n=await fetch(t);if(!n.ok)throw Error(`Failed to fetch worker script (${n.status}): ${t}`);let r=await n.text(),i=new Blob([r],{type:`text/javascript`});return URL.createObjectURL(i)}function fi(t){let n=new Blob([`import ${JSON.stringify(new URL(t,import.meta.url).href)}`],{type:`text/javascript`});return URL.createObjectURL(n)}async function pi(){let t=p.WORKER_URL||si(),n=!t?.endsWith(`.cjs`);if(!oi(t))return ui(t,n);if(n){let r=fi(t);try{return ui(r,n)}finally{URL.revokeObjectURL(r)}}let r=await di(t);try{return ui(r,n)}finally{URL.revokeObjectURL(r)}}const mi=`maplibre_preloaded_worker_pool`;var hi=class e{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let t=[];for(;t.length{for(let n of t)n.terminate()})}}isPreloaded(){return!!this.active[mi]}numActive(){return Object.keys(this.active).length}};const gi=Math.floor(wr.hardwareConcurrency/2);hi.workerCount=ae(globalThis)?Math.max(Math.min(gi,3),1):1;let _i;function vi(){return _i||=new hi,_i}function yi(){vi().acquire(mi)}function bi(){let t=_i;t&&(t.isPreloaded()&&t.numActive()===1?(t.release(mi),_i=null):console.warn(`Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()`))}var Ci=class{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n,this.removed=!1,this.actorsPromise=this.initActors(n)}async initActors(t){let n=await this.workerPool.acquire(t);if(this.removed)return[];if(this.actors=n.map((n,r)=>{let i=new oe(n,t);return i.name=`Worker ${r}`,i}),!this.actors.length)throw Error(`No actors found`);return this.actors}async broadcast(t,n){let r=await this.actorsPromise;return Promise.all(r.map(r=>r.sendAsync({type:t,data:n})))}async getActor(){let t=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%t.length,t[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(t=!0){this.removed=!0;for(let t of this.actors)t.remove();this.actors=[],t&&this.workerPool.release(this.id)}async registerMessageHandler(t,n){let r=await this.actorsPromise;for(let i of r)i.registerMessageHandler(t,n)}async unregisterMessageHandler(t){let n=await this.actorsPromise;for(let r of n)r.unregisterMessageHandler(t)}};let xi;function Si(){return xi||(xi=new Ci(vi(),se),xi.registerMessageHandler(`GR`,(t,n,r)=>u(n,r))),xi}function wi(t,n){let r=ce();return N(r,r,[1,1,0]),le(r,r,[t.width*.5,t.height*.5,1]),t.calculatePosMatrix?ue(r,r,t.calculatePosMatrix(n.toUnwrapped())):r}function Ti(t,n,r){if(t)for(let i of t){let t=n[i];if(t?.source===r&&t.type===`fill-extrusion`)return!0}else for(let t in n){let i=n[t];if(i.source===r&&i.type===`fill-extrusion`)return!0}return!1}function Ei(t,n,r,i,a,o,s){let c=Ti(a?.layers??null,n,t.id),l=o.maxPitchScaleFactor(),u=t.tilesIn(i,l,c);u.sort(ki);let d=[];for(let i of u)d.push({wrappedTileID:i.tileID.wrapped().key,queryResults:i.tile.queryRenderedFeatures(n,r,t.getState(),i.queryGeometry,i.cameraQueryGeometry,i.scale,a,o,l,wi(o,i.tileID),s?(t,n)=>s(i.tileID,t,n):void 0)});return ji(Ai(d),t)}function Di(t,n,r,i,a,o,s){let c={},l=o.queryRenderedSymbols(i),u=[];for(let t of Object.keys(l).map(Number))u.push(s[t]);u.sort(ki);for(let r of u){let i=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],n,r.bucketIndex,r.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState},a.layers,a.availableImages,t);for(let t in i){c[t]||=[];let n=i[t];n.sort((t,n)=>{let i=r.featureSortOrder;if(i){let r=i.indexOf(t.featureIndex);return i.indexOf(n.featureIndex)-r}else return n.featureIndex-t.featureIndex});for(let r of n)c[t].push(r)}}return Mi(c,t,r)}function Oi(t,n){let r=t.getRenderableIds().map(n=>t.getTileByID(n)),i=[],a={};for(let t of r){let r=t.tileID.canonical.key;a[r]||(a[r]=!0,t.querySourceFeatures(i,n))}return i}function ki(t,n){let r=t.tileID,i=n.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}function Ai(t){let n={},r={};for(let{queryResults:i,wrappedTileID:a}of t){r[a]||={};let t=r[a];for(let r in i){let a=i[r];t[r]||={};let o=t[r];n[r]||=[];for(let t of a)o[t.featureIndex]||(o[t.featureIndex]=!0,n[r].push(t))}}return n}function ji(t,n){for(let r in t)for(let i of t[r])Ni(i,n);return t}function Mi(t,n,r){for(let i in t)for(let a of t[i]){let t=r[n[i].source];Ni(a,t)}return t}function Ni(t,n){let r=t.feature,i=n.getFeatureState(r.layer[`source-layer`],r.id);r.source=r.layer.source,r.layer[`source-layer`]&&(r.sourceLayer=r.layer[`source-layer`]),r.state=i}async function Pi(t,n,r,i){let o=t;if(t.url?o=(await g(await n.transformRequest(t.url,`Source`),r)).data:await wr.frameAsync(r,i),!o)return null;let s=de(a(o,t),[`tiles`,`minzoom`,`maxzoom`,`attribution`,`bounds`,`scheme`,`tileSize`,`encoding`]);return`vector_layers`in o&&o.vector_layers&&(s.vectorLayerIds=o.vector_layers.map(t=>t.id)),s}var Fi=class e{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):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 P?new P(t.lng,t.lat):P.convert(t),this}setSouthWest(t){return this._sw=t instanceof P?new P(t.lng,t.lat):P.convert(t),this}extend(t){let n=this._sw,r=this._ne,i,a;if(t instanceof P)i=t,a=t;else if(t instanceof e){if(i=t._sw,a=t._ne,!i||!a)return this}else{if(Array.isArray(t))if(t.length===4||t.every(Array.isArray)){let n=t;return this.extend(e.convert(n))}else{let n=t;return this.extend(P.convert(n))}else if(t&&(`lng`in t||`lon`in t)&&`lat`in t)return this.extend(P.convert(t));return this}return!n&&!r?(this._sw=new P(i.lng,i.lat),this._ne=new P(a.lng,a.lat)):(n.lng=Math.min(i.lng,n.lng),n.lat=Math.min(i.lat,n.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)),this}getCenter(){return new P((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 P(this.getWest(),this.getNorth())}getSouthEast(){return new P(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:n,lat:r}=P.convert(t),i=this._sw.lat<=r&&r<=this._ne.lat,a=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=n&&n>=this._ne.lng),i&&a}intersects(t){if(t=e.convert(t),!(t.getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let n=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(n>=360||r>=360)return!0;let i=fe(this.getWest(),-180,180),a=fe(this.getEast(),-180,180),o=fe(t.getWest(),-180,180),s=fe(t.getEast(),-180,180),c=i>a,l=o>s;return c&&l?!0:c?s>=i||o<=a:l?a>=o||i<=s:o<=a&&s>=i}static convert(t){return t instanceof e||!t?t:new e(t)}static fromLngLat(t,n=0){let r=360*n/40075017,i=r/Math.cos(Math.PI/180*t.lat);return new e(new P(t.lng-i,t.lat-r),new P(t.lng+i,t.lat+r))}adjustAntiMeridian(){let t=new P(this._sw.lng,this._sw.lat),n=new P(this._ne.lng,this._ne.lat);return t.lng>n.lng?new e(t,new P(n.lng+360,n.lat)):new e(t,n)}},Ri=class{constructor(t,n,r){this.bounds=Fi.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=r||24}validateBounds(t){return!Array.isArray(t)||t.length!==4?[-180,-90,180,90]:[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]}contains(t){let n=2**t.z,r={minX:Math.floor(me(this.bounds.getWest())*n),minY:Math.floor(pe(this.bounds.getNorth())*n),maxX:Math.ceil(me(this.bounds.getEast())*n),maxY:Math.ceil(pe(this.bounds.getSouth())*n)};return t.x>=r.minX&&t.x=r.minY&&t.y{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return a({},this._options)}async loadTile(t){let n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:await this.map._requestManager.transformRequest(n,`Tile`),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.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(t),etag:t.etag};r.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();let i=`RT`;if(!t.actor||t.state===`expired`)t.actor=this.dispatcher.getReadyActor(),i=`LT`;else if(t.state===`loading`)return new Promise((n,r)=>{t.reloadPromise={resolve:n,reject:r}});t.abortController=new AbortController;try{let n=await t.actor.sendAsync({type:i,data:r},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,n);let a={};return n?.etagUnmodified&&(a.unmodified=!0),a}catch(n){if(delete t.abortController,t.aborted||he(n))return;if(n&&n.status!==404)throw n;this._afterTileLoadWorkerResponse(t,null)}}async _getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let n=t.tileID.scaledTo(this.maxzoom).canonical,r=n.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:n,overzoomRequest:await this.map._requestManager.transformRequest(r,`Tile`)}}_afterTileLoadWorkerResponse(t,n){if(n?.resourceTiming&&(t.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&t.setExpiryData(n),t.etag=n?.etag,t.loadVectorData(n,this.map.painter),t.reloadPromise){let n=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(n.resolve).catch(n.reject)}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&await t.actor.sendAsync({type:`AT`,data:{uid:t.uid,type:this.type,source:this.id}})}async unloadTile(t){t.unloadVectorData(),t.actor&&await t.actor.sendAsync({type:`RMT`,data:{uid:t.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},Bi=class extends _{constructor(t,n,r,i){super(),this.id=t,this.dispatcher=r,this.setEventedParent(i),this.type=`raster`,this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme=`xyz`,this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=a({type:`raster`},n),a(this,de(n,[`url`,`scheme`,`tileSize`]))}async load(t=!1){this._loaded=!1,this.fire(new K(`dataloading`)),this._tileJSONRequest=new AbortController;try{let n=await Pi(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,n&&(a(this,n),n.bounds&&(this.tileBounds=new Ri(n.bounds,this.minzoom,this.maxzoom)),this.fire(new K(`data`,{sourceDataType:`metadata`})),this.fire(new K(`data`,{sourceDataType:`content`,sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,he(t)||this.fire(new y(f(t)))}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(t){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}serialize(){return a({},this._options)}setPremultiplyAlpha(t){return this._premultiplyAlpha===t||this.setSourceProperty(()=>{this._premultiplyAlpha=t}),this}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}async loadTile(t){let n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this._premultiplyAlpha,i=r?void 0:{premultiplyAlpha:`none`},a=await this.map._requestManager.transformRequest(n,`Tile`);t.abortController=new AbortController;try{let n=await kr.getImage(a,t.abortController,this.map._refreshExpiredTiles,i);if(delete t.abortController,t.aborted){t.state=`unloaded`;return}if(n?.data){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&t.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let i=this.map.painter.context,a=i.gl,o=n.data;t.texture=this.map.painter.getTileTexture(o.width),t.texture?t.texture.update(o,{useMipmap:!0,premultiply:r}):(t.texture=new S(i,o,a.RGBA,{useMipmap:!0,premultiply:r}),t.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST)),t.state=`loaded`}}catch(n){if(delete t.abortController,t.aborted)t.state=`unloaded`;else if(n)throw t.state=`errored`,n}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController)}async unloadTile(t){t.texture&&this.map.painter.saveTileTexture(t.texture)}hasTransition(){return!1}},Vi=class extends Bi{constructor(t,n,r,i){super(t,n,r,i),this.type=`raster-dem`,this.maxzoom=22,this._options=a({type:`raster-dem`},n),this.encoding=n.encoding||`mapbox`,this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}async loadTile(t){let n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=await this.map._requestManager.transformRequest(n,`Tile`);t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{let n=await kr.getImage(r,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted){t.state=`unloaded`;return}if(n?.data){let r=n.data;this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&t.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let i=d(r)&&ge()?r:await this.readImageNow(r),a={type:this.type,uid:t.uid,source:this.id,rawImageData:i,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(t.actor&&t.state!==`expired`&&t.state!==`reloading`)return;await this.dispatcher.waitForInitComplete(),(!t.actor||t.state===`expired`)&&(t.actor=this.dispatcher.getReadyActor()),t.dem=await t.actor.sendAsync({type:`LDT`,data:a}),t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state=`loaded`}}catch(n){if(delete t.abortController,t.aborted)t.state=`unloaded`;else if(n)throw t.state=`errored`,n}}async readImageNow(t){if(typeof VideoFrame<`u`&&_e()){let n=t.width+2,r=t.height+2;try{return new v({width:n,height:r},await ve(t,-1,-1,n,r))}catch{}}return wr.getImageData(t,1)}_getNeighboringTiles(t){let n=t.canonical,r=2**n.z,i=(n.x-1+r)%r,a=n.x===0?t.wrap-1:t.wrap,o=(n.x+1+r)%r,s=n.x+1===r?t.wrap+1:t.wrap,c={};return c[new ye(t.overscaledZ,a,n.z,i,n.y).key]={backfilled:!1},c[new ye(t.overscaledZ,s,n.z,o,n.y).key]={backfilled:!1},n.y>0&&(c[new ye(t.overscaledZ,a,n.z,i,n.y-1).key]={backfilled:!1},c[new ye(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},c[new ye(t.overscaledZ,s,n.z,o,n.y-1).key]={backfilled:!1}),n.y+10||r.addOrUpdateProperties?.length>0;if(!a&&!o)continue;i.push(n.geometry);let s={...n};if(t.set(r.id,s),a&&(i.push(r.newGeometry),s.geometry=r.newGeometry),o){if(r.removeAllProperties?s.properties={}:s.properties={...s.properties||{}},r.removeProperties)for(let t of r.removeProperties)delete s.properties[t];if(r.addOrUpdateProperties)for(let{key:t,value:n}of r.addOrUpdateProperties)s.properties[t]=n}}return i}function Ui(t,n,r){if(!t)return n||{};if(!n)return t||{};r&&(Ki(t.add,r),Ki(n.add,r));let i=Ji(t),a=Ji(n);Wi(i,a);let o={};if((i.removeAll||a.removeAll)&&(o.removeAll=!0),o.remove=new Set([...i.remove,...a.remove]),o.add=new Map([...i.add,...a.add]),o.update=new Map([...i.update,...a.update]),o.remove.size&&o.add.size)for(let t of o.add.keys())o.remove.delete(t);let s=Yi(o);return r&&qi(s.add,r),s}function Wi(t,n){n.removeAll&&(t.add.clear(),t.update.clear(),t.remove.clear(),n.remove.clear());for(let r of n.remove)t.add.delete(r),t.update.delete(r);for(let[r,i]of n.update){let a=t.update.get(r);a&&(n.update.set(r,Gi(a,i)),t.update.delete(r))}}function Gi(t,n){let r={id:t.id};if(n.removeAllProperties&&(delete t.removeProperties,delete t.addOrUpdateProperties,delete n.removeProperties),n.removeProperties)for(let r of n.removeProperties){let n=t.addOrUpdateProperties.findIndex(t=>t.key===r);n>-1&&t.addOrUpdateProperties.splice(n,1)}return(t.removeAllProperties||n.removeAllProperties)&&(r.removeAllProperties=!0),(t.removeProperties||n.removeProperties)&&(r.removeProperties=[...t.removeProperties||[],...n.removeProperties||[]]),(t.addOrUpdateProperties||n.addOrUpdateProperties)&&(r.addOrUpdateProperties=[...t.addOrUpdateProperties||[],...n.addOrUpdateProperties||[]]),(t.newGeometry||n.newGeometry)&&(r.newGeometry=n.newGeometry||t.newGeometry),r}function Ki(t,n){if(t)for(let r of t){let t=Ii(r,n);t!=null&&(r.id=t)}}function qi(t,n){if(t)for(let r of t)Ii(r,n)!=null&&delete r.id}function Ji(t){if(!t)return{};let n={};return n.removeAll=t.removeAll,n.remove=new Set(t.remove||[]),n.add=new Map(t.add?.map(t=>[t.id,t])),n.update=new Map(t.update?.map(t=>[t.id,t])),n}function Yi(t){let n={};return t.removeAll&&(n.removeAll=t.removeAll),t.remove&&(n.remove=Array.from(t.remove)),t.add&&(n.add=Array.from(t.add.values())),t.update&&(n.update=Array.from(t.update.values())),n}function Xi(t){return!t||t.length===0?[]:typeof t[0]==`number`?[t]:t.flatMap(t=>Xi(t))}function Zi(t){return t.type===`GeometryCollection`?t.geometries.flatMap(t=>Zi(t)):Xi(t.coordinates)}function Qi(t){let n=new Fi,r;switch(t.type){case`FeatureCollection`:r=t.features.flatMap(t=>Zi(t.geometry));break;case`Feature`:r=Zi(t.geometry);break;default:r=Zi(t);break}if(r.length===0)return n;for(let t of r){let[r,i]=t;n.extend([r,i])}return n}function $i({x:t,y:n,z:r},i=0){let a=be((t-i)/2**r),o=xe((n+1+i)/2**r),s=be((t+1+i)/2**r),c=xe((n-i)/2**r);return new Fi([a,o],[s,c])}var na=class extends _{constructor(t,n,r,i){super(),this.id=t,this.type=`geojson`,this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actorPromise=r.getActor(),this.setEventedParent(i),this._data=typeof n.data==`string`?{url:n.data}:{geojson:n.data},this._options=a({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&b(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=a({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer===void 0?128:n.buffer),tolerance:this._pixelsToTileUnits(n.tolerance===void 0?.375:n.tolerance),extent:F,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1,promoteId:typeof n.promoteId==`string`?n.promoteId:void 0,cluster:n.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:F,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1}},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(t){return t*(F/this.tileSize)}_tileUnitsToPixels(t){return t/(F/this.tileSize)}_getClusterMaxZoom(t){let n=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||t===void 0||b(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${n}"`),n}async load(){await this._updateWorkerData()}onAdd(t){this.map=t,this.load()}setData(t){return this._data=typeof t==`string`?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t},this._updateWorkerData()}updateData(t){return this._pendingWorkerUpdate.diff=Ui(this._pendingWorkerUpdate.diff,t),this._updateWorkerData()}async getData(){return this._data.url&&await this.once(`data`),this._data.geojson?this._data.geojson:{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}}async getBounds(){return Qi(await this.getData())}setClusterOptions(t){return this.workerOptions.geojsonVtOptions.cluster=t.cluster,t.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),t.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}getClusterOptions(){let{cluster:t,clusterOptions:n}=this.workerOptions.geojsonVtOptions;return{cluster:t,clusterMaxZoom:n.maxZoom,clusterRadius:this._tileUnitsToPixels(n.radius)}}async getClusterExpansionZoom(t){return(await this.actorPromise).sendAsync({type:`GCEZ`,data:{type:this.type,clusterId:t,source:this.id}})}async getClusterChildren(t){return(await this.actorPromise).sendAsync({type:`GCC`,data:{type:this.type,clusterId:t,source:this.id}})}async getClusterLeaves(t,n,r){return(await this.actorPromise).sendAsync({type:`GCL`,data:{type:this.type,source:this.id,clusterId:t,limit:n,offset:r}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate()){b(`No pending worker updates for GeoJSONSource ${this.id}.`);return}let{data:t,diff:n,updateCluster:r}=this._pendingWorkerUpdate,i=this._getLoadGeoJSONParameters(t,n,r);t===void 0?n?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(i),await this._updatePromise}async _getLoadGeoJSONParameters(t,n,r){let i=a({type:this.type,source:this.id},this.workerOptions);if(typeof t==`string`)return i.request=await this.map._requestManager.transformRequest(wr.resolveURL(t),`Source`),i.request.collectResourceTiming=this._collectResourceTiming,i;if(t!==void 0)return i.data=t,i;if(n)return i.dataDiff=n,i;if(r)return i.updateCluster=!0,i}async _dispatchWorkerUpdate(t){this._isUpdatingWorker=!0,this.fire(new K(`dataloading`));try{let n=await t,r=await(await this.actorPromise).sendAsync({type:`LD`,data:n});if(this._isUpdatingWorker=!1,this._removed||r.abandoned){this.fire(new K(`dataabort`));return}r.data&&(this._data={geojson:r.data});let i=this._applyDiffToSource(n.dataDiff),a=this._getShouldReloadTileOptions(i),o={};this._applyResourceTiming(o,r),this.fire(new K(`data`,{...o,sourceDataType:`metadata`})),this.fire(new K(`data`,{...o,sourceDataType:`content`,shouldReloadTileOptions:a}))}catch(t){if(this._isUpdatingWorker=!1,this._removed){this.fire(new K(`dataabort`));return}this.fire(new y(f(t)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(t,n){if(!this._collectResourceTiming)return;let r=n.resourceTiming?.[this.id];if(!r)return;let i=r.slice(0);i?.length&&a(t,{resourceTiming:i})}_applyDiffToSource(t){if(!t)return;let n=typeof this.promoteId==`string`?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let t=Li(this._data.geojson,n);if(!t)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:t}}if(!this._data.updateable)return;let r=Hi(this._data.updateable,t,n);if(!(t.removeAll||this._options.cluster))return r}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map(t=>Qi(t))}}shouldReloadTile(t,{affectedBounds:n}){if(t.state===`loading`)return!0;if(t.state===`unloaded`)return!1;let{buffer:r,extent:i}=this.workerOptions.geojsonVtOptions,a=$i(t.tileID.canonical,r/i);for(let t of n)if(a.intersects(t))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(t){let n=t.actor?`RT`:`LT`;t.actor=await this.actorPromise;let r={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.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};t.abortController=new AbortController;try{let i=await(await this.actorPromise).sendAsync({type:n,data:r},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(i,this.map.painter,n===`RT`)}catch(n){if(delete t.abortController,t.aborted||he(n))return;throw n}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}async unloadTile(t){t.unloadVectorData(),await(await this.actorPromise).sendAsync({type:`RMT`,data:{uid:t.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then(t=>t.sendAsync({type:`RS`,data:{type:this.type,source:this.id}}))}serialize(){return a({},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}},ra=class extends _{constructor(t,n,r,i){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=r,this.coordinates=n.coordinates,this.type=`image`,this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=n}async load(t){this._loaded=!1,this.fire(new K(`dataloading`)),this.url=this.options.url;let n=await this.map._requestManager.transformRequest(this.url,`Image`);this._request=new AbortController;try{let r=await kr.getImage(n,this._request);this._request=null,this._loaded=!0,r?.data&&(this.image=r.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,he(t)||this.fire(new y(f(t)))}}loaded(){return this._loaded}updateImage(t){return this._request&&=(this._request.abort(),null),`image`in t?(this._loaded=!0,this.image=t.image,t.coordinates&&(this.coordinates=t.coordinates),this.texture=null,this._finishLoading(),this):t.url?(this.options.url=t.url,this.load(t.coordinates).finally(()=>this.texture=null),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new K(`data`,{sourceDataType:`metadata`})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&=(this._request.abort(),null)}setCoordinates(t){this.coordinates=t;let n=t.map(I.fromLngLat);return this.tileID=ea(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map(t=>this.tileID.getTilePoint(t)._round()),this.flippedWindingOrder=ta(this.tileCoords),this.fire(new K(`data`,{sourceDataType:`content`})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let t=this.map.painter.context,n=t.gl;this.texture||(this.texture=new S(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let t in this.tiles){let n=this.tiles[t];n.state!==`loaded`&&(n.state=`loaded`,n.texture=this.texture,r=!0)}r&&this.fire(new K(`data`,{sourceDataType:`idle`,sourceId:this.id}))}async loadTile(t){this.tileID?.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state=`errored`}serialize(){return{type:`image`,url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){let{minX:n,minY:r,maxX:i,maxY:a}=Se.fromPoints(t),o={};for(let t=0;t<=25;t++){let s=2**t,c=Math.floor(n*s),l=Math.floor(r*s),u=Math.floor(i*s),d=Math.floor(a*s),f=(c%s+s)%s,p=u%s;o[t]={minWrap:Math.floor(c/s),maxWrap:Math.floor(u/s),minTileXWrapped:f,maxTileXWrapped:p,minTileY:l,maxTileY:d}}return o}};function ea(t){let n=Se.fromPoints(t),r=n.width(),i=n.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(r,i))/Math.LN2)),o=2**a;return new Ce(a,Math.floor((n.minX+n.maxX)/2*o),Math.floor((n.minY+n.maxY)/2*o))}function ta(t){let n=t[1].x-t[0].x,r=t[1].y-t[0].y,i=t[2].x-t[0].x;return n*(t[2].y-t[0].y)-r*i<0}var oa=class extends ra{constructor(t,n,r,i){super(t,n,r,i),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type=`video`,this.options=n}async load(){this._loaded=!1;let t=this.options;this.urls=[];for(let n of t.urls)this.urls.push((await this.map._requestManager.transformRequest(n,`Source`)).url);try{let t=await we(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 y(f(t)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){let n=this.video.seekable;tn.end(0)?this.fire(new y(new Te(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}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 t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new S(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let t in this.tiles){let n=this.tiles[t];n.state!==`loaded`&&(n.state=`loaded`,n.texture=this.texture,r=!0)}r&&this.fire(new K(`data`,{sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`video`,urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},sa=class extends ra{constructor(t,n,r,i){super(t,n,r,i),n.coordinates?(!Array.isArray(n.coordinates)||n.coordinates.length!==4||n.coordinates.some(t=>!Array.isArray(t)||t.length!==2||t.some(t=>typeof t!=`number`)))&&this.fire(new y(new Te(`sources.${t}`,null,`"coordinates" property must be an array of 4 longitude/latitude array pairs`))):this.fire(new y(new Te(`sources.${t}`,null,`missing required property "coordinates"`))),n.animate&&typeof n.animate!=`boolean`&&this.fire(new y(new Te(`sources.${t}`,null,`optional "animate" property must be a boolean value`))),n.canvas?typeof n.canvas!=`string`&&!(n.canvas instanceof HTMLCanvasElement)&&this.fire(new y(new Te(`sources.${t}`,null,`"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance`))):this.fire(new y(new Te(`sources.${t}`,null,`missing required property "canvas"`))),this.options=n,this.animate=n.animate===void 0||n.animate}async load(){if(this._loaded=!0,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 y(Error(`Canvas dimensions cannot be less than or equal to zero.`)));return}this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&=(this.prepare(),!1)},this._finishLoading()}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let n=this.map.painter.context,r=n.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new S(n,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let i=!1;for(let t in this.tiles){let n=this.tiles[t];n.state!==`loaded`&&(n.state=`loaded`,n.texture=this.texture,i=!0)}i&&this.fire(new K(`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 t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}};const ia={},aa=(t,n,r,i)=>{let a=new(ca(n.type))(t,n,r,i);if(a.id!==t)throw Error(`Expected Source id to be ${t} instead of ${a.id}`);return a},ca=t=>{switch(t){case`geojson`:return na;case`image`:return ra;case`raster`:return Bi;case`raster-dem`:return Vi;case`vector`:return zi;case`video`:return oa;case`canvas`:return sa}return ia[t]},la=(t,n)=>{ia[t]=n},ua=async(t,n)=>{if(ca(t))throw Error(`A source type called "${t}" already exists.`);la(t,n)};function da(t,n){let r={};if(!n)return r;for(let i of t){let t=i.layerIds.map(t=>n.getLayer(t)).filter(Boolean);if(t.length!==0){i.layers=t,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map(n=>t.filter(t=>t.id===n)[0]));for(let n of t)r[n.id]=i}}return r}const fa=`RTLPluginLoaded`;var ha=class extends _{constructor(...t){super(...t),this.status=`unavailable`,this.url=null,this.dispatcher=Si()}_syncState(t){return this.status=t,this.dispatcher.broadcast(`SRPS`,{pluginStatus:t,pluginURL:this.url}).catch(t=>{throw this.status=`error`,t})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status=`unavailable`,this.url=null}async setRTLTextPlugin(t,n=!1){if(this.url)throw Error(`setRTLTextPlugin cannot be called multiple times.`);if(this.url=wr.resolveURL(t),!this.url)throw Error(`requested url ${t} is invalid`);if(this.status===`unavailable`)if(n)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 h(fa))}lazyLoad(){this.status===`unavailable`?this.status=`requested`:this.status===`deferred`&&this._requestImport()}};let pa=null;function ma(){return pa||=new ha,pa}var va=class{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=Ee(),this.uses=0,this.tileSize=n,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(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:n,fadingParentID:r,fadeEndTime:i}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=n,this.fadingParentID=r,this.fadeEndTime=i}setSelfFadeLogic(t){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=t}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=U(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state===`errored`||this.state===`loaded`||this.state===`reloading`}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(t){return this.rttObjects[t]}acquireRTT(t,n,r){return this.rttObjects[n]=t.acquireRTT(r)}releaseRTT(t){if(this.rttObjects.length!==0){for(let n of this.rttObjects)n&&t.releaseRTT(n);this.rttObjects.length=0}}loadVectorData(t,n,r){if(t?.etagUnmodified===!0){this.state=`loaded`;return}if(this.hasData()&&this.unloadVectorData(),this.state=`loaded`,!t){this.collisionBoxArray=new De;return}t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestEncoding=t.encoding,this.latestFeatureIndex.rawTileData=t.rawTileData,this.latestFeatureIndex.encoding=t.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=da(t.buckets,n?.style),this.hasSymbolBuckets=!1;for(let t in this.buckets){let n=this.buckets[t];if(n instanceof Oe)if(this.hasSymbolBuckets=!0,r)n.justReloaded=!0;else break}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let t in this.buckets){let n=this.buckets[t];if(n instanceof Oe&&n.hasRTLText){this.hasRTLText=!0,ma().lazyLoad();break}}this.queryPadding=0;for(let t in this.buckets){let r=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(t).queryRadius(r))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}unloadVectorData(){for(let t in this.buckets)this.buckets[t].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(t){return this.buckets[t.id]}upload(t){for(let n in this.buckets){let r=this.buckets[n];r.uploadPending()&&r.upload(t)}let n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new S(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new S(t,this.glyphAtlasImage,n.ALPHA),null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,r,i,a,o,s,c,l,u,d){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:i,cameraQueryGeometry:a,scale:o,tileSize:this.tileSize,pixelPosMatrix:u,transform:c,params:s,queryPadding:this.queryPadding*l,getElevation:d},t,n,r):{}}querySourceFeatures(t,n){let r=this.latestFeatureIndex;if(!r?.rawTileData)return;let i=r.loadVTLayers(),a=n?.sourceLayer?n.sourceLayer:``,o=i._geojsonTileLayer||i[a];if(!o)return;let s=ke(n?.filter,`querySourceFeatures[${a}].filter`,n?.globalState),{z:c,x:l,y:u}=this.tileID.canonical,d={z:c,x:l,y:u};for(let n=0;nt)r=!1;else if(!n)r=!0;else if(this.expirationTime({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),x=[],S=[];if(t.renderWorldCopies&&c.allowWorldCopies())for(let t=1;t<=3;t++)x.push(b(-t)),x.push(b(t));for(x.push(b(0));x.length>0;){let m=x.pop(),_=m.x,b=m.y,C=m.fullyVisible,w={x:_,y:b,z:m.zoom},T=c.getTileBoundingVolume(w,m.wrap,s,n);if(!C){let t=Da(r,T,i);if(t===0)continue;C=t===2}let E=c.distanceToTile2d(a.x,a.y,w,T),D=u;l&&(D=(n.calculateTileZoom||Aa)(t.zoom+Re(t.tileSize/n.tileSize),E,v,y,t.fov)),D=(n.roundZoom?Math.round:Math.floor)(D),D=Math.max(0,D);let O=Math.min(D,f);if(m.wrap=c.getWrap(o,w,m.wrap),m.zoom>=O){if(m.zoom>1),i=m.zoom+1;x.push({zoom:i,x:n,y:r,wrap:m.wrap,fullyVisible:C})}}return S.sort((t,n)=>t.distanceSq-n.distanceSq).map(t=>t.tileID)}const Pa=Se.fromPoints([new i(0,0),new i(F,F)]);function Fa(t){return t===`raster`||t===`image`||t===`video`}function Ia(t,n,r,i,a,o,s){let c=U(),l=Be(n);for(let u of n){let n=t.getTileById(u.key);(n.fadingDirection===0||n.fadeOpacity===0)&&n.resetFadeLogic(),!La(t,n,r,c,i,a,s)&&(Ra(t,n,r,c,o,s)||Ba(n,l,c,s)||n.resetFadeLogic())}}function La(t,n,r,i,a,o,s){if(!n.hasData())return!1;let{tileID:c,fadingRole:l,fadingDirection:u,fadingParentID:d}=n;if(l===0&&u===1&&d)return r[d.key]=d,!0;let f=Math.max(c.overscaledZ-a,o);for(let a=c.overscaledZ-1;a>=f;a--){let o=c.scaledTo(a),l=t.getLoadedTile(o);if(l)return n.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:l.tileID,fadeEndTime:i+s}),l.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:i+s}),r[o.key]=o,!0}return!1}function Ra(t,n,r,i,a,o){if(!n.hasData())return!1;let s=n.tileID.children(a),c=za(t,n,s,r,i,a,o);if(c)return!0;for(let l of s)za(t,n,l.children(a),r,i,a,o)&&(c=!0);return c}function za(t,n,r,i,a,o,s){if(r[0].overscaledZ>=o)return!1;let c=!1;for(let o of r){let r=t.getLoadedTile(o);if(!r)continue;let{fadingRole:l,fadingDirection:u,fadingParentID:d}=r;(l!==0||u!==0||!d)&&(r.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:n.tileID,fadeEndTime:a+s}),n.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+s})),i[o.key]=o,c=!0}return c}function Ba(t,n,r,i){let a=t.tileID;if(t.selfFading)return!0;if(t.hasData())return!1;if(n.has(a)){let n=r+i;return t.setSelfFadeLogic(n),!0}return!1}function Va(t,n){if(n<=0)return!1;let r=U();for(let n of t.getAllTiles())if(n.fadeEndTime>=r)return!0;return!1}function Ha(t,n){let r=n.getRenderableIds();for(let i of r){if(!t.neighboringTiles?.[i])continue;let r=n.getTileById(i);t.neighboringTiles[i].backfilled||Ua(t,r),!r.neighboringTiles?.[t.tileID.key]?.backfilled&&Ua(r,t)}}function Ua(t,n){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let r=n.tileID.canonical.x-t.tileID.canonical.x,i=n.tileID.canonical.y-t.tileID.canonical.y,a=2**t.tileID.canonical.z,o=n.tileID.key;(r!==0||i!==0)&&(Math.abs(i)>1||(Math.abs(r)>1&&(Math.abs(r+a)===1?r+=a:Math.abs(r-a)===1&&(r-=a)),!(!n.dem||!t.dem)&&(t.dem.backfillBorder(n.dem,r,i),t.neighboringTiles?.[o]&&(t.neighboringTiles[o].backfilled=!0))))}var Ka=class{constructor(){this._tiles={}}handleWrapJump(t){let n={};for(let r in this._tiles){let i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),n[i.tileID.key]=i}this._tiles=n}setFeatureState(t,n,r){for(let i in this._tiles)this._tiles[i].setFeatureState(t,n,r)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map(t=>t.tileID).sort(Ve).map(t=>t.key):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,n){this._tiles[t]=n}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){let n=this.getTileById(t.key);return n?.hasData()?n:null}isIdRenderable(t,n=!1){return this.getTileById(t)?.isRenderable(n)}getRenderableIds(t=0,n){let r=[];for(let t of this.getAllIds())this.isIdRenderable(t,n)&&r.push(this.getTileById(t));return n?r.sort((n,r)=>{let a=n.tileID,o=r.tileID,s=new i(a.canonical.x,a.canonical.y)._rotate(-t),c=new i(o.canonical.x,o.canonical.y)._rotate(-t);return a.overscaledZ-o.overscaledZ||c.y-s.y||c.x-s.x}).map(t=>t.tileID.key):r.map(t=>t.tileID).sort(Ve).map(t=>t.key)}},Wa=class e extends _{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(t,n,r){super(),this.id=t,this.dispatcher=r,this.on(`data`,t=>{this._dataHandler(t)}),this.on(`dataloading`,()=>{this._sourceErrored=!1}),this.on(`error`,()=>{this._sourceErrored=this._source.loaded()}),this._source=aa(t,n,r,this),this._inViewTiles=new Ka,this._outOfViewCache=new He(0,t=>this._unloadTile(t)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new ba,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(t)}onRemove(t){for(let t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(t),this._inViewTiles=new Ka}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,n,r){try{let i=await this._source.loadTile(t);this._tileLoaded(t,n,r,i)}catch(n){t.state=`errored`,n.status===404?this.update(this.transform,this.terrain):this._source.fire(new y(f(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 K(`dataabort`,{tile:t,coord:t.tileID}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let n of this._inViewTiles.getAllTiles())n.upload(t),n.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,t)}hasRenderableParent(t){let n=t.overscaledZ-1;if(n>=this._source.minzoom){let r=this.getLoadedTile(t.scaledTo(n));if(r)return this._inViewTiles.isIdRenderable(r.tileID.key)}return!1}reload(t,n=void 0){if(this._paused){this._shouldReloadOnResume=!0;return}this._outOfViewCache.reset();for(let r of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(r);n&&!this._source.shouldReloadTile(i,n)||(t?this._reloadTile(r,i.state===`errored`?`loading`:`expired`):i.state!==`errored`&&this._reloadTile(r,`reloading`))}}async _reloadTile(t,n){let r=this._inViewTiles.getTileById(t);r&&(r.state!==`loading`&&(r.state=n),await this._loadTile(r,t,n))}_tileLoaded(t,n,r,i){t.timeAdded=U(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),r===`expired`&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),!i?.unmodified&&(this.getSource().type===`raster-dem`&&t.dem&&Ha(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new K(`data`,{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,n){let r=this._getLoadedDescendents(n),i=/* @__PURE__ */ new Set;for(let a of n){let n=r[a.key];if(!n?.length){i.add(a);continue}let o=a.overscaledZ+e.maxOverzooming,s=n.filter(t=>t.tileID.overscaledZ<=o);if(!s.length){i.add(a);continue}let c=Math.min(...s.map(t=>t.tileID.overscaledZ)),l=s.filter(t=>t.tileID.overscaledZ===c).map(t=>t.tileID);for(let n of l)t[n.key]=n;this._areDescendentsComplete(l,c,a.overscaledZ)||i.add(a)}return i}_getLoadedDescendents(t){let n={};for(let r of this._inViewTiles.getAllTiles().filter(t=>t.hasData()))for(let i of t)r.tileID.isChildOf(i)&&(n[i.key]||=[],n[i.key].push(r));return n}_areDescendentsComplete(t,n,r){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===n:4**(n-r)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let n=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),r=this._maxTileCacheZoomLevels===null?p.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,i=Math.floor(n*r),a=typeof this._maxTileCacheSize==`number`?Math.min(this._maxTileCacheSize,i):i;this._outOfViewCache.setMaxSize(a)}handleWrapJump(t){let n=(t-(this._prevLng===void 0?t:this._prevLng))/360,r=Math.round(n);this._prevLng=t,r&&(this._inViewTiles.handleWrapJump(r),this._resetTileReloadTimers())}update(t,n){if(!this._sourceLoaded||this._paused)return;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng);let r;!this.used&&!this.usedForTerrain?r=[]:this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new ye(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)):(r=Na(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:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter(t=>this._source.hasTile(t)))),this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let i=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,i&&this.fire(new K(`data`,{sourceDataType:`idle`,sourceId:this.id}));let a=ja(t,this._source),o=this._updateRetainedTiles(r,a),s=Fa(this._source.type);s&&this._rasterFadeDuration>0&&!n&&Ia(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 n of this._inViewTiles.getAllIds())t[n]||this._removeTile(n)}_cleanUpVectorTiles(t){for(let n of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(n);if(t[n]){r.clearSymbolFadeHold();continue}if(!r.hasSymbolBuckets){this._removeTile(n);continue}r.holdingForSymbolFade()?r.symbolFadeFinished()&&this._removeTile(n):r.setSymbolHoldDuration(this.map._fadeDuration)}}_addTerrainIdealTiles(t){let n=[];for(let r of t)if(r.canonical.z>this._source.minzoom){let t=r.scaledTo(r.canonical.z-1);n.push(t);let i=r.scaledTo(Math.max(this._source.minzoom,Math.min(r.canonical.z,5)));n.push(i)}return t.concat(n)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){let r=/* @__PURE__ */ new Set;for(let n of t)this._addTile(n).hasData()||r.add(n);let i=t.reduce((t,n)=>(t[n.key]=n,t),{}),a=this._retainLoadedChildren(i,r),o={},s=Math.max(n-e.maxUnderzooming,this._source.minzoom);for(let t of a){let n=this._inViewTiles.getTileById(t.key),r=n?.wasRequested();for(let a=t.overscaledZ-1;a>=s;--a){let s=t.scaledTo(a);if(o[s.key])break;if(o[s.key]=!0,n=this.getTile(s),!n&&r&&(n=this._addTile(s)),n){let t=n.hasData();if((t||!this.map?.cancelPendingTileRequestsWhileZooming||r)&&(i[s.key]=s),r=n.wasRequested(),t)break}}}return i}_addTile(t){let n=this._inViewTiles.getTileById(t.key);if(n)return n;n=this._outOfViewCache.getAndRemove(t),n&&(n.resetFadeLogic(),this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null));let r=n;return n||(n=new va(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._inViewTiles.setTile(t.key,n),r||this._source.fire(new K(`dataloading`,{tile:n,coord:n.tileID})),n}_setTileReloadTimer(t,n){this._clearTileReloadTimer(t);let r=n.getExpiryTimeout();if(r){let n=()=>{this._reloadTile(t,`expired`),delete this._timers[t]};this._timers[t]=setTimeout(n,r)}}_clearTileReloadTimer(t){let n=this._timers[t];n&&(clearTimeout(n),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 n=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,n)}}refreshTiles(t){for(let n of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(n);!this._inViewTiles.isIdRenderable(n)&&r.state!=`errored`||t.some(t=>t.equals(r.tileID.canonical))&&this._reloadTile(n,`expired`)}}_removeTile(t){let n=this._inViewTiles.getTileById(t);n&&(n.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),!(n.uses>0)&&(n.hasData()&&n.state!==`reloading`?this._outOfViewCache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(t){if(t.dataType===`source`){if(t.sourceDataType===`metadata`){this._sourceLoaded=!0;return}t.sourceDataType!==`content`||!this._sourceLoaded||this._paused||(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,n,r){let i=[],a=this.transform;if(!a)return i;let o=a.getCoveringTilesDetailsProvider().allowWorldCopies(),s=r?a.getCameraQueryGeometry(t):t,c=t=>a.screenPointToMercatorCoordinate(t,this.terrain),l=this.transformBbox(t,c,!o),u=this.transformBbox(s,c,!o),d=this.getIds(),f=Se.fromPoints(u);for(let t of d){let r=this._inViewTiles.getTileById(t);if(r.holdingForSymbolFade())continue;let s=o?[r.tileID]:[r.tileID.unwrapTo(-1),r.tileID.unwrapTo(0)],c=2**(a.zoom-r.tileID.overscaledZ),d=n*r.queryPadding*F/r.tileSize/c;for(let t of s){let n=f.map(n=>t.getTilePoint(new I(n.x,n.y)));if(n.expandBy(d),n.intersects(Pa)){let n=l.map(n=>t.getTilePoint(n)),a=u.map(n=>t.getTilePoint(n));i.push({tile:r,tileID:o?t:t.unwrapTo(0),queryGeometry:n,cameraQueryGeometry:a,scale:c})}}}return i}transformBbox(t,n,r){let i=t.map(n);if(r){let r=Se.fromPoints(t);r.shrinkBy(Math.min(r.width(),r.height())*.001);let a=r.map(n);Se.fromPoints(i).covers(a)||(i=i.map(t=>t.x>.5?new I(t.x-1,t.y,t.z):t))}return i}getVisibleCoordinates(t){let n=this.getRenderableIds(t).map(t=>this._inViewTiles.getTileById(t).tileID);return this.transform&&this.transform.populateCache(n),n}hasTransition(){return this._source.hasTransition()?!0:Fa(this._source.type)&&Va(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,n,r){t||=Ue,this._state.updateState(t,n,r)}removeFeatureState(t,n,r){t||=Ue,this._state.removeFeatureState(t,n,r)}getFeatureState(t,n){return t||=Ue,this._state.getState(t,n)}setDependencies(t,n,r){let i=this._inViewTiles.getTileById(t);i&&i.setDependencies(n,r)}reloadTilesForDependencies(t,n){for(let r of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(r).hasDependency(t,n)&&this._reloadTile(r,`reloading`);this._outOfViewCache.filter(r=>!r.hasDependency(t,n))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if(t.state!==`loaded`&&t.state!==`errored`)return!1;return!0}},Ja=class{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let t=1;t0?(i-o)/s:0;return this.points[a].mult(1-c).add(this.points[n].mult(c))}};function Ga(t,n){let r=!0;return t===`always`||(t===`never`||n===`never`)&&(r=!1),r}var Xa=class{constructor(t,n,r){let i=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(t/r),this.yCellCount=Math.ceil(n/r);for(let t=0;tthis.width||i<0||n>this.height)return[];let c=[];if(t<=0&&n<=0&&this.width<=r&&this.height<=i){if(a)return[{key:null,x1:t,y1:n,x2:r,y2:i}];for(let t=0;t0}hitTestCircle(t,n,r,i,a){let o=t-r,s=t+r,c=n-r,l=n+r;if(s<0||o>this.width||l<0||c>this.height)return!1;let u=[],d={hitTest:!0,overlapMode:i,circle:{x:t,y:n,radius:r},seenUids:{box:{},circle:{}}};return this._forEachCell(o,c,s,l,this._queryCellCircle,u,d,a),u.length>0}_queryCell(t,n,r,i,a,o,s,c){let{seenUids:l,hitTest:u,overlapMode:d}=s,f=this.boxCells[a],p=1e-6;if(f!==null){let a=this.bboxes;for(let s of f)if(!l.box[s]){l.box[s]=!0;let f=s*4,m=this.boxKeys[s];if(t<=a[f+2]+p&&n<=a[f+3]+p&&r>=a[f+0]-p&&i>=a[f+1]-p&&(!c||c(m))&&(!u||!Ga(d,m.overlapMode))&&(o.push({key:m,x1:a[f],y1:a[f+1],x2:a[f+2],y2:a[f+3]}),u))return!0}}let m=this.circleCells[a];if(m!==null){let a=this.circles;for(let s of m)if(!l.circle[s]){l.circle[s]=!0;let f=s*3,p=this.circleKeys[s];if(this._circleAndRectCollide(a[f],a[f+1],a[f+2],t,n,r,i)&&(!c||c(p))&&(!u||!Ga(d,p.overlapMode))){let t=a[f],n=a[f+1],r=a[f+2];if(o.push({key:p,x1:t-r,y1:n-r,x2:t+r,y2:n+r}),u)return!0}}}return!1}_queryCellCircle(t,n,r,i,a,o,s,c){let{circle:l,seenUids:u,overlapMode:d}=s,f=this.boxCells[a];if(f!==null){let t=this.bboxes;for(let n of f)if(!u.box[n]){u.box[n]=!0;let r=n*4,i=this.boxKeys[n];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[r+0],t[r+1],t[r+2],t[r+3])&&(!c||c(i))&&!Ga(d,i.overlapMode))return o.push(!0),!0}}let p=this.circleCells[a];if(p!==null){let t=this.circles;for(let n of p)if(!u.circle[n]){u.circle[n]=!0;let r=n*3,i=this.circleKeys[n];if(this._circlesCollide(t[r],t[r+1],t[r+2],l.x,l.y,l.radius)&&(!c||c(i))&&!Ga(d,i.overlapMode))return o.push(!0),!0}}}_forEachCell(t,n,r,i,a,o,s,c){let l=this._convertToXCellCoord(t),u=this._convertToYCellCoord(n),d=this._convertToXCellCoord(r),f=this._convertToYCellCoord(i);for(let p=l;p<=d;p++)for(let l=u;l<=f;l++){let u=this.xCellCount*l+p;if(a.call(this,t,n,r,i,u,o,s,c))return}}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,r,i,a,o){let s=i-t,c=a-n,l=r+o;return l*l>s*s+c*c}_circleAndRectCollide(t,n,r,i,a,o,s){let c=(o-i)/2,l=Math.abs(t-(i+c));if(l>c+r)return!1;let u=(s-a)/2,d=Math.abs(n-(a+u));if(d>u+r)return!1;if(l<=c||d<=u)return!0;let f=l-c,p=d-u;return f*f+p*p<=r*r}};function qa(t,n){let r=1/(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]),i=1/(n[8]*n[8]+n[9]*n[9]+n[10]*n[10]),a=n[0]*r,o=n[4]*r,s=n[8]*i,c=n[1]*r,l=n[5]*r,u=n[9]*i,d=n[2]*r,f=n[6]*r,p=n[10]*i;t[0]=a,t[1]=o,t[2]=s,t[4]=c,t[5]=l,t[6]=u,t[8]=d,t[9]=f,t[10]=p;let m=n[12],h=n[13],g=n[14];return t[12]=-a*m-c*h-d*g,t[13]=-o*m-l*h-f*g,t[14]=-s*m-u*h-p*g,t[3]=0,t[7]=0,t[11]=0,t[15]=1,t}function Ya(t,n){return t[0]=1/n[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1/n[5],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=1/n[14],t[12]=0,t[13]=0,t[14]=-1,t[15]=n[10]/n[14],t}function Za(t,n){let r=1/(n[0]*n[5]-n[1]*n[4]);return t[0]=n[5]*r,t[1]=-n[1]*r,t[2]=0,t[3]=0,t[4]=-n[4]*r,t[5]=n[0]*r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1/n[10],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1/n[15],t}const Qa=ce();function $a(t,n,r){let i=ce();if(!t){let{vecSouth:t,vecEast:r}=to(n),a=vr();a[0]=r[0],a[1]=r[1],a[2]=t[0],a[3]=t[1],yr(a,a),i[0]=a[0],i[1]=a[1],i[4]=a[2],i[5]=a[3]}return le(i,i,[1/r,1/r,1]),i}function eo(t,n,r,i){if(t){let t=ce();if(!n){let{vecSouth:n,vecEast:i}=to(r);t[0]=i[0],t[1]=i[1],t[4]=n[0],t[5]=n[1]}return le(t,t,[i,i,1]),t}else return r.pixelsToClipSpaceMatrix}function to(t){let n=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),i=Math.cos(t.pitchInRadians),a=Math.cos(t.bearingInRadians),o=Math.sin(t.bearingInRadians),s=We();s[0]=-a*i*r-o*n,s[1]=-o*i*r+a*n;let c=Ge(s);c<1e-9?Ke(s):qe(s,s,1/c);let l=We();l[0]=a*i*n-o*r,l[1]=o*i*n+a*r;let u=Ge(l);return u<1e-9?Ke(l):qe(l,l,1/u),{vecEast:l,vecSouth:s}}function no(t,n,r,a){let o;a?(o=[t,n,a(t,n),1],Je(o,o,r)):(o=[t,n,0,1],bo(o,o,r));let s=o[3];return{point:new i(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function ro(t,n){return .5+t/n*.5}function io(t,n){return t.x>=-n[0]&&t.x<=n[0]&&t.y>=-n[1]&&t.y<=n[1]}function ao(t,n,r,a,o,s,c,l,u,d,f,p,m){let h=r?t.textSizeData:t.iconSizeData,g=Ye(h,n.transform.zoom),_=[256/n.width*2+1,256/n.height*2+1],v=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;v.clear();let y=t.lineVertexArray,b=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=n.transform.width/n.transform.height,S=!1;for(let r=0;rMath.abs(r.x-n.x)*i?{useVertical:!0}:(t===2?n.yr.x)?{needsFlipping:!0}:null}function co(t){let{projectionContext:n,pitchedLabelPlaneMatrixInverse:r,symbol:a,fontSize:o,flip:s,keepUpright:c,glyphOffsetArray:l,dynamicLayoutVertexArray:u,aspectRatio:d,rotateToLine:f}=t,p=o/24,m=a.lineOffsetX*p,h=a.lineOffsetY*p,g;if(a.numGlyphs>1){let t=a.glyphStartIndex+a.numGlyphs,i=a.lineStartIndex,o=a.lineStartIndex+a.lineLength,u=oo(p,l,m,h,s,a,f,n);if(!u)return{notEnoughRoom:!0};let _=po(u.first.point.x,u.first.point.y,n,r),v=po(u.last.point.x,u.last.point.y,n,r);if(c&&!s){let t=so(a.writingMode,_,v,d);if(t)return t}g=[u.first];for(let r=a.glyphStartIndex+1;r0?c.point:lo(n.tileAnchorPoint,s,t,1,n),u=po(t.x,t.y,n,r),f=po(l.x,l.y,n,r),p=so(a.writingMode,u,f,d);if(p)return p}let t=_o(p*l.getoffsetX(a.glyphStartIndex),m,h,s,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,n,f);if(!t||n.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};g=[t]}for(let t of g)Ze(u,t.point,t.angle);return{}}function lo(t,n,r,i,a){let o=t.add(t.sub(n)._unit()),s=fo(o.x,o.y,a).point,c=r.sub(s);return r.add(c._mult(i/c.mag()))}function uo(t,n,r){let a=n.projectionCache;if(a.projections[t])return a.projections[t];let o=new i(n.lineVertexArray.getx(t),n.lineVertexArray.gety(t)),s=fo(o.x,o.y,n);if(s.signedDistanceFromCamera>0)return a.projections[t]=s.point,a.anyProjectionOccluded||=s.isOccluded,s.point;let c=t-r.direction,l=r.distanceFromAnchor===0?n.tileAnchorPoint:new i(n.lineVertexArray.getx(c),n.lineVertexArray.gety(c)),u=r.absOffsetX-r.distanceFromAnchor+1;return lo(l,o,r.previousVertex,u,n)}function fo(t,n,r){let i=t+r.translation[0],a=n+r.translation[1],o;return r.pitchWithMap?(o=no(i,a,r.pitchedLabelPlaneMatrix,r.getElevation),o.isOccluded=!1):(o=r.transform.projectTileCoordinates(i,a,r.unwrappedTileID,r.getElevation),o.point.x=(o.point.x*.5+.5)*r.width,o.point.y=(-o.point.y*.5+.5)*r.height),o}function po(t,n,r,i){if(r.pitchWithMap){let a=[t,n,0,1];return Je(a,a,i),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}else return{x:t/r.width*2-1,y:1-n/r.height*2}}function mo(t,n,r){return r.transform.projectTileCoordinates(t,n,r.unwrappedTileID,r.getElevation)}function ho(t,n,r){return t._unit()._perp()._mult(n*r)}function go(t,n,r,i,a,o,s,c,l){if(c.projectionCache.offsets[t])return c.projectionCache.offsets[t];let u=r.add(n);if(t+l.direction=a)return c.projectionCache.offsets[t]=u,u;let d=uo(t+l.direction,c,l),f=ho(d.sub(r),s,l.direction),p=r.add(f),m=d.add(f);return c.projectionCache.offsets[t]=Qe(o,u,p,m)||u,c.projectionCache.offsets[t]}function _o(t,n,r,i,a,o,s,c,l){let u=i?t-n:t+n,d=u>0?1:-1,f=0;i&&(d*=-1,f=Math.PI),d<0&&(f+=Math.PI);let p=d>0?o+a:o+a+1,m;c.projectionCache.cachedAnchorPoint?m=c.projectionCache.cachedAnchorPoint:(m=fo(c.tileAnchorPoint.x,c.tileAnchorPoint.y,c).point,c.projectionCache.cachedAnchorPoint=m);let h=m,g=m,_,v,y=0,b=0,x=Math.abs(u),S=[],C;for(;y+b<=x;){if(p+=d,p=s)return null;y+=b,g=h,v=_;let t={absOffsetX:x,direction:d,distanceFromAnchor:y,previousVertex:g};if(h=uo(p,c,t),r===0)S.push(g),C=h.sub(g);else{let n,i=h.sub(g);n=i.mag()===0?ho(uo(p+d,c,t).sub(h),r,d):ho(i,r,d),v||=g.add(n),_=go(p,n,h,o,s,v,r,c,t),S.push(v),C=_.sub(v)}b=C.mag()}let w=(x-y)/b,T=C._mult(w)._add(v||g),E=f+Math.atan2(h.y-g.y,h.x-g.x);return S.push(T),{point:T,angle:l?E:0,path:S}}const vo=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function yo(t,n){for(let r=0;r{let i=no(t.x,t.y,r,n.getElevation),a=n.transform.projectTileCoordinates(i.point.x,i.point.y,n.unwrappedTileID,n.getElevation);return a.point.x=(a.point.x*.5+.5)*n.width,a.point.y=(-a.point.y*.5+.5)*n.height,a})}function So(t){let n=0,r=0,i=0,a=0;for(let o=0;or&&(r=a,n=i));return t.slice(n,n+r)}var To=class{constructor(t,n=new Xa(t.width+200,t.height+200,25),r=new Xa(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=r,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+100,this.screenBottomBoundary=t.height+100,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,r,i,a,o,s,c,l,u,d,f){let p=t.anchorPointX+c[0],m=t.anchorPointY+c[1],h=this.projectAndGetPerspectiveRatio(p,m,a,u,f),g=r*h.perspectiveRatio,_;if(!o&&!s){let n=h.x+(d?d.x*g:0),r=h.y+(d?d.y*g:0);_={allPointsOccluded:!1,box:[n+t.x1*g,r+t.y1*g,n+t.x2*g,r+t.y2*g]}}else _=this._projectCollisionBox(t,g,i,a,o,s,c,h,u,d,f);let[v,y,b,x]=_.box,S=o?_.allPointsOccluded:h.isOccluded,C=S;return C||=h.perspectiveRatio=1;t--)m.push(s.path[t]);for(let t=1;tt.signedDistanceFromCamera<=0)?[]:t.map(t=>t.point)}let _=[];if(m.length>0){let t=m[0].clone(),n=m[0].clone();for(let r=1;r=r.x&&n.x<=a.x&&t.y>=r.y&&n.y<=a.y?[m]:n.xa.x||n.ya.y?[]:$e([m],r.x,r.y,a.x,a.y)}for(let r of _){o.reset(r,n*.25);let i=0;i=o.length<=.5*n?1:Math.ceil(o.paddedLength/h)+1;for(let r=0;r=this.screenRightBoundary||i<100||n>this.screenBottomBoundary}isInsideGrid(t,n,r,i){return r>=0&&t=0&&nthis.projectAndGetPerspectiveRatio(t.x,t.y,a,u,f));A=t.some(t=>!t.isOccluded),k=t.map(t=>new i(t.x,t.y))}else A=!0;return{box:tt(k),allPointsOccluded:!A}}},Eo=class{constructor(t,n,r,i){t?this.opacity=Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):this.opacity=i&&r?1:0,this.placed=r}isHidden(){return this.opacity===0&&!this.placed}},Do=class{constructor(t,n,r,i,a){this.text=new Eo(t?t.text:null,n,r,a),this.icon=new Eo(t?t.icon:null,n,i,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Oo=class{constructor(t,n,r){this.text=t,this.icon=n,this.skipFade=r}},ko=class{constructor(t,n,r,i,a){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=r,this.bucketIndex=i,this.tileID=a}},Ao=class{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:t=>t.collisionGroupID===n}}return this.collisionGroups[t]}};function Co(t,n,r,a,o){let{horizontalAlign:s,verticalAlign:c}=nt(t),l=-(s-.5)*n,u=-(c-.5)*r;return new i(l+a[0]*o,u+a[1]*o)}var Mo=class{constructor(t,n,r,i,a){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new To(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new Ao(i),this.collisionCircleArrays={},this.collisionBoxArrays=/* @__PURE__ */ new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){let n=this.terrain;return n?(r,i)=>n.getElevation(t,r,i):null}getBucketParts(t,n,r,i){let a=r.getBucket(n),o=r.latestFeatureIndex;if(!a||!o||n.id!==a.layerIds[0])return;let s=r.collisionBoxArray,c=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-r.tileID.overscaledZ),d=r.tileSize/F,f=r.tileID.toUnwrapped(),p=c.get(`text-rotation-alignment`)===`map`,m=rt(r,1,this.transform.zoom),h=it(this.collisionIndex.transform,r,l.get(`text-translate`),l.get(`text-translate-anchor`)),g=it(this.collisionIndex.transform,r,l.get(`icon-translate`),l.get(`icon-translate-anchor`)),_=$a(p,this.transform,m);this.retainedQueryData[a.bucketInstanceId]=new ko(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,r.tileID);let v={bucket:a,layout:c,translationText:h,translationIcon:g,unwrappedTileID:f,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:d,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:Ye(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(i)for(let n of a.sortKeyRanges){let{sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:a}=n;t.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:a,parameters:v})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v})}attemptAnchorPlacement(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b){let x=at[t.textAnchor],S=[t.textOffset0,t.textOffset1],C=Co(x,r,i,S,a),w=this.collisionIndex.placeCollisionBox(n,f,c,l,u,s,o,g,d.predicate,y,C,b);if(!(v&&!this.collisionIndex.placeCollisionBox(v,f,c,l,u,s,o,_,d.predicate,y,C,b).placeable)&&w.placeable){let t;if(this.prevPlacement?.variableOffsets[p.crossTileID]&&this.prevPlacement?.placements[p.crossTileID]?.text&&(t=this.prevPlacement.variableOffsets[p.crossTileID].anchor),p.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);return this.variableOffsets[p.crossTileID]={textOffset:S,width:r,height:i,anchor:x,textBoxScale:a,prevAnchor:t},this.markUsedJustification(m,x,p,h),m.allowVerticalPlacement&&(this.markUsedOrientation(m,h,p),this.placedOrientations[p.crossTileID]=h),{shift:C,placedGlyphBoxes:w}}}placeLayerBucketPart(t,n,r){let{bucket:i,layout:a,translationText:o,translationIcon:s,unwrappedTileID:c,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,collisionGroup:m}=t.parameters,h=a.get(`text-optional`),g=a.get(`icon-optional`),_=ot(a,`text-overlap`,`text-allow-overlap`),v=_===`always`,y=ot(a,`icon-overlap`,`icon-allow-overlap`),x=y===`always`,S=a.get(`text-rotation-alignment`)===`map`,C=a.get(`text-pitch-alignment`)===`map`,w=a.get(`icon-text-fit`)!==`none`,T=a.get(`symbol-z-order`)===`viewport-y`,E=v&&(x||!i.hasIconData()||g),D=x&&(v||!i.hasTextData()||h);!i.collisionArrays&&f&&i.deserializeCollisionBoxes(f);let O=this.retainedQueryData[i.bucketInstanceId].tileID,k=this._getTerrainElevationFunc(O),A=this.transform.getFastPathSimpleProjectionMatrix(O),j=(t,f,x)=>{if(n[t.crossTileID])return;if(d){this.placements[t.crossTileID]=new Oo(!1,!1,!1);return}let T=!1,j=!1,ee=!0,te=null,M={box:null,placeable:!1,offscreen:null,occluded:!1},ne={box:null,placeable:!1,offscreen:null},re=null,ie=null,ae=null,oe=0,se=0,ce=0;f.textFeatureIndex?oe=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(oe=t.featureIndex),f.verticalTextFeatureIndex&&(se=f.verticalTextFeatureIndex);let N=f.textBox;if(N){let n=n=>{let r=1;if(i.allowVerticalPlacement&&!n&&this.prevPlacement){let n=this.prevPlacement.placedOrientations[t.crossTileID];n&&(this.placedOrientations[t.crossTileID]=n,r=n,this.markUsedOrientation(i,r,t))}return r},a=(n,r)=>{if(i.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&f.verticalTextBox){for(let t of i.writingModes)if(t===2?(M=r(),ne=M):M=n(),M?.placeable)break}else M=n()},l=t.textAnchorOffsetStartIndex,d=t.textAnchorOffsetEndIndex;if(d===l){let r=(n,r)=>{let a=this.collisionIndex.placeCollisionBox(n,_,u,O,c,C,S,o,m.predicate,k,void 0,A);return a?.placeable&&(this.markUsedOrientation(i,r,t),this.placedOrientations[t.crossTileID]=r),a};a(()=>r(N,1),()=>{let n=f.verticalTextBox;return i.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&n?r(n,2):{box:null,offscreen:null}}),n(M?.placeable)}else{let p=at[this.prevPlacement?.variableOffsets[t.crossTileID]?.anchor],h=(n,a,f)=>{let h=n.x2-n.x1,g=n.y2-n.y1,v=t.textBoxScale,b=w&&y===`never`?a:null,x=null,E=_===`never`?1:2,D=`never`;p&&E++;for(let r=0;rh(N,f.iconBox,1),()=>{let n=f.verticalTextBox,r=M?.placeable;return i.allowVerticalPlacement&&!r&&t.numVerticalGlyphVertices>0&&n?h(n,f.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),M&&(T=M.placeable,ee=M.offscreen);let g=n(M?.placeable);if(!T&&this.prevPlacement){let n=this.prevPlacement.variableOffsets[t.crossTileID];n&&(this.variableOffsets[t.crossTileID]=n,this.markUsedJustification(i,n.anchor,t,g))}}}if(re=M,T=re?.placeable,ee=re?.offscreen,t.useRuntimeCollisionCircles&&t.centerJustifiedTextSymbolIndex>=0){let n=i.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),s=Xe(i.textSizeData,p,n),u=a.get(`text-padding`),d=t.collisionCircleDiameter;ie=this.collisionIndex.placeCollisionCircles(_,n,i.lineVertexArray,i.glyphOffsetArray,s,c,l,r,C,m.predicate,d,u,o,k),ie.circles.length&&ie.collisionDetected&&!r&&b(`Collisions detected, but collision boxes are not shown`),T=v||ie.circles.length>0&&!ie.collisionDetected,ee&&=ie.offscreen}if(f.iconFeatureIndex&&(ce=f.iconFeatureIndex),f.iconBox){let t=t=>this.collisionIndex.placeCollisionBox(t,y,u,O,c,C,S,s,m.predicate,k,w&&te?te:void 0,A);ne&&ne.placeable&&f.verticalIconBox?(ae=t(f.verticalIconBox),j=ae.placeable):(ae=t(f.iconBox),j=ae.placeable),ee&&=ae.offscreen}let le=h||t.numHorizontalGlyphVertices===0&&t.numVerticalGlyphVertices===0,ue=g||t.numIconVertices===0;!le&&!ue?j=T=j&&T:ue?le||(j&&=T):T=j&&T;let de=T&&re.placeable,P=j&&ae.placeable;if(de&&(ne&&ne.placeable&&se?this.collisionIndex.insertCollisionBox(re.box,_,a.get(`text-ignore-placement`),i.bucketInstanceId,se,m.ID):this.collisionIndex.insertCollisionBox(re.box,_,a.get(`text-ignore-placement`),i.bucketInstanceId,oe,m.ID)),P&&this.collisionIndex.insertCollisionBox(ae.box,y,a.get(`icon-ignore-placement`),i.bucketInstanceId,ce,m.ID),ie&&T&&this.collisionIndex.insertCollisionCircles(ie.circles,_,a.get(`text-ignore-placement`),i.bucketInstanceId,oe,m.ID),r&&this.storeCollisionData(i.bucketInstanceId,x,f,re,ae,ie),t.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);if(i.bucketInstanceId===0)throw Error(`bucket.bucketInstanceId can't be 0`);let fe=(T||E)&&!re?.occluded,pe=(j||D)&&!ae?.occluded;this.placements[t.crossTileID]=new Oo(fe,pe,ee||i.justReloaded),n[t.crossTileID]=!0};if(T){if(t.symbolInstanceStart!==0)throw Error(`bucket.bucketInstanceId should be 0`);let n=i.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=n.length-1;t>=0;--t){let r=n[t];j(i.symbolInstances.get(r),i.collisionArrays[r],r)}}else for(let n=t.symbolInstanceStart;n=0&&(o>=0&&n!==o?t.text.placedSymbolArray.get(n).crossTileID=0:t.text.placedSymbolArray.get(n).crossTileID=r.crossTileID)}markUsedOrientation(t,n,r){let i=n===1||n===3?n:0,a=n===2?n:0,o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(let n of o)t.text.placedSymbolArray.get(n).placedOrientation=i;r.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let n=this.prevPlacement,r=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;let i=n?n.symbolFadeChange(t):1,a=n?n.opacities:{},o=n?n.variableOffsets:{},s=n?n.placedOrientations:{};for(let t in this.placements){let n=this.placements[t],o=a[t];o?(this.opacities[t]=new Do(o,i,n.text,n.icon),r||=n.text!==o.text.placed,r||=n.icon!==o.icon.placed):(this.opacities[t]=new Do(null,i,n.text,n.icon,n.skipFade),r||=n.text||n.icon)}for(let t in a){let n=a[t];if(!this.opacities[t]){let a=new Do(n,i,!1,!1);a.isHidden()||(this.opacities[t]=a,r||=n.text.placed,r||=n.icon.placed)}}for(let t in o)!this.variableOffsets[t]&&this.opacities[t]&&!this.opacities[t].isHidden()&&(this.variableOffsets[t]=o[t]);for(let t in s)!this.placedOrientations[t]&&this.opacities[t]&&!this.opacities[t].isHidden()&&(this.placedOrientations[t]=s[t]);if(n&&n.lastPlacementChangeTime===void 0)throw Error(`Last placement time for previous placement is not defined`);r?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!=`number`&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){let r={};for(let i of n){let n=i.getBucket(t);n&&i.latestFeatureIndex&&t.id===n.layerIds[0]&&this.updateBucketOpacities(n,i.tileID,r,i.collisionBoxArray)}}updateBucketOpacities(t,n,r,a){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();let o=t.layers[0],s=o.layout,c=new Do(null,0,!1,!1,!0),l=s.get(`text-allow-overlap`),u=s.get(`icon-allow-overlap`),d=o._unevaluatedLayout.hasValue(`text-variable-anchor`)||o._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),f=s.get(`text-rotation-alignment`)===`map`,p=s.get(`text-pitch-alignment`)===`map`,m=s.get(`icon-text-fit`)!==`none`,h=new Do(null,0,l&&(u||!t.hasIconData()||s.get(`icon-optional`)),u&&(l||!t.hasTextData()||s.get(`text-optional`)),!0);!t.collisionArrays&&a&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(a);let g=(t,n,r)=>{for(let i=0;i0||s>0,b=a.numIconVertices>0,x=this.placedOrientations[a.crossTileID],S=x===2,C=x===1||x===3;if(y){let n=Io(v.text),r=S?Lo:n;g(t.text,o,r);let i=C?Lo:n;g(t.text,s,i);let c=v.text.isHidden(),l=[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex];for(let n of l)n>=0&&(t.text.placedSymbolArray.get(n).hidden=c||S?1:0);a.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).hidden=c||C?1:0);let u=this.variableOffsets[a.crossTileID];u&&this.markUsedJustification(t,u.anchor,a,x);let d=this.placedOrientations[a.crossTileID];d&&(this.markUsedJustification(t,`left`,a,d),this.markUsedOrientation(t,d,a))}if(b){let n=Io(v.icon),r=!(m&&a.verticalPlacedIconSymbolIndex&&S);if(a.placedIconSymbolIndex>=0){let i=r?n:Lo;g(t.icon,a.numIconVertices,i),t.icon.placedSymbolArray.get(a.placedIconSymbolIndex).hidden=v.icon.isHidden()}if(a.verticalPlacedIconSymbolIndex>=0){let i=r?Lo:n;g(t.icon,a.numVerticalIconVertices,i),t.icon.placedSymbolArray.get(a.verticalPlacedIconSymbolIndex).hidden=v.icon.isHidden()}}let w=_?.has(n)?_.get(n):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let r=t.collisionArrays[n];if(r){let n=new i(0,0);if(r.textBox||r.verticalTextBox){let i=!0;if(d){let t=this.variableOffsets[l];t?(n=Co(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),f&&n._rotate(p?-this.transform.bearingInRadians:this.transform.bearingInRadians)):i=!1}if(r.textBox||r.verticalTextBox){let a;r.textBox&&(a=S),r.verticalTextBox&&(a=C),wo(t.textCollisionBox.collisionVertexArray,v.text.placed,!i||a,w.text,n.x,n.y)}}if(r.iconBox||r.verticalIconBox){let i=!!(!C&&r.verticalIconBox),a;r.iconBox&&(a=i),r.verticalIconBox&&(a=!i),wo(t.iconCollisionBox.collisionVertexArray,v.icon.placed,a,w.icon,m?n.x:0,m?n.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}};function wo(t,n,r,i,a,o){(!i||i.length===0)&&(i=[0,0,0,0]);let s=i[0]-100,c=i[1]-100,l=i[2]-100,u=i[3]-100;t.emplaceBack(+!!n,+!!r,a||0,o||0,s,c),t.emplaceBack(+!!n,+!!r,a||0,o||0,l,c),t.emplaceBack(+!!n,+!!r,a||0,o||0,l,u),t.emplaceBack(+!!n,+!!r,a||0,o||0,s,u)}const jo=2**25,No=2**24,Po=2**17,Fo=2**16;function Io(t){if(t.opacity===0&&!t.placed)return 0;if(t.opacity===1&&t.placed)return 4294967295;let n=+!!t.placed,r=Math.floor(t.opacity*127);return r*jo+n*No+r*Po+n*Fo+r*512+n*256+r*2+n}const Lo=0;var Bo=class{constructor(t){this._sortAcrossTiles=t.layout.get(`symbol-z-order`)!==`viewport-y`&&!t.layout.get(`symbol-sort-key`).isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,r,i,a){let o=this._bucketParts;for(;this._currentTileIndext.sortKey-n.sortKey));this._currentPartIndex!this._forceFullPlacement&&U()-i>2;for(;this._currentPlacementIndex>=0;){let i=n[t[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(ct(i)&&i.layout&&(!i.minzoom||i.minzoom<=o)&&(!i.maxzoom||i.maxzoom>o)){if(this._inProgressLayer||=new Bo(i),this._inProgressLayer.continuePlacement(r[i.source],this.placement,this._showCollisionBoxes,i,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}};const Ro=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],q=new Uint32Array(96);var zo=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=Ro[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,void 0,t)}constructor(t,n=64,r=Float64Array,i=ArrayBuffer,a){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let o=Ro.indexOf(this.ArrayType),s=t*2*this.ArrayType.BYTES_PER_ELEMENT,c=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-c%8)%8;if(o<0)throw Error(`Unexpected typed array class: ${r}.`);if(a)this.data=a,this.ids=new this.IndexArrayType(a,8,t),this.coords=new r(a,8+c+l,t*2),this._pos=t*2,this._finished=!0;else{let a=this.data=new i(8+s+c+l);this.ids=new this.IndexArrayType(a,8,t),this.coords=new r(a,8+c+l,t*2),this._pos=0,this._finished=!1,new Uint8Array(a,0,2).set([219,16+o]),new Uint16Array(a,2,1)[0]=n,new Uint32Array(a,4,1)[0]=t}}add(t,n){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=n,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return Ho(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,r,i){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:a,coords:o,nodeSize:s}=this;q[0]=0,q[1]=a.length-1,q[2]=0;let c=3,l=[];for(;c>0;){let u=q[--c],d=q[--c],f=q[--c];if(d-f<=s){for(let s=f;s<=d;s++){let c=o[2*s],u=o[2*s+1];c>=t&&c<=r&&u>=n&&u<=i&&l.push(a[s])}continue}let p=f+d>>1,m=o[2*p],h=o[2*p+1];m>=t&&m<=r&&h>=n&&h<=i&&l.push(a[p]),(u===0?t<=m:n<=h)&&(q[c++]=f,q[c++]=p-1,q[c++]=1-u),(u===0?r>=m:i>=h)&&(q[c++]=p+1,q[c++]=d,q[c++]=1-u)}return l}within(t,n,r){let i=[];return this.withinInto(t,n,r,i),i}withinInto(t,n,r,i){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:a,coords:o,nodeSize:s}=this;q[0]=0,q[1]=a.length-1,q[2]=0;let c=3,l=0,u=r*r;for(;c>0;){let d=q[--c],f=q[--c],p=q[--c];if(f-p<=s){for(let r=p;r<=f;r++)Ko(o[2*r],o[2*r+1],t,n)<=u&&(i[l++]=a[r]);continue}let m=p+f>>1,h=o[2*m],g=o[2*m+1];Ko(h,g,t,n)<=u&&(i[l++]=a[m]),(d===0?t-r<=h:n-r<=g)&&(q[c++]=p,q[c++]=m-1,q[c++]=1-d),(d===0?t+r>=h:n+r>=g)&&(q[c++]=m+1,q[c++]=f,q[c++]=1-d)}return l}};function Ho(t,n,r,i,a,o){if(a-i<=r)return;let s=i+a>>1;Uo(t,n,s,i,a,o),Ho(t,n,r,i,s-1,1-o),Ho(t,n,r,s+1,a,1-o)}function Uo(t,n,r,i,a,o){for(;a>i;){if(a-i>600){let s=a-i+1,c=r-i+1,l=Math.log(s),u=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*u*(s-u)/s)*(c-s/2<0?-1:1);Uo(t,n,r,Math.max(i,Math.floor(r-c*u/s+d)),Math.min(a,Math.floor(r+(s-c)*u/s+d)),o)}let s=n[2*r+o],c=i,l=a;for(Wo(t,n,i,r),n[2*a+o]>s&&Wo(t,n,i,a);cs;)l--}n[2*i+o]===s?Wo(t,n,i,l):(l++,Wo(t,n,l,a)),l<=r&&(i=l+1),r<=l&&(a=l-1)}}function Wo(t,n,r,i){Go(t,r,i),Go(n,2*r,2*i),Go(n,2*r+1,2*i+1)}function Go(t,n,r){let i=t[n];t[n]=t[r],t[r]=i}function Ko(t,n,r,i){let a=t-r,o=n-i;return a*a+o*o}const qo=512/F/2;var Xo=class{constructor(t,n,r){this.tileID=t,this.bucketInstanceId=r,this._symbolsByKey={};let i=/* @__PURE__ */ new Map;for(let t=0;t({x:Math.floor(t.anchorX*qo),y:Math.floor(t.anchorY*qo)})),crossTileIDs:n.map(t=>t.crossTileID)};if(r.positions.length>128){let t=new zo(r.positions.length,16,Uint16Array);for(let{x:n,y:i}of r.positions)t.add(n,i);t.finish(),delete r.positions,r.index=t}this._symbolsByKey[t]=r}}getScaledCoordinates(t,n){let{x:r,y:i,z:a}=this.tileID.canonical,{x:o,y:s,z:c}=n.canonical,l=qo/2**(c-a),u=(o*F+t.anchorX)*l,d=(s*F+t.anchorY)*l,f=r*F*qo,p=i*F*qo;return{x:Math.floor(u-f),y:Math.floor(d-p)}}findMatches(t,n,r){let i=this.tileID.canonical.zt)}},Zo=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Qo=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let n=Math.round((t-this.lng)/360);if(n!==0)for(let t in this.indexes){let r=this.indexes[t],i={};for(let t in r){let a=r[t];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+n),i[a.tileID.key]=a}this.indexes[t]=i}this.lng=t}addBucket(t,n,r){if(this.indexes[t.overscaledZ]?.[t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;tt.overscaledZ)for(let r in a){let o=a[r];o.tileID.isChildOf(t)&&o.findMatches(n.symbolInstances,t,i)}else{let o=a[t.scaledTo(Number(r)).key];o&&o.findMatches(n.symbolInstances,t,i)}}for(let t=0;t 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);}`,os=`void main() {fragColor=vec4(1.0);}`;const ss={prelude:J(Jo,Yo),projectionMercator:J(``,`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:J(``,`#define GLOBE_RADIUS 6371008.8 -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;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 spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}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;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len -);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) {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) {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:J(es,ts),backgroundPattern:J(ns,rs),circle:J(is,as),clippingMask:J(os,`layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),heatmap:J(`uniform highp float u_intensity;in vec2 v_extrude; +} 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);}`,os=`void main() {fragColor=vec4(1.0);}`;const ss={prelude:J(Jo,Yo),projectionMercator:J(` +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:J(`uniform bool u_projection_clip_antimeridian;in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}`,`#define GLOBE_RADIUS 6371008.8 +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;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:J(es,ts),backgroundPattern:J(ns,rs),circle:J(is,as),clippingMask:J(os,`layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}`),heatmap:J(`uniform highp float u_intensity;in vec2 v_extrude; #pragma maplibre: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { @@ -393,7 +391,7 @@ void main() { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity -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); +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 @@ -437,7 +435,7 @@ in float v_depth; void main() { #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity -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); +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 @@ -490,7 +488,7 @@ void main() { #pragma maplibre: initialize lowp float pixel_ratio_to #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity -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; +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 @@ -553,7 +551,7 @@ void main() { #pragma maplibre: initialize lowp float floorwidth #pragma maplibre: initialize mediump vec4 dasharray_from #pragma maplibre: initialize mediump vec4 dasharray_to -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); +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 @@ -612,7 +610,7 @@ void main() { #pragma maplibre: initialize lowp float floorwidth #pragma maplibre: initialize mediump vec4 dasharray_from #pragma maplibre: initialize mediump vec4 dasharray_to -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); +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 @@ -750,7 +748,7 @@ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ra #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:J(`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:J(`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;}`),terrainCoords:J(`precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}`,`layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;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);}`),projectionErrorMeasurement:J(`flat in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}`,`layout(location=0) in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;flat out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}`),atmosphere:J(`#ifdef GL_ES +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:J(`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:J(`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;}`),terrainCoords:J(`precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}`,`layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;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);}`),atmosphere:J(`#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 @@ -803,7 +801,7 @@ uniform ${r} ${i} u_${a}; #else ${r} ${i} ${a} = u_${a}; #endif -`}),{fragmentSource:t,vertexSource:n,staticAttributes:i,staticUniforms:s}}var us=class{constructor(t,n,r){this.vertexBuffer=t,this.indexBuffer=n,this.segments=r}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const cs=ct([{name:`a_pos`,type:`Int16`,components:2}]),ls=`#define PROJECTION_MERCATOR`,ds=`mercator`;var ms=class{constructor(){this._cachedMesh=null}get name(){return`mercator`}get useSubdivision(){return!1}get shaderVariantName(){return ds}get shaderDefine(){return ls}get shaderPreludeCode(){return ss.projectionMercator}get vertexShaderPreludeCode(){return ss.projectionMercator.vertexSource}get subdivisionGranularity(){return lt.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,n,r,i,a){if(this._cachedMesh)return this._cachedMesh;let o=new ut;o.emplaceBack(0,0),o.emplaceBack(I,0),o.emplaceBack(0,I),o.emplaceBack(I,I);let s=t.createVertexBuffer(o,cs.members),c=dt.simpleSegment(0,0,4,2),l=new ft;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=t.createIndexBuffer(l);return this._cachedMesh=new us(s,u,c),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}},fs=class e{constructor(t=0,n=0,r=0,i=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0||isNaN(i)||i<0)throw Error(`Invalid value for edge-insets, top, bottom, left and right must all be numbers`);this.top=t,this.bottom=n,this.left=r,this.right=i}interpolate(t,n,r){return n.top!=null&&t.top!=null&&(this.top=pt.number(t.top,n.top,r)),n.bottom!=null&&t.bottom!=null&&(this.bottom=pt.number(t.bottom,n.bottom,r)),n.left!=null&&t.left!=null&&(this.left=pt.number(t.left,n.left,r)),n.right!=null&&t.right!=null&&(this.right=pt.number(t.right,n.right,r)),this}getCenter(t,n){return new i(R((this.left+t-this.right)/2,0,t),R((this.top+n-this.bottom)/2,0,n))}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new e(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function ps(t,n){if(!t.renderWorldCopies||t.lngRange)return;let r=n.lng-t.center.lng;n.lng+=r>180?-360:r<-180?360:0}function hs(t){return Math.max(0,Math.floor(t))}var vs=class{constructor(t,n){this.applyConstrain=(t,n)=>this._constrainOverride===null?this._callbacks.defaultConstrain(t,n):this._constrainOverride(t,n),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=n?.renderWorldCopies===void 0||!!n?.renderWorldCopies,this._minZoom=n?.minZoom||0,this._maxZoom=n?.maxZoom||22,this._minPitch=n?.minPitch===void 0||n?.minPitch===null?0:n?.minPitch,this._maxPitch=n?.maxPitch===void 0||n?.maxPitch===null?60:n?.maxPitch,this._constrainOverride=n?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new F(0,0),this._elevation=0,this._zoom=0,this._tileZoom=hs(this._zoom),this._scale=Pe(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new fs,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,n,r){this._constrainOverride=t.constrainOverride,this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=hs(this._zoom),this._scale=Pe(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new fs(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!r&&t.autoCalculateNearFarZ,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){t===void 0&&(t=null),this._constrainOverride!==t&&(this._constrainOverride=t,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 i(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){let n=de(t,-180,180)*Math.PI/180;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=yr(),xr(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(t){let n=R(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){let n=t/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return mt(this._fovInRadians)}setFov(t){t=R(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=Ne(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){let n=this.applyConstrain(this._center,t).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=Pe(n),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(t){(t.lat!==this._center.lat||t.lng!==this._center.lng)&&(this._unmodified=!1,this._center=t,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,n){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,r){this._unmodified=!1,this._edgeInsets.interpolate(t,n,r),this.constrainInternal(),this._calcMatrices()}resize(t,n,r=!0){this._width=t,this._height=n,r&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange?.length!==2||this._lngRange?.length!==2?null:new Ii([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-Me,Me])}getCameraQueryGeometry(t,n){if(n.length===1)return[n[0],t];{let{minX:r,minY:a,maxX:o,maxY:s}=xe.fromPoints(n).extend(t);return[new i(r,a),new i(o,a),new i(o,s),new i(r,s),new i(r,a)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let t=this._unmodified,{center:n,zoom:r}=this.applyConstrain(this.center,this.zoom);this.setCenter(n),this.setZoom(r),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=Fe(new Float64Array(16));P(t,t,[this._width/2,-this._height/2,1]),N(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=Fe(new Float64Array(16)),P(t,t,[1,-1,1]),N(t,t,[-1,-1,0]),P(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t;let n=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(n)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,n,r,i){let a=r===void 0?this.bearing:r,o=i=i===void 0?this.pitch:i,{distanceToCenter:s,clampedElevation:c}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,o),{x:l,y:u}=Da(o,a),d=L.fromLngLat(t,n),f=ht(1,d.y),p,m,h=0;do{if(h+=1,h>10)break;m=s/f;let t=l*m,n=u*m;p=new L(d.x+t,d.y+n),f=1/p.meterInMercatorCoordinateUnits()}while(Math.abs(s-m*f)>1e-12);return{center:p.toLngLat(),elevation:c,zoom:Le(this.height/2/Math.tan(this.fovInRadians/2)/m/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t===0)return;let n=1/this.worldSize,r=Ie(1,this.center.lat)*this.worldSize,i=L.fromLngLat(this.center,this.elevation),a=i.x/n,o=i.y/n,s=i.z/n,c=this.pitch,l=this.bearing,{x:u,y:d,z:f}=Da(c,l),p=this.cameraToCenterDistance,m=a+p*-u,h=o+p*-d,g=s+p*f,{distanceToCenter:_,clampedElevation:v}=this._distanceToCenterFromAltElevationPitch(g/r,t,c),y=_*r,b=m+u*y,x=h+d*y,S=new L(b*n,x*n,0).toLngLat(),C=Ie(1,S.lat),w=Le(this.height/2/Math.tan(this.fovInRadians/2)/_/C/this.tileSize);this._elevation=v,this._center=S,this.setZoom(w)}_distanceToCenterFromAltElevationPitch(t,n,r){let i=-Math.cos(Ne(r)),a=t-n,o,s=n;return i*a>=0||Math.abs(i)<.1?(o=1e4,s=t+o*i):o=-a/i,{distanceToCenter:o,clampedElevation:s}}getCameraPoint(){let t=this.pitchInRadians,n=Math.tan(t)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i(n*Math.sin(this.rollInRadians),n*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let t=Ie(1,this.center.lat)*this.worldSize,n=this.cameraToCenterDistance/t;return Ea(this.center,this.elevation,this.pitch,this.bearing,n).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];let n=t.canonical.z>=0?1<this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]0?(n+=t[i]*this.min[i],r+=t[i]*this.max[i]):(r+=t[i]*this.min[i],n+=t[i]*this.max[i]);return n>=0?2:r<0?0:1}},bs=class{distanceToTile2d(t,n,r,i){let a=i,o=a.distanceX([t,n]),s=a.distanceY([t,n]);return Math.hypot(o,s)}getWrap(t,n,r){return r}getTileBoundingVolume(t,n,r,i){let a=0,o=0;if(i?.terrain){let s=new ve(t.z,n,t.z,t.x,t.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}let s=1<r}allowWorldCopies(){return!0}prepareNextFrame(){}},_s=class e{constructor(t,n,r){this.points=t,this.planes=n,this.aabb=r}static fromInvProjectionMatrix(t,n=1,r=0,i,a){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=a?[[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]],c=2**r,l=o.map(r=>ys(r,t,n,c));i&&xs(l,s[0],i,a);let u=s.map(t=>{let n=yt([],bt([],xt([],l[t[0]],l[t[1]]),xt([],l[t[2]],l[t[1]]))),r=-St(n,l[t[1]]);return n.concat(r)}),d=[1/0,1/0,1/0],f=[-1/0,-1/0,-1/0];for(let t of l)for(let n=0;n<3;n++)d[n]=Math.min(d[n],t[n]),f[n]=Math.max(f[n],t[n]);return new e(l,u,new gs(d,f))}};function ys(t,n,r,i){let a=qe([],t,n),o=1/a[3]/r*i;return Ct(a,a,[o,o,1/a[3],o])}function xs(t,n,r,i){let a=i?4:0,o=i?0:4,s=0,c=[],l=[];for(let n=0;n<4;n++){let r=xt([],t[n+o],t[n+a]),i=wt(r);gt(r,r,1/i),c.push(i),l.push(r)}for(let n=0;n<4;n++){let i=Tt(t[n+a],l[n],r);s=i!==null&&i>=0?Math.max(s,i):Math.max(s,c[n])}let u=Ss(t,n),d=Cs(r,u);if(d!==null){let t=d/St(l[0],u);s=Math.min(s,t)}for(let n=0;n<4;n++){let r=Math.min(s,c[n]);t[n+o]=[t[n+a][0]+l[n][0]*r,t[n+a][1]+l[n][1]*r,t[n+a][2]+l[n][2]*r,1]}}function Ss(t,n){let r=xt([],t[n[0]],t[n[1]]),i=xt([],t[n[2]],t[n[1]]),a=[0,0,0,0];return yt(a,bt([],r,i)),a[3]=-St(a,t[n[0]]),a}function Cs(t,n){let r=Et([],t,1/Dt(t)),i=xt([],n,gt([],r,St(n,r))),a=Dt(i);if(a>0){let t=Math.sqrt(1-r[3]*r[3]);return Ot(n,_t([],gt([],r,-r[3]),gt([],i,t/a)))}else return null}var ws=class e{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,n,r){this._helper.interpolatePadding(t,n,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,r=!0){this._helper.resize(t,n,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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,n){}constructor(t){this._posMatrixCache=/* @__PURE__ */ new Map,this._alignedPosMatrixCache=/* @__PURE__ */ new Map,this._fogMatrixCacheF32=/* @__PURE__ */ new Map,this.defaultConstrain=(t,n)=>{n=R(+n,this.minZoom,this.maxZoom);let r={center:new F(t.lng,t.lat),zoom:n},a=this._helper._lngRange;!this._helper._renderWorldCopies&&a===null&&(a=[-179.9999999999,179.9999999999]);let o=this.tileSize*Pe(r.zoom),s=0,c=o,l=0,u=o,d=0,f=0,{x:p,y:m}=this.size;if(this._helper._latRange){let t=this._helper._latRange;s=fe(t[1])*o,c=fe(t[0])*o,c-sc&&(v=c-t)}if(a){let t=(l+u)/2,n=h;this._helper._renderWorldCopies&&(n=de(h,t-o/2,t+o/2));let r=p/2;n-ru&&(_=u-r)}return(_!==void 0||v!==void 0)&&(r.center=Ca(o,new i(_??h,v??g)).wrap()),r},this.applyConstrain=(t,n)=>this._helper.applyConstrain(t,n),this._helper=new vs({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,n)=>this.defaultConstrain(t,n)},t),this._coveringTilesDetailsProvider=new bs}clone(){let t=new e;return t.apply(this,!1),t}apply(t,n,r){this._helper.apply(t,n,r)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){let n=[new kt(0,t)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new i(0,0)),a=this.screenPointToMercatorCoordinate(new i(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new i(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new i(0,this._helper._height)),c=Math.floor(Math.min(r.x,a.x,o.x,s.x)),l=Math.floor(Math.max(r.x,a.x,o.x,s.x));for(let r=c-1;r<=l+1;r++)r!==0&&n.push(new kt(r,t))}return n}getCameraFrustum(){return _s.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){let n=this.screenPointToLocation(this.centerPoint,t),r=t?t.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(r)}setLocationAtPoint(t,n){let r=Ie(this.elevation,this.center.lat),i=this.screenPointToMercatorCoordinateAtZ(n,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),o=L.fromLngLat(t),s=new L(o.x-(i.x-a.x),o.y-(i.y-a.y));this.setCenter(s?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,n){return n?this.coordinatePoint(L.fromLngLat(t),n.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(L.fromLngLat(t))}screenPointToLocation(t,n){return this.screenPointToMercatorCoordinate(t,n)?.toLngLat()}screenPointToMercatorCoordinate(t,n){if(n){let r=n.pointCoordinate(t);if(r!=null)return r}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,n){let r=n||0,i=[t.x,t.y,0,1],a=[t.x,t.y,1,1];qe(i,i,this._pixelMatrixInverse),qe(a,a,this._pixelMatrixInverse);let o=i[3],s=a[3],c=i[0]/o,l=a[0]/s,u=i[1]/o,d=a[1]/s,f=i[2]/o,p=a[2]/s,m=f===p?0:(r-f)/(p-f);return new L(pt.number(c,l,m)/this.worldSize,pt.number(u,d,m)/this.worldSize,r)}coordinatePoint(t,n=0,r=this._pixelMatrix){let a=[t.x*this.worldSize,t.y*this.worldSize,n,1];return qe(a,a,r),new i(a[0]/a[3],a[1]/a[3])}getBounds(){let t=Math.max(0,this._helper._height/2-wa(this));return new Ii().extend(this.screenPointToLocation(new i(0,t))).extend(this.screenPointToLocation(new i(this._helper._width,t))).extend(this.screenPointToLocation(new i(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new i(0,this._helper._height)))}isPointOnMapSurface(t,n){return n?n.pointCoordinate(t)!=null:t.y>this.height/2-wa(this)}calculatePosMatrix(t,n=!1,r=!1){let i=t.key??At(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(i)){let t=a.get(i);return r?t.f32:t.f64}let o=Ta(t,this.worldSize);le(o,n?this._alignedProjMatrix:this._viewProjMatrix,o);let s={f64:o,f32:new Float32Array(o)};return a.set(i,s),r?s.f32:s.f64}calculateFogMatrix(t){let n=t.key,r=this._fogMatrixCacheF32;if(r.has(n))return r.get(n);let i=Ta(t,this.worldSize);return le(i,this._fogMatrix,i),r.set(n,new Float32Array(i)),r.get(n)}calculateCenterFromCameraLngLatAlt(t,n,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,r,i)}_calculateNearFarZIfNeeded(t,n,r){if(!this._helper.autoCalculateNearFarZ)return;let i=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=t-i*this._helper._pixelPerMeter/Math.cos(n),o=i<0?a:t,s=Math.PI/2+this.pitchInRadians,c=Ne(this.fov)*(Math.abs(Math.cos(Ne(this.roll)))*this.height+Math.abs(Math.sin(Ne(this.roll)))*this.width)/this.height*(.5+r.y/this.height),l=Math.sin(c)*o/Math.sin(R(Math.PI-s-c,.01,Math.PI-.01)),u=wa(this),d=Math.atan(u/this._helper.cameraToCenterDistance),f=Ne(90-va),p=d>f?2*d*(.5+r.y/(u*2)):f,m=Math.sin(p)*o/Math.sin(R(Math.PI-s-p,.01,Math.PI-.01)),h=Math.min(l,m);this._helper._farZ=(Math.cos(Math.PI/2-n)*h+o)*1.01,this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let t=this.centerOffset,n=Sa(this.worldSize,this.center),r=n.x,i=n.y;this._helper._pixelPerMeter=Ie(1,this.center.lat)*this.worldSize;let a=Ne(Math.min(this.pitch,va)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a));this._calculateNearFarZIfNeeded(o,a,t);let s;s=new Float64Array(16),jt(s,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),Ya(this._invProjMatrix,s),s[8]=-t.x*2/this._helper._width,s[9]=t.y*2/this._helper._height,this._projectionMatrix=Mt(s),P(s,s,[1,-1,1]),N(s,s,[0,0,-this._helper.cameraToCenterDistance]),Nt(s,s,-this.rollInRadians),Pt(s,s,this.pitchInRadians),Nt(s,s,-this.bearingInRadians),N(s,s,[-r,-i,0]),this._mercatorMatrix=P([],s,[this.worldSize,this.worldSize,this.worldSize]),P(s,s,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=le(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),N(s,s,[0,0,-this.elevation]),this._viewProjMatrix=s,this._invViewProjMatrix=Ft([],s);let c=[0,0,-1,1];qe(c,c,this._invViewProjMatrix),this._cameraPosition=[c[0]/c[3],c[1]/c[3],c[2]/c[3]],this._fogMatrix=new Float64Array(16),jt(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=-t.x*2/this.width,this._fogMatrix[9]=t.y*2/this.height,P(this._fogMatrix,this._fogMatrix,[1,-1,1]),N(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),Nt(this._fogMatrix,this._fogMatrix,-this.rollInRadians),Pt(this._fogMatrix,this._fogMatrix,this.pitchInRadians),Nt(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),N(this._fogMatrix,this._fogMatrix,[-r,-i,0]),P(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),N(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=le(new Float64Array(16),this.clipSpaceToPixelsMatrix,s);let l=this._helper._width%2/2,u=this._helper._height%2/2,d=Math.cos(this.bearingInRadians),f=Math.sin(-this.bearingInRadians),p=r-Math.round(r)+d*l+f*u,m=i-Math.round(i)+d*u+f*l,h=new Float64Array(s);if(N(h,h,[p>.5?p-1:p,m>.5?m-1:m,0]),this._alignedProjMatrix=h,s=Ft(new Float64Array(16),this._pixelMatrix),!s)throw Error(`failed to invert matrix`);this._pixelMatrixInverse=s,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new i(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return qe(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let t=Ie(1,this.center.lat)*this.worldSize,n=this._helper.cameraToCenterDistance/t;return Ea(this.center,this.elevation,this.pitch,this.bearing,n).toLngLat()}lngLatToCameraDepth(t,n){let r=L.fromLngLat(t),i=[r.x*this.worldSize,r.y*this.worldSize,n,1];return qe(i,i,this._viewProjMatrix),i[2]/i[3]}getProjectionData(t){let{overscaledTileID:n,aligned:r,applyTerrainMatrix:i}=t,a=this._helper.getMercatorTileCoordinates(n),o=n?this.calculatePosMatrix(n,r,!0):null,s;return s=n?.terrainRttPosMatrix32f&&i?n.terrainRttPosMatrix32f:o||It(),{mainMatrix:s,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,n,r){return 1}transformLightDirection(t){return vt(t)}getRayDirectionFromPixel(t){throw Error(`Not implemented.`)}projectTileCoordinates(t,n,r,a){let o=this.calculatePosMatrix(r),s;a?(s=[t,n,a(t,n),1],qe(s,s,o)):(s=[t,n,0,1],bo(s,s,o));let c=s[3];return{point:new i(s[0]/c,s[1]/c),signedDistanceFromCamera:c,isOccluded:!1}}populateCache(t){for(let n of t)this.calculatePosMatrix(n)}getProjectionDataForCustomLayer(t=!0){let n=new ve(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:t}),i=Ta(n,this.worldSize);le(i,this._viewProjMatrix,i);let a=[I,I,this.worldSize/this._helper.pixelsPerMeter],o=Lt();return P(o,i,a),{...r,tileMercatorCoords:[0,0,1,1],fallbackMatrix:o,mainMatrix:o}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function Ts(){b(`Map cannot fit within canvas with the given bounds, padding, and/or offset.`)}function Es(t){if(t.useSlerp)if(t.k<1){let n=Rt(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),r=Rt(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),i=new Float64Array(4);zt(i,n,r,t.k);let a=Bt(i);t.tr.setRoll(a.roll),t.tr.setPitch(a.pitch),t.tr.setBearing(a.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(pt.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(pt.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(pt.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function Ds(t,n,r,a,o){let s=o.padding,c=Sa(o.worldSize,r.getNorthWest()),l=Sa(o.worldSize,r.getNorthEast()),u=Sa(o.worldSize,r.getSouthEast()),d=Sa(o.worldSize,r.getSouthWest()),f=Ne(-a),p=c.rotate(f),m=l.rotate(f),h=u.rotate(f),g=d.rotate(f),_=new i(Math.max(p.x,m.x,g.x,h.x),Math.max(p.y,m.y,g.y,h.y)),v=new i(Math.min(p.x,m.x,g.x,h.x),Math.min(p.y,m.y,g.y,h.y)),y=_.sub(v),b=o.width-(s.left+s.right+n.left+n.right),x=o.height-(s.top+s.bottom+n.top+n.bottom),S=b/y.x,C=x/y.y;if(C<0||S<0){Ts();return}let w=Math.min(Le(o.scale*Math.min(S,C)),t.maxZoom),T=i.convert(t.offset),E=new i((n.left-n.right)/2,(n.top-n.bottom)/2).rotate(Ne(a)),D=T.add(E).mult(o.scale/Pe(w));return{center:Ca(o.worldSize,c.add(u).div(2).sub(D)),zoom:w,bearing:a}}var As=class{get useGlobeControls(){return!1}handlePanInertia(t,n){let r=t.mag(),i=Math.abs(wa(n));return{easingOffset:t.mult(Math.min(i*.75/r,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(t,n){t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta),t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta)}handleMapControlsPan(t,n,r){t.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(r,t.around)}cameraForBoxAndBearing(t,n,r,i,a){return Ds(t,n,r,i,a)}handleJumpToCenterZoom(t,n){let r=n.zoom===void 0?t.zoom:+n.zoom;t.zoom!==r&&t.setZoom(+n.zoom),n.center!==void 0&&t.setCenter(F.convert(n.center))}handleEaseTo(t,n){let r=t.zoom,i=t.padding,a={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},s=n.zoom!==void 0,c=!t.isPaddingEqual(n.padding),l=!1,u=s?+n.zoom:t.zoom,d=t.centerPoint.add(n.offsetAsPoint),f=t.screenPointToLocation(d),{center:p,zoom:m}=t.applyConstrain(F.convert(n.center||f),u??r);ps(t,p);let h=Sa(t.worldSize,f),g=Sa(t.worldSize,p).sub(h),_=Pe(m-r);return l=m!==r,{easeFunc:s=>{if(l&&t.setZoom(pt.number(r,m,s)),Vt(a,o)||Es({startEulerAngles:a,endEulerAngles:o,tr:t,k:s,useSlerp:a.roll!=o.roll}),c&&(t.interpolatePadding(i,n.padding,s),d=t.centerPoint.add(n.offsetAsPoint)),n.around)t.setLocationAtPoint(n.around,n.aroundPoint);else{let n=Pe(t.zoom-r),i=(m>r?Math.min(2,_):Math.max(.5,_))**(1-s),a=Ca(t.worldSize,h.add(g.mult(s*i)).mult(n));t.setLocationAtPoint(t.renderWorldCopies?a.wrap():a,d)}},isZooming:l,elevationCenter:p}}handleFlyTo(t,n){let r=n.zoom!==void 0,i=t.zoom,a=t.applyConstrain(F.convert(n.center||n.locationAtOffset),r?+n.zoom:i),o=a.center,s=a.zoom;ps(t,o);let c=t.worldSize,l=Sa(c,n.locationAtOffset),u=Sa(c,o).sub(l),d=u.mag(),f=Pe(s-i),p=n.minZoom===void 0?t.minZoom:+n.minZoom,m=Math.max(p,t.minZoom),h=Math.min(m,i,s),g=t.applyConstrain(o,h).zoom;return{easeFunc:(n,r,a,d)=>{t.setZoom(n===1?s:i+Le(r));let f=n===1?o:Ca(c,l.add(u.mult(a)));t.setLocationAtPoint(t.renderWorldCopies?f.wrap():f,d)},scaleOfZoom:f,targetCenter:o,scaleOfMinZoom:Pe(g-i),pixelPathLength:d}}};let Os;const ks=()=>Os||=new A({type:new j(D.projection.type,`type`)});var Y=class{constructor(t,n,r){this.blendFunction=t,this.blendColor=n,this.mask=r}};Y.Replace=[1,0],Y.disabled=new Y(Y.Replace,z.transparent,[!1,!1,!1,!1]),Y.unblended=new Y(Y.Replace,z.transparent,[!0,!0,!0,!0]),Y.alphaBlended=new Y([1,771],z.transparent,[!0,!0,!0,!0]);const js=1029,Ms=2305;var X=class{constructor(t,n,r){this.enable=t,this.mode=n,this.frontFace=r}};X.disabled=new X(!1,js,Ms),X.backCCW=new X(!0,js,Ms),X.frontCCW=new X(!0,1028,Ms);var Z=class{constructor(t,n,r){this.func=t,this.mask=n,this.range=r}};Z.ReadOnly=!1,Z.ReadWrite=!0,Z.disabled=new Z(519,Z.ReadOnly,[0,1]);const Ns=7680;var Q=class{constructor(t,n,r,i,a,o){this.test=t,this.ref=n,this.mask=r,this.fail=i,this.depthFail=a,this.pass=o}};Q.disabled=new Q({func:519,mask:0},0,0,Ns,Ns,Ns);const Ps=(t,n)=>({u_input:new B(t,n.u_input),u_output_expected:new B(t,n.u_output_expected)}),Fs=(t,n)=>({u_input:t,u_output_expected:n});var Is=class e{get awaitingQuery(){return!!this._readbackQueue}constructor(t){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=t;let n=t.context,r=n.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;let i=new ut;i.emplaceBack(-1,-1),i.emplaceBack(2,-1),i.emplaceBack(-1,2);let a=new ft;a.emplaceBack(0,1,2),this._fullscreenTriangle=new us(n.createVertexBuffer(i,cs.members),n.createIndexBuffer(a),dt.simpleSegment(0,0,i.length,a.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(r.TEXTURE1);let 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.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA8,this._texWidth,this._texHeight),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null)}destroy(){let t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,n){let r=this._updateCount;return this._readbackQueue?r>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():r>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,n),this._updateCount++,this._measuredError}_bindFramebuffer(){let t=this._cachedRenderContext.context,n=t.gl;t.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,n){let r=this._cachedRenderContext.context,i=r.gl;this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:z.transparent}),this._cachedRenderContext.useProgram(`projectionErrorMeasurement`).draw(r,i.TRIANGLES,Z.disabled,Q.disabled,Y.unblended,X.disabled,Fs(t,n),null,null,`$clipping`,this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),i.bindBuffer(i.PIXEL_PACK_BUFFER,this._pbo),i.readBuffer(i.COLOR_ATTACHMENT0),i.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),i.bindBuffer(i.PIXEL_PACK_BUFFER,null);let a=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);i.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:a}}_tryReadback(){let t=this._cachedRenderContext.context.gl;if(!this._readbackQueue)return;let n=t.clientWaitSync(this._readbackQueue.sync,0,0);if(n===t.WAIT_FAILED){b(`WebGL2 clientWaitSync failed.`),this._readbackQueue=null,this._lastReadbackFrame=this._updateCount;return}n!==t.TIMEOUT_EXPIRED&&(t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this._readbackQueue=null,this._measuredError=e._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount)}static _parseRGBA8float(t){let n=0;return n+=t[0]/256,n+=t[1]/65536,n+=t[2]/16777216,t[3]<127&&(n=-n),n/128}};const Ls=I/128;function Rs(t,n){let r=zs(n,`16bit`),i=ut.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),a=ft.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new us(t.createVertexBuffer(i,cs.members),t.createIndexBuffer(a),dt.simpleSegment(0,0,i.length,a.length))}function zs(t,n){let r=t.granularity===void 0?1:Math.max(t.granularity,1),i=r+(t.generateBorders?2:0),a=r+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),o=i+1,s=a+1,c=t.generateBorders?-1:0,l=t.generateBorders||t.extendToNorthPole?-1:0,u=r+ +!!t.generateBorders,d=r+(t.generateBorders||t.extendToSouthPole?1:0),f=o*s,p=i*a*6,m=o*s>65536;if(m&&n===`16bit`)throw Error(`Granularity is too large and meshes would not fit inside 16 bit vertex indices.`);let h=m||n===`32bit`,g=new Int16Array(f*2),_=0;for(let n=l;n<=d;n++)for(let i=c;i<=u;i++){let a=i/r*I;i===-1&&(a=-Ls),i===r+1&&(a=I+Ls);let o=n/r*I;n===-1&&(o=t.extendToNorthPole?Ht:-Ls),n===r+1&&(o=t.extendToSouthPole?Ut:I+Ls),g[_++]=a,g[_++]=o}let v=h?new Uint32Array(p):new Uint16Array(p),y=0;for(let t=0;t0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return`globe`}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,n,r,i,a){return this.currentProjection.getMeshFromTileID(t,n,r,i,a)}setProjection(t){this._transitionable.setValue(`type`,t?.type||`mercator`)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}};function Hs(t){let n=Xs(t.worldSize,t.center.lat);return 2*Math.PI*n}function Us(t,n,r){let i=St(Ys(n),Ys(r)),a=Math.acos(i),o=Hs(t);return a/(2*Math.PI)*o}function Ks(t,n){return[Jt(t*Math.PI*2+Math.PI,Math.PI*2),2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-Math.PI*.5]}function qs(t,n){let r=Math.cos(n),i=new Float64Array(3);return i[0]=Math.sin(t)*r,i[1]=Math.sin(n),i[2]=Math.cos(t)*r,i}function Js(t,n,r,i,a){let o=1/(1<1e-6){let i=t[0]/r,a=t[2]/r,o=Math.acos(a);return new F(de((i>0?o:-o)/Math.PI*180,-180,180),n)}else return new F(0,n)}function Qs(t){let n=Yt();return n[0]=t[0]*-t[3],n[1]=t[1]*-t[3],n[2]=t[2]*-t[3],{center:n,radius:Math.sqrt(1-t[3]*t[3])}}function $s(t,n,r){let i=Yt();xt(i,r,t);let a=Yt();return Xt(a,t,i,n/Dt(i)),a}function ec(t){return Math.cos(t*Math.PI/180)}function tc(t,n){let r=ec(t);return Le(ec(n)/r)}function nc(t,n){return 360/Hs({worldSize:t,center:{lat:n}})}function rc(t,n){let r=t.rotate(n.bearingInRadians),i=n.zoom+tc(n.center.lat,0),a=Gt(1/ec(n.center.lat),1/ec(Math.min(Math.abs(n.center.lat),60)),Zt(i,7,3,0,1)),o=nc(n.worldSize,n.center.lat);return new F(n.center.lng-r.x*o*a,R(n.center.lat+r.y*o,-Me,Me))}function ic(t){let n=.5*t,r=Math.sin(n),i=Math.cos(n);return Math.log(r+i)-Math.log(i-r)}function ac(t,n,r,i){let a=t.lat+r*i;if(Math.abs(r)>1){let o=t.lat+r,s=(Math.sign(o)===Math.sign(t.lat)?Math.abs(t.lat):-Math.abs(t.lat))*Math.PI/180,c=Math.abs(t.lat+r)*Math.PI/180,l=ic(s+i*(c-s)),u=ic(s),d=ic(c),f=(l-u)/(d-u);return new F(t.lng+n*f,a)}else return new F(t.lng+n*i,a)}var cc=class{constructor(t){this._cachePrevious=/* @__PURE__ */ new Map,this._cache=/* @__PURE__ */ new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;let t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,n,r,i){let a=`${t.z}_${t.x}_${t.y}_${i?.terrain?`t`:``}`,o=this._cache.get(a);if(o)return o;let s=this._cachePrevious.get(a);if(s)return this._cache.set(a,s),s;let c=this._boundingVolumeFactory(t,n,r,i);return this._cache.set(a,c),this._hadAnyChanges=!0,c}},oc=class e{constructor(t,n,r,i){this.min=r,this.max=i,this.points=t,this.planes=n}static fromAabb(t,n){let r=[];for(let i=0;i<8;i++)r.push([(i>>0&1)==1?n[0]:t[0],(i>>1&1)==1?n[1]:t[1],(i>>2&1)==1?n[2]:t[2]]);return new e(r,[[-1,0,0,n[0]],[1,0,0,-t[0]],[0,-1,0,n[1]],[0,1,0,-t[1]],[0,0,-1,n[2]],[0,0,1,-t[2]]],t,n)}static fromCenterSizeAngles(t,n,r){let i=Qt([],r[0],r[1],r[2]),a=$t([],[n[0],0,0],i),o=$t([],[0,n[1],0],i),s=$t([],[0,0,n[2]],i),c=[...t],l=[...t];for(let n=0;n<8;n++)for(let r=0;r<3;r++){let i=t[r]+a[r]*((n>>0&1)==1?1:-1)+o[r]*((n>>1&1)==1?1:-1)+s[r]*((n>>2&1)==1?1:-1);c[r]=Math.min(c[r],i),l[r]=Math.max(l[r],i)}let u=[];for(let n=0;n<8;n++){let r=[...t];_t(r,r,gt([],a,(n>>0&1)==1?1:-1)),_t(r,r,gt([],o,(n>>1&1)==1?1:-1)),_t(r,r,gt([],s,(n>>2&1)==1?1:-1)),u.push(r)}return new e(u,[[...a,-St(a,u[0])],[...o,-St(o,u[0])],[...s,-St(s,u[0])],[-a[0],-a[1],-a[2],-St(a,u[7])],[-o[0],-o[1],-o[2],-St(o,u[7])],[-s[0],-s[1],-s[2],-St(s,u[7])]],c,l)}intersectsFrustum(t){let n=!0,r=this.points.length,i=this.planes.length,a=t.planes.length,o=t.points.length;for(let i=0;i=0&&o++}if(o===0)return 0;o=0&&i++}if(i===0)return 0}return 1}intersectsPlane(t){let n=this.points.length,r=0;for(let i=0;i=0&&r++}return r===n?2:r===0?0:1}};function sc(t,n,r){let i=t-n;return i<0?-i:Math.max(0,i-r)}function lc(t,n,r,i,a){let o=t-r,s;return s=o<0?Math.min(-o,1+o-a):o>a?Math.min(Math.max(o-a,0),1-o):0,Math.max(s,sc(n,i,a))}var fc=class{constructor(){this._boundingVolumeCache=new cc(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,n,r,i){let a=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(t,n,r,i){return this._boundingVolumeCache.getTileBoundingVolume(t,n,r,i)}_computeTileBoundingVolume(t,n,r,i){let a=0,o=0;if(i?.terrain){let s=new ve(t.z,n,t.z,t.x,t.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}if(a/=en,o/=en,a+=1,o+=1,t.z<=0)return oc.fromAabb([-o,-o,-o],[o,o,o]);if(t.z===1)return oc.fromAabb([t.x===0?-o:0,t.y===0?0:-o,-o],[t.x===0?0:o,t.y===0?o:0,o]);{let n=[Js(0,0,t.x,t.y,t.z),Js(I,0,t.x,t.y,t.z),Js(I,I,t.x,t.y,t.z),Js(0,I,t.x,t.y,t.z)],r=[];for(let t of n)r.push(gt([],t,o));if(o!==a)for(let t of n)r.push(gt([],t,a));t.y===0&&r.push([0,1,0]),t.y===(1<=(1<{let r=R(t.lat,-Me,Me),i=R(+n,this.minZoom+tc(0,r),this.maxZoom);return{center:new F(t.lng,r),zoom:i}},this.applyConstrain=(t,n)=>this._helper.applyConstrain(t,n),this._helper=new vs({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,n)=>this.defaultConstrain(t,n)},t),this._coveringTilesDetailsProvider=new fc}clone(){let t=new e;return t.apply(this,!1),t}apply(t,n,r){this._globeLatitudeErrorCorrectionRadians=r||0,this._helper.apply(t,n)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=Yt();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:n,applyGlobeMatrix:r}=t,i=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:i,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!r,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){let n=this.pitchInRadians,r=this.cameraToCenterDistance/t,i=Math.sin(n)*r,a=Math.cos(n)*r+1,o=1/Math.sqrt(i*i+a*a)*1,s=-i,c=a,l=Math.sqrt(s*s+c*c);s/=l,c/=l;let u=[0,s,c];an(u,u,[0,0,0],-this.bearingInRadians),on(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),sn(u,u,[0,0,0],this.center.lng*Math.PI/180);let d=1/wt(u);return gt(u,u,d),[...u,-o*d]}isLocationOccluded(t){return!this.isSurfacePointVisible(Ys(t))}transformLightDirection(t){let n=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,i=Math.cos(r),a=[Math.sin(n)*i,Math.sin(r),Math.cos(n)*i],o=[a[2],0,-a[0]],s=[0,0,0];bt(s,o,a),yt(o,o),yt(s,s);let c=[o[0]*t[0]+s[0]*t[1]+a[0]*t[2],o[1]*t[0]+s[1]*t[1]+a[1]*t[2],o[2]*t[0]+s[2]*t[1]+a[2]*t[2]],l=[0,0,0];return yt(l,c),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,n,r){let i=ba(t,n,r.canonical),a=Ks(i.x,i.y);return this.getCircleRadiusCorrection()/Math.cos(a[1])}projectTileCoordinates(t,n,r,a){let o=r.canonical,s=Js(t,n,o.x,o.y,o.z),c=1+(a?a(t,n):0)/en,l=[s[0]*c,s[1]*c,s[2]*c,1];qe(l,l,this._globeViewProjMatrixNoCorrection);let u=this._cachedClippingPlane,d=u[0]*s[0]+u[1]*s[1]+u[2]*s[2]+u[3]<0;return{point:new i(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:d}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;let t=Xs(this.worldSize,this.center.lat),n=Lt(),r=Lt();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+t*2),jt(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;n[8]=-i.x*2/this._helper._width,n[9]=i.y*2/this._helper._height,this._projectionMatrix=Mt(n),this._globeProjMatrixInverted=Lt(),Ft(this._globeProjMatrixInverted,n),N(n,n,[0,0,-this.cameraToCenterDistance]),Nt(n,n,this.rollInRadians),Pt(n,n,-this.pitchInRadians),Nt(n,n,this.bearingInRadians),N(n,n,[0,0,-t]);let a=Yt();a[0]=t,a[1]=t,a[2]=t,Pt(r,n,this.center.lat*Math.PI/180),cn(r,r,-this.center.lng*Math.PI/180),P(r,r,a),this._globeViewProjMatrixNoCorrection=r,Pt(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),cn(n,n,-this.center.lng*Math.PI/180),P(n,n,a),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=Lt(),Ft(this._globeViewProjMatrixNoCorrectionInverted,r);let o=Yt();this._cameraPosition=Yt(),this._cameraPosition[2]=this.cameraToCenterDistance/t,an(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),on(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),an(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),_t(this._cameraPosition,this._cameraPosition,[0,0,1]),on(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),sn(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);let s=Mt(this._globeViewProjMatrixNoCorrectionInverted);P(s,s,[1,1,-1]),this._cachedFrustum=_s.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){b(`calculateFogMatrix is not supported on globe projection.`);let n=Lt();return Fe(n),n}getVisibleUnwrappedCoordinates(t){return[new kt(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){if(t){b(`terrain is not fully supported on vertical perspective projection.`);return}this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){if(!this._globeViewProjMatrixNoCorrection)return 1;let r=Ys(t);gt(r,r,1+n/en);let i=nn();return qe(i,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),i[2]/i[3]}populateCache(t){}getBounds(){let t=this.width*.5,n=this.height*.5,r=[new i(0,0),new i(t,0),new i(this.width,0),new i(this.width,n),new i(this.width,this.height),new i(t,this.height),new i(0,this.height),new i(0,n)],a=[];for(let t of r)a.push(this.unprojectScreenPoint(t));let o=0,s=0,c=0,l=0,u=this.center;for(let t of a){let n=ln(u.lng,t.lng),r=ln(u.lat,t.lat);no&&(o=n),rc&&(c=r)}let d=[u.lng+s,u.lat+l,u.lng+o,u.lat+c];return this.isSurfacePointOnScreen([0,1,0])&&(d[3]=90,d[0]=-180,d[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(d[1]=-90,d[0]=-180,d[2]=180),new Ii(d)}calculateCenterFromCameraLngLatAlt(t,n,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,r,i)}setLocationAtPoint(t,n){let r=Ys(this.unprojectScreenPoint(n)),i=Ys(t),a=Yt();un(a);let o=Yt();sn(o,r,a,-this.center.lng*Math.PI/180),on(o,o,a,this.center.lat*Math.PI/180);let s=i[0]*i[0]+i[2]*i[2],c=o[0]*o[0];if(s=-_&&m<=_,y=g>=-_&&g<=_,b,x;if(v&&y){let t=this.center.lng*Math.PI/180,n=this.center.lat*Math.PI/180,r=fn(d,t),i=fn(m,n),a=fn(f,t),o=fn(g,n);r+i=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let n=nn();return qe(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(t,n){let r=St(t,n),i=Yt(),a=Yt();gt(a,n,r),xt(i,t,a);let o=1-St(i,i);if(o<0)return null;let s=St(t,t)-1,c=-r+(r<0?1:-1)*Math.sqrt(o),l=s/c,u=c;return{tMin:Math.min(l,u),tMax:Math.max(l,u)}}unprojectScreenPoint(t){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(t),i=this.rayPlanetIntersection(n,r);if(i){let t=Yt();_t(t,n,[r[0]*i.tMin,r[1]*i.tMin,r[2]*i.tMin]);let a=Yt();return yt(a,t),Zs(a)}let a=this._cachedClippingPlane,o=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],s=-Ot(a,n)/o,c=Yt();if(s>0)_t(c,n,[r[0]*s,r[1]*s,r[2]*s]);else{let t=Yt();_t(t,n,[r[0]*2,r[1]*2,r[2]*2]);let i=Ot(this._cachedClippingPlane,t);xt(c,t,[this._cachedClippingPlane[0]*i,this._cachedClippingPlane[1]*i,this._cachedClippingPlane[2]*i])}let l=Qs(a);return Zs($s(l.center,l.radius,c))}getProjectionDataForCustomLayer(t=!0){let n=this.getProjectionData({overscaledTileID:new ve(0,0,0,0,0),applyGlobeMatrix:t});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(t){}},pc=class e{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,n,r){this._helper.interpolatePadding(t,n,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,r=!0){this._helper.resize(t,n,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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,n){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(t,n)=>this.currentTransform.defaultConstrain(t,n),this.applyConstrain=(t,n)=>this._helper.applyConstrain(t,n),this._helper=new vs({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,n)=>this.defaultConstrain(t,n)},t),this._globeness=1,this._mercatorTransform=new ws,this._verticalPerspectiveTransform=new dc}clone(){let t=new e;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this,!1),t}apply(t,n){this._helper.apply(t,n),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}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 n=this._mercatorTransform.getProjectionData(t),r=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?r.mainMatrix:n.mainMatrix,clippingPlane:r.clippingPlane,tileMercatorCoords:r.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return Gt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return Gt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,n,r){return Gt(this._mercatorTransform.getPitchedTextCorrection(t,n,r),this._verticalPerspectiveTransform.getPitchedTextCorrection(t,n,r),this._globeness)}projectTileCoordinates(t,n,r,i){return this.currentTransform.projectTileCoordinates(t,n,r,i)}_calcMatrices(){!this._helper._width||!this._helper._height||(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}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._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){return this.currentTransform.lngLatToCameraDepth(t,n)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,n,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,r,i)}setLocationAtPoint(t,n){if(!this.isGlobeRendering){this._mercatorTransform.setLocationAtPoint(t,n),this.apply(this._mercatorTransform,!1);return}this._verticalPerspectiveTransform.setLocationAtPoint(t,n),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,n){return this.currentTransform.locationToScreenPoint(t,n)}screenPointToMercatorCoordinate(t,n){return this.currentTransform.screenPointToMercatorCoordinate(t,n)}screenPointToLocation(t,n){return this.currentTransform.screenPointToLocation(t,n)}isPointOnMapSurface(t,n){return this.currentTransform.isPointOnMapSurface(t,n)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let n=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return n;let r=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return r.fallbackMatrix=n.mainMatrix,r}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},mc=class e{get useGlobeControls(){return!0}handlePanInertia(t,n){let r=rc(t,n);return Math.abs(r.lng-n.center.lng)>180&&(r.lng=n.center.lng+179.5*Math.sign(r.lng-n.center.lng)),{easingCenter:r,easingOffset:new i(0,0)}}handleMapControlsRollPitchBearingZoom(t,n){let r=t.around,i=n.screenPointToLocation(r);t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta);let a=n.zoom;t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta);let o=n.zoom-a;if(o===0)return;let s=ln(n.center.lng,i.lng),c=s/(Math.abs(s/180)+1),l=ln(n.center.lat,i.lat),u=n.getRayDirectionFromPixel(r),d=n.cameraPosition,f=St(d,u)*-1,p=Yt();_t(p,d,[u[0]*f,u[1]*f,u[2]*f]);let m=wt(p)-1,h=Math.exp(-Math.max(m-.3,0)*.5),g=Xs(n.worldSize,n.center.lat)/Math.min(n.width,n.height),_=Zt(g,.9,.5,1,.25),v=(1-Pe(-o))*Math.min(h,_),y=n.center.lat,b=n.zoom,x=new F(n.center.lng+c*v,R(n.center.lat+l*v,-Me,Me));n.setLocationAtPoint(i,r);let S=n.center,C=Zt(Math.abs(s),45,85,0,1),w=Zt(g,.75,.35,0,1),T=Math.max(C,w)**.25,E=ln(S.lng,x.lng),D=ln(S.lat,x.lat);n.setCenter(new F(S.lng+E*T,S.lat+D*T).wrap()),n.setZoom(b+tc(y,n.center.lat))}handleMapControlsPan(t,n,r){if(!t.panDelta)return;let i=n.center.lat,a=n.zoom;n.setCenter(rc(t.panDelta,n).wrap()),n.setZoom(a+tc(i,n.center.lat))}cameraForBoxAndBearing(t,n,r,i,a){let o=Ds(t,n,r,i,a),s=n.left/a.width*2-1,c=(a.width-n.right)/a.width*2-1,l=n.top/a.height*-2+1,u=(a.height-n.bottom)/a.height*-2+1,d=ln(r.getWest(),r.getEast())<0,f=d?r.getEast():r.getWest(),p=d?r.getWest():r.getEast(),m=Math.max(r.getNorth(),r.getSouth()),h=Math.min(r.getNorth(),r.getSouth()),g=f+ln(f,p)*.5,_=m+ln(m,h)*.5,v=a.clone();v.setCenter(o.center),v.setBearing(o.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(o.zoom);let y=v.modelViewProjectionMatrix,b=[Ys(r.getNorthWest()),Ys(r.getNorthEast()),Ys(r.getSouthWest()),Ys(r.getSouthEast()),Ys(new F(p,_)),Ys(new F(f,_)),Ys(new F(g,m)),Ys(new F(g,h))],x=Ys(o.center),S=1/0;for(let t of b)s<0&&(S=e.getLesserNonNegativeNonNull(S,e.solveVectorScale(t,x,y,`x`,s))),c>0&&(S=e.getLesserNonNegativeNonNull(S,e.solveVectorScale(t,x,y,`x`,c))),l>0&&(S=e.getLesserNonNegativeNonNull(S,e.solveVectorScale(t,x,y,`y`,l))),u<0&&(S=e.getLesserNonNegativeNonNull(S,e.solveVectorScale(t,x,y,`y`,u)));if(!Number.isFinite(S)||S===0){Ts();return}return o.zoom=Math.min(v.zoom+Le(S),t.maxZoom),o}handleJumpToCenterZoom(t,n){let r=t.center.lat,i=t.applyConstrain(n.center?F.convert(n.center):t.center,t.zoom).center;t.setCenter(i.wrap());let a=n.zoom===void 0?t.zoom+tc(r,i.lat):+n.zoom;t.zoom!==a&&t.setZoom(a)}handleEaseTo(t,n){let r=t.zoom,a=t.center,o=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},c={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},l=n.zoom!==void 0,u=!t.isPaddingEqual(n.padding),d=!1,f=n.center?F.convert(n.center):a,p=t.applyConstrain(f,r).center;ps(t,p);let m=t.clone();m.setCenter(p),m.setZoom(l?+n.zoom:r+tc(a.lat,f.lat)),m.setBearing(n.bearing);let h=new i(R(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),R(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));m.setLocationAtPoint(p,h);let g=(n.offset&&n.offsetAsPoint.mag())>0?m.center:p,_=l?+n.zoom:r+tc(a.lat,g.lat),v=r+tc(a.lat,0),y=_+tc(g.lat,0),x=ln(a.lng,g.lng),S=ln(a.lat,g.lat),C=Pe(y-v);return d=_!==r,{easeFunc:r=>{if(Vt(s,c)||Es({startEulerAngles:s,endEulerAngles:c,tr:t,k:r,useSlerp:s.roll!=c.roll}),u&&t.interpolatePadding(o,n.padding,r),n.around)b(`Easing around a point is not supported under globe projection.`),t.setLocationAtPoint(n.around,n.aroundPoint);else{let n=ac(a,x,S,r*(y>v?Math.min(2,C):Math.max(.5,C))**(1-r));t.setCenter(n.wrap())}if(d){let n=pt.number(v,y,r)+tc(0,t.center.lat);t.setZoom(n)}},isZooming:d,elevationCenter:g}}handleFlyTo(t,n){let r=n.zoom!==void 0,a=t.center,o=t.zoom,s=t.padding,c=!t.isPaddingEqual(n.padding),l=t.applyConstrain(F.convert(n.center||n.locationAtOffset),o).center,u=r?+n.zoom:t.zoom+tc(t.center.lat,l.lat),d=t.clone();d.setCenter(l),d.setZoom(u),d.setBearing(n.bearing);let f=new i(R(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),R(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));d.setLocationAtPoint(l,f);let p=d.center;ps(t,p);let m=Us(t,a,p),h=o+tc(a.lat,0),g=u+tc(p.lat,0),_=Pe(g-h),v=typeof n.minZoom==`number`?+n.minZoom:t.minZoom,y=Math.max(v,t.minZoom)+tc(p.lat,0),b=Math.min(y,h,g)+tc(0,p.lat),x=Pe(t.applyConstrain(p,b).zoom+tc(p.lat,0)-h),S=ln(a.lng,p.lng),C=ln(a.lat,p.lat);return{easeFunc:(r,i,o,l)=>{let d=ac(a,S,C,o);c&&t.interpolatePadding(s,n.padding,r);let f=r===1?p:d;t.setCenter(f.wrap());let m=h+Le(i);t.setZoom(r===1?u:m+tc(0,f.lat))},scaleOfZoom:_,targetCenter:p,scaleOfMinZoom:x,pixelPathLength:m}}static solveVectorScale(t,n,r,i,a){let o=a,s=i===`x`?[r[0],r[4],r[8],r[12]]:[r[1],r[5],r[9],r[13]],c=[r[3],r[7],r[11],r[15]],l=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],u=t[0]*c[0]+t[1]*c[1]+t[2]*c[2],d=n[0]*s[0]+n[1]*s[1]+n[2]*s[2],f=n[0]*c[0]+n[1]*c[1]+n[2]*c[2],p=(d+s[3]-o*f-o*c[3])/(d-l-o*f+o*u);return d+o*u===l+o*f||c[3]*(l-d)+s[3]*(f-u)+l*f===d*u?null:p}static getLesserNonNegativeNonNull(t,n){return n!==null&&n>=0&&n{for(let t in this.tileManagers){let n=this.tileManagers[t].getSource().type;(n===`vector`||n===`geojson`)&&this.tileManagers[t].reload()}},this.map=t,this.dispatcher=new wi(yi(),t._getMapId()),this.dispatcher.registerMessageHandler(`GG`,(t,n)=>this.getGlyphs(t,n)),this.dispatcher.registerMessageHandler(`GI`,(t,n)=>this.getImages(t,n)),this.dispatcher.registerMessageHandler(`GDA`,(t,n)=>this.getDashes(t,n)),this.imageManager=new Yr,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(t._missingStyleImageResolver);let r=t._container?.lang||typeof document<`u`&&document.documentElement?.lang||void 0;this.glyphManager=new ti(t._requestManager,n.localIdeographFontFamily,r),this.lineAtlas=new ui(256,512),this.crossTileSymbolIndex=new $o,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast(`SR`,mn()),ha().on(pa,this._rtlPluginLoaded),this.on(`data`,t=>{if(t.dataType!==`source`||t.sourceDataType!==`metadata`)return;let n=this.tileManagers[t.sourceId];if(!n)return;let r=n.getSource();if(r?.vectorLayerIds)for(let t in this._layers){let n=this._layers[t];n.source===r.id&&this._validateLayer(n)}})}_setInitialValues(){this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new hn,this._availableImages=[],this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,n){this._checkLoaded();let r=n===null?this.stylesheet.state?.[t]?.default??null:n;if(gn(r,this._globalState[t]))return this;this._globalState[t]=r,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();let n=[];for(let r in t)gn(this._globalState[r],t[r].default)||(n.push(r),this._globalState[r]=t[r].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(t){if(t.length===0)return;let n=/* @__PURE__ */ new Set,r={};for(let i of t){r[i]=this._globalState[i];for(let t in this._layers){let r=this._layers[t],a=r.getLayoutAffectingGlobalStateRefs(),o=r.getPaintAffectingGlobalStateRefs(),s=r.getVisibilityAffectingGlobalStateRefs();if(a.has(i)&&n.add(r.source),o.has(i))for(let{name:t,value:n}of o.get(i))this._updatePaintProperty(r,t,n);s?.has(i)&&(r.recalculateVisibility(),this._updateLayer(r))}}this.dispatcher.broadcast(`UGS`,r);for(let t in this.tileManagers)n.has(t)&&(this._reloadSource(t),this._changed=!0)}async loadURL(t,n={},r){this.fire(new Ir(`dataloading`)),n.validate=typeof n.validate!=`boolean`||n.validate,this._loadStyleRequest=new AbortController;let i=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(t,`Style`);_n(i.signal);let o=await g(a,i);this._loadStyleRequest===i&&(this._loadStyleRequest=null),this._load(o.data,n,r)}catch(t){this._loadStyleRequest===i&&(this._loadStyleRequest=null),t&&!i.signal.aborted&&this.fire(new y(f(t)))}}loadJSON(t,n={},r){this.fire(new Ir(`dataloading`)),this._frameRequest=new AbortController,Tr.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,r)}).catch(()=>{})}loadEmpty(){this.fire(new Ir(`dataloading`)),this._load(gc,{validate:!1})}_load(t,n,r){let i=n.transformStyle?n.transformStyle(r,t):t;if(!(n.validate&&vn(this,i))){i={...i},this._loaded=!0,this.stylesheet=i;for(let t in i.sources)this.addSource(t,i.sources[t],{validate:!1});i.sprite?this._loadSprite(i.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(i.glyphs),this._createLayers(),this.light=new oi(this.stylesheet.light),this._setProjectionInternal(this.stylesheet.projection?.type||`mercator`),this.sky=new li(this.stylesheet.sky),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new Ir(`data`)),this.fire(new Fr)}}_createLayers(){let t=yn(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast(`SL`,t),this._order=t.map(t=>t.id),this._layers={},this._serializedLayers=null;for(let n of t){let t=bn(n,this._globalState);if(t.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=t,xn(t)&&this.tileManagers[t.source]){let r=n.paint?.[`raster-fade-duration`]??t.paint.get(`raster-fade-duration`);this.tileManagers[t.source].setRasterFadeDuration(r)}}}_loadSprite(t,n=!1,r=void 0){this.imageManager.setLoaded(!1);let i=new AbortController;this._spriteRequest=i;let a;Gr(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(t=>{if(this._spriteRequest=null,t)for(let r in t){this._spritesImagesIds[r]=[];let i=this._spritesImagesIds[r]?this._spritesImagesIds[r].filter(n=>!(n in t)):[];for(let t of i)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(let i in t[r]){let a=r===`default`?i:`${r}:${i}`;this._spritesImagesIds[r].push(a),a in this.imageManager.images?this.imageManager.updateImage(a,t[r][i],!1):this.imageManager.addImage(a,t[r][i]),n&&(this._changedImages[a]=!0)}}}).catch(t=>{this._spriteRequest=null,a=t,i.signal.aborted||this.fire(new y(a))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new Ir(`data`)),r&&r(a)})}_unloadSprite(){for(let t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._imagesListDirty=!0,this._changed=!0,this.fire(new Ir(`data`))}_validateLayer(t){let n=this.tileManagers[t.source];if(!n)return;let r=t.sourceLayer;if(!r)return;let i=n.getSource();(i.type===`geojson`||i.vectorLayerIds&&!i.vectorLayerIds.includes(r))&&this.fire(new y(Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(t,n=!1){let r=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n?Sn(r):r);let i=[];for(let a of t)if(r[a]){let t=n?Sn(r[a]):r[a];i.push(t)}return i}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};let n=Object.keys(this._layers);for(let r of n){let n=this._layers[r];n.type!==`custom`&&(t[r]=n.serialize())}return t}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let t in this.tileManagers)if(this.tileManagers[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error(`Style is not done loading.`)}update(t){if(!this._loaded)return;let n=this._changed;if(n){this._imagesListDirty&&=(this.dispatcher.broadcast(`SI`,this._availableImages),!1);let n=Object.keys(this._updatedLayers),r=Object.keys(this._removedLayers);(n.length||r.length)&&this._updateWorkerLayers(n,r);for(let t in this._updatedSources){let n=this._updatedSources[t];if(n===`reload`)this._reloadSource(t);else if(n===`clear`)this._clearSource(t);else throw Error(`Invalid action ${n}`)}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let n in this._updatedPaintProps)this._layers[n].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}let r={};for(let t in this.tileManagers){let n=this.tileManagers[t];r[t]=n.used,n.used=!1}for(let n of this._order){let r=this._layers[n];r.recalculate(t,this._availableImages),!r.isHidden(t.zoom)&&r.source&&(this.tileManagers[r.source].used=!0)}for(let t in r){let n=this.tileManagers[t];!!r[t]!=!!n.used&&n.fire(new K(`data`,{sourceDataType:`visibility`,sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,n&&this.fire(new Ir(`data`))}_updateTilesForChangedImages(){let t=Object.keys(this._changedImages);if(t.length){for(let n in this.tileManagers)this.tileManagers[n].reloadTilesForDependencies([`icons`,`patterns`],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies([`glyphs`],[``]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast(`UL`,{layers:this._serializeByIds(t,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){this._checkLoaded();let r=this.serialize();if(t=n.transformStyle?n.transformStyle(r,t):t,(n.validate??!0)&&vn(this,t))return!1;t=Sn(t),t.layers=yn(t.layers);let i=Cn(r,t),a=this._getOperationsToPerform(i);if(a.unimplemented.length>0)throw Error(`Unimplemented: ${a.unimplemented.join(`, `)}.`);if(a.operations.length===0)return!1;for(let t of a.operations)t();return this.stylesheet=t,this._serializedLayers=null,this.fire(new Fr({style:this})),!0}_getOperationsToPerform(t){let n=[],r=[];for(let i of t)switch(i.command){case`setCenter`:case`setZoom`:case`setBearing`:case`setPitch`:case`setRoll`:continue;case`addLayer`:n.push(()=>this.addLayer.apply(this,i.args));break;case`removeLayer`:n.push(()=>this.removeLayer.apply(this,i.args));break;case`setPaintProperty`:n.push(()=>this.setPaintProperty.apply(this,i.args));break;case`setLayoutProperty`:n.push(()=>this.setLayoutProperty.apply(this,i.args));break;case`setFilter`:n.push(()=>this.setFilter.apply(this,i.args));break;case`addSource`:n.push(()=>this.addSource.apply(this,i.args));break;case`removeSource`:n.push(()=>this.removeSource.apply(this,i.args));break;case`setLayerZoomRange`:n.push(()=>this.setLayerZoomRange.apply(this,i.args));break;case`setLight`:n.push(()=>this.setLight.apply(this,i.args));break;case`setGeoJSONSourceData`:n.push(()=>this.setGeoJSONSourceData.apply(this,i.args));break;case`setGlyphs`:n.push(()=>this.setGlyphs.apply(this,i.args));break;case`setSprite`:n.push(()=>this.setSprite.apply(this,i.args));break;case`setTerrain`:n.push(()=>this.map.setTerrain.apply(this,i.args));break;case`setSky`:n.push(()=>this.setSky.apply(this,i.args));break;case`setProjection`:this.setProjection.apply(this,i.args);break;case`setGlobalState`:n.push(()=>this.setGlobalState.apply(this,i.args));break;case`setTransition`:n.push(()=>{});break;default:r.push(i.command);break}return{operations:n,unimplemented:r}}addImage(t,n){if(this.getImage(t)){this.fire(new y(Error(`An image named "${t}" already exists.`)));return}this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}setMissingImageResolver(t){this.imageManager.setMissingImageResolver(t)}removeImage(t){if(!this.getImage(t)){this.fire(new y(Error(`An image named "${t}" does not exist.`)));return}this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new Ir(`data`))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,r={}){if(this._checkLoaded(),this.tileManagers[t]!==void 0)throw Error(`Source "${t}" already exists.`);if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(`, `)}.`);if(wn.has(n.type)&&this._validate(M.source,`sources.${t}`,n,null,r))return;this.map?._collectResourceTiming&&(n.collectResourceTiming=!0);let i=this.tileManagers[t]=new Wa(t,n,this.dispatcher);i.style=this,i.setEventedParent(this,()=>({isSourceLoaded:i.loaded(),source:i.serialize(),sourceId:t})),i.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw Error(`There is no source with this ID=${t}`);for(let n in this._layers)if(this._layers[n].source===t)return this.fire(new y(Error(`Source "${t}" cannot be removed while layer "${n}" is using it.`)));let n=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],n.fire(new K(`data`,{sourceDataType:`metadata`,sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw Error(`There is no source with this ID=${t}`);let r=this.tileManagers[t].getSource();if(r.type!==`geojson`)throw Error(`geojsonSource.type is ${r.type}, which is !== 'geojson`);r.setData(n),this._changed=!0}getSource(t){return this.tileManagers[t]?.getSource()}addLayer(t,n,r={}){this._checkLoaded();let i=t.id;if(this.getLayer(i)){this.fire(new y(Error(`Layer "${i}" already exists on this map.`)));return}let o;if(t.type===`custom`){if(Tn(this,En(t)))return;o=bn(t,this._globalState)}else{if(`source`in t&&typeof t.source==`object`&&(this.addSource(i,t.source),t=Sn(t),t=a(t,{source:i})),this._validate(M.layer,`layers.${i}`,t,{arrayIndex:-1},r))return;o=bn(t,this._globalState),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}})}let s=n?this._order.indexOf(n):this._order.length;if(n&&s===-1){this.fire(new y(Error(`Cannot add layer "${i}" before non-existing layer "${n}".`)));return}if(this._order.splice(s,0,i),this._layerOrderChanged=!0,this._layers[i]=o,this._removedLayers[i]&&o.source&&o.type!==`custom`){let t=this._removedLayers[i];delete this._removedLayers[i],t.type===o.type?(this._updatedSources[o.source]=`reload`,this.tileManagers[o.source].pause()):this._updatedSources[o.source]=`clear`}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t]){this.fire(new y(Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));return}if(t===n)return;let r=this._order.indexOf(t);this._order.splice(r,1);let i=n?this._order.indexOf(n):this._order.length;if(n&&i===-1){this.fire(new y(Error(`Cannot move layer "${t}" before non-existing layer "${n}".`)));return}this._order.splice(i,0,t),this._layerOrderChanged=!0}removeLayer(t){this._checkLoaded();let n=this._layers[t];if(!n){this.fire(new y(Error(`Cannot remove non-existing layer "${t}".`)));return}n.setEventedParent(null);let r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,r){this._checkLoaded();let i=this.getLayer(t);if(!i){this.fire(new y(Error(`Cannot set the zoom range of non-existing layer "${t}".`)));return}(i.minzoom!==n||i.maxzoom!==r)&&(n!=null&&(i.minzoom=n),r!=null&&(i.maxzoom=r),this._updateLayer(i))}setFilter(t,n,r={}){this._checkLoaded();let i=this.getLayer(t);if(!i){this.fire(new y(Error(`Cannot filter non-existing layer "${t}".`)));return}if(!gn(i.filter,n)){if(n==null){i.setFilter(void 0),this._updateLayer(i);return}this._validate(M.filter,`layers.${i.id}.filter`,n,null,r)||(i.setFilter(Sn(n)),this._updateLayer(i))}}getFilter(t){return Sn(this.getLayer(t).filter)}setLayoutProperty(t,n,r,i={}){this._checkLoaded();let a=this.getLayer(t);if(!a){this.fire(new y(Error(`Cannot style non-existing layer "${t}".`)));return}gn(a.getLayoutProperty(n),r)||(a.setLayoutProperty(n,r,i),this._updateLayer(a))}getLayoutProperty(t,n){let r=this.getLayer(t);if(!r){this.fire(new y(Error(`Cannot get style of non-existing layer "${t}".`)));return}return r.getLayoutProperty(n)}setPaintProperty(t,n,r,i={}){this._checkLoaded();let a=this.getLayer(t);if(!a){this.fire(new y(Error(`Cannot style non-existing layer "${t}".`)));return}gn(a.getPaintProperty(n),r)||this._updatePaintProperty(a,n,r,i)}_updatePaintProperty(t,n,r,i={}){t.setPaintProperty(n,r,i)&&this._updateLayer(t),xn(t)&&n===`raster-fade-duration`&&this.tileManagers[t.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();let r=t.source,i=t.sourceLayer,a=this.tileManagers[r];if(a===void 0){this.fire(new y(Error(`The source '${r}' does not exist in the map's style.`)));return}let o=a.getSource().type;if(o===`geojson`&&i){this.fire(new y(Error(`GeoJSON sources cannot have a sourceLayer parameter.`)));return}if(o===`vector`&&!i){this.fire(new y(Error(`The sourceLayer parameter must be provided for vector source types.`)));return}if(t.id===void 0){this.fire(new y(Error(`The feature id parameter must be provided.`)));return}let s=[`__proto__`,`constructor`,`prototype`];if(n&&Object.keys(n).some(t=>s.includes(t))){this.fire(new y(Error(`The feature state should not include one of the following keys: ${s}`)));return}a.setFeatureState(i,t.id,n)}removeFeatureState(t,n){this._checkLoaded();let r=t.source,i=this.tileManagers[r];if(i===void 0){this.fire(new y(Error(`The source '${r}' does not exist in the map's style.`)));return}let a=i.getSource().type,o=a===`vector`?t.sourceLayer:void 0;if(a===`vector`&&!o){this.fire(new y(Error(`The sourceLayer parameter must be provided for vector source types.`)));return}if(n&&typeof t.id!=`string`&&typeof t.id!=`number`){this.fire(new y(Error(`A feature id is required to remove its specific state property.`)));return}i.removeFeatureState(o,t.id,n)}getFeatureState(t){this._checkLoaded();let n=t.source,r=t.sourceLayer,i=this.tileManagers[n];if(i===void 0){this.fire(new y(Error(`The source '${n}' does not exist in the map's style.`)));return}if(i.getSource().type===`vector`&&!r){this.fire(new y(Error(`The sourceLayer parameter must be provided for vector source types.`)));return}return t.id===void 0&&this.fire(new y(Error(`The feature id parameter must be provided.`))),i.getFeatureState(r,t.id)}getTransition(){return a({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let t=Dn(this.tileManagers,t=>t.serialize()),n=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return On({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,transition:i.transition,projection:i.projection,sources:t,layers:n,terrain:r},t=>t!==void 0)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.tileManagers[t.source].getSource().type!==`raster`&&(this._updatedSources[t.source]=`reload`,this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){let n=t=>this._layers[t].type===`fill-extrusion`,r={},i=[];for(let a=this._order.length-1;a>=0;a--){let o=this._order[a];if(n(o)){r[o]=a;for(let n of t){let t=n[o];if(t)for(let n of t)i.push(n)}}}i.sort((t,n)=>n.intersectionZ-t.intersectionZ);let a=[];for(let o=this._order.length-1;o>=0;o--){let s=this._order[o];if(n(s))for(let t=i.length-1;t>=0;t--){let n=i[t].feature;if(r[n.layer.id]this.map.terrain.getElevation(t,n,r):void 0));return this.placement&&a.push(Oi(this._layers,o,this.tileManagers,t,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(t,n){n?.filter&&this._validate(M.filter,`querySourceFeatures.filter`,n.filter,null,n);let r=this.tileManagers[t];return r?ki(r,n?{...n,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let n in t)if(!gn(t[n],r[n])){i=!0;break}if(!i)return;let o={now:U(),transition:a({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(o)}getProjection(){return this.stylesheet?.projection}setProjection(t){this._checkLoaded();let n=t??{type:`mercator`};if(this.stylesheet.projection=t,this.projection){if(this.projection.name===n.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(n.type)}getSky(){return this.stylesheet?.sky}setSky(t,n={}){this._checkLoaded();let r=this.getSky(),i=!1;if(!t&&!r)return;if(t&&!r)i=!0;else if(!t&&r)i=!0;else for(let n in t)if(!gn(t[n],r[n])){i=!0;break}if(!i)return;let o={now:U(),transition:a({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,n),this.sky.updateTransitions(o)}_setProjectionInternal(t){let n=hc(t,this.map._camera?.transform.constrainOverride);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(let t in this.tileManagers)this.tileManagers[t].reload()}_validate(t,n,r,i,a={}){return re(this,t,{key:n,style:this.serialize(),value:r,...i},a)}_remove(t=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),ha().off(pa,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let n=this.tileManagers[t];n.setEventedParent(null),n.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast(`RM`,void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(let n in this.tileManagers)this.tileManagers[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(let t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,n,r,i,a=!1){let o=!1,s=!1,c={};for(let n of this._order){let r=this._layers[n];if(r.type!==`symbol`)continue;if(!c[r.source]){let t=this.tileManagers[r.source];c[r.source]=t.getRenderableIds(!0).map(n=>t.getTileByID(n)).sort((t,n)=>n.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(n.tileID)?-1:1))}let i=this.crossTileSymbolIndex.addLayer(r,c[r.source],t.center.lng);o||=i}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||=this._layerOrderChanged||r===0,(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(U(),t.zoom))&&(this.pauseablePlacement=new Vo(t,this.map.terrain,this._order,a,n,r,i,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(U()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(let t of this._order){let n=this._layers[t];n.type===`symbol`&&this.placement.updateLayerOpacities(n,c[n.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(U())}_releaseSymbolFadeTiles(){for(let t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}async getImages(t,n){let r=await this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let i=this.tileManagers[n.source];return i&&i.setDependencies(n.tileID.key,n.type,n.icons),r}async getGlyphs(t,n){let r=await this.glyphManager.getGlyphs(n.stacks),i=this.tileManagers[n.source];return i&&i.setDependencies(n.tileID.key,n.type,[``]),r}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),!(t&&this._validate(M.glyphs,`glyphs`,t,null,n))&&(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}async getDashes(t,n){let r={};for(let[t,i]of Object.entries(n.dashes))r[t]=this.lineAtlas.getDash(i.dasharray,i.round);return r}addSprite(t,n,r={},i){this._checkLoaded();let a=[{id:t,url:n}],o=[...jr(this.stylesheet.sprite),...a];this._validate(M.sprite,`sprite`,o,null,r)||(this.stylesheet.sprite=o,this._loadSprite(a,!0,i))}removeSprite(t){this._checkLoaded();let n=jr(this.stylesheet.sprite);if(!n.find(n=>n.id===t)){this.fire(new y(Error(`Sprite "${t}" doesn't exists on this map.`)));return}if(this._spritesImagesIds[t])for(let n of this._spritesImagesIds[t])this.imageManager.removeImage(n),this._changedImages[n]=!0;n.splice(n.findIndex(n=>n.id===t),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._imagesListDirty=!0,this._changed=!0,this.fire(new Ir(`data`))}getSprite(){return jr(this.stylesheet.sprite)}setSprite(t,n={},r){this._checkLoaded(),!(t&&this._validate(M.sprite,`sprite`,t,null,n))&&(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let t in this.tileManagers){let n=this.tileManagers[t];n.setEventedParent(null),n.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(let t in this._layers){let n=this._layers[t];n.setEventedParent(null),n.onRemove&&n.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 vc=ct([{name:`a_pos`,type:`Int16`,components:2},{name:`a_texture_pos`,type:`Int16`,components:2}]);var Sc=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,r,i,a,o,s,c,l){this.context=t;let u=this.boundPaintVertexBuffers.length!==i.length;for(let t=0;!u&&t({u_depth:new V(t,n.u_depth),u_terrain:new V(t,n.u_terrain),u_terrain_dim:new B(t,n.u_terrain_dim),u_terrain_matrix:new An(t,n.u_terrain_matrix),u_terrain_unpack:new kn(t,n.u_terrain_unpack),u_terrain_exaggeration:new B(t,n.u_terrain_exaggeration)}),xc=(t,n)=>({u_texture:new V(t,n.u_texture),u_ele_delta:new B(t,n.u_ele_delta),u_fog_matrix:new An(t,n.u_fog_matrix),u_fog_color:new jn(t,n.u_fog_color),u_fog_ground_blend:new B(t,n.u_fog_ground_blend),u_fog_ground_blend_opacity:new B(t,n.u_fog_ground_blend_opacity),u_horizon_color:new jn(t,n.u_horizon_color),u_horizon_fog_blend:new B(t,n.u_horizon_fog_blend),u_is_globe_mode:new B(t,n.u_is_globe_mode)}),Cc=(t,n)=>({u_ele_delta:new B(t,n.u_ele_delta)}),wc=(t,n)=>({u_texture:new V(t,n.u_texture),u_terrain_coords_id:new B(t,n.u_terrain_coords_id),u_ele_delta:new B(t,n.u_ele_delta)}),Tc=(t,n,r,i,a)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:n,u_fog_color:r?r.properties.get(`fog-color`):z.white,u_fog_ground_blend:r?r.properties.get(`fog-ground-blend`):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get(`horizon-color`):z.white,u_horizon_fog_blend:r?r.properties.get(`horizon-fog-blend`):1,u_is_globe_mode:+!!a}),Ec=t=>({u_ele_delta:t}),Dc=(t,n)=>({u_terrain_coords_id:t/255,u_texture:0,u_ele_delta:n}),Oc=(t,n)=>({u_projection_matrix:new An(t,n.u_projection_matrix),u_projection_tile_mercator_coords:new kn(t,n.u_projection_tile_mercator_coords),u_projection_clipping_plane:new kn(t,n.u_projection_clipping_plane),u_projection_transition:new B(t,n.u_projection_transition),u_projection_fallback_matrix:new An(t,n.u_projection_fallback_matrix)}),kc={mainMatrix:`u_projection_matrix`,tileMercatorCoords:`u_projection_tile_mercator_coords`,clippingPlane:`u_projection_clipping_plane`,projectionTransition:`u_projection_transition`,fallbackMatrix:`u_projection_fallback_matrix`};function Ac(t){let n=[];for(let r of t){if(r===null)continue;let t=r.split(` `);n.push(t.pop())}return n}var Nc=class{constructor(t,n,r,i,a,o,s,c,l=[]){let u=t.gl;this.program=u.createProgram();let d=Ac(n.staticAttributes),f=r?r.getBinderAttributes():[],p=d.concat(f),m=ss.prelude.staticUniforms?Ac(ss.prelude.staticUniforms):[],h=s.staticUniforms?Ac(s.staticUniforms):[],g=n.staticUniforms?Ac(n.staticUniforms):[],_=r?r.getBinderUniforms():[],v=m.concat(h).concat(g).concat(_),y=[];for(let t of v)y.includes(t)||y.push(t);let b=r?r.defines():[];b.unshift(`#version 300 es`),a&&b.push(`#define OVERDRAW_INSPECTOR;`),o&&b.push(`#define TERRAIN3D;`),c&&b.push(c),l&&b.push(...l);let x=b.concat(ss.prelude.fragmentSource,s.fragmentSource,n.fragmentSource).join(` +`}),{fragmentSource:t,vertexSource:n,staticAttributes:i,staticUniforms:s}}var us=class{constructor(t,n,r){this.vertexBuffer=t,this.indexBuffer=n,this.segments=r}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const cs=lt([{name:`a_pos`,type:`Int16`,components:2}]),ls=`#define PROJECTION_MERCATOR`,ds=`mercator`;var ms=class{constructor(){this._cachedMesh=null}get name(){return`mercator`}get useSubdivision(){return!1}get shaderVariantName(){return ds}get shaderDefine(){return ls}get shaderPreludeCode(){return ss.projectionMercator}get vertexShaderPreludeCode(){return ss.projectionMercator.vertexSource}get subdivisionGranularity(){return ut.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(t,n,r,i,a){if(this._cachedMesh)return this._cachedMesh;let o=new dt;o.emplaceBack(0,0),o.emplaceBack(F,0),o.emplaceBack(0,F),o.emplaceBack(F,F);let s=t.createVertexBuffer(o,cs.members),c=ft.simpleSegment(0,0,4,2),l=new pt;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=t.createIndexBuffer(l);return this._cachedMesh=new us(s,u,c),this._cachedMesh}recalculate(){}hasTransition(){return!1}},fs=class e{constructor(t=0,n=0,r=0,i=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0||isNaN(i)||i<0)throw Error(`Invalid value for edge-insets, top, bottom, left and right must all be numbers`);this.top=t,this.bottom=n,this.left=r,this.right=i}interpolate(t,n,r){return n.top!=null&&t.top!=null&&(this.top=mt.number(t.top,n.top,r)),n.bottom!=null&&t.bottom!=null&&(this.bottom=mt.number(t.bottom,n.bottom,r)),n.left!=null&&t.left!=null&&(this.left=mt.number(t.left,n.left,r)),n.right!=null&&t.right!=null&&(this.right=mt.number(t.right,n.right,r)),this}getCenter(t,n){return new i(L((this.left+t-this.right)/2,0,t),L((this.top+n-this.bottom)/2,0,n))}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new e(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function ps(t,n){if(!t.renderWorldCopies||t.lngRange)return;let r=n.lng-t.center.lng;n.lng+=r>180?-360:r<-180?360:0}function hs(t){return Math.max(0,Math.floor(t))}var vs=class{constructor(t,n){this.applyConstrain=(t,n)=>this._constrainOverride===null?this._callbacks.defaultConstrain(t,n):this._constrainOverride(t,n),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=n?.renderWorldCopies===void 0||!!n?.renderWorldCopies,this._minZoom=n?.minZoom||0,this._maxZoom=n?.maxZoom||22,this._minPitch=n?.minPitch===void 0||n?.minPitch===null?0:n?.minPitch,this._maxPitch=n?.maxPitch===void 0||n?.maxPitch===null?60:n?.maxPitch,this._constrainOverride=n?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new P(0,0),this._elevation=0,this._zoom=0,this._tileZoom=hs(this._zoom),this._scale=Fe(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new fs,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,n,r){this._constrainOverride=t.constrainOverride,this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=hs(this._zoom),this._scale=Fe(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new fs(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!r&&t.autoCalculateNearFarZ,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){t===void 0&&(t=null),this._constrainOverride!==t&&(this._constrainOverride=t,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 i(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){let n=fe(t,-180,180)*Math.PI/180;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=vr(),br(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(t){let n=L(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){let n=t/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return ht(this._fovInRadians)}setFov(t){t=L(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=Pe(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){let n=this.applyConstrain(this._center,t).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=Fe(n),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(t){(t.lat!==this._center.lat||t.lng!==this._center.lng)&&(this._unmodified=!1,this._center=t,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,n){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,r){this._unmodified=!1,this._edgeInsets.interpolate(t,n,r),this.constrainInternal(),this._calcMatrices()}resize(t,n,r=!0){this._width=t,this._height=n,r&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange?.length!==2||this._lngRange?.length!==2?null:new Fi([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-Ne,Ne])}getCameraQueryGeometry(t,n){if(n.length===1)return[n[0],t];{let{minX:r,minY:a,maxX:o,maxY:s}=Se.fromPoints(n).extend(t);return[new i(r,a),new i(o,a),new i(o,s),new i(r,s),new i(r,a)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let t=this._unmodified,{center:n,zoom:r}=this.applyConstrain(this.center,this.zoom);this.setCenter(n),this.setZoom(r),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=Ie(new Float64Array(16));le(t,t,[this._width/2,-this._height/2,1]),N(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=Ie(new Float64Array(16)),le(t,t,[1,-1,1]),N(t,t,[-1,-1,0]),le(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t;let n=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(n)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,n,r,i){let a=r===void 0?this.bearing:r,o=i=i===void 0?this.pitch:i,{distanceToCenter:s,clampedElevation:c}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,o),{x:l,y:u}=Ea(o,a),d=I.fromLngLat(t,n),f=gt(1,d.y),p,m,h=0;do{if(h+=1,h>10)break;m=s/f;let t=l*m,n=u*m;p=new I(d.x+t,d.y+n),f=1/p.meterInMercatorCoordinateUnits()}while(Math.abs(s-m*f)>1e-12);return{center:p.toLngLat(),elevation:c,zoom:Re(this.height/2/Math.tan(this.fovInRadians/2)/m/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t===0)return;let n=1/this.worldSize,r=Le(1,this.center.lat)*this.worldSize,i=I.fromLngLat(this.center,this.elevation),a=i.x/n,o=i.y/n,s=i.z/n,c=this.pitch,l=this.bearing,{x:u,y:d,z:f}=Ea(c,l),p=this.cameraToCenterDistance,m=a+p*-u,h=o+p*-d,g=s+p*f,{distanceToCenter:_,clampedElevation:v}=this._distanceToCenterFromAltElevationPitch(g/r,t,c),y=_*r,b=m+u*y,x=h+d*y,S=new I(b*n,x*n,0).toLngLat(),C=Le(1,S.lat),w=Re(this.height/2/Math.tan(this.fovInRadians/2)/_/C/this.tileSize);this._elevation=v,this._center=S,this.setZoom(w)}_distanceToCenterFromAltElevationPitch(t,n,r){let i=-Math.cos(Pe(r)),a=t-n,o,s=n;return i*a>=0||Math.abs(i)<.1?(o=1e4,s=t+o*i):o=-a/i,{distanceToCenter:o,clampedElevation:s}}getCameraPoint(){let t=this.pitchInRadians,n=Math.tan(t)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i(n*Math.sin(this.rollInRadians),n*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let t=Le(1,this.center.lat)*this.worldSize,n=this.cameraToCenterDistance/t;return Ta(this.center,this.elevation,this.pitch,this.bearing,n).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];let n=t.canonical.z>=0?1<this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]0?(n+=t[i]*this.min[i],r+=t[i]*this.max[i]):(r+=t[i]*this.min[i],n+=t[i]*this.max[i]);return n>=0?2:r<0?0:1}},bs=class{distanceToTile2d(t,n,r,i){let a=i,o=a.distanceX([t,n]),s=a.distanceY([t,n]);return Math.hypot(o,s)}getWrap(t,n,r){return r}getTileBoundingVolume(t,n,r,i){let a=Math.min(0,r),o=Math.max(0,r);if(i?.terrain){let r=new ye(t.z,n,t.z,t.x,t.y),s=i.terrain.getMinMaxElevation(r);a=s.minElevation??a,o=s.maxElevation??o}let s=1<r}allowWorldCopies(){return!0}prepareNextFrame(){}},_s=class e{constructor(t,n,r){this.points=t,this.planes=n,this.aabb=r}static fromInvProjectionMatrix(t,n=1,r=0,i,a){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=a?[[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]],c=2**r,l=o.map(r=>ys(r,t,n,c));i&&xs(l,s[0],i,a);let u=s.map(t=>{let n=bt([],xt([],St([],l[t[0]],l[t[1]]),St([],l[t[2]],l[t[1]]))),r=-Ct(n,l[t[1]]);return n.concat(r)}),d=[1/0,1/0,1/0],f=[-1/0,-1/0,-1/0];for(let t of l)for(let n=0;n<3;n++)d[n]=Math.min(d[n],t[n]),f[n]=Math.max(f[n],t[n]);return new e(l,u,new gs(d,f))}};function ys(t,n,r,i){let a=Je([],t,n),o=1/a[3]/r*i;return wt(a,a,[o,o,1/a[3],o])}function xs(t,n,r,i){let a=i?4:0,o=i?0:4,s=0,c=[],l=[];for(let n=0;n<4;n++){let r=St([],t[n+o],t[n+a]),i=Tt(r);_t(r,r,1/i),c.push(i),l.push(r)}for(let n=0;n<4;n++){let i=Et(t[n+a],l[n],r);s=i!==null&&i>=0?Math.max(s,i):Math.max(s,c[n])}let u=Ss(t,n),d=Cs(r,u);if(d!==null){let t=d/Ct(l[0],u);s=Math.min(s,t)}for(let n=0;n<4;n++){let r=Math.min(s,c[n]);t[n+o]=[t[n+a][0]+l[n][0]*r,t[n+a][1]+l[n][1]*r,t[n+a][2]+l[n][2]*r,1]}}function Ss(t,n){let r=St([],t[n[0]],t[n[1]]),i=St([],t[n[2]],t[n[1]]),a=[0,0,0,0];return bt(a,xt([],r,i)),a[3]=-Ct(a,t[n[0]]),a}function Cs(t,n){let r=Dt([],t,1/Ot(t)),i=St([],n,_t([],r,Ct(n,r))),a=Ot(i);if(a>0){let t=Math.sqrt(1-r[3]*r[3]);return kt(n,vt([],_t([],r,-r[3]),_t([],i,t/a)))}else return null}var ws=class e{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,n,r){this._helper.interpolatePadding(t,n,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,r=!0){this._helper.resize(t,n,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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){this._posMatrixCache=/* @__PURE__ */ new Map,this._alignedPosMatrixCache=/* @__PURE__ */ new Map,this._fogMatrixCacheF32=/* @__PURE__ */ new Map,this.defaultConstrain=(t,n)=>{n=L(+n,this.minZoom,this.maxZoom);let r={center:new P(t.lng,t.lat),zoom:n},a=this._helper._lngRange;!this._helper._renderWorldCopies&&a===null&&(a=[-179.9999999999,179.9999999999]);let o=this.tileSize*Fe(r.zoom),s=0,c=o,l=0,u=o,d=0,f=0,{x:p,y:m}=this.size;if(this._helper._latRange){let t=this._helper._latRange;s=pe(t[1])*o,c=pe(t[0])*o,c-sc&&(v=c-t)}if(a){let t=(l+u)/2,n=h;this._helper._renderWorldCopies&&(n=fe(h,t-o/2,t+o/2));let r=p/2;n-ru&&(_=u-r)}return(_!==void 0||v!==void 0)&&(r.center=Sa(o,new i(_??h,v??g)).wrap()),r},this.applyConstrain=(t,n)=>this._helper.applyConstrain(t,n),this._helper=new vs({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,n)=>this.defaultConstrain(t,n)},t),this._coveringTilesDetailsProvider=new bs}clone(){let t=new e;return t.apply(this,!1),t}apply(t,n,r){this._helper.apply(t,n,r)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){let n=[new At(0,t)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new i(0,0)),a=this.screenPointToMercatorCoordinate(new i(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new i(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new i(0,this._helper._height)),c=Math.floor(Math.min(r.x,a.x,o.x,s.x)),l=Math.floor(Math.max(r.x,a.x,o.x,s.x));for(let r=c-1;r<=l+1;r++)r!==0&&n.push(new At(r,t))}return n}getCameraFrustum(){return _s.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){let n=this.screenPointToLocation(this.centerPoint,t),r=t?t.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(r)}setLocationAtPoint(t,n){let r=Le(this.elevation,this.center.lat),i=this.screenPointToMercatorCoordinateAtZ(n,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),o=I.fromLngLat(t),s=new I(o.x-(i.x-a.x),o.y-(i.y-a.y));this.setCenter(s?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,n){return n?this.coordinatePoint(I.fromLngLat(t),n.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(I.fromLngLat(t))}screenPointToLocation(t,n){return this.screenPointToMercatorCoordinate(t,n)?.toLngLat()}screenPointToMercatorCoordinate(t,n){if(n){let r=n.pointCoordinate(t);if(r!=null)return r}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,n){let r=n||0,i=[t.x,t.y,0,1],a=[t.x,t.y,1,1];Je(i,i,this._pixelMatrixInverse),Je(a,a,this._pixelMatrixInverse);let o=i[3],s=a[3],c=i[0]/o,l=a[0]/s,u=i[1]/o,d=a[1]/s,f=i[2]/o,p=a[2]/s,m=f===p?0:(r-f)/(p-f);return new I(mt.number(c,l,m)/this.worldSize,mt.number(u,d,m)/this.worldSize,r)}coordinatePoint(t,n=0,r=this._pixelMatrix){let a=[t.x*this.worldSize,t.y*this.worldSize,n,1];return Je(a,a,r),new i(a[0]/a[3],a[1]/a[3])}getBounds(){let t=Math.max(0,this._helper._height/2-Ca(this));return new Fi().extend(this.screenPointToLocation(new i(0,t))).extend(this.screenPointToLocation(new i(this._helper._width,t))).extend(this.screenPointToLocation(new i(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new i(0,this._helper._height)))}isPointOnMapSurface(t,n){return n?n.pointCoordinate(t)!=null:t.y>this.height/2-Ca(this)}calculatePosMatrix(t,n=!1,r=!1){let i=t.key??jt(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(i)){let t=a.get(i);return r?t.f32:t.f64}let o=wa(t,this.worldSize);ue(o,n?this._alignedProjMatrix:this._viewProjMatrix,o);let s={f64:o,f32:new Float32Array(o)};return a.set(i,s),r?s.f32:s.f64}calculateFogMatrix(t){let n=t.key,r=this._fogMatrixCacheF32;if(r.has(n))return r.get(n);let i=wa(t,this.worldSize);return ue(i,this._fogMatrix,i),r.set(n,new Float32Array(i)),r.get(n)}calculateCenterFromCameraLngLatAlt(t,n,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,r,i)}_calculateNearFarZIfNeeded(t,n,r){if(!this._helper.autoCalculateNearFarZ)return;let i=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=t-i*this._helper._pixelPerMeter/Math.cos(n),o=i<0?a:t,s=Math.PI/2+this.pitchInRadians,c=Pe(this.fov)*(Math.abs(Math.cos(Pe(this.roll)))*this.height+Math.abs(Math.sin(Pe(this.roll)))*this.width)/this.height*(.5+r.y/this.height),l=Math.sin(c)*o/Math.sin(L(Math.PI-s-c,.01,Math.PI-.01)),u=Ca(this),d=Math.atan(u/this._helper.cameraToCenterDistance),f=Pe(90-_a),p=d>f?2*d*(.5+r.y/(u*2)):f,m=Math.sin(p)*o/Math.sin(L(Math.PI-s-p,.01,Math.PI-.01)),h=Math.min(l,m);this._helper._farZ=(Math.cos(Math.PI/2-n)*h+o)*1.01,this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let t=this.centerOffset,n=xa(this.worldSize,this.center),r=n.x,i=n.y;this._helper._pixelPerMeter=Le(1,this.center.lat)*this.worldSize;let a=Pe(Math.min(this.pitch,_a)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a));this._calculateNearFarZIfNeeded(o,a,t);let s;s=new Float64Array(16),Mt(s,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),Ya(this._invProjMatrix,s),s[8]=-t.x*2/this._helper._width,s[9]=t.y*2/this._helper._height,this._projectionMatrix=Nt(s),le(s,s,[1,-1,1]),N(s,s,[0,0,-this._helper.cameraToCenterDistance]),Pt(s,s,-this.rollInRadians),Ft(s,s,this.pitchInRadians),Pt(s,s,-this.bearingInRadians),N(s,s,[-r,-i,0]),this._mercatorMatrix=le([],s,[this.worldSize,this.worldSize,this.worldSize]),le(s,s,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=ue(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),N(s,s,[0,0,-this.elevation]),this._viewProjMatrix=s,this._invViewProjMatrix=It([],s);let c=[0,0,-1,1];Je(c,c,this._invViewProjMatrix),this._cameraPosition=[c[0]/c[3],c[1]/c[3],c[2]/c[3]],this._fogMatrix=new Float64Array(16),Mt(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=-t.x*2/this.width,this._fogMatrix[9]=t.y*2/this.height,le(this._fogMatrix,this._fogMatrix,[1,-1,1]),N(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),Pt(this._fogMatrix,this._fogMatrix,-this.rollInRadians),Ft(this._fogMatrix,this._fogMatrix,this.pitchInRadians),Pt(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),N(this._fogMatrix,this._fogMatrix,[-r,-i,0]),le(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),N(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=ue(new Float64Array(16),this.clipSpaceToPixelsMatrix,s);let l=this._helper._width%2/2,u=this._helper._height%2/2,d=Math.cos(this.bearingInRadians),f=Math.sin(-this.bearingInRadians),p=r-Math.round(r)+d*l+f*u,m=i-Math.round(i)+d*u+f*l,h=new Float64Array(s);if(N(h,h,[p>.5?p-1:p,m>.5?m-1:m,0]),this._alignedProjMatrix=h,s=It(new Float64Array(16),this._pixelMatrix),!s)throw Error(`failed to invert matrix`);this._pixelMatrixInverse=s,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new i(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return Je(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let t=Le(1,this.center.lat)*this.worldSize,n=this._helper.cameraToCenterDistance/t;return Ta(this.center,this.elevation,this.pitch,this.bearing,n).toLngLat()}lngLatToCameraDepth(t,n){let r=I.fromLngLat(t),i=[r.x*this.worldSize,r.y*this.worldSize,n,1];return Je(i,i,this._viewProjMatrix),i[2]/i[3]}getProjectionData(t){let{overscaledTileID:n,aligned:r,applyTerrainMatrix:i}=t,a=this._helper.getMercatorTileCoordinates(n),o=n?this.calculatePosMatrix(n,r,!0):null,s;return s=n?.terrainRttPosMatrix32f&&i?n.terrainRttPosMatrix32f:o||Lt(),{mainMatrix:s,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s,clipAntimeridian:!1}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,n,r){return 1}transformLightDirection(t){return yt(t)}getRayDirectionFromPixel(t){throw Error(`Not implemented.`)}projectTileCoordinates(t,n,r,a){let o=this.calculatePosMatrix(r),s;a?(s=[t,n,a(t,n),1],Je(s,s,o)):(s=[t,n,0,1],bo(s,s,o));let c=s[3];return{point:new i(s[0]/c,s[1]/c),signedDistanceFromCamera:c,isOccluded:!1}}populateCache(t){for(let n of t)this.calculatePosMatrix(n)}getProjectionDataForCustomLayer(t=!0){let n=new ye(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:t}),i=wa(n,this.worldSize);ue(i,this._viewProjMatrix,i);let a=[F,F,this.worldSize/this._helper.pixelsPerMeter],o=Rt();return le(o,i,a),{...r,tileMercatorCoords:[0,0,1,1],fallbackMatrix:o,mainMatrix:o}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function Ts(){b(`Map cannot fit within canvas with the given bounds, padding, and/or offset.`)}function Es(t){if(t.useSlerp)if(t.k<1){let n=zt(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),r=zt(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),i=new Float64Array(4);Bt(i,n,r,t.k);let a=Vt(i);t.tr.setRoll(a.roll),t.tr.setPitch(a.pitch),t.tr.setBearing(a.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(mt.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(mt.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(mt.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function Ds(t,n,r,a,o){let s=o.padding,c=xa(o.worldSize,r.getNorthWest()),l=xa(o.worldSize,r.getNorthEast()),u=xa(o.worldSize,r.getSouthEast()),d=xa(o.worldSize,r.getSouthWest()),f=Pe(-a),p=c.rotate(f),m=l.rotate(f),h=u.rotate(f),g=d.rotate(f),_=new i(Math.max(p.x,m.x,g.x,h.x),Math.max(p.y,m.y,g.y,h.y)),v=new i(Math.min(p.x,m.x,g.x,h.x),Math.min(p.y,m.y,g.y,h.y)),y=_.sub(v),b=o.width-(s.left+s.right+n.left+n.right),x=o.height-(s.top+s.bottom+n.top+n.bottom),S=b/y.x,C=x/y.y;if(C<0||S<0){Ts();return}let w=Math.min(Re(o.scale*Math.min(S,C)),t.maxZoom),T=i.convert(t.offset),E=new i((n.left-n.right)/2,(n.top-n.bottom)/2).rotate(Pe(a)),D=T.add(E).mult(o.scale/Fe(w));return{center:Sa(o.worldSize,c.add(u).div(2).sub(D)),zoom:w,bearing:a}}var As=class{get useGlobeControls(){return!1}handlePanInertia(t,n){let r=t.mag(),i=Math.abs(Ca(n));return{easingOffset:t.mult(Math.min(i*.75/r,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(t,n){t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta),t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta)}handleMapControlsPan(t,n,r){t.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(r,t.around)}cameraForBoxAndBearing(t,n,r,i,a){return Ds(t,n,r,i,a)}handleJumpToCenterZoom(t,n){let r=n.zoom===void 0?t.zoom:+n.zoom;t.zoom!==r&&t.setZoom(+n.zoom),n.center!==void 0&&t.setCenter(P.convert(n.center))}handleEaseTo(t,n){let r=t.zoom,i=t.padding,a={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},s=n.zoom!==void 0,c=!t.isPaddingEqual(n.padding),l=!1,u=s?+n.zoom:t.zoom,d=t.centerPoint.add(n.offsetAsPoint),f=t.screenPointToLocation(d),{center:p,zoom:m}=t.applyConstrain(P.convert(n.center||f),u??r);ps(t,p);let h=xa(t.worldSize,f),g=xa(t.worldSize,p).sub(h),_=Fe(m-r);return l=m!==r,{easeFunc:s=>{if(l&&t.setZoom(mt.number(r,m,s)),Ht(a,o)||Es({startEulerAngles:a,endEulerAngles:o,tr:t,k:s,useSlerp:a.roll!=o.roll}),c&&(t.interpolatePadding(i,n.padding,s),d=t.centerPoint.add(n.offsetAsPoint)),n.around)t.setLocationAtPoint(n.around,n.aroundPoint);else{let n=Fe(t.zoom-r),i=(m>r?Math.min(2,_):Math.max(.5,_))**(1-s),a=Sa(t.worldSize,h.add(g.mult(s*i)).mult(n));t.setLocationAtPoint(t.renderWorldCopies?a.wrap():a,d)}},isZooming:l,elevationCenter:p}}handleFlyTo(t,n){let r=n.zoom!==void 0,i=t.zoom,a=t.applyConstrain(P.convert(n.center||n.locationAtOffset),r?+n.zoom:i),o=a.center,s=a.zoom;ps(t,o);let c=t.worldSize,l=xa(c,n.locationAtOffset),u=xa(c,o).sub(l),d=u.mag(),f=Fe(s-i),p=n.minZoom===void 0?t.minZoom:+n.minZoom,m=Math.max(p,t.minZoom),h=Math.min(m,i,s),g=t.applyConstrain(o,h).zoom;return{easeFunc:(n,r,a,d)=>{t.setZoom(n===1?s:i+Re(r));let f=n===1?o:Sa(c,l.add(u.mult(a)));t.setLocationAtPoint(t.renderWorldCopies?f.wrap():f,d)},scaleOfZoom:f,targetCenter:o,scaleOfMinZoom:Fe(g-i),pixelPathLength:d}}};let Os;const ks=()=>Os||=new A({type:new j(D.projection.type,`type`)}),js=F/128;function Ms(t,n){let r=Ns(n,`16bit`),i=dt.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),a=pt.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new us(t.createVertexBuffer(i,cs.members),t.createIndexBuffer(a),ft.simpleSegment(0,0,i.length,a.length))}function Ns(t,n){let r=t.granularity===void 0?1:Math.max(t.granularity,1),i=r+(t.generateBorders?2:0),a=r+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),o=i+1,s=a+1,c=t.generateBorders?-1:0,l=t.generateBorders||t.extendToNorthPole?-1:0,u=r+ +!!t.generateBorders,d=r+(t.generateBorders||t.extendToSouthPole?1:0),f=o*s,p=i*a*6,m=o*s>65536;if(m&&n===`16bit`)throw Error(`Granularity is too large and meshes would not fit inside 16 bit vertex indices.`);let h=m||n===`32bit`,g=new Int16Array(f*2),_=0;for(let n=l;n<=d;n++)for(let i=c;i<=u;i++){let a=i/r*F;i===-1&&(a=-js),i===r+1&&(a=F+js);let o=n/r*F;n===-1&&(o=t.extendToNorthPole?Ut:-js),n===r+1&&(o=t.extendToSouthPole?Wt:F+js),g[_++]=a,g[_++]=o}let v=h?new Uint32Array(p):new Uint16Array(p),y=0;for(let t=0;t0}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return`globe`}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}getMeshFromTileID(t,n,r,i,a){return this.currentProjection.getMeshFromTileID(t,n,r,i,a)}setProjection(t){this._transitionable.setValue(`type`,t?.type||`mercator`)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}};function Fs(t){let n=Us(t.worldSize,t.center.lat);return 2*Math.PI*n}function Is(t,n,r){let i=Ct(Hs(n),Hs(r)),a=Math.acos(i),o=Fs(t);return a/(2*Math.PI)*o}function zs(t,n){return[qt(t*Math.PI*2+Math.PI,Math.PI*2),2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-Math.PI*.5]}function Bs(t,n){let r=Math.cos(n),i=new Float64Array(3);return i[0]=Math.sin(t)*r,i[1]=Math.sin(n),i[2]=Math.cos(t)*r,i}function Vs(t,n,r,i,a){let o=1/(1<1e-6){let i=t[0]/r,a=t[2]/r,o=Math.acos(a);return new P(fe((i>0?o:-o)/Math.PI*180,-180,180),n)}else return new P(0,n)}function Gs(t){let n=R();return n[0]=t[0]*-t[3],n[1]=t[1]*-t[3],n[2]=t[2]*-t[3],{center:n,radius:Math.sqrt(1-t[3]*t[3])}}function Ks(t,n,r){let i=R();St(i,r,t);let a=R();return Jt(a,t,i,n/Ot(i)),a}function qs(t){return Math.cos(t*Math.PI/180)}function Js(t,n){let r=qs(t);return Re(qs(n)/r)}function Ys(t,n){return 360/Fs({worldSize:t,center:{lat:n}})}function Xs(t,n){let r=t.rotate(n.bearingInRadians),i=n.zoom+Js(n.center.lat,0),a=Yt(1/qs(n.center.lat),1/qs(Math.min(Math.abs(n.center.lat),60)),Xt(i,7,3,0,1)),o=Ys(n.worldSize,n.center.lat);return new P(n.center.lng-r.x*o*a,L(n.center.lat+r.y*o,-Ne,Ne))}function Zs(t){let n=.5*t,r=Math.sin(n),i=Math.cos(n);return Math.log(r+i)-Math.log(i-r)}function Qs(t,n,r,i){let a=t.lat+r*i;if(Math.abs(r)>1){let o=t.lat+r,s=(Math.sign(o)===Math.sign(t.lat)?Math.abs(t.lat):-Math.abs(t.lat))*Math.PI/180,c=Math.abs(t.lat+r)*Math.PI/180,l=Zs(s+i*(c-s)),u=Zs(s),d=Zs(c),f=(l-u)/(d-u);return new P(t.lng+n*f,a)}else return new P(t.lng+n*i,a)}var tc=class{constructor(t){this._cachePrevious=/* @__PURE__ */ new Map,this._cache=/* @__PURE__ */ new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;let t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,n,r,i){let a=`${t.z}_${t.x}_${t.y}_${i?.terrain?`t`:``}_${Math.round(r)}`,o=this._cache.get(a);if(o)return o;let s=this._cachePrevious.get(a);if(s)return this._cache.set(a,s),s;let c=this._boundingVolumeFactory(t,n,r,i);return this._cache.set(a,c),this._hadAnyChanges=!0,c}},$s=class e{constructor(t,n,r,i){this.min=r,this.max=i,this.points=t,this.planes=n}static fromAabb(t,n){let r=[];for(let i=0;i<8;i++)r.push([(i>>0&1)==1?n[0]:t[0],(i>>1&1)==1?n[1]:t[1],(i>>2&1)==1?n[2]:t[2]]);return new e(r,[[-1,0,0,n[0]],[1,0,0,-t[0]],[0,-1,0,n[1]],[0,1,0,-t[1]],[0,0,-1,n[2]],[0,0,1,-t[2]]],t,n)}static fromCenterSizeAngles(t,n,r){let i=Zt([],r[0],r[1],r[2]),a=Qt([],[n[0],0,0],i),o=Qt([],[0,n[1],0],i),s=Qt([],[0,0,n[2]],i),c=[...t],l=[...t];for(let n=0;n<8;n++)for(let r=0;r<3;r++){let i=t[r]+a[r]*((n>>0&1)==1?1:-1)+o[r]*((n>>1&1)==1?1:-1)+s[r]*((n>>2&1)==1?1:-1);c[r]=Math.min(c[r],i),l[r]=Math.max(l[r],i)}let u=[];for(let n=0;n<8;n++){let r=[...t];vt(r,r,_t([],a,(n>>0&1)==1?1:-1)),vt(r,r,_t([],o,(n>>1&1)==1?1:-1)),vt(r,r,_t([],s,(n>>2&1)==1?1:-1)),u.push(r)}return new e(u,[[...a,-Ct(a,u[0])],[...o,-Ct(o,u[0])],[...s,-Ct(s,u[0])],[-a[0],-a[1],-a[2],-Ct(a,u[7])],[-o[0],-o[1],-o[2],-Ct(o,u[7])],[-s[0],-s[1],-s[2],-Ct(s,u[7])]],c,l)}intersectsFrustum(t){let n=!0,r=this.points.length,i=this.planes.length,a=t.planes.length,o=t.points.length;for(let i=0;i=0&&o++}if(o===0)return 0;o=0&&i++}if(i===0)return 0}return 1}intersectsPlane(t){let n=this.points.length,r=0;for(let i=0;i=0&&r++}return r===n?2:r===0?0:1}};function ec(t,n,r){let i=t-n;return i<0?-i:Math.max(0,i-r)}function nc(t,n,r,i,a){let o=t-r,s;return s=o<0?Math.min(-o,1+o-a):o>a?Math.min(Math.max(o-a,0),1-o):0,Math.max(s,ec(n,i,a))}var ac=class{constructor(){this._boundingVolumeCache=new tc(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,n,r,i){let a=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(t,n,r,i){return this._boundingVolumeCache.getTileBoundingVolume(t,n,r,i)}_computeTileBoundingVolume(t,n,r,i){let a=Math.min(0,r),o=Math.max(0,r);if(i?.terrain){let r=new ye(t.z,n,t.z,t.x,t.y),s=i.terrain.getMinMaxElevation(r);a=s.minElevation??a,o=s.maxElevation??o}if(a/=$t,o/=$t,a+=1,o+=1,t.z<=0)return $s.fromAabb([-o,-o,-o],[o,o,o]);if(t.z===1)return $s.fromAabb([t.x===0?-o:0,t.y===0?0:-o,-o],[t.x===0?0:o,t.y===0?o:0,o]);{let n=[Vs(0,0,t.x,t.y,t.z),Vs(F,0,t.x,t.y,t.z),Vs(F,F,t.x,t.y,t.z),Vs(0,F,t.x,t.y,t.z)],r=[];for(let t of n)r.push(_t([],t,o));if(o!==a)for(let t of n)r.push(_t([],t,a));t.y===0&&r.push([0,1,0]),t.y===(1<=(1<{let r=L(t.lat,-Ne,Ne),i=L(+n,this.minZoom+Js(0,r),this.maxZoom);return{center:new P(t.lng,r),zoom:i}},this.applyConstrain=(t,n)=>this._helper.applyConstrain(t,n),this._helper=new vs({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,n)=>this.defaultConstrain(t,n)},t),this._coveringTilesDetailsProvider=new ac}clone(){let t=new e;return t.apply(this,!1),t}apply(t,n){this._helper.apply(t,n)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=R();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:n,applyGlobeMatrix:r}=t,i=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:i,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!r,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:n?.canonical.z===0}}_computeClippingPlane(t){let n=this.pitchInRadians,r=this.cameraToCenterDistance/t,i=Math.sin(n)*r,a=Math.cos(n)*r+1,o=1/Math.sqrt(i*i+a*a)*1,s=-i,c=a,l=Math.sqrt(s*s+c*c);s/=l,c/=l;let u=[0,s,c];rn(u,u,[0,0,0],-this.bearingInRadians),an(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),on(u,u,[0,0,0],this.center.lng*Math.PI/180);let d=1/Tt(u);return _t(u,u,d),[...u,-o*d]}isLocationOccluded(t){return!this.isSurfacePointVisible(Hs(t))}transformLightDirection(t){let n=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,i=Math.cos(r),a=[Math.sin(n)*i,Math.sin(r),Math.cos(n)*i],o=[a[2],0,-a[0]],s=[0,0,0];xt(s,o,a),bt(o,o),bt(s,s);let c=[o[0]*t[0]+s[0]*t[1]+a[0]*t[2],o[1]*t[0]+s[1]*t[1]+a[1]*t[2],o[2]*t[0]+s[2]*t[1]+a[2]*t[2]],l=[0,0,0];return bt(l,c),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,n,r){let i=ya(t,n,r.canonical),a=zs(i.x,i.y);return this.getCircleRadiusCorrection()/Math.cos(a[1])}projectTileCoordinates(t,n,r,a){let o=r.canonical,s=Vs(t,n,o.x,o.y,o.z),c=1+(a?a(t,n):0)/$t,l=[s[0]*c,s[1]*c,s[2]*c,1];Je(l,l,this._globeViewProjMatrixF64);let u=this._cachedClippingPlane,d=u[0]*s[0]+u[1]*s[1]+u[2]*s[2]+u[3]<0;return{point:new i(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:d}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;let t=Us(this.worldSize,this.center.lat),n=Rt();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+t*2),Mt(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let r=this.centerOffset;n[8]=-r.x*2/this._helper._width,n[9]=r.y*2/this._helper._height,this._projectionMatrix=Nt(n),this._globeProjMatrixInverted=Rt(),It(this._globeProjMatrixInverted,n),N(n,n,[0,0,-this.cameraToCenterDistance]),Pt(n,n,this.rollInRadians),Ft(n,n,-this.pitchInRadians),Pt(n,n,this.bearingInRadians),N(n,n,[0,0,-t]);let i=R();i[0]=t,i[1]=t,i[2]=t,Ft(n,n,this.center.lat*Math.PI/180),sn(n,n,-this.center.lng*Math.PI/180),le(n,n,i),this._globeViewProjMatrixF64=n,this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixF64Inverted=Rt(),It(this._globeViewProjMatrixF64Inverted,n);let a=R();this._cameraPosition=R(),this._cameraPosition[2]=this.cameraToCenterDistance/t,rn(this._cameraPosition,this._cameraPosition,a,-this.rollInRadians),an(this._cameraPosition,this._cameraPosition,a,this.pitchInRadians),rn(this._cameraPosition,this._cameraPosition,a,-this.bearingInRadians),vt(this._cameraPosition,this._cameraPosition,[0,0,1]),an(this._cameraPosition,this._cameraPosition,a,-this.center.lat*Math.PI/180),on(this._cameraPosition,this._cameraPosition,a,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);let o=Nt(this._globeViewProjMatrixF64Inverted);le(o,o,[1,1,-1]),this._cachedFrustum=_s.fromInvProjectionMatrix(o,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){b(`calculateFogMatrix is not supported on globe projection.`);let n=Rt();return Ie(n),n}getVisibleUnwrappedCoordinates(t){return[new At(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){if(t){b(`terrain is not fully supported on vertical perspective projection.`);return}this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){if(!this._globeViewProjMatrixF64)return 1;let r=Hs(t);_t(r,r,1+n/$t);let i=tn();return Je(i,[r[0],r[1],r[2],1],this._globeViewProjMatrixF64),i[2]/i[3]}populateCache(t){}getBounds(){let t=this.width*.5,n=this.height*.5,r=[new i(0,0),new i(t,0),new i(this.width,0),new i(this.width,n),new i(this.width,this.height),new i(t,this.height),new i(0,this.height),new i(0,n)],a=[];for(let t of r)a.push(this.unprojectScreenPoint(t));let o=0,s=0,c=0,l=0,u=this.center;for(let t of a){let n=cn(u.lng,t.lng),r=cn(u.lat,t.lat);no&&(o=n),rc&&(c=r)}let d=[u.lng+s,u.lat+l,u.lng+o,u.lat+c];return this.isSurfacePointOnScreen([0,1,0])&&(d[3]=90,d[0]=-180,d[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(d[1]=-90,d[0]=-180,d[2]=180),new Fi(d)}calculateCenterFromCameraLngLatAlt(t,n,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,r,i)}setLocationAtPoint(t,n){let r=Hs(this.unprojectScreenPoint(n)),i=Hs(t),a=R();ln(a);let o=R();on(o,r,a,-this.center.lng*Math.PI/180),an(o,o,a,this.center.lat*Math.PI/180);let s=i[0]*i[0]+i[2]*i[2],c=o[0]*o[0];if(s=-_&&m<=_,y=g>=-_&&g<=_,b,x;if(v&&y){let t=this.center.lng*Math.PI/180,n=this.center.lat*Math.PI/180,r=dn(d,t),i=dn(m,n),a=dn(f,t),o=dn(g,n);r+i=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let n=tn();return Je(n,[...t,1],this._globeViewProjMatrixF64),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(t,n){let r=Ct(t,n),i=R(),a=R();_t(a,n,r),St(i,t,a);let o=1-Ct(i,i);if(o<0)return null;let s=Ct(t,t)-1,c=-r+(r<0?1:-1)*Math.sqrt(o),l=s/c,u=c;return{tMin:Math.min(l,u),tMax:Math.max(l,u)}}unprojectScreenPoint(t){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(t),i=this.rayPlanetIntersection(n,r);if(i){let t=R();vt(t,n,[r[0]*i.tMin,r[1]*i.tMin,r[2]*i.tMin]);let a=R();return bt(a,t),Ws(a)}let a=this._cachedClippingPlane,o=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],s=-kt(a,n)/o,c=R();if(s>0)vt(c,n,[r[0]*s,r[1]*s,r[2]*s]);else{let t=R();vt(t,n,[r[0]*2,r[1]*2,r[2]*2]);let i=kt(this._cachedClippingPlane,t);St(c,t,[this._cachedClippingPlane[0]*i,this._cachedClippingPlane[1]*i,this._cachedClippingPlane[2]*i])}let l=Gs(a);return Ws(Ks(l.center,l.radius,c))}getProjectionDataForCustomLayer(t=!0){let n=this.getProjectionData({overscaledTileID:new ye(0,0,0,0,0),applyGlobeMatrix:t});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(t){}},oc=class e{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,n,r){this._helper.interpolatePadding(t,n,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,r=!0){this._helper.resize(t,n,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}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=(t,n)=>this.currentTransform.defaultConstrain(t,n),this.applyConstrain=(t,n)=>this._helper.applyConstrain(t,n),this._helper=new vs({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,n)=>this.defaultConstrain(t,n)},t),this._globeness=1,this._mercatorTransform=new ws,this._verticalPerspectiveTransform=new ic}clone(){let t=new e;return t._globeness=this._globeness,t.apply(this,!1),t}apply(t,n){this._helper.apply(t,n),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1)}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 n=this._mercatorTransform.getProjectionData(t),r=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?r.mainMatrix:n.mainMatrix,clippingPlane:r.clippingPlane,tileMercatorCoords:r.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix,clipAntimeridian:r.clipAntimeridian}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return Yt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return Yt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,n,r){return Yt(this._mercatorTransform.getPitchedTextCorrection(t,n,r),this._verticalPerspectiveTransform.getPitchedTextCorrection(t,n,r),this._globeness)}projectTileCoordinates(t,n,r,i){return this.currentTransform.projectTileCoordinates(t,n,r,i)}_calcMatrices(){!this._helper._width||!this._helper._height||(this._verticalPerspectiveTransform.apply(this,!1),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}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._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){return this.currentTransform.lngLatToCameraDepth(t,n)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,n,r,i){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,r,i)}setLocationAtPoint(t,n){if(!this.isGlobeRendering){this._mercatorTransform.setLocationAtPoint(t,n),this.apply(this._mercatorTransform,!1);return}this._verticalPerspectiveTransform.setLocationAtPoint(t,n),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,n){return this.currentTransform.locationToScreenPoint(t,n)}screenPointToMercatorCoordinate(t,n){return this.currentTransform.screenPointToMercatorCoordinate(t,n)}screenPointToLocation(t,n){return this.currentTransform.screenPointToLocation(t,n)}isPointOnMapSurface(t,n){return this.currentTransform.isPointOnMapSurface(t,n)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let n=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return n;let r=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return r.fallbackMatrix=n.mainMatrix,r}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},sc=class e{get useGlobeControls(){return!0}handlePanInertia(t,n){let r=Xs(t,n);return Math.abs(r.lng-n.center.lng)>180&&(r.lng=n.center.lng+179.5*Math.sign(r.lng-n.center.lng)),{easingCenter:r,easingOffset:new i(0,0)}}handleMapControlsRollPitchBearingZoom(t,n){let r=t.around,i=n.screenPointToLocation(r);t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta);let a=n.zoom;t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta);let o=n.zoom-a;if(o===0)return;let s=cn(n.center.lng,i.lng),c=s/(Math.abs(s/180)+1),l=cn(n.center.lat,i.lat),u=n.getRayDirectionFromPixel(r),d=n.cameraPosition,f=Ct(d,u)*-1,p=R();vt(p,d,[u[0]*f,u[1]*f,u[2]*f]);let m=Tt(p)-1,h=Math.exp(-Math.max(m-.3,0)*.5),g=Us(n.worldSize,n.center.lat)/Math.min(n.width,n.height),_=Xt(g,.9,.5,1,.25),v=(1-Fe(-o))*Math.min(h,_),y=n.center.lat,b=n.zoom,x=new P(n.center.lng+c*v,L(n.center.lat+l*v,-Ne,Ne));n.setLocationAtPoint(i,r);let S=n.center,C=Xt(Math.abs(s),45,85,0,1),w=Xt(g,.75,.35,0,1),T=Math.max(C,w)**.25,E=cn(S.lng,x.lng),D=cn(S.lat,x.lat);n.setCenter(new P(S.lng+E*T,S.lat+D*T).wrap()),n.setZoom(b+Js(y,n.center.lat))}handleMapControlsPan(t,n,r){if(!t.panDelta)return;let i=n.center.lat,a=n.zoom;n.setCenter(Xs(t.panDelta,n).wrap()),n.setZoom(a+Js(i,n.center.lat))}cameraForBoxAndBearing(t,n,r,i,a){let o=Ds(t,n,r,i,a),s=n.left/a.width*2-1,c=(a.width-n.right)/a.width*2-1,l=n.top/a.height*-2+1,u=(a.height-n.bottom)/a.height*-2+1,d=cn(r.getWest(),r.getEast())<0,f=d?r.getEast():r.getWest(),p=d?r.getWest():r.getEast(),m=Math.max(r.getNorth(),r.getSouth()),h=Math.min(r.getNorth(),r.getSouth()),g=f+cn(f,p)*.5,_=m+cn(m,h)*.5,v=a.clone();v.setCenter(o.center),v.setBearing(o.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(o.zoom);let y=v.modelViewProjectionMatrix,b=[Hs(r.getNorthWest()),Hs(r.getNorthEast()),Hs(r.getSouthWest()),Hs(r.getSouthEast()),Hs(new P(p,_)),Hs(new P(f,_)),Hs(new P(g,m)),Hs(new P(g,h))],x=Hs(o.center),S=1/0;for(let t of b)s<0&&(S=e.getLesserNonNegativeNonNull(S,e.solveVectorScale(t,x,y,`x`,s))),c>0&&(S=e.getLesserNonNegativeNonNull(S,e.solveVectorScale(t,x,y,`x`,c))),l>0&&(S=e.getLesserNonNegativeNonNull(S,e.solveVectorScale(t,x,y,`y`,l))),u<0&&(S=e.getLesserNonNegativeNonNull(S,e.solveVectorScale(t,x,y,`y`,u)));if(!Number.isFinite(S)||S===0){Ts();return}return o.zoom=Math.min(v.zoom+Re(S),t.maxZoom),o}handleJumpToCenterZoom(t,n){let r=t.center.lat,i=t.applyConstrain(n.center?P.convert(n.center):t.center,t.zoom).center;t.setCenter(i.wrap());let a=n.zoom===void 0?t.zoom+Js(r,i.lat):+n.zoom;t.zoom!==a&&t.setZoom(a)}handleEaseTo(t,n){let r=t.zoom,a=t.center,o=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},c={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},l=n.zoom!==void 0,u=!t.isPaddingEqual(n.padding),d=!1,f=n.center?P.convert(n.center):a,p=t.applyConstrain(f,r).center;ps(t,p);let m=t.clone();m.setCenter(p),m.setZoom(l?+n.zoom:r+Js(a.lat,f.lat)),m.setBearing(n.bearing);let h=new i(L(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),L(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));m.setLocationAtPoint(p,h);let g=(n.offset&&n.offsetAsPoint.mag())>0?m.center:p,_=l?+n.zoom:r+Js(a.lat,g.lat),v=r+Js(a.lat,0),y=_+Js(g.lat,0),x=cn(a.lng,g.lng),S=cn(a.lat,g.lat),C=Fe(y-v);return d=_!==r,{easeFunc:r=>{if(Ht(s,c)||Es({startEulerAngles:s,endEulerAngles:c,tr:t,k:r,useSlerp:s.roll!=c.roll}),u&&t.interpolatePadding(o,n.padding,r),n.around)b(`Easing around a point is not supported under globe projection.`),t.setLocationAtPoint(n.around,n.aroundPoint);else{let n=Qs(a,x,S,r*(y>v?Math.min(2,C):Math.max(.5,C))**(1-r));t.setCenter(n.wrap())}if(d){let n=mt.number(v,y,r)+Js(0,t.center.lat);t.setZoom(n)}},isZooming:d,elevationCenter:g}}handleFlyTo(t,n){let r=n.zoom!==void 0,a=t.center,o=t.zoom,s=t.padding,c=!t.isPaddingEqual(n.padding),l=t.applyConstrain(P.convert(n.center||n.locationAtOffset),o).center,u=r?+n.zoom:t.zoom+Js(t.center.lat,l.lat),d=t.clone();d.setCenter(l),d.setZoom(u),d.setBearing(n.bearing);let f=new i(L(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),L(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));d.setLocationAtPoint(l,f);let p=d.center;ps(t,p);let m=Is(t,a,p),h=o+Js(a.lat,0),g=u+Js(p.lat,0),_=Fe(g-h),v=typeof n.minZoom==`number`?+n.minZoom:t.minZoom,y=Math.max(v,t.minZoom)+Js(p.lat,0),b=Math.min(y,h,g)+Js(0,p.lat),x=Fe(t.applyConstrain(p,b).zoom+Js(p.lat,0)-h),S=cn(a.lng,p.lng),C=cn(a.lat,p.lat);return{easeFunc:(r,i,o,l)=>{let d=Qs(a,S,C,o);c&&t.interpolatePadding(s,n.padding,r);let f=r===1?p:d;t.setCenter(f.wrap());let m=h+Re(i);t.setZoom(r===1?u:m+Js(0,f.lat))},scaleOfZoom:_,targetCenter:p,scaleOfMinZoom:x,pixelPathLength:m}}static solveVectorScale(t,n,r,i,a){let o=a,s=i===`x`?[r[0],r[4],r[8],r[12]]:[r[1],r[5],r[9],r[13]],c=[r[3],r[7],r[11],r[15]],l=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],u=t[0]*c[0]+t[1]*c[1]+t[2]*c[2],d=n[0]*s[0]+n[1]*s[1]+n[2]*s[2],f=n[0]*c[0]+n[1]*c[1]+n[2]*c[2],p=(d+s[3]-o*f-o*c[3])/(d-l-o*f+o*u);return d+o*u===l+o*f||c[3]*(l-d)+s[3]*(f-u)+l*f===d*u?null:p}static getLesserNonNegativeNonNull(t,n){return n!==null&&n>=0&&n{for(let t in this.tileManagers){let n=this.tileManagers[t].getSource().type;(n===`vector`||n===`geojson`)&&this.tileManagers[t].reload()}},this.map=t,this.dispatcher=new Ci(vi(),t._getMapId()),this.dispatcher.registerMessageHandler(`GG`,(t,n)=>this.getGlyphs(t,n)),this.dispatcher.registerMessageHandler(`GI`,(t,n)=>this.getImages(t,n)),this.dispatcher.registerMessageHandler(`GDA`,(t,n)=>this.getDashes(t,n)),this.imageManager=new Jr,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(t._missingStyleImageResolver);let r=t._container?.lang||typeof document<`u`&&document.documentElement?.lang||void 0;this.glyphManager=new ei(t._requestManager,n.localIdeographFontFamily,r),this.lineAtlas=new li(256,512),this.crossTileSymbolIndex=new $o,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast(`SR`,pn()),ma().on(fa,this._rtlPluginLoaded),this.on(`data`,t=>{if(t.dataType!==`source`||t.sourceDataType!==`metadata`)return;let n=this.tileManagers[t.sourceId];if(!n)return;let r=n.getSource();if(r?.vectorLayerIds)for(let t in this._layers){let n=this._layers[t];n.source===r.id&&this._validateLayer(n)}})}_setInitialValues(){this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new mn,this._availableImages=[],this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,n){this._checkLoaded();let r=n===null?this.stylesheet.state?.[t]?.default??null:n;if(hn(r,this._globalState[t]))return this;this._globalState[t]=r,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();let n=[];for(let r in t)hn(this._globalState[r],t[r].default)||(n.push(r),this._globalState[r]=t[r].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(t){if(t.length===0)return;let n=/* @__PURE__ */ new Set,r={};for(let i of t){r[i]=this._globalState[i];for(let t in this._layers){let r=this._layers[t],a=r.getLayoutAffectingGlobalStateRefs(),o=r.getPaintAffectingGlobalStateRefs(),s=r.getVisibilityAffectingGlobalStateRefs();if(a.has(i)&&n.add(r.source),o.has(i))for(let{name:t,value:n}of o.get(i))this._updatePaintProperty(r,t,n);s?.has(i)&&(r.recalculateVisibility(),this._updateLayer(r))}}this.dispatcher.broadcast(`UGS`,r);for(let t in this.tileManagers)n.has(t)&&(this._reloadSource(t),this._changed=!0)}async loadURL(t,n={},r){this.fire(new Fr(`dataloading`)),n.validate=typeof n.validate!=`boolean`||n.validate,this._loadStyleRequest=new AbortController;let i=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(t,`Style`);gn(i.signal);let o=await g(a,i);this._loadStyleRequest===i&&(this._loadStyleRequest=null),this._load(o.data,n,r)}catch(t){this._loadStyleRequest===i&&(this._loadStyleRequest=null),t&&!i.signal.aborted&&this.fire(new y(f(t)))}}loadJSON(t,n={},r){this.fire(new Fr(`dataloading`)),this._frameRequest=new AbortController,wr.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,r)}).catch(()=>{})}loadEmpty(){this.fire(new Fr(`dataloading`)),this._load(lc,{validate:!1})}_load(t,n,r){let i=n.transformStyle?n.transformStyle(r,t):t;if(!(n.validate&&_n(this,i))){i={...i},this._loaded=!0,this.stylesheet=i;for(let t in i.sources)this.addSource(t,i.sources[t],{validate:!1});i.sprite?this._loadSprite(i.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(i.glyphs),this._createLayers(),this.light=new ai(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||`mercator`),this.sky=new ci(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new Fr(`data`)),this.fire(new Pr)}}_createLayers(){let t=vn(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast(`SL`,t),this._order=t.map(t=>t.id),this._layers={},this._serializedLayers=null;for(let n of t){let t=yn(n,this._globalState);if(t.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=t,bn(t)&&this.tileManagers[t.source]){let r=n.paint?.[`raster-fade-duration`]??t.paint.get(`raster-fade-duration`);this.tileManagers[t.source].setRasterFadeDuration(r)}}}_loadSprite(t,n=!1,r=void 0){this.imageManager.setLoaded(!1);let i=new AbortController;this._spriteRequest=i;let a;Wr(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(t=>{if(this._spriteRequest=null,t)for(let r in t){this._spritesImagesIds[r]=[];let i=this._spritesImagesIds[r]?this._spritesImagesIds[r].filter(n=>!(n in t)):[];for(let t of i)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(let i in t[r]){let a=r===`default`?i:`${r}:${i}`;this._spritesImagesIds[r].push(a),a in this.imageManager.images?this.imageManager.updateImage(a,t[r][i],!1):this.imageManager.addImage(a,t[r][i]),n&&(this._changedImages[a]=!0)}}}).catch(t=>{this._spriteRequest=null,a=t,i.signal.aborted||this.fire(new y(a))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new Fr(`data`)),r&&r(a)})}_unloadSprite(){for(let t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._imagesListDirty=!0,this._changed=!0,this.fire(new Fr(`data`))}_validateLayer(t){let n=this.tileManagers[t.source];if(!n)return;let r=t.sourceLayer;if(!r)return;let i=n.getSource();(i.type===`geojson`||i.vectorLayerIds&&!i.vectorLayerIds.includes(r))&&this.fire(new y(Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(t,n=!1){let r=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n?xn(r):r);let i=[];for(let a of t)if(r[a]){let t=n?xn(r[a]):r[a];i.push(t)}return i}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};let n=Object.keys(this._layers);for(let r of n){let n=this._layers[r];n.type!==`custom`&&(t[r]=n.serialize())}return t}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let t in this.tileManagers)if(this.tileManagers[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error(`Style is not done loading.`)}update(t){if(!this._loaded)return;let n=this._changed;if(n){this._imagesListDirty&&=(this.dispatcher.broadcast(`SI`,this._availableImages),!1);let n=Object.keys(this._updatedLayers),r=Object.keys(this._removedLayers);(n.length||r.length)&&this._updateWorkerLayers(n,r);for(let t in this._updatedSources){let n=this._updatedSources[t];if(n===`reload`)this._reloadSource(t);else if(n===`clear`)this._clearSource(t);else throw Error(`Invalid action ${n}`)}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let n in this._updatedPaintProps)this._layers[n].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}let r={};for(let t in this.tileManagers){let n=this.tileManagers[t];r[t]=n.used,n.used=!1}for(let n of this._order){let r=this._layers[n];r.recalculate(t,this._availableImages),!r.isHidden(t.zoom)&&r.source&&(this.tileManagers[r.source].used=!0)}for(let t in r){let n=this.tileManagers[t];!!r[t]!=!!n.used&&n.fire(new K(`data`,{sourceDataType:`visibility`,sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,n&&this.fire(new Fr(`data`))}_updateTilesForChangedImages(){let t=Object.keys(this._changedImages);if(t.length){for(let n in this.tileManagers)this.tileManagers[n].reloadTilesForDependencies([`icons`,`patterns`],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies([`glyphs`],[``]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast(`UL`,{layers:this._serializeByIds(t,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){this._checkLoaded();let r=this.serialize();if(t=n.transformStyle?n.transformStyle(r,t):t,(n.validate??!0)&&_n(this,t))return!1;t=xn(t),t.layers=vn(t.layers);let i=Sn(r,t),a=this._getOperationsToPerform(i);if(a.unimplemented.length>0)throw Error(`Unimplemented: ${a.unimplemented.join(`, `)}.`);if(a.operations.length===0)return!1;for(let t of a.operations)t();return this.stylesheet=t,this._serializedLayers=null,this.fire(new Pr({style:this})),!0}_getOperationsToPerform(t){let n=[],r=[];for(let i of t)switch(i.command){case`setCenter`:case`setZoom`:case`setBearing`:case`setPitch`:case`setRoll`:continue;case`addLayer`:n.push(()=>this.addLayer.apply(this,i.args));break;case`removeLayer`:n.push(()=>this.removeLayer.apply(this,i.args));break;case`setPaintProperty`:n.push(()=>this.setPaintProperty.apply(this,i.args));break;case`setLayoutProperty`:n.push(()=>this.setLayoutProperty.apply(this,i.args));break;case`setFilter`:n.push(()=>this.setFilter.apply(this,i.args));break;case`addSource`:n.push(()=>this.addSource.apply(this,i.args));break;case`removeSource`:n.push(()=>this.removeSource.apply(this,i.args));break;case`setLayerZoomRange`:n.push(()=>this.setLayerZoomRange.apply(this,i.args));break;case`setLight`:n.push(()=>this.setLight.apply(this,i.args));break;case`setGeoJSONSourceData`:n.push(()=>this.setGeoJSONSourceData.apply(this,i.args));break;case`setGlyphs`:n.push(()=>this.setGlyphs.apply(this,i.args));break;case`setSprite`:n.push(()=>this.setSprite.apply(this,i.args));break;case`setTerrain`:n.push(()=>this.map.setTerrain.apply(this,i.args));break;case`setSky`:n.push(()=>this.setSky.apply(this,i.args));break;case`setProjection`:this.setProjection.apply(this,i.args);break;case`setGlobalState`:n.push(()=>this.setGlobalState.apply(this,i.args));break;case`setTransition`:n.push(()=>{});break;default:r.push(i.command);break}return{operations:n,unimplemented:r}}addImage(t,n){if(this.getImage(t)){this.fire(new y(Error(`An image named "${t}" already exists.`)));return}this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}setMissingImageResolver(t){this.imageManager.setMissingImageResolver(t)}removeImage(t){if(!this.getImage(t)){this.fire(new y(Error(`An image named "${t}" does not exist.`)));return}this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new Fr(`data`))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,r={}){if(this._checkLoaded(),this.tileManagers[t]!==void 0)throw Error(`Source "${t}" already exists.`);if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(`, `)}.`);if(Cn.has(n.type)&&this._validate(M.source,`sources.${t}`,n,null,r))return;this.map?._collectResourceTiming&&(n.collectResourceTiming=!0);let i=this.tileManagers[t]=new Wa(t,n,this.dispatcher);i.style=this,i.setEventedParent(this,()=>({isSourceLoaded:i.loaded(),source:i.serialize(),sourceId:t})),i.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw Error(`There is no source with this ID=${t}`);for(let n in this._layers)if(this._layers[n].source===t)return this.fire(new y(Error(`Source "${t}" cannot be removed while layer "${n}" is using it.`)));let n=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],n.fire(new K(`data`,{sourceDataType:`metadata`,sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw Error(`There is no source with this ID=${t}`);let r=this.tileManagers[t].getSource();if(r.type!==`geojson`)throw Error(`geojsonSource.type is ${r.type}, which is !== 'geojson`);r.setData(n),this._changed=!0}getSource(t){return this.tileManagers[t]?.getSource()}addLayer(t,n,r={}){this._checkLoaded();let i=t.id;if(this.getLayer(i)){this.fire(new y(Error(`Layer "${i}" already exists on this map.`)));return}let o;if(t.type===`custom`){if(wn(this,Tn(t)))return;o=yn(t,this._globalState)}else{if(`source`in t&&typeof t.source==`object`&&(this.addSource(i,t.source),t=xn(t),t=a(t,{source:i})),this._validate(M.layer,`layers.${i}`,t,{arrayIndex:-1},r))return;o=yn(t,this._globalState),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}})}let s=n?this._order.indexOf(n):this._order.length;if(n&&s===-1){this.fire(new y(Error(`Cannot add layer "${i}" before non-existing layer "${n}".`)));return}if(this._order.splice(s,0,i),this._layerOrderChanged=!0,this._layers[i]=o,this._removedLayers[i]&&o.source&&o.type!==`custom`){let t=this._removedLayers[i];delete this._removedLayers[i],t.type===o.type?(this._updatedSources[o.source]=`reload`,this.tileManagers[o.source].pause()):this._updatedSources[o.source]=`clear`}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t]){this.fire(new y(Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));return}if(t===n)return;let r=this._order.indexOf(t);this._order.splice(r,1);let i=n?this._order.indexOf(n):this._order.length;if(n&&i===-1){this.fire(new y(Error(`Cannot move layer "${t}" before non-existing layer "${n}".`)));return}this._order.splice(i,0,t),this._layerOrderChanged=!0}removeLayer(t){this._checkLoaded();let n=this._layers[t];if(!n){this.fire(new y(Error(`Cannot remove non-existing layer "${t}".`)));return}n.setEventedParent(null);let r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,r){this._checkLoaded();let i=this.getLayer(t);if(!i){this.fire(new y(Error(`Cannot set the zoom range of non-existing layer "${t}".`)));return}(i.minzoom!==n||i.maxzoom!==r)&&(n!=null&&(i.minzoom=n),r!=null&&(i.maxzoom=r),this._updateLayer(i))}setFilter(t,n,r={}){this._checkLoaded();let i=this.getLayer(t);if(!i){this.fire(new y(Error(`Cannot filter non-existing layer "${t}".`)));return}if(!hn(i.filter,n)){if(n==null){i.setFilter(void 0),this._updateLayer(i);return}this._validate(M.filter,`layers.${i.id}.filter`,n,null,r)||(i.setFilter(xn(n)),this._updateLayer(i))}}getFilter(t){return xn(this.getLayer(t).filter)}setLayoutProperty(t,n,r,i={}){this._checkLoaded();let a=this.getLayer(t);if(!a){this.fire(new y(Error(`Cannot style non-existing layer "${t}".`)));return}hn(a.getLayoutProperty(n),r)||(a.setLayoutProperty(n,r,i),this._updateLayer(a))}getLayoutProperty(t,n){let r=this.getLayer(t);if(!r){this.fire(new y(Error(`Cannot get style of non-existing layer "${t}".`)));return}return r.getLayoutProperty(n)}setPaintProperty(t,n,r,i={}){this._checkLoaded();let a=this.getLayer(t);if(!a){this.fire(new y(Error(`Cannot style non-existing layer "${t}".`)));return}hn(a.getPaintProperty(n),r)||this._updatePaintProperty(a,n,r,i)}_updatePaintProperty(t,n,r,i={}){t.setPaintProperty(n,r,i)&&this._updateLayer(t),bn(t)&&n===`raster-fade-duration`&&this.tileManagers[t.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();let r=t.source,i=t.sourceLayer,a=this.tileManagers[r];if(a===void 0){this.fire(new y(Error(`The source '${r}' does not exist in the map's style.`)));return}let o=a.getSource().type;if(o===`geojson`&&i){this.fire(new y(Error(`GeoJSON sources cannot have a sourceLayer parameter.`)));return}if(o===`vector`&&!i){this.fire(new y(Error(`The sourceLayer parameter must be provided for vector source types.`)));return}if(t.id===void 0){this.fire(new y(Error(`The feature id parameter must be provided.`)));return}let s=[`__proto__`,`constructor`,`prototype`];if(n&&Object.keys(n).some(t=>s.includes(t))){this.fire(new y(Error(`The feature state should not include one of the following keys: ${s}`)));return}a.setFeatureState(i,t.id,n)}removeFeatureState(t,n){this._checkLoaded();let r=t.source,i=this.tileManagers[r];if(i===void 0){this.fire(new y(Error(`The source '${r}' does not exist in the map's style.`)));return}let a=i.getSource().type,o=a===`vector`?t.sourceLayer:void 0;if(a===`vector`&&!o){this.fire(new y(Error(`The sourceLayer parameter must be provided for vector source types.`)));return}if(n&&typeof t.id!=`string`&&typeof t.id!=`number`){this.fire(new y(Error(`A feature id is required to remove its specific state property.`)));return}i.removeFeatureState(o,t.id,n)}getFeatureState(t){this._checkLoaded();let n=t.source,r=t.sourceLayer,i=this.tileManagers[n];if(i===void 0){this.fire(new y(Error(`The source '${n}' does not exist in the map's style.`)));return}if(i.getSource().type===`vector`&&!r){this.fire(new y(Error(`The sourceLayer parameter must be provided for vector source types.`)));return}return t.id===void 0&&this.fire(new y(Error(`The feature id parameter must be provided.`))),i.getFeatureState(r,t.id)}getTransition(){return a({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let t=En(this.tileManagers,t=>t.serialize()),n=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return Dn({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,transition:i.transition,projection:i.projection,sources:t,layers:n,terrain:r},t=>t!==void 0)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.tileManagers[t.source].getSource().type!==`raster`&&(this._updatedSources[t.source]=`reload`,this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){let n=t=>this._layers[t].type===`fill-extrusion`,r={},i=[];for(let a=this._order.length-1;a>=0;a--){let o=this._order[a];if(n(o)){r[o]=a;for(let n of t){let t=n[o];if(t)for(let n of t)i.push(n)}}}i.sort((t,n)=>n.intersectionZ-t.intersectionZ);let a=[];for(let o=this._order.length-1;o>=0;o--){let s=this._order[o];if(n(s))for(let t=i.length-1;t>=0;t--){let n=i[t].feature;if(r[n.layer.id]this.map.terrain.getElevation(t,n,r):void 0));return this.placement&&a.push(Di(this._layers,o,this.tileManagers,t,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(t,n){n?.filter&&this._validate(M.filter,`querySourceFeatures.filter`,n.filter,null,n);let r=this.tileManagers[t];return r?Oi(r,n?{...n,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let n in t)if(!hn(t[n],r[n])){i=!0;break}if(!i)return;let o={now:U(),transition:a({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(o)}getProjection(){return this.stylesheet?.projection}setProjection(t){this._checkLoaded();let n=t??{type:`mercator`};if(this.stylesheet.projection=t,this.projection){if(this.projection.name===n.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(n.type)}getSky(){return this.stylesheet?.sky}setSky(t,n={}){this._checkLoaded();let r=this.getSky(),i=!1;if(!t&&!r)return;if(t&&!r)i=!0;else if(!t&&r)i=!0;else for(let n in t)if(!hn(t[n],r[n])){i=!0;break}if(!i)return;let o={now:U(),transition:a({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,n),this.sky.updateTransitions(o)}_setProjectionInternal(t){let n=cc(t,this.map._camera?.transform.constrainOverride,this._globalState);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(let t in this.tileManagers)this.tileManagers[t].reload()}_validate(t,n,r,i,a={}){return re(this,t,{key:n,style:this.serialize(),value:r,...i},a)}_remove(t=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),ma().off(fa,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let n=this.tileManagers[t];n.setEventedParent(null),n.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast(`RM`,void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(let n in this.tileManagers)this.tileManagers[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(let t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,n,r,i,a=!1){let o=!1,s=!1,c={};for(let n of this._order){let r=this._layers[n];if(r.type!==`symbol`)continue;if(!c[r.source]){let t=this.tileManagers[r.source];c[r.source]=t.getRenderableIds(!0).map(n=>t.getTileByID(n)).sort((t,n)=>n.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(n.tileID)?-1:1))}let i=this.crossTileSymbolIndex.addLayer(r,c[r.source],t.center.lng);o||=i}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||=this._layerOrderChanged||r===0,(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(U(),t.zoom))&&(this.pauseablePlacement=new Vo(t,this.map.terrain,this._order,a,n,r,i,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(U()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(let t of this._order){let n=this._layers[t];n.type===`symbol`&&this.placement.updateLayerOpacities(n,c[n.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(U())}_releaseSymbolFadeTiles(){for(let t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}async getImages(t,n){let r=await this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let i=this.tileManagers[n.source];return i&&i.setDependencies(n.tileID.key,n.type,n.icons),r}async getGlyphs(t,n){let r=await this.glyphManager.getGlyphs(n.stacks),i=this.tileManagers[n.source];return i&&i.setDependencies(n.tileID.key,n.type,[``]),r}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),!(t&&this._validate(M.glyphs,`glyphs`,t,null,n))&&(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}async getDashes(t,n){let r={};for(let[t,i]of Object.entries(n.dashes))r[t]=this.lineAtlas.getDash(i.dasharray,i.round);return r}addSprite(t,n,r={},i){this._checkLoaded();let a=[{id:t,url:n}],o=[...Ar(this.stylesheet.sprite),...a];this._validate(M.sprite,`sprite`,o,null,r)||(this.stylesheet.sprite=o,this._loadSprite(a,!0,i))}removeSprite(t){this._checkLoaded();let n=Ar(this.stylesheet.sprite);if(!n.find(n=>n.id===t)){this.fire(new y(Error(`Sprite "${t}" doesn't exists on this map.`)));return}if(this._spritesImagesIds[t])for(let n of this._spritesImagesIds[t])this.imageManager.removeImage(n),this._changedImages[n]=!0;n.splice(n.findIndex(n=>n.id===t),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._imagesListDirty=!0,this._changed=!0,this.fire(new Fr(`data`))}getSprite(){return Ar(this.stylesheet.sprite)}setSprite(t,n={},r){this._checkLoaded(),!(t&&this._validate(M.sprite,`sprite`,t,null,n))&&(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let t in this.tileManagers){let n=this.tileManagers[t];n.setEventedParent(null),n.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(let t in this._layers){let n=this._layers[t];n.setEventedParent(null),n.onRemove&&n.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 dc=lt([{name:`a_pos`,type:`Int16`,components:2},{name:`a_texture_pos`,type:`Int16`,components:2}]);var hc=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,r,i,a,o,s,c,l){this.context=t;let u=this.boundPaintVertexBuffers.length!==i.length;for(let t=0;!u&&t({u_depth:new B(t,n.u_depth),u_terrain:new B(t,n.u_terrain),u_terrain_dim:new z(t,n.u_terrain_dim),u_terrain_matrix:new kn(t,n.u_terrain_matrix),u_terrain_unpack:new On(t,n.u_terrain_unpack),u_terrain_exaggeration:new z(t,n.u_terrain_exaggeration)}),mc=(t,n)=>({u_texture:new B(t,n.u_texture),u_ele_delta:new z(t,n.u_ele_delta),u_fog_matrix:new kn(t,n.u_fog_matrix),u_fog_color:new An(t,n.u_fog_color),u_fog_ground_blend:new z(t,n.u_fog_ground_blend),u_fog_ground_blend_opacity:new z(t,n.u_fog_ground_blend_opacity),u_horizon_color:new An(t,n.u_horizon_color),u_horizon_fog_blend:new z(t,n.u_horizon_fog_blend),u_is_globe_mode:new z(t,n.u_is_globe_mode)}),gc=(t,n)=>({u_ele_delta:new z(t,n.u_ele_delta)}),_c=(t,n)=>({u_texture:new B(t,n.u_texture),u_terrain_coords_id:new z(t,n.u_terrain_coords_id),u_ele_delta:new z(t,n.u_ele_delta)}),vc=(t,n,r,i,a)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:n,u_fog_color:r?r.properties.get(`fog-color`):V.white,u_fog_ground_blend:r?r.properties.get(`fog-ground-blend`):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get(`horizon-color`):V.white,u_horizon_fog_blend:r?r.properties.get(`horizon-fog-blend`):1,u_is_globe_mode:+!!a}),yc=t=>({u_ele_delta:t}),bc=(t,n)=>({u_terrain_coords_id:t/255,u_texture:0,u_ele_delta:n}),xc=(t,n)=>({u_projection_matrix:new kn(t,n.u_projection_matrix),u_projection_tile_mercator_coords:new On(t,n.u_projection_tile_mercator_coords),u_projection_clipping_plane:new On(t,n.u_projection_clipping_plane),u_projection_transition:new z(t,n.u_projection_transition),u_projection_fallback_matrix:new kn(t,n.u_projection_fallback_matrix),u_projection_clip_antimeridian:new B(t,n.u_projection_clip_antimeridian)}),Sc=t=>({u_projection_matrix:t.mainMatrix,u_projection_tile_mercator_coords:t.tileMercatorCoords,u_projection_clipping_plane:t.clippingPlane,u_projection_transition:t.projectionTransition,u_projection_fallback_matrix:t.fallbackMatrix,u_projection_clip_antimeridian:+!!t.clipAntimeridian});function Cc(t){let n=[];for(let r of t){if(r===null)continue;let t=r.split(` `);n.push(t.pop())}return n}var Ec=class{constructor(t,n,r,i,a,o,s,c,l=[]){let u=t.gl;this.program=u.createProgram();let d=Cc(n.staticAttributes),f=r?r.getBinderAttributes():[],p=d.concat(f),m=ss.prelude.staticUniforms?Cc(ss.prelude.staticUniforms):[],h=s.staticUniforms?Cc(s.staticUniforms):[],g=n.staticUniforms?Cc(n.staticUniforms):[],_=r?r.getBinderUniforms():[],v=m.concat(h).concat(g).concat(_),y=[];for(let t of v)y.includes(t)||y.push(t);let b=r?r.defines():[];b.unshift(`#version 300 es`),a&&b.push(`#define OVERDRAW_INSPECTOR;`),o&&b.push(`#define TERRAIN3D;`),c&&b.push(c),l&&b.push(...l);let x=b.concat(ss.prelude.fragmentSource,s.fragmentSource,n.fragmentSource).join(` `),S=b.concat(ss.prelude.vertexSource,s.vertexSource,n.vertexSource).join(` -`),C=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}if(u.shaderSource(C,x),u.compileShader(C),!u.getShaderParameter(C,u.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${u.getShaderInfoLog(C)}`);u.attachShader(this.program,C);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}if(u.shaderSource(w,S),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`);u.attachShader(this.program,w),this.attributes={};let T={};this.numAttributes=p.length;for(let t=0;t=0&&(this.attributes[t]=n)}if(!u.getProgramParameter(this.program,u.LINK_STATUS))throw Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`);u.deleteShader(w),u.deleteShader(C);for(let t of y)if(t&&!T[t]){let n=u.getUniformLocation(this.program,t);n&&(T[t]=n)}this.fixedUniforms=i(t,T),this.terrainUniforms=yc(t,T),this.projectionUniforms=Oc(t,T),this.binderUniforms=r?r.getUniforms(t,T):[]}draw(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y){let b=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(r),t.setStencilMode(i),t.setColorMode(a),t.setCullFace(o),c){t.activeTexture.set(b.TEXTURE2),b.bindTexture(b.TEXTURE_2D,c.depthTexture),t.activeTexture.set(b.TEXTURE3),b.bindTexture(b.TEXTURE_2D,c.texture);for(let t in this.terrainUniforms)this.terrainUniforms[t].set(c[t])}if(l)for(let t in l){let n=kc[t];this.projectionUniforms[n].set(l[t])}if(s)for(let t in this.fixedUniforms)this.fixedUniforms[t].set(s[t]);g&&g.setUniforms(t,this.binderUniforms,m,{zoom:h});let x=0;switch(n){case b.LINES:x=2;break;case b.TRIANGLES:x=3;break;case b.LINE_STRIP:x=1;break}for(let r of p.get())r.vaos||={},r.vaos[u]||=new Sc,r.vaos[u].bind(t,this,d,g?g.getPaintVertexBuffers():[],f,r.vertexOffset,_,v,y),b.drawElements(n,r.primitiveLength*x,b.UNSIGNED_SHORT,r.primitiveOffset*x*2)}};function jc(t,n,r){let i=1/nt(r,1,n.transform.tileZoom),a=2**r.tileID.overscaledZ,o=r.tileSize*2**n.transform.tileZoom/a,s=o*(r.tileID.canonical.x+r.tileID.wrap*a),c=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[s>>16,c>>16],u_pixel_coord_lower:[s&65535,c&65535]}}function Mc(t,n,r,i){let a=r.imageManager.getPattern(t.from.toString()),o=r.imageManager.getPattern(t.to.toString()),{width:s,height:c}=r.imageManager.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,d=u*(i.tileID.canonical.x+i.tileID.wrap*l),f=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,c],u_mix:n.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:n.fromScale,u_scale_b:n.toScale,u_tile_units_to_pixels:1/nt(i,1,r.transform.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[d&65535,f&65535]}}const Pc=(t,n)=>({u_lightpos:new Mn(t,n.u_lightpos),u_lightpos_globe:new Mn(t,n.u_lightpos_globe),u_lightintensity:new B(t,n.u_lightintensity),u_lightcolor:new Mn(t,n.u_lightcolor),u_vertical_gradient:new B(t,n.u_vertical_gradient),u_opacity:new B(t,n.u_opacity),u_fill_translate:new H(t,n.u_fill_translate)}),Fc=(t,n)=>({u_lightpos:new Mn(t,n.u_lightpos),u_lightpos_globe:new Mn(t,n.u_lightpos_globe),u_lightintensity:new B(t,n.u_lightintensity),u_lightcolor:new Mn(t,n.u_lightcolor),u_vertical_gradient:new B(t,n.u_vertical_gradient),u_height_factor:new B(t,n.u_height_factor),u_opacity:new B(t,n.u_opacity),u_fill_translate:new H(t,n.u_fill_translate),u_image:new V(t,n.u_image),u_texsize:new H(t,n.u_texsize),u_pixel_coord_upper:new H(t,n.u_pixel_coord_upper),u_pixel_coord_lower:new H(t,n.u_pixel_coord_lower),u_scale:new Mn(t,n.u_scale),u_fade:new B(t,n.u_fade)}),Ic=(t,n,r,i)=>{let a=t.style.light,o=a.getCartesianPosition(),s=Nn();a.properties.get(`anchor`)===`viewport`&&Pn(s,t.transform.bearingInRadians),Fn(o,o,s);let c=t.transform.transformLightDirection(o),l=a.properties.get(`color`);return{u_lightpos:o,u_lightpos_globe:c,u_lightintensity:a.properties.get(`intensity`),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+n,u_opacity:r,u_fill_translate:i}},Lc=(t,n,r,i,o,s,c)=>a(Ic(t,n,r,i),jc(s,t,c),{u_height_factor:-(2**o.overscaledZ)/c.tileSize/8}),Rc=(t,n)=>({u_fill_translate:new H(t,n.u_fill_translate)}),zc=(t,n)=>({u_image:new V(t,n.u_image),u_texsize:new H(t,n.u_texsize),u_pixel_coord_upper:new H(t,n.u_pixel_coord_upper),u_pixel_coord_lower:new H(t,n.u_pixel_coord_lower),u_scale:new Mn(t,n.u_scale),u_fade:new B(t,n.u_fade),u_fill_translate:new H(t,n.u_fill_translate)}),Bc=(t,n)=>({u_world:new H(t,n.u_world),u_fill_translate:new H(t,n.u_fill_translate)}),Vc=(t,n)=>({u_world:new H(t,n.u_world),u_image:new V(t,n.u_image),u_texsize:new H(t,n.u_texsize),u_pixel_coord_upper:new H(t,n.u_pixel_coord_upper),u_pixel_coord_lower:new H(t,n.u_pixel_coord_lower),u_scale:new Mn(t,n.u_scale),u_fade:new B(t,n.u_fade),u_fill_translate:new H(t,n.u_fill_translate)}),Hc=(t,n,r,i)=>a(jc(n,t,r),{u_fill_translate:i}),Uc=t=>({u_fill_translate:t}),Wc=(t,n)=>({u_world:t,u_fill_translate:n}),Gc=(t,n,r,i,o)=>a(Hc(t,n,r,o),{u_world:i}),Kc=(t,n)=>({u_camera_to_center_distance:new B(t,n.u_camera_to_center_distance),u_scale_with_map:new V(t,n.u_scale_with_map),u_pitch_with_map:new V(t,n.u_pitch_with_map),u_extrude_scale:new H(t,n.u_extrude_scale),u_device_pixel_ratio:new B(t,n.u_device_pixel_ratio),u_globe_extrude_scale:new B(t,n.u_globe_extrude_scale),u_translate:new H(t,n.u_translate)}),qc=(t,n,r,i,a)=>{let o=t.transform,s,c,l=0;if(r.paint.get(`circle-pitch-alignment`)===`map`){let t=nt(n,1,o.zoom);s=!0,c=[t,t],l=t/(I*2**n.tileID.overscaledZ)*2*Math.PI*a}else s=!1,c=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(r.paint.get(`circle-pitch-scale`)===`map`),u_pitch_with_map:+s,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:c,u_globe_extrude_scale:l,u_translate:i}},Jc=(t,n)=>({u_pixel_extrude_scale:new H(t,n.u_pixel_extrude_scale)}),Yc=(t,n)=>({u_viewport_size:new H(t,n.u_viewport_size)}),Xc=t=>({u_pixel_extrude_scale:[1/t.width,1/t.height]}),Zc=t=>({u_viewport_size:[t.width,t.height]}),Qc=(t,n)=>({u_color:new jn(t,n.u_color),u_overlay:new V(t,n.u_overlay),u_overlay_scale:new B(t,n.u_overlay_scale)}),$c=(t,n=1)=>({u_color:t,u_overlay:0,u_overlay_scale:n}),el=(t,n)=>({u_extrude_scale:new B(t,n.u_extrude_scale),u_intensity:new B(t,n.u_intensity),u_globe_extrude_scale:new B(t,n.u_globe_extrude_scale)}),tl=(t,n)=>({u_matrix:new An(t,n.u_matrix),u_world:new H(t,n.u_world),u_image:new V(t,n.u_image),u_color_ramp:new V(t,n.u_color_ramp),u_opacity:new B(t,n.u_opacity)}),nl=(t,n,r,i)=>{let a=nt(t,1,n)/(I*2**t.tileID.overscaledZ)*2*Math.PI*i;return{u_extrude_scale:nt(t,1,n),u_intensity:r,u_globe_extrude_scale:a}},rl=(t,n,r,i)=>{let a=ce();In(a,0,t.width,t.height,0,0,1);let o=t.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:r,u_color_ramp:i,u_opacity:n.paint.get(`heatmap-opacity`)}},il=(t,n)=>({u_image:new V(t,n.u_image),u_latrange:new H(t,n.u_latrange),u_exaggeration:new B(t,n.u_exaggeration),u_altitudes:new Rn(t,n.u_altitudes),u_azimuths:new Rn(t,n.u_azimuths),u_accent:new jn(t,n.u_accent),u_method:new V(t,n.u_method),u_shadows:new Ln(t,n.u_shadows),u_highlights:new Ln(t,n.u_highlights)}),al=(t,n)=>({u_matrix:new An(t,n.u_matrix),u_image:new V(t,n.u_image),u_dimension:new H(t,n.u_dimension),u_zoom:new B(t,n.u_zoom),u_unpack:new kn(t,n.u_unpack)}),ol=(t,n,r)=>{let i=r.paint.get(`hillshade-accent-color`),a;switch(r.paint.get(`hillshade-method`)){case`basic`:a=4;break;case`combined`:a=1;break;case`igor`:a=2;break;case`multidirectional`:a=3;break;default:a=0;break}let o=r.getIlluminationProperties();for(let n=0;n{let r=n.stride,i=ce();return In(i,0,I,-I,0,0,1),N(i,i,[0,-I,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:n.getUnpackVector()}};function cl(t,n){let r=2**n.canonical.z,i=n.canonical.y;return[new L(0,i/r).toLngLat().lat,new L(0,(i+1)/r).toLngLat().lat]}const ll=(t,n)=>({u_image:new V(t,n.u_image),u_unpack:new kn(t,n.u_unpack),u_dimension:new H(t,n.u_dimension),u_elevation_stops:new V(t,n.u_elevation_stops),u_color_stops:new V(t,n.u_color_stops),u_color_ramp_size:new V(t,n.u_color_ramp_size),u_opacity:new B(t,n.u_opacity)}),ul=(t,n,r=0)=>({u_image:0,u_unpack:n.getUnpackVector(),u_dimension:[n.stride,n.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:r,u_opacity:t.paint.get(`color-relief-opacity`)}),dl=(t,n)=>({u_translation:new H(t,n.u_translation),u_ratio:new B(t,n.u_ratio),u_device_pixel_ratio:new B(t,n.u_device_pixel_ratio),u_units_to_pixels:new H(t,n.u_units_to_pixels)}),fl=(t,n)=>({u_translation:new H(t,n.u_translation),u_ratio:new B(t,n.u_ratio),u_device_pixel_ratio:new B(t,n.u_device_pixel_ratio),u_units_to_pixels:new H(t,n.u_units_to_pixels),u_image:new V(t,n.u_image),u_image_height:new B(t,n.u_image_height)}),pl=(t,n)=>({u_translation:new H(t,n.u_translation),u_texsize:new H(t,n.u_texsize),u_ratio:new B(t,n.u_ratio),u_device_pixel_ratio:new B(t,n.u_device_pixel_ratio),u_image:new V(t,n.u_image),u_units_to_pixels:new H(t,n.u_units_to_pixels),u_scale:new Mn(t,n.u_scale),u_fade:new B(t,n.u_fade)}),ml=(t,n)=>({u_translation:new H(t,n.u_translation),u_ratio:new B(t,n.u_ratio),u_device_pixel_ratio:new B(t,n.u_device_pixel_ratio),u_units_to_pixels:new H(t,n.u_units_to_pixels),u_image:new V(t,n.u_image),u_mix:new B(t,n.u_mix),u_tileratio:new B(t,n.u_tileratio),u_crossfade_from:new B(t,n.u_crossfade_from),u_crossfade_to:new B(t,n.u_crossfade_to),u_lineatlas_width:new B(t,n.u_lineatlas_width),u_lineatlas_height:new B(t,n.u_lineatlas_height)}),hl=(t,n)=>({u_translation:new H(t,n.u_translation),u_ratio:new B(t,n.u_ratio),u_device_pixel_ratio:new B(t,n.u_device_pixel_ratio),u_units_to_pixels:new H(t,n.u_units_to_pixels),u_image:new V(t,n.u_image),u_image_height:new B(t,n.u_image_height),u_tileratio:new B(t,n.u_tileratio),u_crossfade_from:new B(t,n.u_crossfade_from),u_crossfade_to:new B(t,n.u_crossfade_to),u_image_dash:new V(t,n.u_image_dash),u_mix:new B(t,n.u_mix),u_lineatlas_width:new B(t,n.u_lineatlas_width),u_lineatlas_height:new B(t,n.u_lineatlas_height)}),gl=(t,n,r,i)=>{let a=t.transform;return{u_translation:Sl(t,n,r),u_ratio:i/nt(n,1,a.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},_l=(t,n,r,i,o)=>a(gl(t,n,r,i),{u_image:0,u_image_height:o}),vl=(t,n,r,i,a)=>{let o=t.transform,s=xl(n,o);return{u_translation:Sl(t,n,r),u_texsize:n.imageAtlasTexture.size,u_ratio:i/nt(n,1,o.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},yl=(t,n,r,i,o)=>{let s=t.transform,c=xl(n,s);return a(gl(t,n,r,i),{u_tileratio:c,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image:0,u_mix:o.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})},bl=(t,n,r,i,o,s)=>{let c=t.transform,l=xl(n,c);return a(gl(t,n,r,i),{u_image:0,u_image_height:s,u_tileratio:l,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image_dash:1,u_mix:o.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})};function xl(t,n){return 1/nt(t,1,n.tileZoom)}function Sl(t,n,r){return rt(t.transform,n,r.paint.get(`line-translate`),r.paint.get(`line-translate-anchor`))}const Cl=(t,n)=>({u_image:new V(t,n.u_image),u_opacity:new B(t,n.u_opacity)}),wl=(t,n)=>({u_image:n,u_opacity:t}),Tl=(t,n)=>({u_tl_parent:new H(t,n.u_tl_parent),u_scale_parent:new B(t,n.u_scale_parent),u_buffer_scale:new B(t,n.u_buffer_scale),u_fade_t:new B(t,n.u_fade_t),u_opacity:new B(t,n.u_opacity),u_image0:new V(t,n.u_image0),u_image1:new V(t,n.u_image1),u_brightness_low:new B(t,n.u_brightness_low),u_brightness_high:new B(t,n.u_brightness_high),u_saturation_factor:new B(t,n.u_saturation_factor),u_contrast_factor:new B(t,n.u_contrast_factor),u_spin_weights:new Mn(t,n.u_spin_weights),u_coords_top:new kn(t,n.u_coords_top),u_coords_bottom:new kn(t,n.u_coords_bottom)}),El=(t,n,r,i,a)=>({u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get(`raster-opacity`),u_image0:0,u_image1:1,u_brightness_low:i.paint.get(`raster-brightness-min`),u_brightness_high:i.paint.get(`raster-brightness-max`),u_saturation_factor:kl(i.paint.get(`raster-saturation`)),u_contrast_factor:Ol(i.paint.get(`raster-contrast`)),u_spin_weights:Dl(i.paint.get(`raster-hue-rotate`)),u_coords_top:[a[0].x,a[0].y,a[1].x,a[1].y],u_coords_bottom:[a[3].x,a[3].y,a[2].x,a[2].y]});function Dl(t){t*=Math.PI/180;let n=Math.sin(t),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*n-r+1)/3,(Math.sqrt(3)*n-r+1)/3]}function Ol(t){return t>0?1/(1-t):1+t}function kl(t){return t>0?1-1/(1.001-t):-t}const Al=(t,n)=>({u_is_size_zoom_constant:new V(t,n.u_is_size_zoom_constant),u_is_size_feature_constant:new V(t,n.u_is_size_feature_constant),u_size_t:new B(t,n.u_size_t),u_size:new B(t,n.u_size),u_camera_to_center_distance:new B(t,n.u_camera_to_center_distance),u_pitch:new B(t,n.u_pitch),u_rotate_symbol:new V(t,n.u_rotate_symbol),u_aspect_ratio:new B(t,n.u_aspect_ratio),u_fade_change:new B(t,n.u_fade_change),u_label_plane_matrix:new An(t,n.u_label_plane_matrix),u_coord_matrix:new An(t,n.u_coord_matrix),u_is_text:new V(t,n.u_is_text),u_pitch_with_map:new V(t,n.u_pitch_with_map),u_is_along_line:new V(t,n.u_is_along_line),u_is_variable_anchor:new V(t,n.u_is_variable_anchor),u_texsize:new H(t,n.u_texsize),u_texture:new V(t,n.u_texture),u_translation:new H(t,n.u_translation),u_pitched_scale:new B(t,n.u_pitched_scale),u_is_offset:new V(t,n.u_is_offset)}),jl=(t,n)=>({u_is_size_zoom_constant:new V(t,n.u_is_size_zoom_constant),u_is_size_feature_constant:new V(t,n.u_is_size_feature_constant),u_size_t:new B(t,n.u_size_t),u_size:new B(t,n.u_size),u_camera_to_center_distance:new B(t,n.u_camera_to_center_distance),u_pitch:new B(t,n.u_pitch),u_rotate_symbol:new V(t,n.u_rotate_symbol),u_aspect_ratio:new B(t,n.u_aspect_ratio),u_fade_change:new B(t,n.u_fade_change),u_label_plane_matrix:new An(t,n.u_label_plane_matrix),u_coord_matrix:new An(t,n.u_coord_matrix),u_is_text:new V(t,n.u_is_text),u_pitch_with_map:new V(t,n.u_pitch_with_map),u_is_along_line:new V(t,n.u_is_along_line),u_is_variable_anchor:new V(t,n.u_is_variable_anchor),u_texsize:new H(t,n.u_texsize),u_texture:new V(t,n.u_texture),u_gamma_scale:new B(t,n.u_gamma_scale),u_device_pixel_ratio:new B(t,n.u_device_pixel_ratio),u_is_halo:new V(t,n.u_is_halo),u_is_plain:new V(t,n.u_is_plain),u_translation:new H(t,n.u_translation),u_pitched_scale:new B(t,n.u_pitched_scale),u_is_offset:new V(t,n.u_is_offset)}),Ml=(t,n)=>({u_is_size_zoom_constant:new V(t,n.u_is_size_zoom_constant),u_is_size_feature_constant:new V(t,n.u_is_size_feature_constant),u_size_t:new B(t,n.u_size_t),u_size:new B(t,n.u_size),u_camera_to_center_distance:new B(t,n.u_camera_to_center_distance),u_pitch:new B(t,n.u_pitch),u_rotate_symbol:new V(t,n.u_rotate_symbol),u_aspect_ratio:new B(t,n.u_aspect_ratio),u_fade_change:new B(t,n.u_fade_change),u_label_plane_matrix:new An(t,n.u_label_plane_matrix),u_coord_matrix:new An(t,n.u_coord_matrix),u_is_text:new V(t,n.u_is_text),u_pitch_with_map:new V(t,n.u_pitch_with_map),u_is_along_line:new V(t,n.u_is_along_line),u_is_variable_anchor:new V(t,n.u_is_variable_anchor),u_texsize:new H(t,n.u_texsize),u_texsize_icon:new H(t,n.u_texsize_icon),u_texture:new V(t,n.u_texture),u_texture_icon:new V(t,n.u_texture_icon),u_gamma_scale:new B(t,n.u_gamma_scale),u_device_pixel_ratio:new B(t,n.u_device_pixel_ratio),u_is_halo:new V(t,n.u_is_halo),u_translation:new H(t,n.u_translation),u_pitched_scale:new B(t,n.u_pitched_scale),u_is_offset:new V(t,n.u_is_offset)}),Nl=(t,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let h=s.transform;return{u_is_size_zoom_constant:+(t===`constant`||t===`source`),u_is_size_feature_constant:+(t===`constant`||t===`camera`),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:h.cameraToCenterDistance,u_pitch:h.pitch/360*2*Math.PI,u_rotate_symbol:+r,u_aspect_ratio:h.width/h.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:c,u_coord_matrix:l,u_is_text:+d,u_pitch_with_map:+i,u_is_along_line:a,u_is_variable_anchor:o,u_texsize:f,u_texture:0,u_translation:u,u_pitched_scale:p,u_is_offset:m}},Pl=(t,n,r,i,o,s,c,l,u,d,f,p,m,h,g)=>{let _=c.transform;return a(Nl(t,n,r,i,o,s,c,l,u,d,f,p,h,g),{u_gamma_scale:i?Math.cos(_.pitch*Math.PI/180)*_.cameraToCenterDistance:1,u_device_pixel_ratio:c.pixelRatio,u_is_halo:+!!m,u_is_plain:1})},Fl=(t,n,r,i,o,s,c,l,u,d,f,p,m,h)=>a(Pl(t,n,r,i,o,s,c,l,u,d,!0,f,!0,m,h),{u_texsize_icon:p,u_texture_icon:1}),Il=(t,n)=>({u_opacity:new B(t,n.u_opacity),u_color:new jn(t,n.u_color)}),Ll=(t,n)=>({u_opacity:new B(t,n.u_opacity),u_image:new V(t,n.u_image),u_pattern_tl_a:new H(t,n.u_pattern_tl_a),u_pattern_br_a:new H(t,n.u_pattern_br_a),u_pattern_tl_b:new H(t,n.u_pattern_tl_b),u_pattern_br_b:new H(t,n.u_pattern_br_b),u_texsize:new H(t,n.u_texsize),u_mix:new B(t,n.u_mix),u_pattern_size_a:new H(t,n.u_pattern_size_a),u_pattern_size_b:new H(t,n.u_pattern_size_b),u_scale_a:new B(t,n.u_scale_a),u_scale_b:new B(t,n.u_scale_b),u_pixel_coord_upper:new H(t,n.u_pixel_coord_upper),u_pixel_coord_lower:new H(t,n.u_pixel_coord_lower),u_tile_units_to_pixels:new B(t,n.u_tile_units_to_pixels)}),Rl=(t,n)=>({u_opacity:t,u_color:n}),zl=(t,n,r,i,o)=>a(Mc(r,o,n,i),{u_opacity:t}),Bl=(t,n)=>({u_sun_pos:new Mn(t,n.u_sun_pos),u_atmosphere_blend:new B(t,n.u_atmosphere_blend),u_globe_position:new Mn(t,n.u_globe_position),u_globe_radius:new B(t,n.u_globe_radius),u_inv_proj_matrix:new An(t,n.u_inv_proj_matrix)}),Vl=(t,n,r,i,a)=>({u_sun_pos:t,u_atmosphere_blend:n,u_globe_position:r,u_globe_radius:i,u_inv_proj_matrix:a}),Hl=(t,n)=>({u_sky_color:new jn(t,n.u_sky_color),u_horizon_color:new jn(t,n.u_horizon_color),u_horizon:new H(t,n.u_horizon),u_horizon_normal:new H(t,n.u_horizon_normal),u_sky_horizon_blend:new B(t,n.u_sky_horizon_blend),u_sky_blend:new B(t,n.u_sky_blend)}),Ul=(t,n,r)=>{let i=Math.cos(n.rollInRadians),a=Math.sin(n.rollInRadians),o=wa(n),s=n.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:t.properties.get(`sky-color`),u_horizon_color:t.properties.get(`horizon-color`),u_horizon:[(n.width/2-o*a)*r,(n.height/2+o*i)*r],u_horizon_normal:[-a,i],u_sky_horizon_blend:t.properties.get(`sky-horizon-blend`)*n.height/2*r,u_sky_blend:s}},Wl=(t,n)=>{},Gl={fillExtrusion:Pc,fillExtrusionPattern:Fc,fill:Rc,fillPattern:zc,fillOutline:Bc,fillOutlinePattern:Vc,circle:Kc,collisionBox:Jc,collisionCircle:Yc,debug:Qc,depth:Wl,clippingMask:Wl,heatmap:el,heatmapTexture:tl,hillshade:il,hillshadePrepare:al,colorRelief:ll,line:dl,lineGradient:fl,linePattern:pl,lineSDF:ml,lineGradientSDF:hl,layerOpacity:Cl,raster:Tl,symbolIcon:Al,symbolSDF:jl,symbolTextAndIcon:Ml,background:Il,backgroundPattern:Ll,terrain:xc,terrainDepth:Cc,terrainCoords:wc,projectionErrorMeasurement:Ps,atmosphere:Bl,sky:Hl};var Jl=class{constructor(t,n,r){this.context=t;let i=t.gl;this.buffer=i.createBuffer(),this.dynamicDraw=!!r,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||n.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let n=this.context.gl;if(!this.dynamicDraw)throw Error(`Attempted to update data while not in dynamic mode.`);this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){let t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}};const Kl={Int8:`BYTE`,Uint8:`UNSIGNED_BYTE`,Int16:`SHORT`,Uint16:`UNSIGNED_SHORT`,Int32:`INT`,Uint32:`UNSIGNED_INT`,Float32:`FLOAT`};var Xl=class{constructor(t,n,r,i){this.length=n.length,this.attributes=r,this.itemSize=n.bytesPerElement,this.dynamicDraw=i,this.context=t;let a=t.gl;this.buffer=a.createBuffer(),t.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||n.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);let n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let r of this.attributes){let i=n.attributes[r.name];i!==void 0&&t.enableVertexAttribArray(i)}}setVertexAttribPointers(t,n,r){for(let i of this.attributes){let a=n.attributes[i.name];a!==void 0&&t.vertexAttribPointer(a,i.components,t[Kl[i.type]],!1,this.itemSize,i.offset+this.itemSize*(r||0))}}destroy(){let t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}},$=class{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}},Zl=class extends ${getDefault(){return z.transparent}set(t){let n=this.current;t.r===n.r&&t.g===n.g&&t.b===n.b&&t.a===n.a&&!this.dirty||(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},Ql=class extends ${getDefault(){return 1}set(t){t===this.current&&!this.dirty||(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}},$l=class extends ${getDefault(){return 0}set(t){t===this.current&&!this.dirty||(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}},eu=class extends ${getDefault(){return[!0,!0,!0,!0]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&!this.dirty||(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},tu=class extends ${getDefault(){return!0}set(t){t===this.current&&!this.dirty||(this.gl.depthMask(t),this.current=t,this.dirty=!1)}},nu=class extends ${getDefault(){return 255}set(t){t===this.current&&!this.dirty||(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}},ru=class extends ${getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let n=this.current;t.func===n.func&&t.ref===n.ref&&t.mask===n.mask&&!this.dirty||(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}},iu=class extends ${getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&!this.dirty||(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}},au=class extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}},ou=class extends ${getDefault(){return[0,1]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&!this.dirty||(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}},su=class extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}},cu=class extends ${getDefault(){return this.gl.LESS}set(t){t===this.current&&!this.dirty||(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}},lu=class extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}},uu=class extends ${getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&!this.dirty||(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}},du=class extends ${getDefault(){return z.transparent}set(t){let n=this.current;t.r===n.r&&t.g===n.g&&t.b===n.b&&t.a===n.a&&!this.dirty||(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},fu=class extends ${getDefault(){return this.gl.FUNC_ADD}set(t){t===this.current&&!this.dirty||(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}},pu=class extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}},mu=class extends ${getDefault(){return this.gl.BACK}set(t){t===this.current&&!this.dirty||(this.gl.cullFace(t),this.current=t,this.dirty=!1)}},hu=class extends ${getDefault(){return this.gl.CCW}set(t){t===this.current&&!this.dirty||(this.gl.frontFace(t),this.current=t,this.dirty=!1)}},gu=class extends ${getDefault(){return null}set(t){t===this.current&&!this.dirty||(this.gl.useProgram(t),this.current=t,this.dirty=!1)}},_u=class extends ${getDefault(){return this.gl.TEXTURE0}set(t){t===this.current&&!this.dirty||(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}},vu=class extends ${getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&!this.dirty||(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},yu=class extends ${getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}},bu=class extends ${getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}},xu=class extends ${getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}},Su=class extends ${getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},Cu=class extends ${getDefault(){return null}set(t){let n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},wu=class extends ${getDefault(){return null}set(t){t===this.current&&!this.dirty||(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}},Tu=class extends ${getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}},Eu=class extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}},Du=class extends ${getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}},Ou=class extends ${constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}},ku=class extends Ou{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}},Au=class extends Ou{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}},ju=class extends Ou{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}},Mu=class{constructor(t,n,r,i,a){this.context=t,this.width=n,this.height=r;let o=t.gl,s=this.framebuffer=o.createFramebuffer();if(this.colorAttachment=new ku(t,s),i)this.depthAttachment=a?new ju(t,s):new Au(t,s);else if(a)throw Error(`Stencil cannot be set without depth`)}destroy(){let t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){let n=this.depthAttachment.get();n&&t.deleteRenderbuffer(n)}t.deleteFramebuffer(this.framebuffer)}},Nu=class{constructor(t){this.gl=t,this.clearColor=new Zl(this),this.clearDepth=new Ql(this),this.clearStencil=new $l(this),this.colorMask=new eu(this),this.depthMask=new tu(this),this.stencilMask=new nu(this),this.stencilFunc=new ru(this),this.stencilOp=new iu(this),this.stencilTest=new au(this),this.depthRange=new ou(this),this.depthTest=new su(this),this.depthFunc=new cu(this),this.blend=new lu(this),this.blendFunc=new uu(this),this.blendColor=new du(this),this.blendEquation=new fu(this),this.cullFace=new pu(this),this.cullFaceSide=new mu(this),this.frontFace=new hu(this),this.program=new gu(this),this.activeTexture=new _u(this),this.viewport=new vu(this),this.bindFramebuffer=new yu(this),this.bindRenderbuffer=new bu(this),this.bindTexture=new xu(this),this.bindVertexBuffer=new Su(this),this.bindElementBuffer=new Cu(this),this.bindVertexArray=new wu(this),this.pixelStoreUnpack=new Tu(this),this.pixelStoreUnpackPremultiplyAlpha=new Eu(this),this.pixelStoreUnpackFlipY=new Du(this),this.extTextureFilterAnisotropic=t.getExtension(`EXT_texture_filter_anisotropic`),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),t.getExtension(`EXT_color_buffer_half_float`),t.getExtension(`EXT_color_buffer_float`)}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}createIndexBuffer(t,n){return new Jl(this,t,n)}createVertexBuffer(t,n,r){return new Xl(this,t,n,r)}createRenderbuffer(t,n,r){let i=this.gl,a=i.createRenderbuffer();return this.bindRenderbuffer.set(a),i.renderbufferStorage(i.RENDERBUFFER,t,n,r),this.bindRenderbuffer.set(null),a}createFramebuffer(t,n,r,i){return new Mu(this,t,n,r,i)}clear({color:t,depth:n,stencil:r}){let i=this.gl,a=0;t&&(a|=i.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(a|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),r!==void 0&&(a|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),i.clear(a)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func===this.gl.ALWAYS&&!t.mask?this.depthTest.set(!1):(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range))}setStencilMode(t){t.test.func===this.gl.ALWAYS&&!t.mask?this.stencilTest.set(!1):(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask}))}setColorMode(t){gn(t.blendFunction,Y.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){return this.gl.createVertexArray()}deleteVertexArray(t){this.gl.deleteVertexArray(t)}unbindVAO(){this.bindVertexArray.set(null)}};let ql;function Yl(t,n,r,i,a){let o=t.context,s=t.transform,c=o.gl,l=t.useProgram(`collisionBox`),u=[],d=0,f=0;for(let p of i){let i=n.getTile(p).getBucket(r);if(!i)continue;let m=a?i.textCollisionBox:i.iconCollisionBox,h=i.collisionCircleArray;h.length>0&&(u.push({circleArray:h,circleOffset:f,coord:p}),d+=h.length/4,f=d),m&&l.draw(o,c.LINES,Z.disabled,Q.disabled,t.colorModeForRenderPass(),X.disabled,Xc(t.transform),t.style.map.terrain?.getTerrainData(p),s.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,t.transform.zoom,null,null,m.collisionVertexBuffer)}if(!a||!u.length)return;let p=t.useProgram(`collisionCircle`),m=new zn;m.resize(d*4),m._trim();let h=0;for(let t of u)for(let n=0;nd.getElevation(a,t,n):null;Bu(o,f,p,l,u,_,n,h,v,rt(u,t,s,c),a.toUnwrapped(),r)}}}function zu(t,n,r,a,o,s){let c=n.tileAnchorPoint.add(new i(n.translation[0],n.translation[1]));if(n.pitchWithMap){let t=a.mult(s);r||(t=t.rotate(-o));let i=c.add(t);return no(i.x,i.y,n.pitchedLabelPlaneMatrix,n.getElevation).point}else if(r){let r=fo(n.tileAnchorPoint.x+1,n.tileAnchorPoint.y,n).point.sub(t),i=Math.atan(r.y/r.x)+(r.x<0?Math.PI:0);return t.add(a.rotate(i))}else return t.add(a)}function Bu(t,n,r,a,o,s,c,l,u,d,f,p){let m=t.text.placedSymbolArray,h=t.text.dynamicLayoutVertexArray,g=t.icon.dynamicLayoutVertexArray,_={};h.clear();for(let g=0;g=0&&(_[v.associatedIconIndex]={shiftedAnchor:k,angle:A})}}if(u){g.clear();let n=t.icon.placedSymbolArray;for(let t=0;tt.style.map.terrain.getElevation(c,n,r):null;ao(l,t,a,ae,n,v,u,r.layout.get(`text-rotation-alignment`)===`map`,c.toUnwrapped(),g.width,g.height,se,i)}let F=a&&w||le,de=v?ae:t.transform.clipSpaceToPixelsMatrix,fe=y||F?Fu:de,pe=m&&r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(1)!==0,me;me=m?l.iconsInText?Fl(C.kind,k,b,v,y,F,t,fe,oe,se,j,ee,E,ue):Pl(C.kind,k,b,v,y,F,t,fe,oe,se,a,j,pe,E,ue):Nl(C.kind,k,b,v,y,F,t,fe,oe,se,a,j,E,ue);let he={program:O,buffers:d,uniformValues:me,projectionData:N,atlasTexture:te,atlasTextureIcon:ne,atlasInterpolation:M,atlasInterpolationIcon:re,isSDF:m,hasHalo:pe};if(x&&l.canOverlap){S=!0;let t=d.segments.get();for(let n of t)T.push({segments:new dt([n]),sortKey:n.sortKey,state:he,terrainData:A})}else T.push({segments:d.segments,sortKey:0,state:he,terrainData:A})}S&&T.sort((t,n)=>t.sortKey-n.sortKey);let D=r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(null)??1/0,O=r.layout.get(`text-letter-spacing`).constantOr(0)*24<0||D>1;for(let n of T){let i=n.state;m.activeTexture.set(h.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,h.CLAMP_TO_EDGE),i.atlasTextureIcon&&(m.activeTexture.set(h.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,h.CLAMP_TO_EDGE));let a=i.isSDF&&i.hasHalo;if(a){let a=i.uniformValues;a.u_is_halo=1,O&&(a.u_is_plain=0,Uu(i.buffers,n.segments,r,t,i.program,C,d,f,a,i.projectionData,n.terrainData),a.u_is_halo=0,a.u_is_plain=1)}Uu(i.buffers,n.segments,r,t,i.program,C,d,f,i.uniformValues,i.projectionData,n.terrainData),a&&!O&&(i.uniformValues.u_is_halo=0)}}function Uu(t,n,r,i,a,o,s,c,l,u,d){let f=i.context,p=f.gl;a.draw(f,p.TRIANGLES,o,s,c,X.backCCW,l,d,u,r.id,t.layoutVertexBuffer,t.indexBuffer,n,r.paint,i.transform.zoom,t.programConfigurations.get(r.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Wu(t,n,r,i,a){if(t.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=r.paint.get(`circle-opacity`),c=r.paint.get(`circle-stroke-width`),l=r.paint.get(`circle-stroke-opacity`),u=!r.layout.get(`circle-sort-key`).isConstant();if(s.constantOr(1)===0&&(c.constantOr(1)===0||l.constantOr(1)===0))return;let d=t.context,f=d.gl,p=t.transform,m=t.getDepthModeForSublayer(0,Z.ReadOnly),h=Q.disabled,g=t.colorModeForRenderPass(),_=[],v=p.getCircleRadiusCorrection();for(let a of i){let i=n.getTile(a),s=i.getBucket(r);if(!s)continue;let c=rt(p,i,r.paint.get(`circle-translate`),r.paint.get(`circle-translate-anchor`)),l=s.programConfigurations.get(r.id),d=t.useProgram(`circle`,l),f=s.layoutVertexBuffer,m=s.indexBuffer,h=t.style.map.terrain?.getTerrainData(a),g={programConfiguration:l,program:d,layoutVertexBuffer:f,indexBuffer:m,uniformValues:qc(t,i,r,c,v),terrainData:h,projectionData:p.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!o,applyTerrainMatrix:!0})};if(u){let t=s.segments.get();for(let n of t)_.push({segments:new dt([n]),sortKey:n.sortKey,state:g})}else _.push({segments:s.segments,sortKey:0,state:g})}u&&_.sort((t,n)=>t.sortKey-n.sortKey);for(let n of _){let{programConfiguration:i,program:a,layoutVertexBuffer:o,indexBuffer:s,uniformValues:c,terrainData:l,projectionData:u}=n.state,p=n.segments;a.draw(d,f.TRIANGLES,m,h,g,X.backCCW,c,l,u,r.id,o,s,p,r.paint,t.transform.zoom,i)}}function Gu(t,n,r,i,a){if(r.paint.get(`heatmap-opacity`)===0)return;let o=t.context,{isRenderingToTexture:s,isRenderingGlobe:c}=a;if(t.style.map.terrain){for(let a of i){let i=n.getTile(a);n.hasRenderableParent(a)||(t.renderPass===`offscreen`?Ju(t,i,r,a,c):t.renderPass===`translucent`&&Yu(t,r,a,s,c))}o.viewport.set([0,0,t.width,t.height])}else t.renderPass===`offscreen`?Ku(t,n,r,i):t.renderPass===`translucent`&&qu(t,r)}function Ku(t,n,r,i){let a=t.context,o=a.gl,s=t.transform,c=Q.disabled,l=new Y([o.ONE,o.ONE],z.transparent,[!0,!0,!0,!0]);Xu(a,t,r),a.clear({color:z.transparent});for(let u of i){if(n.hasRenderableParent(u))continue;let i=n.getTile(u),d=i.getBucket(r);if(!d)continue;let f=d.programConfigurations.get(r.id),p=t.useProgram(`heatmap`,f),m=s.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),h=s.getCircleRadiusCorrection();p.draw(a,o.TRIANGLES,Z.disabled,c,l,X.backCCW,nl(i,s.zoom,r.paint.get(`heatmap-intensity`),h),null,m,r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,s.zoom,f)}a.viewport.set([0,0,t.width,t.height])}function qu(t,n){let r=t.context,i=r.gl;r.setColorMode(t.colorModeForRenderPass());let a=n.heatmapFbos.get(Hn);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),Qu(r,n).bind(i.LINEAR,i.CLAMP_TO_EDGE),t.useProgram(`heatmapTexture`).draw(r,i.TRIANGLES,Z.disabled,Q.disabled,t.colorModeForRenderPass(),X.disabled,rl(t,n,0,1),null,null,n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,n.paint,t.transform.zoom))}function Ju(t,n,r,i,a){let o=t.context,s=o.gl,c=Q.disabled,l=new Y([s.ONE,s.ONE],z.transparent,[!0,!0,!0,!0]),u=n.getBucket(r);if(!u)return;let d=i.key,f=r.heatmapFbos.get(d);f||(f=Zu(o,n.tileSize,n.tileSize),r.heatmapFbos.set(d,f)),o.bindFramebuffer.set(f.framebuffer),o.viewport.set([0,0,n.tileSize,n.tileSize]),o.clear({color:z.transparent});let p=u.programConfigurations.get(r.id),m=t.useProgram(`heatmap`,p,!a),h=t.transform.getProjectionData({overscaledTileID:n.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=t.style.map.terrain.getTerrainData(i);m.draw(o,s.TRIANGLES,Z.disabled,c,l,X.disabled,nl(n,t.transform.zoom,r.paint.get(`heatmap-intensity`),1),g,h,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,t.transform.zoom,p)}function Yu(t,n,r,i,a){let o=t.context,s=o.gl,c=t.transform;o.setColorMode(t.colorModeForRenderPass());let l=Qu(o,n),u=r.key,d=n.heatmapFbos.get(u);if(!d)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,d.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);let f=c.getProjectionData({overscaledTileID:r,applyTerrainMatrix:a,applyGlobeMatrix:!i});t.useProgram(`heatmapTexture`).draw(o,s.TRIANGLES,Z.disabled,Q.disabled,t.colorModeForRenderPass(),X.disabled,rl(t,n,0,1),null,f,n.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,n.paint,c.zoom),d.destroy(),n.heatmapFbos.delete(u)}function Xu(t,n,r){let i=t.gl;t.activeTexture.set(i.TEXTURE1),t.viewport.set([0,0,n.width/4,n.height/4]);let a=r.heatmapFbos.get(Hn);a?(i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),t.bindFramebuffer.set(a.framebuffer)):(a=Zu(t,n.width/4,n.height/4),r.heatmapFbos.set(Hn,a))}function Zu(t,n,r){let i=t.gl,a=i.createTexture();i.bindTexture(i.TEXTURE_2D,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texStorage2D(i.TEXTURE_2D,1,i.RGBA16F,n,r);let o=t.createFramebuffer(n,r,!1,!1);return o.colorAttachment.set(a),o}function Qu(t,n){return n.colorRampTexture||=new S(t,n.colorRamp,t.gl.RGBA),n.colorRampTexture}function $u(t,n,r,i){let a=t.context,o=a.bindFramebuffer.get(),s=a.viewport.get(),[,,c,l]=s;return ed(t,c,l),a.viewport.set([0,0,c,l]),a.clear({color:z.transparent,depth:1,stencil:0}),t.currentStencilSource=void 0,t.renderTileClippingMasks(n,r,i),{compositeTarget:o,compositeViewport:s}}function ed(t,n,r){let i=t.context.gl;if(!t.layerOpacityFbo){let a=t.context.createFramebuffer(n,r,!0,!0),o=i.createTexture();i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,r,0,i.RGBA,i.UNSIGNED_BYTE,null),a.colorAttachment.set(o),a.depthAttachment.set(t.context.createRenderbuffer(i.DEPTH_STENCIL,n,r)),t.layerOpacityFbo=a,t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer);return}if(t.layerOpacityFbo.width===n&&t.layerOpacityFbo.height===r){t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer);return}let a=t.layerOpacityFbo;i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,r,0,i.RGBA,i.UNSIGNED_BYTE,null),t.context.bindRenderbuffer.set(a.depthAttachment.get()),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,n,r),t.context.bindRenderbuffer.set(null),a.width=n,a.height=r,t.context.bindFramebuffer.set(a.framebuffer)}function td(t,n,r,i){let a=t.context,o=a.gl;a.bindFramebuffer.set(r.compositeTarget),a.viewport.set(r.compositeViewport),a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,t.layerOpacityFbo.colorAttachment.get()),t.useProgram(`layerOpacity`).draw(a,o.TRIANGLES,Z.disabled,Q.disabled,t.colorModeForRenderPass(),X.disabled,wl(n,0),null,null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom),t.currentStencilSource=void 0}function nd(t,n,r,i,a,o,s,c){let l=256;if(a.stepInterpolant){let i=n.getSource().maxzoom,a=s.canonical.z===i?Math.ceil(1<t.options.anisotropicFilterPitch&&p.texParameterf(p.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);let k=t.getTerrainDataForTile(C,u),A=h.getProjectionData({overscaledTileID:C,aligned:v,applyGlobeMatrix:!u,applyTerrainMatrix:!0}),j=El(D,E,O.fadeMix,r,c),ee=g.getMeshFromTileID(f,C.canonical,o,s,`raster`),te=a?a[C.overscaledZ]:Q.disabled;m.draw(f,p.TRIANGLES,i,te,_,l?X.frontCCW:X.backCCW,j,k,A,r.id,ee.vertexBuffer,ee.indexBuffer,ee.segments)}}function Td(t,n,r,i){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(r===0||i)return a;if(t.fadingParentID){let i=n.getLoadedTile(t.fadingParentID);if(!i)return a;let o=2**(i.tileID.overscaledZ-t.tileID.overscaledZ);return{parentTile:i,parentScaleBy:o,parentTopLeft:[t.tileID.canonical.x*o%1,t.tileID.canonical.y*o%1],fadeValues:Ed(t,i,r)}}return t.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:Dd(t,r)}:a}function Ed(t,n,r){let i=U(),a=(i-t.timeAdded)/r,o=(i-n.timeAdded)/r,s=t.fadingDirection===1,c=R(a,0,1),l=R(1-o,0,1),u=s?c:l;return{tileOpacity:u,parentTileOpacity:s?l:c,fadeMix:{opacity:1,mix:1-u}}}function Dd(t,n){let r=R((U()-t.timeAdded)/n,0,1);return{tileOpacity:r,fadeMix:{opacity:r,mix:0}}}function Od(t,n,r,i,a){let o=r.paint.get(`background-color`),s=r.paint.get(`background-opacity`);if(s===0)return;let{isRenderingToTexture:c}=a,l=t.context,u=l.gl,d=t.style.projection,f=t.transform,p=f.tileSize,m=r.paint.get(`background-pattern`);if(t.isPatternMissing(m))return;let h=!m&&o.a===1&&s===1&&t.opaquePassEnabledForLayer()?`opaque`:`translucent`;if(t.renderPass!==h)return;let g=Q.disabled,_=t.getDepthModeForSublayer(0,h===`opaque`?Z.ReadWrite:Z.ReadOnly),v=t.colorModeForRenderPass(),y=t.useProgram(m?`backgroundPattern`:`background`),b=i||Na(f,{tileSize:p,terrain:t.style.map.terrain});m&&(l.activeTexture.set(u.TEXTURE0),t.imageManager.bind(t.context));let x=r.getCrossfadeParameters();for(let n of b){let i=f.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),a=m?zl(s,t,m,{tileID:n,tileSize:p},x):Rl(s,o),h=t.getTerrainDataForTile(n,c),b=d.getMeshFromTileID(l,n.canonical,!1,!0,`raster`);y.draw(l,u.TRIANGLES,_,g,v,X.backCCW,a,h,i,r.id,b.vertexBuffer,b.indexBuffer,b.segments)}}const kd=new z(1,0,0,1),Ad=new z(0,1,0,1),jd=new z(0,0,1,1),Md=new z(1,0,1,1),Nd=new z(0,1,1,1);function Pd(t){let n=t.transform.padding;Id(t,t.transform.height-(n.top||0),3,kd),Id(t,n.bottom||0,3,Ad),Ld(t,n.left||0,3,jd),Ld(t,t.transform.width-(n.right||0),3,Md);let r=t.transform.centerPoint;Fd(t,r.x,t.transform.height-r.y,Nd)}function Fd(t,n,r,i){Rd(t,n-2/2,r-20/2,2,20,i),Rd(t,n-20/2,r-2/2,20,2,i)}function Id(t,n,r,i){Rd(t,0,n+r/2,t.transform.width,r,i)}function Ld(t,n,r,i){Rd(t,n-r/2,0,r,t.transform.height,i)}function Rd(t,n,r,i,a,o){let s=t.context,c=s.gl;c.enable(c.SCISSOR_TEST),c.scissor(n*t.pixelRatio,r*t.pixelRatio,i*t.pixelRatio,a*t.pixelRatio),s.clear({color:o}),c.disable(c.SCISSOR_TEST)}function zd(t,n,r){for(let i of r)Bd(t,n,i)}function Bd(t,n,r){let i=t.context,a=i.gl,o=t.useProgram(`debug`),s=Z.disabled,c=Q.disabled,l=t.colorModeForRenderPass(),u=`$debug`,d=t.style.map.terrain?.getTerrainData(r);i.activeTexture.set(a.TEXTURE0);let f=n.getTileByID(r.key).latestRawTileData?.byteLength||0,p=Math.floor(f/1024),m=n.getTile(r).tileSize,h=512/Math.min(m,512)*(r.overscaledZ/t.transform.zoom)*.5,g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),Vd(t,`${g} ${p}kB`);let _=t.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(i,a.TRIANGLES,s,c,Y.alphaBlended,X.disabled,$c(z.transparent,h),null,_,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),o.draw(i,a.LINE_STRIP,s,c,l,X.disabled,$c(z.red),d,_,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Vd(t,n){t.initDebugOverlayCanvas();let r=t.debugOverlayCanvas,i=t.context.gl,a=t.debugOverlayCanvas.getContext(`2d`);a.clearRect(0,0,r.width,r.height),a.shadowColor=`white`,a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle=`white`,a.textBaseline=`top`,a.font=`bold 36px Open Sans, sans-serif`,a.fillText(n,5,5),a.strokeText(n,5,5),t.debugOverlayTexture.update(r),t.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}function Hd(t,n){let r=null,i=Object.values(t._layers).flatMap(r=>r.source&&!r.isHidden(n)?[t.tileManagers[r.source]]:[]),a=i.filter(t=>t.getSource().type===`vector`),o=i.filter(t=>t.getSource().type!==`vector`),s=t=>{(!r||r.getSource().maxzooml.getProjectionData({overscaledTileID:new ve(t.tileID.canonical.z,t.tileID.wrap??0,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),aligned:t.aligned,applyGlobeMatrix:t.applyGlobeMatrix,applyTerrainMatrix:t.applyTerrainMatrix})},f=s.renderingMode?s.renderingMode:`2d`;if(t.renderPass===`offscreen`){let n=s.prerender;n&&(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),n.call(s,o.gl,d),o.setDirty(),t.setBaseState())}else if(t.renderPass===`translucent`){t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(Q.disabled);let n=f===`3d`?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,Z.ReadOnly);o.setDepthMode(n),s.render(o.gl,d),o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}function Wd(t,n){let r=t.context,i=r.gl,a=t.transform,o=Y.unblended,s=new Z(i.LEQUAL,Z.ReadWrite,[0,1]),c=n.tileManager.getRenderableTiles(),l=t.useProgram(`terrainDepth`);r.bindFramebuffer.set(n.getFramebuffer(`depth`).framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:z.transparent,depth:1});for(let t of c){let c=n.getTerrainMesh(t.tileID),u=n.getTerrainData(t.tileID),d=a.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),f=Ec(n.getSkirtLength(a.zoom));l.draw(r,i.TRIANGLES,s,Q.disabled,o,X.backCCW,f,u,d,`terrain`,c.vertexBuffer,c.indexBuffer,c.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}function Gd(t,n){let r=t.context,i=r.gl,a=t.transform,o=Y.unblended,s=new Z(i.LEQUAL,Z.ReadWrite,[0,1]),c=n.getCoordsTexture(),l=n.tileManager.getRenderableTiles(),u=t.useProgram(`terrainCoords`);r.bindFramebuffer.set(n.getFramebuffer(`coords`).framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:z.transparent,depth:1}),n.coordsIndex=[];for(let t of l){let l=n.getTerrainMesh(t.tileID),d=n.getTerrainData(t.tileID);r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,c.texture);let f=Dc(255-n.coordsIndex.length,n.getSkirtLength(a.zoom)),p=a.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(r,i.TRIANGLES,s,Q.disabled,o,X.backCCW,f,d,p,`terrain`,l.vertexBuffer,l.indexBuffer,l.segments),n.coordsIndex.push(t.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}function Kd(t,n,r,i){let{isRenderingGlobe:a}=i,o=t.context,s=o.gl,c=t.transform,l=t.colorModeForRenderPass(),u=t.getDepthModeFor3D(),d=t.useProgram(`terrain`);o.bindFramebuffer.set(null),o.viewport.set([0,0,t.width,t.height]);for(let i of r){let r=n.getTerrainMesh(i.tileID),f=t.renderToTexture.getTexture(i),p=n.getTerrainData(i.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,f.texture);let m=Tc(n.getSkirtLength(c.zoom),c.calculateFogMatrix(i.tileID.toUnwrapped()),t.style.sky,c.pitch,a),h=c.getProjectionData({overscaledTileID:i.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});d.draw(o,s.TRIANGLES,u,Q.disabled,l,X.backCCW,m,p,h,`terrain`,r.vertexBuffer,r.indexBuffer,r.segments)}}function qd(t,n){if(!n.mesh){let r=new ut;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new ft;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),n.mesh=new us(t.createVertexBuffer(r,cs.members),t.createIndexBuffer(i),dt.simpleSegment(0,0,r.length,i.length))}return n.mesh}function Jd(t,n){let r=t.context,i=r.gl,a=Ul(n,t.transform,t.pixelRatio),o=new Z(i.LEQUAL,Z.ReadWrite,[0,1]),s=Q.disabled,c=t.colorModeForRenderPass(),l=t.useProgram(`sky`),u=qd(r,n);l.draw(r,i.TRIANGLES,o,s,c,X.disabled,a,null,void 0,`sky`,u.vertexBuffer,u.indexBuffer,u.segments)}function Yd(t,n){let r=t.getCartesianPosition();Gn(r,r);let i=Fe(new Float64Array(16));return t.properties.get(`anchor`)===`map`&&(Nt(i,i,n.rollInRadians),Pt(i,i,-n.pitchInRadians),Nt(i,i,n.bearingInRadians),Pt(i,i,n.center.lat*Math.PI/180),cn(i,i,-n.center.lng*Math.PI/180)),Kn(r,r,i),r}function Xd(t,n,r){let i=t.context,a=i.gl,o=t.useProgram(`atmosphere`),s=new Z(a.LEQUAL,Z.ReadOnly,[0,1]),c=t.transform,l=Yd(r,t.transform),u=c.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),d=n.properties.get(`atmosphere-blend`)*u.projectionTransition;if(d===0)return;let f=Xs(c.worldSize,c.center.lat),p=c.inverseProjectionMatrix,m=new Float64Array(4);m[3]=1,qe(m,m,c.modelViewProjectionMatrix),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1,qe(m,m,p),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1;let h=Vl(l,d,[m[0],m[1],m[2]],f,p),g=qd(i,n);o.draw(i,a.TRIANGLES,s,Q.disabled,Y.alphaBlended,X.disabled,h,null,null,`atmosphere`,g.vertexBuffer,g.indexBuffer,g.segments)}const Zd={symbol:Iu,circle:Wu,heatmap:Gu,line:sd,fill:ud,fillExtrusion:md,hillshade:gd,colorRelief:yd,raster:Cd,background:Od,sky:Jd,atmosphere:Xd,custom:Ud,debug:zd,debugPadding:Pd,terrainDepth:Wd,terrainCoords:Gd};var Qd=class e{constructor(t,n){this.drawFunctions=Zd,this.context=new Nu(t),this.transform=n,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:Fe(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Wa.maxOverzooming+Wa.maxUnderzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new $o}resize(t,n,r){if(this.width=Math.floor(t*r),this.height=Math.floor(n*r),this.pixelRatio=r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let t of this.style._order)this.style._layers[t].resize()}setup(){let t=this.context,n=new ut;n.emplaceBack(0,0),n.emplaceBack(I,0),n.emplaceBack(0,I),n.emplaceBack(I,I),this.tileExtentBuffer=t.createVertexBuffer(n,cs.members),this.tileExtentSegments=dt.simpleSegment(0,0,4,2);let r=new ut;r.emplaceBack(0,0),r.emplaceBack(I,0),r.emplaceBack(0,I),r.emplaceBack(I,I),this.debugBuffer=t.createVertexBuffer(r,cs.members),this.debugSegments=dt.simpleSegment(0,0,4,5);let i=new qn;i.emplaceBack(0,0,0,0),i.emplaceBack(I,0,I,0),i.emplaceBack(0,I,0,I),i.emplaceBack(I,I,I,I),this.rasterBoundsBuffer=t.createVertexBuffer(i,vc.members),this.rasterBoundsSegments=dt.simpleSegment(0,0,4,2);let a=new ut;a.emplaceBack(0,0),a.emplaceBack(I,0),a.emplaceBack(0,I),a.emplaceBack(I,I),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(a,cs.members),this.rasterBoundsSegmentsPosOnly=dt.simpleSegment(0,0,4,5);let o=new ut;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(o,cs.members),this.viewportSegments=dt.simpleSegment(0,0,4,2);let s=new Jn;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(s);let c=new ft;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(c);let l=this.context.gl;this.stencilClearMode=new Q({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new us(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=ce();In(r,0,this.width,this.height,0,0,1),P(r,r,[n.drawingBufferWidth,n.drawingBufferHeight,0]);let i={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram(`clippingMask`,null,!0).draw(t,n.TRIANGLES,Z.disabled,this.stencilClearMode,Y.disabled,X.disabled,null,null,i,`$clipping`,this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(t,n,r){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n?.length)return;this.currentStencilSource=t.source,this.nextStencilID+n.length>256&&this.clearStencil();let i=this.context;i.setColorMode(Y.disabled),i.setDepthMode(Z.disabled);let a={};for(let t of n)a[t.key]=this.nextStencilID++;this._renderTileMasks(a,n,r,!0),this._renderTileMasks(a,n,r,!1),this._tileClippingMaskIDs=a}_renderTileMasks(t,n,r,i){let a=this.context,o=a.gl,s=this.style.projection,c=this.transform,l=this.useProgram(`clippingMask`);for(let u of n){let n=t[u.key],d=this.getTerrainDataForTile(u,r),f=s.getMeshFromTileID(this.context,u.canonical,i,!0,`stencil`),p=c.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!r,applyTerrainMatrix:!0});l.draw(a,o.TRIANGLES,Z.disabled,new Q({func:o.ALWAYS,mask:0},n,255,o.KEEP,o.KEEP,o.REPLACE),Y.disabled,r?X.disabled:X.backCCW,null,d,p,`$clipping`,f.vertexBuffer,f.indexBuffer,f.segments)}}getTerrainDataForTile(t,n){return n&&this.style.projection?.name===`mercator`?null:this.style.map.terrain?.getTerrainData(t)||null}_renderTilesDepthBuffer(){let t=this.context,n=t.gl,r=this.style.projection,i=this.transform,a=this.useProgram(`depth`),o=this.getDepthModeFor3D(),s=Na(i,{tileSize:i.tileSize});for(let c of s){let s=this.style.map.terrain?.getTerrainData(c),l=r.getMeshFromTileID(this.context,c.canonical,!0,!0,`raster`),u=i.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(t,n.TRIANGLES,o,Q.disabled,Y.disabled,X.backCCW,null,s,u,`$clipping`,l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,n=this.context.gl;return new Q({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){let n=this.context.gl;return new Q({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){let n=this.context.gl,r=t.sort((t,n)=>n.overscaledZ-t.overscaledZ),i=r[r.length-1].overscaledZ,a=r[0].overscaledZ-i+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();let t={};for(let r=0;rn.overscaledZ-t.overscaledZ),i=r[r.length-1].overscaledZ,a=r[0].overscaledZ-i+1;if(this.clearStencil(),a>1){let t={},o={};for(let r=0;r0};for(let t in i){let n=i[t];n.used&&n.prepare(this.context),a[t]=n.getVisibleCoordinates(!1),o[t]=a[t].slice().reverse(),s[t]=n.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;tthis.useProgram(t)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?z.black:z.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass=`opaque`,this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){let t=this.style._layers[r[this.currentLayer]],n=i[t.source],o=a[t.source];this.renderTileClippingMasks(t,o,!1),this.renderLayer(this,n,t,o,c)}this.renderPass=`translucent`;let l=!1;for(this.currentLayer=0;this.currentLayer0?n.pop():null}acquireRTT(t){let n=this.context.gl,r=this._rttObjectRecyclePool.pop();if(r)return r.size!==t&&(n.bindTexture(n.TEXTURE_2D,r.texture.texture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t,t,0,n.RGBA,n.UNSIGNED_BYTE,null),r.texture.size=[t,t],r.size=t),r;let i=new S(this.context,{width:t,height:t,data:null},n.RGBA);return i.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.context.extTextureFilterAnisotropic&&n.texParameterf(n.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:i,size:t}}bindRTT(t){let n=this.context.gl,r=t.size;if(!this._rttSharedFbo){let t=this.context.createFramebuffer(r,r,!0,!0),i=this.context.createRenderbuffer(n.DEPTH_STENCIL,r,r);t.depthAttachment.set(i),this._rttSharedFbo={fbo:t,depthRenderbuffer:i,size:r}}this._rttSharedFbo.size!==r&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),n.renderbufferStorage(n.RENDERBUFFER,n.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)}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let n=this.imageManager.getPattern(t.from.toString()),r=this.imageManager.getPattern(t.to.toString());return!n||!r}useProgram(t,n,r=!1,i=[]){this.cache||={};let a=!!this.style.map.terrain,o=this.style.projection,s=r?ss.projectionMercator:o.shaderPreludeCode,c=r?ls:o.shaderDefine,l=`/${r?ds:o.shaderVariantName}`,u=n?n.cacheKey:``,d=this._showOverdrawInspector?`/overdraw`:``,f=a?`/terrain`:``,p=i?`/${i.join(`/`)}`:``,m=t+u+l+d+f+p;return this.cache[m]||=new Nc(this.context,ss[t],n,Gl[t],this._showOverdrawInspector,a,s,c,i),this.cache[m]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){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 S(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){if(this._tileTextures){for(let t in this._tileTextures){let n=this._tileTextures[t];if(n)for(let t of n)t.destroy()}this._tileTextures={}}for(let t of this._rttObjectRecyclePool)t.texture.destroy();if(this._rttObjectRecyclePool=[],this._rttSharedFbo){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}if(this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(let t in this.cache){let n=this.cache[t];n?.program&&this.context.gl.deleteProgram(n.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}},tf=class extends Error{constructor(t,n){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=t,this.statusMessage=n?.statusMessage??null}};function $d(t,n){let r=!1,i=null,a,o=()=>{i=null,r&&=(t(...a),i=setTimeout(o,n),!1)};return(...t)=>(r=!0,a=t,i||o(),i)}var rf=class{constructor(t){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace(`#`,``)),this._getCurrentHash=()=>{let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||``).split(`/`):([...t.keys()][0]??``).split(`/`)},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let n=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:n,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 n=decodeURIComponent(t.toString()).replace(/=&/g,`&`).replace(/=$/g,``),r=n?`#${n}`:``,i=window.location.href.replace(/(#.+)?$/,r);i=i.replace(`&&`,`&`),window.history.replaceState(window.history.state,null,i)},this._updateHash=$d(this._updateHashUnthrottled,30*1e3/100),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,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(t){let n=this._map.getCenter(),r=Math.round(this._map.getZoom()*100)/100,i=10**Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.round(n.lng*i)/i,o=Math.round(n.lat*i)/i,s=this._map.getBearing(),c=this._map.getPitch(),l=``;if(t?l+=`/${a}/${o}/${r}`:l+=`${r}/${o}/${a}`,(s||c)&&(l+=`/${Math.round(s*10)/10}`),c&&(l+=`/${Math.round(c)}`),this._hashName){let t=this._getHashParams();return t.set(this._hashName,l),`#${decodeURIComponent(t.toString()).replace(/=&/g,`&`).replace(/=$/g,``)}`}return`#${l}`}_isValidHash(t){if(t.length<3||t.some(t=>isNaN(+t)))return!1;try{new F(+t[2],+t[1])}catch{return!1}let n=+t[0],r=+(t[3]||0),i=+(t[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}};const ef={linearity:.3,easing:sr(0,0,.3,1)},nf=a({deceleration:2500,maxSpeed:1400},ef),af=a({deceleration:20,maxSpeed:1400},ef),of=a({deceleration:1e3,maxSpeed:360},ef),sf=a({deceleration:1e3,maxSpeed:90},ef),cf=a({deceleration:1e3,maxSpeed:360},ef);var df=class{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:U(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,n=U();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,roll:0,pan:new i(0,0),pinchAround:void 0,around:void 0};for(let{settings:t}of this._inertiaBuffer)n.zoom+=t.zoomDelta||0,n.bearing+=t.bearingDelta||0,n.pitch+=t.pitchDelta||0,n.roll+=t.rollDelta||0,t.panDelta&&n.pan._add(t.panDelta),t.around&&(n.around=t.around),t.pinchAround&&(n.pinchAround=t.pinchAround);let r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(n.pan.mag()){let i=uf(n.pan.mag(),r,a({},nf,t||{})),s=n.pan.mult(i.amount/n.pan.mag()),c=this._map._camera.cameraHelper.handlePanInertia(s,this._map._camera.transform);o.center=c.easingCenter,o.offset=c.easingOffset,lf(o,i)}if(n.zoom){let t=uf(n.zoom,r,af);o.zoom=cr(this._map.getZoom()+t.amount,this._map.getZoomSnap(),t.amount),lf(o,t)}if(n.bearing){let t=uf(n.bearing,r,of);o.bearing=this._map.getBearing()+R(t.amount,-179,179),lf(o,t)}if(n.pitch){let t=uf(n.pitch,r,sf);o.pitch=this._map.getPitch()+t.amount,lf(o,t)}if(n.roll){let t=uf(n.roll,r,cf);o.roll=this._map.getRoll()+R(t.amount,-179,179),lf(o,t)}if(o.zoom||o.bearing){let t=n.pinchAround===void 0?n.around:n.pinchAround;o.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),a(o,{noMoveStart:!0})}};function lf(t,n){(!t.duration||t.duration=this._clickTolerance||this._map.fire(new Lr(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Lr(t.type,this._map,t))}mouseover(t){this._map.fire(new Lr(t.type,this._map,t))}mouseout(t){this._map.fire(new Lr(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Rr(t.type,this._map,t))}touchmove(t){this._map.fire(new Rr(t.type,this._map,t))}touchend(t){this._map.fire(new Rr(t.type,this._map,t))}touchcancel(t){this._map.fire(new Rr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},hf=class{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Lr(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Lr(`contextmenu`,this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Lr(t.type,this._map,t)),this._map.listens(`contextmenu`)&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},gf=class{constructor(t,n,r){this._map=t,this._tr=r,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1,n.boxZoom&&typeof n.boxZoom==`object`&&(this._boxZoomEnd=n.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(W.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;let r=n;if(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)t.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})}}}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent(`boxzoomcancel`,t))}reset(){this._active=!1,this._container.classList.remove(`maplibregl-crosshair`),this._box&&=(this._box.remove(),null),W.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new Br(t,{originalEvent:n}))}};function ff(t,n){if(t.length!==n.length)throw Error(`The number of touches and points are not equal - touches ${t.length}, points ${n.length}`);let r={};for(let i=0;ithis.numTouches)&&(this.aborted=!0),!this.aborted&&(this.startTime===void 0&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=pf(n),this.touches=ff(r,n)))}touchmove(t,n,r){if(this.aborted||!this.centroid)return;let i=ff(r,n);for(let t in this.touches){let n=this.touches[t],r=i[t];(!r||r.dist(n)>30)&&(this.aborted=!0)}}touchend(t,n,r){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),r.length===0){let t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}},bf=class{constructor(t){this.singleTap=new yf(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,r){this.singleTap.touchstart(t,n,r)}touchmove(t,n,r){this.singleTap.touchmove(t,n,r)}touchend(t,n,r){let i=this.singleTap.touchend(t,n,r);if(i){let n=t.timeStamp-this.lastTime<500,r=!this.lastTap||this.lastTap.dist(i)<30;if((!n||!r)&&this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}},xf=class{constructor(t,n){this._tr=n,this._zoomIn=new bf({numTouches:1,numTaps:2}),this._zoomOut=new bf({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,r){this._zoomIn.touchstart(t,n,r),this._zoomOut.touchstart(t,n,r)}touchmove(t,n,r){this._zoomIn.touchmove(t,n,r),this._zoomOut.touchmove(t,n,r)}touchend(t,n,r){let i=this._zoomIn.touchend(t,n,r),a=this._zoomOut.touchend(t,n,r),o=this._tr;if(i)return this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:n=>n.easeTo({duration:300,zoom:cr(o.zoom+1,n.getZoomSnap()),around:o.unproject(i)},{originalEvent:t})};if(a)return this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:n=>n.easeTo({duration:300,zoom:cr(o.zoom-1,n.getZoomSnap()),around:o.unproject(a)},{originalEvent:t})}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Sf=class{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){let n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.rollDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){!this.isEnabled()||this._lastPoint||this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;let r=this._lastPoint;if(!r)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t)){this.reset(t);return}let i=Array.isArray(n)?n[0]:n;if(!(!this._moved&&i.dist(r)!0}),n=new Ef){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(t,n,r){if(t instanceof MouseEvent)return n(t);if(typeof TouchEvent<`u`&&t instanceof TouchEvent)return r(t)}startMove(t){this._executeRelevantHandler(t,t=>{this.mouseMoveStateManager.startMove(t)},t=>{this.oneFingerTouchMoveStateManager.startMove(t)})}endMove(t){this._executeRelevantHandler(t,t=>{this.mouseMoveStateManager.endMove(t)},t=>{this.oneFingerTouchMoveStateManager.endMove(t)})}isValidStartEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidStartEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t))}isValidMoveEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidMoveEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t))}isValidEndEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidEndEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t))}};const Cf=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};function wf({enable:t,clickTolerance:n}){return new Sf({clickTolerance:n,move:(t,n)=>({around:n,panDelta:n.sub(t)}),activateOnStart:!0,moveStateManager:new Tf({checkCorrectEvent:t=>t.button===0&&!t.ctrlKey}),enable:t,assignEvents:Cf})}function Of({enable:t,clickTolerance:n,aroundCenter:r=!0,minPixelCenterThreshold:a=100,rotateDegreesPerPixelMoved:o=.8},s){return new Sf({clickTolerance:n,move:(t,n)=>{let c=s();if(r&&Math.abs(c.y-t.y)>a)return{bearingDelta:lr(new i(t.x,n.y),n,c)};let l=(n.x-t.x)*o;return r&&n.yt.button===0&&t.ctrlKey||t.button===2&&!t.ctrlKey}),enable:t,assignEvents:Cf})}function kf({enable:t,clickTolerance:n,pitchDegreesPerPixelMoved:r=-.5}){return new Sf({clickTolerance:n,move:(t,n)=>({pitchDelta:(n.y-t.y)*r}),moveStateManager:new Tf({checkCorrectEvent:t=>t.button===0&&t.ctrlKey||t.button===2}),enable:t,assignEvents:Cf})}function Af({enable:t,clickTolerance:n,rollDegreesPerPixelMoved:r=.3},i){return new Sf({clickTolerance:n,move:(t,n)=>{let a=i(),o=(n.x-t.x)*r;return n.yt.button===2&&t.ctrlKey}),enable:t,assignEvents:Cf})}var Nf=class{constructor(t,n){this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new i(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,n,r){return this._calculateTransform(t,n,r)}touchmove(t,n,r){if(this._active){if(this._shouldBePrevented(r.length)){this._map.cooperativeGestures.notifyGestureBlocked(`touch_pan`,t);return}return t.preventDefault(),this._calculateTransform(t,n,r)}}touchend(t,n,r){this._calculateTransform(t,n,r),this._active&&this._shouldBePrevented(r.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,r){r.length>0&&(this._active=!0);let a=ff(r,n),o=new i(0,0),s=new i(0,0),c=0;for(let t in a){let n=a[t],r=this._touches[t];r&&(o._add(n),s._add(n.sub(r)),c++,a[t]=n)}if(this._touches=a,this._shouldBePrevented(c)||!s.mag())return;let l=s.div(c);if(this._sum._add(l),!(this._sum.mag()Math.abs(t.x)}var Hf=class extends Pf{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,r){super.touchstart(t,n,r),this._currentTouchCount=r.length}_start(t){this._lastPoints=t,Lf(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,r){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let i=t[0].sub(this._lastPoints[0]),a=t[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(i,a,r.timeStamp),this._valid)return this._lastPoints=t,this._active=!0,{pitchDelta:(i.y+a.y)/2*-.5}}gestureBeginsVertically(t,n,r){if(this._valid!==void 0)return this._valid;let i=t.mag()>=2,a=n.mag()>=2;if(!i&&!a)return;if(!i||!a)return this._firstMove===void 0&&(this._firstMove=r),r-this._firstMove<100&&void 0;let o=t.y>0==n.y>0;return Lf(t)&&Lf(n)&&o}};const zf={panStep:100,bearingStep:15,pitchStep:10};var Wf=class{constructor(t,n){this._tr=n;let r=zf;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,r=0,i=0,a=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),a=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),a=1);break;case 38:t.shiftKey?i=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?i=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{let c=this._tr;s.easeTo({duration:300,easeId:`keyboardHandler`,easing:Vf,zoom:n?cr(c.zoom+n*(t.shiftKey?2:1),s.getZoomSnap()):c.zoom,bearing:c.bearing+r*this._bearingStep,pitch:c.pitch+i*this._pitchStep,offset:[-a*this._panStep,-o*this._panStep],center:c.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function Vf(t){return t*(2-t)}const Uf=4.000244140625;var qf=class{constructor(t,n,r){this._onTimeout=t=>{this._type=`wheel`,this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=r,this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around===`center`)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return this._map.cooperativeGestures.isEnabled()?!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t)):!1}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t)){this._map.cooperativeGestures.notifyGestureBlocked(`wheel_zoom`,t);return}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*40:t.deltaY,r=U(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,n!==0&&n%Uf==0?this._type=`wheel`:n!==0&&Math.abs(n)<4?this._type=`trackpad`:i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(i*n)<200?`trackpad`:`wheel`,this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=W.mousePos(this._map.getCanvas(),t),r=this._tr;this._aroundCenter?this._aroundPoint=r.transform.locationToScreenPoint(F.convert(r.center)):this._aroundPoint=n,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let t=this._tr.transform;if(typeof this._lastExpectedZoom==`number`){let n=t.zoom-this._lastExpectedZoom;typeof this._startZoom==`number`&&(this._startZoom+=n),typeof this._targetZoom==`number`&&(this._targetZoom+=n)}if(this._delta!==0){let n=this._type===`wheel`&&Math.abs(this._delta)>Uf?this._wheelZoomRate:this._defaultZoomRate,r=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&r!==0&&(r=1/r);let i=typeof this._targetZoom==`number`?Pe(this._targetZoom):t.scale,a=t.applyConstrain(t.getCameraLngLat(),Le(i*r)).zoom,o=this._map.getZoomSnap();if(this._type===`wheel`&&o>0){let n=cr(t.zoom,o);this._targetZoom=cr(a,o,a-n)}else this._targetZoom=a;this._type===`wheel`&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom==`number`?this._targetZoom:t.zoom,r=this._startZoom,i=this._easing,a=!1,o;if(this._type===`wheel`&&r&&i){let t=U()-this._lastWheelEventTime,s=Math.min((t+5)/200,1),c=i(s);o=pt.number(r,n,c),s<1?this._needsRerender=!0:a=!0}else o=n,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=o,{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=ur;if(this._prevEase){let t=this._prevEase,r=(U()-t.start)/t.duration,i=t.easing(r+.01)-t.easing(r),a=.27/Math.sqrt(i*i+1e-4)*.01;n=sr(a,Math.sqrt(.27*.27-a*a),.25,1)}return this._prevEase={start:U(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},Jf=class{constructor(t,n){this._clickZoom=t,this._tapZoom=n}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()}},Yf=class{constructor(t,n){this._tr=n,this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:cr(this._tr.zoom+(t.shiftKey?-1:1),r.getZoomSnap()),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Xf=class{constructor(){this._tap=new bf({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(t){this._zoomRate=t??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,r){if(!this._swipePoint)if(!this._tapTime)this._tap.touchstart(t,n,r);else{let i=n[0],a=t.timeStamp-this._tapTime<500,o=this._tapPoint.dist(i)<30;!a||!o?this.reset():r.length>0&&(this._swipePoint=i,this._swipeTouch=r[0].identifier)}}touchmove(t,n,r){if(!this._tapTime)this._tap.touchmove(t,n,r);else if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;let i=n[0],a=i.y-this._swipePoint.y;return this._swipePoint=i,t.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}touchend(t,n,r){if(this._tapTime)this._swipePoint&&r.length===0&&this.reset();else{let i=this._tap.touchend(t,n,r);i&&(this._tapTime=t.timeStamp,this._tapPoint=i)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Zf=class{constructor(t,n,r){this._el=t,this._mousePan=n,this._touchPan=r}enable(t){this._inertiaOptions=t||{},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()}},Qf=class{constructor(t,n,r,i){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=n,this._mousePitch=r,this._mouseRoll=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},$f=class{constructor(t,n,r,i){this._el=t,this._touchZoom=n,this._touchRotate=r,this._tapDragZoom=i,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add(`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(t){this._touchZoom.setZoomRate(t),this._tapDragZoom.setZoomRate(t)}setZoomThreshold(t){this._touchZoom.setZoomThreshold(t)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},ep=class{constructor(t,n){this._bypassKey=navigator.userAgent.includes(`Mac`)?`metaKey`:`ctrlKey`,this._map=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let t=this._map.getCanvasContainer();t.classList.add(`maplibregl-cooperative-gestures`),this._container=W.create(`div`,`maplibregl-cooperative-gesture-screen`,t);let n=this._map._getUIString(`CooperativeGesturesHandler.WindowsHelpText`);this._bypassKey===`metaKey`&&(n=this._map._getUIString(`CooperativeGesturesHandler.MacHelpText`));let r=this._map._getUIString(`CooperativeGesturesHandler.MobileHelpText`),i=document.createElement(`div`);i.className=`maplibregl-desktop-message`,i.textContent=n,this._container.appendChild(i);let a=document.createElement(`div`);a.className=`maplibregl-mobile-message`,a.textContent=r,this._container.appendChild(a),this._container.setAttribute(`aria-hidden`,`true`)}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove(`maplibregl-cooperative-gestures`)),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,n){this._enabled&&(this._map.fire(new Pr(`cooperativegestureprevented`,{gestureType:t,originalEvent:n})),this._container.classList.add(`maplibregl-show`),setTimeout(()=>{this._container.classList.remove(`maplibregl-show`)},100))}},tp=class{constructor(t){this._camera=t}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(t){return this.transform.screenPointToLocation(i.convert(t),this._camera.terrain)}};const Gf=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;var rp=class extends h{};function Kf(t){return t.panDelta?.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}var ap=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(t,n,r){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,n)=>{if(t.type===`blur`){this.stop(!0);return}this._updatingCamera=!0;let r=t.type===`renderFrame`?void 0:t,i={needsRenderFrame:!1},a={},o={};for(let{handlerName:s,handler:c,allowed:l}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(o,l,s))c.reset();else if(c[n||t.type]){if(dr(t,n||t.type)){let r=W.mousePos(this._map.getCanvas(),t);u=c[n||t.type](t,r)}else if(fr(t,n||t.type)){let r=t.touches,i=this._getMapTouches(r),a=W.touchPos(this._map.getCanvas(),i);u=c[n||t.type](t,a,i)}else pr(n||t.type)||(u=c[n||t.type](t));this.mergeHandlerResult(i,a,u,s,r),u?.needsRenderFrame&&this._triggerRenderFrame()}(u||c.isActive())&&(o[s]=c)}let s={};for(let t in this._previousActiveHandlers)o[t]||(s[t]=r);this._previousActiveHandlers=o,(Object.keys(s).length||Kf(i))&&(this._changes.push([i,a,s]),this._triggerRenderFrame()),(Object.keys(o).length||Kf(i))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=t,this._camera=n,this._transformProvider=new tp(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new df(t),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r);let i=this._el;this._listeners=[[i,`touchstart`,{passive:!0}],[i,`touchmove`,{passive:!1}],[i,`touchend`,void 0],[i,`touchcancel`,void 0],[i,`mousedown`,void 0],[i,`mousemove`,void 0],[i,`mouseup`,void 0],[this._ownerDocument,`mousemove`,{capture:!0}],[this._ownerDocument,`mouseup`,void 0],[i,`mouseover`,void 0],[i,`mouseout`,void 0],[i,`dblclick`,void 0],[i,`click`,void 0],[i,`keydown`,{capture:!1}],[i,`keyup`,void 0],[i,`wheel`,{passive:!1}],[i,`contextmenu`,void 0],[this._ownerWindow,`blur`,void 0]];for(let[t,n,r]of this._listeners)t.addEventListener(n,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(let[t,n,r]of this._listeners)t.removeEventListener(n,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){let n=this._map,r=n.getCanvasContainer();this._add(`mapEvent`,new mf(n,t));let i=n.boxZoom=new gf(n,t,this._transformProvider);this._add(`boxZoom`,i),t.interactive&&t.boxZoom&&i.enable();let a=n.cooperativeGestures=new ep(n,t.cooperativeGestures);this._add(`cooperativeGestures`,a),t.cooperativeGestures&&a.enable();let o=new xf(n,this._transformProvider),s=new Yf(n,this._transformProvider);n.doubleClickZoom=new Jf(s,o),this._add(`tapZoom`,o),this._add(`clickZoom`,s),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();let c=new Xf;this._add(`tapDragZoom`,c);let l=n.touchPitch=new Hf(n);this._add(`touchPitch`,l),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);let u=()=>n.project(n.getCenter()),d=Of(t,u),f=kf(t),p=Af(t,u);n.dragRotate=new Qf(t,d,f,p),this._add(`mouseRotate`,d,[`mousePitch`]),this._add(`mousePitch`,f,[`mouseRotate`,`mouseRoll`]),this._add(`mouseRoll`,p,[`mousePitch`]),t.interactive&&t.dragRotate&&n.dragRotate.enable();let m=wf(t),h=new Nf(t,n);n.dragPan=new Zf(r,m,h),this._add(`mousePan`,m),this._add(`touchPan`,h,[`touchZoom`,`touchRotate`]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);let g=new Bf,_=new Rf;n.touchZoomRotate=new $f(r,_,g,c),this._add(`touchRotate`,g,[`touchPan`,`touchZoom`]),this._add(`touchZoom`,_,[`touchPan`,`touchRotate`]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate),this._add(`blockableMapEvent`,new hf(n));let v=n.scrollZoom=new qf(n,()=>this._triggerRenderFrame(),this._transformProvider);this._add(`scrollZoom`,v,[`mousePan`]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);let y=n.keyboard=new Wf(n,this._transformProvider);this._add(`keyboard`,y),t.interactive&&t.keyboard&&n.keyboard.enable()}_add(t,n,r){this._handlers.push({handlerName:t,handler:n,allowed:r}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Gf(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,r){for(let i in t)if(i!==r&&!n?.includes(i))return!0;return!1}_getMapTouches(t){let n=[];for(let r of t){let t=r.target;this._el.contains(t)&&n.push(r)}return n}mergeHandlerResult(t,n,r,i,o){if(!r)return;a(t,r);let s={handlerName:i,originalEvent:r.originalEvent||o};r.zoomDelta!==void 0&&(n.zoom=s),r.panDelta!==void 0&&(n.drag=s),r.rollDelta!==void 0&&(n.roll=s),r.pitchDelta!==void 0&&(n.pitch=s),r.bearingDelta!==void 0&&(n.rotate=s)}_applyChanges(){let t={},n={},r={};for(let[o,s,c]of this._changes)o.panDelta&&(t.panDelta=(t.panDelta||new i(0,0))._add(o.panDelta)),o.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(t.rollDelta=(t.rollDelta||0)+o.rollDelta),o.around!==void 0&&(t.around=o.around),o.pinchAround!==void 0&&(t.pinchAround=o.pinchAround),o.noInertia&&(t.noInertia=o.noInertia),a(n,s),a(r,c);this._updateMapTransform(t,n,r),this._changes=[]}_updateMapTransform(t,n,r){let i=this._map,a=this._camera.getTransformForUpdate(),o=i.terrain;if(!Kf(t)&&!(o&&this._terrainMovement)){this._fireEvents(n,r,!0);return}this._camera.stop(!0);let{panDelta:s,zoomDelta:c,bearingDelta:l,pitchDelta:u,rollDelta:d,around:f,pinchAround:p}=t;p!==void 0&&(f=p),f||=this._camera.transform.centerPoint,o&&!a.isPointOnMapSurface(f)&&(f=a.centerPoint);let m={panDelta:s,zoomDelta:c,rollDelta:d,pitchDelta:u,bearingDelta:l,around:f};this._camera.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(f)&&(f=a.centerPoint);let h=f.distSqr(a.centerPoint)<.01?a.center:a.screenPointToLocation(s?f.sub(s):f);this._handleMapControls({terrain:o,tr:a,deltasForHelper:m,preZoomAroundLoc:h,combinedEventsInProgress:n,panDelta:s}),this._camera.applyUpdatedTransform(a),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,r,!0)}_handleMapControls({terrain:t,tr:n,deltasForHelper:r,preZoomAroundLoc:i,combinedEventsInProgress:a,panDelta:o}){let s=this._camera.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(r,n),!t){s.handleMapControlsPan(r,n,i);return}if(s.useGlobeControls){!this._terrainMovement&&(a.drag||a.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),s.handleMapControlsPan(r,n,i);return}if(!this._terrainMovement&&(a.drag||a.zoom)){this._terrainMovement=!0,this._camera.elevationFreeze=!0,s.handleMapControlsPan(r,n,i);return}if(a.drag&&this._terrainMovement&&o){n.setCenter(n.screenPointToLocation(n.centerPoint.sub(o)));return}s.handleMapControlsPan(r,n,i)}_fireEvents(t,n,r){let i=Gf(this._eventsInProgress),a=Gf(t),o={};for(let n in t){let{originalEvent:r}=t[n];this._eventsInProgress[n]||(o[`${n}start`]=r),this._eventsInProgress[n]=t[n]}!i&&a&&this._fireEvent(`movestart`,a.originalEvent);for(let t in o)this._fireEvent(t,o[t]);a&&this._fireEvent(`move`,a.originalEvent);for(let n in t){let{originalEvent:r}=t[n];this._fireEvent(n,r)}let s={},c;for(let t in this._eventsInProgress){let{handlerName:r,originalEvent:i}=this._eventsInProgress[t];this._handlersById[r].isActive()||(delete this._eventsInProgress[t],c=n[r]||i,s[`${t}end`]=c)}for(let t in s)this._fireEvent(t,s[t]);let l=Gf(this._eventsInProgress),u=(i||a)&&!l;if(u&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1;let t=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(t)}if(r&&u){this._updatingCamera=!0;let t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=t=>t!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new rp(`renderFrame`,{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}},op=class extends _{constructor(t){super(),this._renderFrameCallback=()=>{let t=Math.min((U()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new ws,this.cameraHelper=new As,t.minZoom!==void 0&&this.transform.setMinZoom(t.minZoom),t.maxZoom!==void 0&&this.transform.setMaxZoom(t.maxZoom),t.minPitch!==void 0&&this.transform.setMinPitch(t.minPitch),t.maxPitch!==void 0&&this.transform.setMaxPitch(t.maxPitch),t.renderWorldCopies!==void 0&&this.transform.setRenderWorldCopies(t.renderWorldCopies),t.transformConstrain!==null&&this.transform.setConstrainOverride(t.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=t.bearingSnap,this._zoomSnap=t.zoomSnap,this._requestRenderFrame=t.requestRenderFrame,this._cancelRenderFrame=t.cancelRenderFrame,this.terrain=t.terrain,this._centerClampedToGround=t.centerClampedToGround??!0,this.transformCameraUpdate=t.transformCameraUpdate??null,this._stopHandlers=t.stopHandlers??(()=>{}),this.on(`moveend`,()=>{delete this._requestedCameraState})}migrateProjection(t,n){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=n}getCenter(){return new F(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,n){return this.jumpTo({elevation:t},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,n,r){return t=i.convert(t).mult(-1),this.panTo(this.transform.center,a({offset:t},n),r)}panTo(t,n,r){return this.easeTo(a({center:t},n),r)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,r){return this.easeTo(a({zoom:t},n),r)}zoomIn(t,n){return this.zoomTo(cr(this.getZoom()+1,this._zoomSnap),t,n),this}zoomOut(t,n){return this.zoomTo(cr(this.getZoom()-1,this._zoomSnap),t,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,n){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new G(`movestart`,n)).fire(new G(`move`,n)).fire(new G(`moveend`,n))),this}getBearing(){return this.transform.bearing}setZoomSnap(t){return this._zoomSnap=t,this}getZoomSnap(){return this._zoomSnap}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,r){return this.easeTo(a({bearing:t},n),r)}resetNorth(t,n){return this.rotateTo(0,a({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(a({bearing:0,pitch:0,roll:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing()){_.easeFunc(i),this.terrain&&!t.freezeElevation&&this._updateElevation(i),this.applyUpdatedTransform(r),this._fireMoveEvents(n)},r=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n,r)},t),this}_prepareEase(t,n,r={}){this._moving=!0,!n&&!r.moving&&this.fire(new G(`movestart`,t)),this._zooming&&!r.zooming&&this.fire(new G(`zoomstart`,t)),this._rotating&&!r.rotating&&this.fire(new G(`rotatestart`,t)),this._pitching&&!r.pitching&&this.fire(new G(`pitchstart`,t)),this._rolling&&!r.rolling&&this.fire(new G(`rollstart`,t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this.elevationFreeze=!0}_updateElevation(t){(this._elevationStart===void 0||this._elevationCenter===void 0)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){let r=this._elevationTarget-this._elevationStart,i=(n-(r*t+this._elevationStart))/(1-t);this._elevationStart+=t*(r-i),this._elevationTarget=n}this.transform.setElevation(pt.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}getTransformForUpdate(){return!this.transformCameraUpdate&&!this.terrain?this.transform:(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState)}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};let n=t.getCameraLngLat(),r=t.getCameraAltitude(),i=this.terrain?this.terrain.getElevationForLngLatZoom(n,t.zoom):0;if(rthis._elevateCameraIfInsideTerrain(t)),this.transformCameraUpdate&&n.push(t=>this.transformCameraUpdate(t)),!n.length)return;let r=t.clone();for(let t of n){let n=r.clone(),{center:i,zoom:a,roll:o,pitch:s,bearing:c,elevation:l}=t(n);i&&n.setCenter(i),l!==void 0&&n.setElevation(l),a!==void 0&&n.setZoom(a),o!==void 0&&n.setRoll(o),s!==void 0&&n.setPitch(s),c!==void 0&&n.setBearing(c),r.apply(n,!1)}this.transform.apply(r,!1)}_fireMoveEvents(t){this.fire(new G(`move`,t)),this._zooming&&this.fire(new G(`zoom`,t)),this._rotating&&this.fire(new G(`rotate`,t)),this._pitching&&this.fire(new G(`pitch`,t)),this._rolling&&this.fire(new G(`roll`,t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let r=this._zooming,i=this._rotating,a=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new G(`zoomend`,t)),i&&this.fire(new G(`rotateend`,t)),a&&this.fire(new G(`pitchend`,t)),o&&this.fire(new G(`rollend`,t)),this.fire(new G(`moveend`,t))}flyTo(t,n){if(!t.essential&&Tr.prefersReducedMotion){let r=ue(t,[`center`,`zoom`,`bearing`,`pitch`,`roll`,`elevation`,`padding`]);return this.jumpTo(r,n)}this.stop(),t=a({offset:[0,0],speed:1.2,curve:1.42,easing:ur},t),`zoom`in t&&this._zoomSnap&&(t.zoom=cr(t.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),o=r.bearing,s=r.pitch,c=r.roll,l=r.padding,u=`bearing`in t?this._normalizeBearing(t.bearing,o):o,d=`pitch`in t?+t.pitch:s,f=`roll`in t?this._normalizeBearing(t.roll,c):c,p=`padding`in t?t.padding:r.padding,m=i.convert(t.offset),h=r.centerPoint.add(m),g=r.screenPointToLocation(h),_=this.cameraHelper.handleFlyTo(r,{bearing:u,pitch:d,roll:f,padding:p,locationAtOffset:g,offsetAsPoint:m,center:t.center,minZoom:t.minZoom,zoom:t.zoom}),v=t.curve,y=Math.max(r.width,r.height),b=y/_.scaleOfZoom,x=_.pixelPathLength,S=y/_.scaleOfMinZoom;v=Math.min(v,Math.sqrt(S/x*2));let C=v*v;function w(t){let n=(b*b-y*y+(t?-1:1)*C*C*x*x)/(2*(t?b:y)*C*x);return Math.log(Math.sqrt(n*n+1)-n)}function T(t){return(Math.exp(t)-Math.exp(-t))/2}function E(t){return(Math.exp(t)+Math.exp(-t))/2}function D(t){return T(t)/E(t)}let O=w(!1),k=function(t){return E(O)/E(O+v*t)},A=function(t){return y*((E(O)*D(O+v*t)-T(O))/C)/x},j=(w(!0)-O)/v;if(Math.abs(x)<2e-6||!isFinite(j)){if(Math.abs(y-b)<1e-6)return this.easeTo(t,n);let r=b0,k=t=>Math.exp(r*v*t)}if(`duration`in t)t.duration=+t.duration;else{let n=`screenSpeed`in t?+t.screenSpeed/v:+t.speed;t.duration=1e3*j/n}return t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=o!==u,this._pitching=d!==s,this._rolling=f!==c,this._padding=!r.isPaddingEqual(p),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(_.targetCenter),this._ease(i=>{let a=i*j,g=1/k(a),v=A(a);this._rotating&&r.setBearing(pt.number(o,u,i)),this._pitching&&r.setPitch(pt.number(s,d,i)),this._rolling&&r.setRoll(pt.number(c,f,i)),this._padding&&(r.interpolatePadding(l,p,i),h=r.centerPoint.add(m)),_.easeFunc(i,g,v,h),this.terrain&&!t.freezeElevation&&this._updateElevation(i),this.applyUpdatedTransform(r),this._fireMoveEvents(n)},()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},t),this}isEasing(){return!!this._easeFrameId}stop(t){return this._stop(t)}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,n)}return t||this._stopHandlers(),this}_ease(t,n,r){r.animate===!1||r.duration===0?(t(1),n()):(this._easeStart=U(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=de(t,-180,180);let r=Math.abs(t-n);return Math.abs(t-360-n)MapLibre`};var cp=class{constructor(t=np){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=t}getDefaultPosition(){return`bottom-right`}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=W.create(`details`,`maplibregl-ctrl maplibregl-ctrl-attrib`),this._compactButton=W.create(`summary`,`maplibregl-ctrl-attrib-button`,this._container),this._compactButton.addEventListener(`click`,this._toggleAttribution),this._setElementTitle(this._compactButton,`ToggleAttribution`),this._innerContainer=W.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(t,n){let r=this._map._getUIString(`AttributionControl.${n}`);t.title=r,t.setAttribute(`aria-label`,r)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(t=>typeof t==`string`?t:``)):typeof this.options.customAttribution==`string`&&t.push(this.options.customAttribution)),this._map.style.stylesheet){let t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}let n=this._map.style.tileManagers;for(let r in n){let i=n[r];if(i.used||i.usedForTerrain){let n=i.getSource();n.attribution&&!t.includes(n.attribution)&&t.push(n.attribution)}}t=t.filter(t=>String(t).trim()),t.sort((t,n)=>t.length-n.length),t=t.filter((n,r)=>{for(let i=r+1;i{let t=this._container.children;if(t.length){let n=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&n.classList.add(`maplibregl-compact`):n.classList.remove(`maplibregl-compact`)}},this.options=t}getDefaultPosition(){return`bottom-left`}onAdd(t){this._map=t,this._compact=this.options?.compact,this._container=W.create(`div`,`maplibregl-ctrl`);let n=W.create(`a`,`maplibregl-ctrl-logo`);return n.target=`_blank`,n.rel=`noopener nofollow`,n.href=`https://maplibre.org/`,n.setAttribute(`aria-label`,this._map._getUIString(`LogoControl.Title`)),n.setAttribute(`rel`,`noopener nofollow`),this._container.appendChild(n),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}},up=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){let n=this._currentlyRunning,r=n?this._queue.concat(n):this._queue;for(let n of r)if(n.id===t){n.cancelled=!0;return}}run(t=0){if(this._currentlyRunning)throw Error(`Attempting to run(), but is already running.`);let n=this._currentlyRunning=this._queue;this._queue=[];for(let r of n)if(!r.cancelled&&(r.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const ip=ct([{name:`a_pos3d`,type:`Int16`,components:3}]);var fp=class extends _{constructor(t){super(),this._lastTilesetChange=U(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(t,n){this.tileManager.update(t,n),this._renderableTilesKeys=[];let r={};for(let i of Na(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[i.key]=!0,this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.terrainRttPosMatrix32f=new Float32Array(16),In(i.terrainRttPosMatrix32f,0,I,I,0,0,1),this._tiles[i.key]=new ya(i,this.tileSize),this._lastTilesetChange=U());for(let t in this._tiles)r[t]||(this._tiles[t].releaseRTT(this.tileManager.map.painter),delete this._tiles[t])}releaseRTT(t){for(let n in this._tiles){let r=this._tiles[n];(r.tileID.equals(t)||r.tileID.isChildOf(t)||t.isChildOf(r.tileID))&&r.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let t in this._tiles)this._tiles[t].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,n){return n?this._getTerrainCoordsForTileRanges(t,n):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){let n={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID,a=t.clone(),o=Lt();if(i.canonical.equals(t.canonical))In(o,0,I,I,0,0,1);else if(i.canonical.isChildOf(t.canonical)){let n=i.canonical.z-t.canonical.z,r=i.canonical.x-(i.canonical.x>>n<>n<>n;In(o,0,s,s,0,0,1),N(o,o,[-r*s,-a*s,0])}else if(t.canonical.isChildOf(i.canonical)){let n=t.canonical.z-i.canonical.z,r=t.canonical.x-(t.canonical.x>>n<>n<>n;In(o,0,I,I,0,0,1),N(o,o,[r*s,a*s,0]),P(o,o,[1/2**n,1/2**n,0])}else continue;a.terrainRttPosMatrix32f=new Float32Array(o),n[r]=a}return n}_getTerrainCoordsForTileRanges(t,n){let r={};for(let i of this._renderableTilesKeys){let a=this._tiles[i].tileID;if(!this._isWithinTileRanges(a,n))continue;let o=t.clone(),s=Lt();if(a.canonical.z===t.canonical.z){let n=t.canonical.x-a.canonical.x+t.wrap*(1<t.canonical.z){let n=a.canonical.z-t.canonical.z,r=a.canonical.x-(a.canonical.x>>n<>n<>n),c=t.canonical.y-(a.canonical.y>>n),l=I>>n;In(s,0,l,l,0,0,1),N(s,s,[-r*l+o*I,-i*l+c*I,0])}else{let n=t.canonical.z-a.canonical.z,r=t.canonical.x-(t.canonical.x>>n<>n<>n)-a.canonical.x,c=(t.canonical.y>>n)-a.canonical.y,l=I<r.maxzoom&&(i=r.maxzoom),i=r.minzoom&&!a?.dem;)a=this.findTileInCaches(t.scaledTo(i--).key);return a}findTileInCaches(t){let n=this.tileManager.getTileByID(t);return n||(n=this.tileManager._outOfViewCache.getByKey(t),n)}anyTilesAfterTime(t=U()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,n){let r=n[t.canonical.z];return!!r&&(t.wrap>r.minWrap||t.wrap=r.minTileXWrapped&&t.canonical.x<=r.maxTileXWrapped&&t.canonical.y>=r.minTileY&&t.canonical.y<=r.maxTileY)}},pp=class{constructor(t,n,r,i=`auto`){this._meshCache={},this.painter=t,this.tileManager=new fp(n),this.options=r,this.exaggeration=typeof r.exaggeration==`number`?r.exaggeration:1,this._terrainSkirtLength=i,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboCoordsTexture&&=(this._fboCoordsTexture.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null),this._coordsTexture&&=(this._coordsTexture.destroy(),null);for(let t in this._meshCache)this._meshCache[t].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(t,n,r,i=I){let a=t.normalizeCoordinates(n,r,i);if(!a)return 0;let o=this.getTerrainData(a.tileID),s=o.tile?.dem;if(!s)return 0;let c=mr([],[a.x/i*I,a.y/i*I],o.u_terrain_matrix),l=[c[0]*s.dim,c[1]*s.dim];return s.sampleBilinear(l[0],l[1])}getElevationForLngLatZoom(t,n){if(!hr(n,t.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(r,i%I,a%I,I)}getElevationForLngLat(t,n){let r=Na(n,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),i=0;for(let t of r)t.canonical.z>i&&(i=Math.min(t.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,i)}getElevation(t,n,r,i=I){return this.getDEMElevation(t,n,r,i)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){let t=this.painter.context,n=new v({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new S(t,n,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new S(t,new v({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=Fe([])}let n=this.tileManager.getSourceTile(t,!0);if(n?.dem&&(!n.demTexture||n.needsTerrainPrepare)){let t=this.painter.context;n.demTexture||=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new S(t,n.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),n.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}let r=n&&n.toString()+n.tileID.key+t.key;if(r&&!this._demMatrixCache[r]){let i=this.tileManager.getSource().maxzoom,a=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=i?a=t.canonical.z-i:b(`cannot calculate elevation if elevation maxzoom > source.maxzoom`));let o=t.canonical.x-(t.canonical.x>>a<>a<>8<<4|t>>8,n[r+3]=0;let r=new S(t,new v({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),t.gl.RGBA,{premultiply:!1});return r.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(t){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();let n=new Uint8Array(4),r=this.painter.context,i=r.gl,a=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer(`coords`).framebuffer),i.readPixels(a,s-o-1,1,1,i.RGBA,i.UNSIGNED_BYTE,n),r.bindFramebuffer.set(null);let c=n[0]+(n[2]>>4<<8),l=n[1]+((n[2]&15)<<8),u=this.coordsIndex[255-n[3]],d=u&&this.tileManager.getTileByID(u);if(!d)return null;let f=this._coordsTextureSize,p=(1<0,r=n&&t.canonical.y===0,i=n&&t.canonical.y===(1<!t._layers[r].isHidden(n));let r=/* @__PURE__ */ new Set;for(let n of this._renderableLayerIds){let i=t._layers[n],a=i.source;a&&sp[i.type]&&r.add(a)}this._coordsAscending={},this._rttFingerprints={};for(let n of r){let r=t.tileManagers[n];if(!r)continue;this._coordsAscending[n]={};let i=this._coordsAscending[n],a=r.getSource(),o=a instanceof ia?a.terrainTileRanges:null;for(let t of r.getVisibleCoordinates()){let n=this.terrain.tileManager.getTerrainCoords(t,o);for(let t in n)i[t]||=[],i[t].push(n[t])}this._rttFingerprints[n]={};let s=this._rttFingerprints[n],c=r.getState().revision;for(let t in i)s[t]=`${i[t].map(t=>t.key).sort().join()}#${c}`}for(let t of this._renderableTiles)for(let n in this._rttFingerprints){let r=this._rttFingerprints[n][t.tileID.key];r&&r!==t.rttFingerprint[n]&&t.releaseRTT(this.painter)}}renderLayer(t,n){if(t.isHidden(this.painter.transform.zoom))return!1;let r={...n,isRenderingToTexture:!0},i=t.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(sp[i]&&((!this._prevType||!sp[this._prevType])&&this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(t.id),!o))return!0;if(sp[this._prevType]||sp[i]&&o){this._prevType=i;let t=this._stacks.length-1,n=this._stacks[t]||[];for(let i of this._renderableTiles){if(this._rttTiles.push(i),i.getRTT(t))continue;let o=i.acquireRTT(a,t,this.rttSize);a.bindRTT(o),a.context.clear({color:z.transparent,stencil:0}),a.currentStencilSource=void 0;for(let t of n){let n=a.style._layers[t],o=n.source?this._coordsAscending[n.source][i.tileID.key]:[i.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),a.renderTileClippingMasks(n,o,!0),a.renderLayer(a,a.style.tileManagers[n.source],n,o,r),n.source&&(i.rttFingerprint[n.source]=this._rttFingerprints[n.source][i.tileID.key])}}return Kd(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],sp[i]}return!1}};const dp={"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`},mp=vr,gp={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:np,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:p.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:`sans-serif`,pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:`auto`,zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var yp=class extends _{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(t){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new up,this._controls=[],this._mapId=Te(),this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=t=>{if(t.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),!this.style){this.fire(new Ur(`webglcontextlost`,{originalEvent:t}));return}for(let t of Object.values(this.style._layers))if(t.type===`custom`&&console.warn(`Custom layer with id '${t.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),t._listeners)for(let[n]of Object.entries(t._listeners))console.warn(`Custom layer with id '${t.id}' had event listeners for event '${n}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new Ur(`webglcontextlost`,{originalEvent:t}))},this._contextRestored=t=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.painter&&(this.resize(),this._update(),this._resizeInternal(),this.fire(new Ur(`webglcontextrestored`,{originalEvent:t})))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let n={...gp,...t,canvasContextAttributes:{...gp.canvasContextAttributes,...t.canvasContextAttributes}};if(n.minZoom!=null&&n.maxZoom!=null&&n.minZoom>n.maxZoom)throw Error(`maxZoom must be greater than or equal to minZoom`);if(n.minPitch!=null&&n.maxPitch!=null&&n.minPitch>n.maxPitch)throw Error(`maxPitch must be greater than or equal to minPitch`);if(n.minPitch!=null&&n.minPitch<0)throw Error(`minPitch must be greater than or equal to 0`);if(n.maxPitch!=null&&n.maxPitch>180)throw Error(`maxPitch must be less than or equal to 180`);if(this._camera=new op({minZoom:n.minZoom,maxZoom:n.maxZoom,minPitch:n.minPitch,maxPitch:n.maxPitch,bearingSnap:n.bearingSnap,zoomSnap:n.zoomSnap,renderWorldCopies:n.renderWorldCopies,centerClampedToGround:n.centerClampedToGround,terrain:this.terrain,transformConstrain:n.transformConstrain,requestRenderFrame:t=>this._requestRenderFrame(t),cancelRenderFrame:t=>this._cancelRenderFrame(t),transformCameraUpdate:n.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes={...n.canvasContextAttributes},this._trackResize=n.trackResize===!0,this._terrainSkirtLength=n.terrainSkirtLength,this._refreshExpiredTiles=n.refreshExpiredTiles===!0,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=n.crossSourceCollisions===!0,this._collectResourceTiming=n.collectResourceTiming===!0,this._locale={...dp,...n.locale},this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this._zoomLevelsToOverscale=n.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=n.cancelPendingTileRequestsWhileZooming===!0,this.setAnisotropicFilterPitch(n.anisotropicFilterPitch),n.reduceMotion!==void 0&&(Tr.prefersReducedMotion=n.reduceMotion),this._imageQueueHandle=Ar.addThrottleControl(()=>this.isMoving()),this._requestManager=new Nr(n.transformRequest),this._container=this._resolveContainer(n.container),n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),!this.painter)return;this.on(`move`,()=>this._update(!1)),this.on(`moveend`,()=>this._update(!1)),this.on(`zoom`,()=>this._update(!0)),this.on(`terrain`,()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)}),this.once(`idle`,()=>this._idleTriggered=!0),this._handlers=new ap(this,this._camera,n),typeof window<`u`&&(this._ownerWindow.addEventListener(`online`,this._onWindowOnline,!1),this._setupResizeObserver());let r=typeof n.hash==`string`&&n.hash||void 0;this._hash=n.hash?new rf(r).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,a({},n.fitBoundsOptions,{duration:0}))));let i=typeof n.style==`string`||n.style?.projection?.type!==`globe`;this.resize(null,i),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style&&this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}),n.attributionControl&&this.addControl(new cp(typeof n.attributionControl==`boolean`?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new lp,n.logoPosition),this.on(`style.load`,()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let t=ue(this.style.stylesheet,[`center`,`zoom`,`bearing`,`pitch`,`roll`]);this.jumpTo(t)}}),this.on(`data`,t=>{this._update(t.dataType===`style`),this.fire(t.dataType===`style`?new Ir(`styledata`,t):new K(`sourcedata`,t))}),this.on(`dataloading`,t=>{this.fire(t.dataType===`style`?new Ir(`styledataloading`,t):new K(`sourcedataloading`,t))}),this.on(`dataabort`,t=>{this.fire(new K(`sourcedataabort`,t))})}_getMapId(){return this._mapId}setGlobalStateProperty(t,n){return this.style.setGlobalStateProperty(t,n),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(t,n){if(n===void 0&&(n=t.getDefaultPosition?t.getDefaultPosition():`top-right`),!t?.onAdd)return this.fire(new y(Error(`Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.`)));let r=t.onAdd(this);this._controls.push(t);let i=this._controlPositions[n];return n.includes(`bottom`)?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(t){if(!t?.onRemove)return this.fire(new y(Error(`Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.`)));let n=this._controls.indexOf(t);return n>-1&&this._controls.splice(n,1),t.onRemove(this),this}hasControl(t){return this._controls.includes(t)}coveringTiles(t){return Na(this._camera.transform,t)}setTransformCameraUpdate(t){this._camera.transformCameraUpdate=t}getCenter(){return new F(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(t,n){return this._camera.setCenter(t,n),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(t,n){return this._camera.setCenterElevation(t,n),this}setCenterClampedToGround(t){this._camera.setCenterClampedToGround(t)}panBy(t,n,r){return this._camera.panBy(t,n,r),this}panTo(t,n,r){return this._camera.panTo(t,n,r),this}getZoom(){return this._camera.transform.zoom}setZoom(t,n){return this._camera.setZoom(t,n),this}zoomTo(t,n,r){return this._camera.zoomTo(t,n,r),this}zoomIn(t,n){return this._camera.zoomIn(t,n),this}zoomOut(t,n){return this._camera.zoomOut(t,n),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(t,n){return this._camera.setVerticalFieldOfView(t,n),this}getBearing(){return this._camera.transform.bearing}setBearing(t,n){return this._camera.setBearing(t,n),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(t){return this._camera.setZoomSnap(t),this}getPadding(){return this._camera.transform.padding}setPadding(t,n){return this._camera.setPadding(t,n),this}rotateTo(t,n,r){return this._camera.rotateTo(t,n,r),this}resetNorth(t,n){return this._camera.resetNorth(t,n),this}resetNorthPitch(t,n){return this._camera.resetNorthPitch(t,n),this}snapToNorth(t,n){return this._camera.snapToNorth(t,n),this}getPitch(){return this._camera.transform.pitch}setPitch(t,n){return this._camera.setPitch(t,n),this}getRoll(){return this._camera.transform.roll}setRoll(t,n){return this._camera.setRoll(t,n),this}cameraForBounds(t,n){return this._camera.cameraForBounds(t,n)}fitBounds(t,n,r){return this._camera.fitBounds(t,n,r),this}fitScreenCoordinates(t,n,r,i,a){return this._camera.fitScreenCoordinates(t,n,r,i,a),this}jumpTo(t,n){return this._camera.jumpTo(t,n),this}calculateCameraOptionsFromCameraLngLatAltRotation(t,n,r,i,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(t,n,r,i,a)}easeTo(t,n){return this._camera.easeTo(t,n),this}flyTo(t,n){return this._camera.flyTo(t,n),this}stop(){return this._camera.stop(),this}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(F.convert(t),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(t,n,r,i){return i==null&&this.terrain&&(i=this.terrain.getElevationForLngLat(r,this._camera.transform)),this._camera.calculateCameraOptionsFromTo(t,n,r,i)}resize(t,n=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(n);let r=!this._camera._moving;return r&&(this.stop(),this.fire(new G(`movestart`,t)).fire(new G(`move`,t))),this.fire(new Pr(`resize`,t)),r&&this.fire(new G(`moveend`,t)),this}_resizeInternal(t=!0){let[n,r]=this._containerDimensions(),i=this._getClampedPixelRatio(n,r);if(this._resizeCanvas(n,r,i),this.painter.resize(n,r,i),this.painter.overLimit()){let t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];let i=this._getClampedPixelRatio(n,r);this._resizeCanvas(n,r,i),this.painter.resize(n,r,i)}this._resizeTransform(t)}_resizeTransform(t=!0){let[n,r]=this._containerDimensions();this._camera.transform.resize(n,r,t),this._camera._requestedCameraState?.resize(n,r,t)}_getClampedPixelRatio(t,n){let{0:r,1:i}=this._maxCanvasSize,a=this.getPixelRatio(),o=t*a,s=n*a,c=o>r?r/o:1,l=s>i?i/s:1;return Math.min(c,l)*a}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(t){return this._camera.transform.setMaxBounds(Ii.convert(t)),this._update()}setMinZoom(t){if(t??=-2,t>=-2&&t<=this._camera.transform.maxZoom){let n=this._camera.transform.zoom,r=this._camera.getTransformForUpdate();return r.setMinZoom(t),this._camera.applyUpdatedTransform(r),this._update(),n!==this._camera.transform.zoom&&this.fire(new G(`zoomstart`)).fire(new G(`zoom`)).fire(new G(`zoomend`)).fire(new G(`movestart`)).fire(new G(`move`)).fire(new G(`moveend`)),this}else throw Error(`minZoom must be between -2 and the current maxZoom, inclusive`)}getMinZoom(){return this._camera.transform.minZoom}setMaxZoom(t){if(t??=22,t>=this._camera.transform.minZoom){let n=this._camera.transform.zoom,r=this._camera.getTransformForUpdate();return r.setMaxZoom(t),this._camera.applyUpdatedTransform(r),this._update(),n!==this._camera.transform.zoom&&this.fire(new G(`zoomstart`)).fire(new G(`zoom`)).fire(new G(`zoomend`)).fire(new G(`movestart`)).fire(new G(`move`)).fire(new G(`moveend`)),this}else throw Error(`maxZoom must be greater than the current minZoom`)}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(t){if(t??=0,t<0)throw Error(`minPitch must be greater than or equal to 0`);if(t>=0&&t<=this._camera.transform.maxPitch){let n=this._camera.transform.pitch,r=this._camera.getTransformForUpdate();return r.setMinPitch(t),this._camera.applyUpdatedTransform(r),this._update(),n!==this._camera.transform.pitch&&this.fire(new G(`pitchstart`)).fire(new G(`pitch`)).fire(new G(`pitchend`)).fire(new G(`movestart`)).fire(new G(`move`)).fire(new G(`moveend`)),this}else throw Error(`minPitch must be between 0 and the current maxPitch, inclusive`)}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(t){if(t??=60,t>180)throw Error(`maxPitch must be less than or equal to 180`);if(t>=this._camera.transform.minPitch){let n=this._camera.transform.pitch,r=this._camera.getTransformForUpdate();return r.setMaxPitch(t),this._camera.applyUpdatedTransform(r),this._update(),n!==this._camera.transform.pitch&&this.fire(new G(`pitchstart`)).fire(new G(`pitch`)).fire(new G(`pitchend`)).fire(new G(`movestart`)).fire(new G(`move`)).fire(new G(`moveend`)),this}else throw Error(`maxPitch must be greater than the current minPitch`)}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(t){if(t??=20,t>180)throw Error(`anisotropicFilterPitch must be less than or equal to 180`);if(t<0)throw Error(`anisotropicFilterPitch must be greater than or equal to 0`);return this._anisotropicFilterPitch=t,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(t){return this._camera.transform.setRenderWorldCopies(t),this._update()}setTransformConstrain(t){return this._camera.transform.setConstrainOverride(t),this._update()}project(t){return this._camera.transform.locationToScreenPoint(F.convert(t),this.style&&this.terrain)}unproject(t){return this._camera.transform.screenPointToLocation(i.convert(t),this.terrain)}isMoving(){return this._camera.isMoving()||this._handlers?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlers?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlers?.isRotating()||!1}_createDelegatedListener(t,n,r){if(t===`mouseenter`||t===`mouseover`){let i=!1;return{layers:n,listener:r,delegates:{mousemove:a=>{let o=n.filter(t=>this.getLayer(t)),s=o.length===0?[]:this.queryRenderedFeatures(a.point,{layers:o});s.length?i||(i=!0,r.call(this,new Lr(t,this,a.originalEvent,{features:s}))):i=!1},mouseout:()=>{i=!1}}}}else if(t===`mouseleave`||t===`mouseout`){let i=!1;return{layers:n,listener:r,delegates:{mousemove:a=>{let o=n.filter(t=>this.getLayer(t));(o.length===0?[]:this.queryRenderedFeatures(a.point,{layers:o})).length?i=!0:i&&(i=!1,r.call(this,new Lr(t,this,a.originalEvent)))},mouseout:n=>{i&&(i=!1,r.call(this,new Lr(t,this,n.originalEvent)))}}}}else{let i=t=>{let i=n.filter(t=>this.getLayer(t)),a=i.length===0?[]:this.queryRenderedFeatures(t.point,{layers:i});a.length&&(t.features=a,r.call(this,t),delete t.features)};return{layers:n,listener:r,delegates:{[t]:i}}}}_saveDelegatedListener(t,n){this._delegatedListeners||={},this._delegatedListeners[t]||=[],this._delegatedListeners[t].push(n)}_removeDelegatedListener(t,n,r){if(!this._delegatedListeners?.[t])return;let i=this._delegatedListeners[t];for(let t=0;tn.includes(t))){for(let t in a.delegates)this.off(t,a.delegates[t]);i.splice(t,1);return}}}on(t,n,r){if(r===void 0)return super.on(t,n);let i=typeof n==`string`?[n]:n,a=this._createDelegatedListener(t,i,r);this._saveDelegatedListener(t,a);for(let t in a.delegates)this.on(t,a.delegates[t]);return{unsubscribe:()=>{this._removeDelegatedListener(t,i,r)}}}once(t,n,r){if(r===void 0)return super.once(t,n);let i=typeof n==`string`?[n]:n,a=this._createDelegatedListener(t,i,r);for(let n in a.delegates){let o=a.delegates[n];a.delegates[n]=(...n)=>{this._removeDelegatedListener(t,i,r),o(...n)}}this._saveDelegatedListener(t,a);for(let t in a.delegates)this.once(t,a.delegates[t]);return this}off(t,n,r){if(r===void 0)return super.off(t,n);let i=typeof n==`string`?[n]:n;return this._removeDelegatedListener(t,i,r),this}queryRenderedFeatures(t,n){if(!this.style)return[];let r,a=t instanceof i||Array.isArray(t),o=a?t:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(n||=(a?{}:t)||{},o instanceof i||typeof o[0]==`number`)r=[i.convert(o)];else{let t=i.convert(o[0]),n=i.convert(o[1]);r=[t,new i(n.x,t.y),n,new i(t.x,n.y),t]}return this.style.queryRenderedFeatures(r,n,this._camera.transform)}querySourceFeatures(t,n){return this.style.querySourceFeatures(t,n)}setStyle(t,n){return n=a({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},n),n.diff!==!1&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(t,n))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){let n=this._locale[t];if(n==null)throw Error(`Missing UI string '${t}'`);return n}_updateStyle(t,n){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,n.transformStyle&&this.style&&!this.style._loaded){this.style.once(`style.load`,()=>this._updateStyle(t,n));return}let r=this.style&&n.transformStyle?this.style.serialize():void 0;if(this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t)this.style=new bc(this,n||{});else return this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style,this;return this.style.setEventedParent(this,{style:this.style}),typeof t==`string`?this.style.loadURL(t,n,r):this.style.loadJSON(t,n,r),this}_lazyInitEmptyStyle(){this.style||(this.style=new bc(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(t,n){if(this._diffStyleRequest?.abort(),typeof t==`string`){let r=t;this._diffStyleRequest=new AbortController;let i=this._diffStyleRequest;try{let t=await this._requestManager.transformRequest(r,`Style`);if(i.signal.aborted){this._diffStyleRequest=null;return}let a=await g(t,i);this._diffStyleRequest=null,this._updateDiff(a.data,n)}catch(t){this._diffStyleRequest=null,me(t)||this.fire(new y(f(t)))}}else typeof t==`object`&&(this._diffStyleRequest=null,this._updateDiff(t,n))}_updateDiff(t,n){try{this.style.setState(t,n)&&this._update(!0)}catch(r){b(`Unable to perform style diff: ${f(r).message}. Rebuilding the style from scratch.`),this._updateStyle(t,n)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(!this.style){b(`There is no style added to the map.`);return}return this.style.loaded()}addSource(t,n){return this._lazyInitEmptyStyle(),this.style.addSource(t,n),this._update(!0)}isSourceLoaded(t){let n=this.style?.tileManagers[t];if(n===void 0){this.fire(new y(Error(`There is no tile manager with ID '${t}'`)));return}return n.loaded()}setTerrain(t,n={}){if(this.style._checkLoaded(),t&&re(this,M.terrain,{value:t},n))return this;if(this._terrainDataCallback&&this.style.off(`data`,this._terrainDataCallback),!t)this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this._camera.terrain=null,this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0);else{let n=this.style.tileManagers[t.source];if(!n)throw Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);this.terrain===null&&n.reload();for(let n in this.style._layers){let r=this.style._layers[n];r.type===`hillshade`&&r.source===t.source&&b(`You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`),r.type===`color-relief`&&r.source===t.source&&b(`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=new pp(this.painter,n,t,this._terrainSkirtLength),this.painter.renderToTexture=new hp(this.painter,this.terrain),this._camera.terrain=this.terrain,this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._terrainDataCallback=n=>{n.dataType===`style`?this.terrain.tileManager.releaseAllRTT():n.dataType===`source`&&n.tile&&(n.sourceId===t.source&&!this._camera.elevationFreeze&&(this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom))),n.source?.type===`image`?this.terrain.tileManager.releaseAllRTT():this.terrain.tileManager.releaseRTT(n.tile.tileID))},this.style.on(`data`,this._terrainDataCallback)}return this.fire(new Vr({terrain:t})),this}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let t=this.style?.tileManagers;for(let n of Object.values(t))if(!n.areTilesLoaded())return!1;return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style?.getSource(t)}setSourceTileLodParams(t,n,r){if(r){let i=this.getSource(r);if(!i)throw Error(`There is no source with ID "${r}", cannot set LOD parameters`);i.calculateTileZoom=Aa(Math.max(1,t),Math.max(1,n))}else for(let r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=Aa(Math.max(1,t),Math.max(1,n));return this._update(!0),this}refreshTiles(t,n){let r=this.style.tileManagers[t];if(!r)throw Error(`There is no tile manager with ID "${t}", cannot refresh tile`);n===void 0?r.reload(!0):r.refreshTiles(n.map(t=>new Se(t.z,t.x,t.y)))}addImage(t,n,r={}){this._lazyInitEmptyStyle();let i=this._createStyleImage(n,r);return i?(this.style.addImage(t,i),i.userImage?.onAdd&&i.userImage.onAdd(this,t),this):this}setMissingStyleImageResolver(t){return this._missingStyleImageResolver=t,this.style?.setMissingImageResolver(t),this}_createStyleImage(t,n={}){let{pixelRatio:r=1,sdf:i=!1,stretchX:a,stretchY:o,content:s,textFitWidth:c,textFitHeight:l}=n;if(t instanceof HTMLImageElement||d(t)){let{width:n,height:u,data:d}=Tr.getImageData(t);return{data:new v({width:n,height:u},d),pixelRatio:r,stretchX:a,stretchY:o,content:s,textFitWidth:c,textFitHeight:l,sdf:i,version:0}}else if(t.width===void 0||t.height===void 0)return this.fire(new y(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;else{let{width:n,height:u,data:d}=t,f=t;return{data:new v({width:n,height:u},new Uint8Array(d)),pixelRatio:r,stretchX:a,stretchY:o,content:s,textFitWidth:c,textFitHeight:l,sdf:i,version:0,userImage:f}}}updateImage(t,n){let r=this.style.getImage(t);if(!r)return this.fire(new y(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:a,data:o}=n instanceof HTMLImageElement||d(n)?Tr.getImageData(n):n;if(i===void 0||a===void 0)return this.fire(new y(Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(i!==r.data.width||a!==r.data.height)return this.fire(new y(Error(`The width and height of the updated image must be that same as the previous version of the image`)));let s=!(n instanceof HTMLImageElement||d(n));return r.data.replace(o,s),this.style.updateImage(t,r),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new y(Error(`Missing required image id`))),!1)}removeImage(t){this.style.removeImage(t)}async loadImage(t){return Ar.getImage(await this._requestManager.transformRequest(t,`Image`),new AbortController)}listImages(){return this.style?.listImages()??[]}addLayer(t,n){return this._lazyInitEmptyStyle(),this.style.addLayer(t,n),this._update(!0)}moveLayer(t,n){return this.style.moveLayer(t,n),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style?.getLayer(t)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(t,n,r){return this.style.setLayerZoomRange(t,n,r),this._update(!0)}setFilter(t,n,r={}){return this.style?.setFilter(t,n,r),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,n,r,i={}){return this.style?.setPaintProperty(t,n,r,i),this._update(!0)}getPaintProperty(t,n){return this.style.getPaintProperty(t,n)}setLayoutProperty(t,n,r,i={}){return this.style.setLayoutProperty(t,n,r,i),this._update(!0)}getLayoutProperty(t,n){return this.style.getLayoutProperty(t,n)}setGlyphs(t,n={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,n),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,n,r={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,n,r,t=>{t||this._update(!0)}),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,n={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,n,t=>{t||this._update(!0)}),this}setLight(t,n={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,n),this._update(!0)}getLight(){return this.style.getLight()}setSky(t,n={}){return this._lazyInitEmptyStyle(),this.style.setSky(t,n),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,n){return this.style.setFeatureState(t,n),this._update()}removeFeatureState(t,n){return this.style.removeFeatureState(t,n),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,n=0;return this._container&&(t=this._container.clientWidth||400,n=this._container.clientHeight||300),[t,n]}_setupResizeObserver(){let t=!1,n=$d(t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())},50),r=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new r(r=>{if(!t){t=!0;return}n(r)}),this._resizeObserver.observe(this._container)}_resolveContainer(t){if(typeof t==`string`){let n=document.getElementById(t);if(!n)throw Error(`Container '${t}' not found.`);return n}if(t instanceof HTMLElement||t&&typeof t==`object`&&t.nodeType===1)return t;throw Error(`Invalid type: 'container' must be a String or HTMLElement.`)}_setupContainer(){let t=this._container;t.classList.add(`maplibregl-map`);let n=this._canvasContainer=W.create(`div`,`maplibregl-canvas-container`,t);this._interactive&&n.classList.add(`maplibregl-interactive`),this._canvas=W.create(`canvas`,`maplibregl-canvas`,n),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`);let r=this._containerDimensions(),i=this._getClampedPixelRatio(r[0],r[1]);this._resizeCanvas(r[0],r[1],i);let a=this._controlContainer=W.create(`div`,`maplibregl-control-container`,t),o=this._controlPositions={};for(let t of[`top-left`,`top-right`,`bottom-left`,`bottom-right`])o[t]=W.create(`div`,`maplibregl-ctrl-${t} `,a);this._container.addEventListener(`scroll`,this._onMapScroll,!1)}_resizeCanvas(t,n,r){this._canvas.width=Math.floor(r*t),this._canvas.height=Math.floor(r*n),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${n}px`}_setupPainter(){let t={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},n=null;this._canvas.addEventListener(`webglcontextcreationerror`,t=>{n=t},{once:!0});let r=this._canvas.getContext(`webgl2`,t);if(!r){this.fire(new y(new tf(t,n)));return}this.painter=new Qd(r,this._camera.transform)}migrateProjection(t,n){this._camera.migrateProjection(t,n),this.painter.transform=t,this.fire(new Hr({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?._loaded?(this._styleDirty||=t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){let n=this._idleTriggered?this._fadeDuration:0,r=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let i=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let t=this._camera.transform.zoom,r=U();this.style.zoomHistory.update(t,r);let a=new ie(t,{now:r,fadeDuration:n,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=a.crossFadingFactor();(o!==1||o!==this._crossFadingFactor)&&(i=!0,this._crossFadingFactor=o),this.style.update(a)}let a=this.style.projection?.transitionState>0!==r;this.style.projection?.setErrorQueryLatitudeDegrees(this._camera.transform.center.lat),this._camera.transform.setTransitionState(this.style.projection?.transitionState,this.style.projection?.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||a)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,n,this._crossSourceCollisions,a),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:n,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new Pr(`render`)),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Pr(`load`))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let o=this._sourcesDirty||this._styleDirty||this._placementDirty;return o||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new Pr(`idle`)),this._loaded&&!this._fullyLoaded&&!o&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<`u`&&this._ownerWindow.removeEventListener(`online`,this._onWindowOnline,!1),Ar.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let t=this.painter.context.gl.getExtension(`WEBGL_lose_context`);t?.loseContext&&t.loseContext(),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`),this._removed=!0,this.fire(new Pr(`remove`))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Tr.frame(this._frameRequest,t=>{this._frameRequest=null;try{this._render(t)}catch(t){if(!me(t))throw t}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return mp}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}};const _p={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var xp=class{constructor(t){this._updateZoomButtons=()=>{let t=this._map.getZoom(),n=t===this._map.getMaxZoom(),r=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute(`aria-disabled`,n.toString()),this._zoomOutButton.setAttribute(`aria-disabled`,r.toString())},this._rotateCompassArrow=()=>{let t=this._map.getPitch(),n=this._map.getRoll(),r=this._map.getBearing(),i=1/Math.cos(Ne(t))**.5;if(this.options.visualizePitch&&this.options.visualizeRoll){this._compassIcon.style.transform=`scale(${i}) rotateZ(${-n}deg) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizePitch){this._compassIcon.style.transform=`scale(${i}) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizeRoll){this._compassIcon.style.transform=`rotate(${-r-n}deg)`;return}this._compassIcon.style.transform=`rotate(${-r}deg)`},this._setButtonTitle=(t,n)=>{let r=this._map._getUIString(`NavigationControl.${n}`);t.title=r,t.setAttribute(`aria-label`,r)},this.options=a({},_p,t),this._container=W.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})),W.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})),W.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=W.create(`span`,`maplibregl-ctrl-icon`,this._compass),this._compassIcon.setAttribute(`aria-hidden`,`true`))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,`ZoomIn`),this._setButtonTitle(this._zoomOutButton,`ZoomOut`),this._map.on(`zoom`,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 Sp(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off(`zoom`,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(t,n){let r=W.create(`button`,t,this._container);return r.type=`button`,r.addEventListener(`click`,n),r}},Sp=class{constructor(t,n,r=!1){this.mousedown=t=>{this.startMove(t,W.mousePos(this.element,t)),window.addEventListener(`mousemove`,this.mousemove),window.addEventListener(`mouseup`,this.mouseup)},this.mousemove=t=>{this.move(t,W.mousePos(this.element,t))},this.mouseup=t=>{this._rotatePitchHandler.dragEnd(t),this.offTemp()},this.touchstart=t=>{t.targetTouches.length===1?(this._startPos=this._lastPos=W.touchPos(this.element,t.targetTouches)[0],this.startMove(t,this._startPos),window.addEventListener(`touchmove`,this.touchmove,{passive:!1}),window.addEventListener(`touchend`,this.touchend)):this.reset()},this.touchmove=t=>{t.targetTouches.length===1?(this._lastPos=W.touchPos(this.element,t.targetTouches)[0],this.move(t,this._lastPos)):this.reset()},this.touchend=t=>{t.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n;let a=new Df;this._rotatePitchHandler=new Sf({clickTolerance:3,move:(t,a)=>{let o=n.getBoundingClientRect(),s=new i((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:lr(new i(t.x,a.y),a,s),pitchDelta:r?(a.y-t.y)*-.5:void 0}},moveStateManager:a,enable:!0,assignEvents:()=>{}}),this.map=t,n.addEventListener(`mousedown`,this.mousedown),n.addEventListener(`touchstart`,this.touchstart,{passive:!1}),n.addEventListener(`touchcancel`,this.reset)}startMove(t,n){this._rotatePitchHandler.dragStart(t,n),W.disableDrag()}move(t,n){let r=this.map,{bearingDelta:i,pitchDelta:a}=this._rotatePitchHandler.dragMove(t,n)||{};i&&r.setBearing(r.getBearing()+i),a&&r.setPitch(r.getPitch()+a)}off(){let t=this.element;t.removeEventListener(`mousedown`,this.mousedown),t.removeEventListener(`touchstart`,this.touchstart),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend),t.removeEventListener(`touchcancel`,this.reset),this.offTemp()}offTemp(){W.enableDrag(),window.removeEventListener(`mousemove`,this.mousemove),window.removeEventListener(`mouseup`,this.mouseup),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend)}};let vp;async function bp(t=!1){if(vp!==void 0&&!t)return vp;if(window.navigator.permissions===void 0)return vp=!!window.navigator.geolocation,vp;try{vp=(await window.navigator.permissions.query({name:`geolocation`})).state!==`denied`}catch{vp=!!window.navigator.geolocation}return vp}function Cp(t,n,r,i=!1){if(i||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return t?.wrap();let a=new F(t.lng,t.lat);if(t=new F(t.lng,t.lat),n){let i=new F(t.lng-360,t.lat),a=new F(t.lng+360,t.lat),o=r.locationToScreenPoint(t).distSqr(n);r.locationToScreenPoint(i).distSqr(n)180;){let n=r.locationToScreenPoint(t);if(n.x>=0&&n.y>=0&&n.x<=r.width&&n.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(t))?t:a}const wp={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 Tp(t,n,r){let i=t.classList;for(let t in wp)i.remove(`maplibregl-${r}-anchor-${t}`);i.add(`maplibregl-${r}-anchor-${n}`)}var Op=class extends h{},kp=class extends h{},Ap=class extends _{constructor(t){if(super(),this._onClick=t=>{this.fire(new kp(`click`,{originalEvent:t}))},this._onKeyPress=t=>{(t.code===`Space`||t.code===`Enter`)&&this.togglePopup()},this._onMapClick=t=>{let n=t.originalEvent.target,r=this._element;this._popup&&(n===r||r.contains(n))&&this.togglePopup()},this._update=t=>{if(!this._map)return;let n=this._map.loaded()&&!this._map.isMoving();(t?.type===`terrain`||t?.type===`render`&&!n)&&this._map.once(`render`,this._update),this._lngLat=Cp(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r=``;this._rotationAlignment===`viewport`||this._rotationAlignment===`auto`?r=`rotateZ(${this._rotation}deg)`:this._rotationAlignment===`map`&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i=``;this._pitchAlignment===`viewport`||this._pitchAlignment===`auto`?i=`rotateX(0deg)`:this._pitchAlignment===`map`&&(i=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(!t||t.type===`moveend`)&&(this._pos=this._pos.round()),this._element.style.transform=`${wp[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${r}`,Tr.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity(t?.type===`moveend`)}).catch(()=>{})},this._onMove=t=>{if(!this._isDragging){let n=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=n}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 Op(`dragstart`))),this.fire(new Op(`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 Op(`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=t?.anchor||`center`,this._color=t?.color||`#3FB1CE`,this._scale=t?.scale||1,this._draggable=t?.draggable||!1,this._clickTolerance=t?.clickTolerance||0,this._subpixelPositioning=t?.subpixelPositioning||!1,this._isDragging=!1,this._state=`inactive`,this._rotation=t?.rotation||0,this._rotationAlignment=t?.rotationAlignment||`auto`,this._pitchAlignment=t?.pitchAlignment&&t.pitchAlignment!==`auto`?t.pitchAlignment:this._rotationAlignment,this.setOpacity(t?.opacity,t?.opacityWhenCovered),t?.element)this._element=t.element,this._offset=i.convert(t?.offset||[0,0]);else{this._defaultMarker=!0,this._element=W.create(`div`);let n=W.createNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttributeNS(null,`display`,`block`),n.setAttributeNS(null,`height`,`41px`),n.setAttributeNS(null,`width`,`27px`),n.setAttributeNS(null,`viewBox`,`0 0 27 41`);let r=W.createNS(`http://www.w3.org/2000/svg`,`g`);r.setAttributeNS(null,`stroke`,`none`),r.setAttributeNS(null,`stroke-width`,`1`),r.setAttributeNS(null,`fill`,`none`),r.setAttributeNS(null,`fill-rule`,`evenodd`);let a=W.createNS(`http://www.w3.org/2000/svg`,`g`);a.setAttributeNS(null,`fill-rule`,`nonzero`);let o=W.createNS(`http://www.w3.org/2000/svg`,`g`);o.setAttributeNS(null,`transform`,`translate(3.0, 29.0)`),o.setAttributeNS(null,`fill`,`#000000`);for(let t of[{rx:`10.5`,ry:`5.25002273`},{rx:`10.5`,ry:`5.25002273`},{rx:`9.5`,ry:`4.77275007`},{rx:`8.5`,ry:`4.29549936`},{rx:`7.5`,ry:`3.81822308`},{rx:`6.5`,ry:`3.34094679`},{rx:`5.5`,ry:`2.86367051`},{rx:`4.5`,ry:`2.38636864`}]){let n=W.createNS(`http://www.w3.org/2000/svg`,`ellipse`);n.setAttributeNS(null,`opacity`,`0.04`),n.setAttributeNS(null,`cx`,`10.5`),n.setAttributeNS(null,`cy`,`5.80029008`),n.setAttributeNS(null,`rx`,t.rx),n.setAttributeNS(null,`ry`,t.ry),o.appendChild(n)}let s=W.createNS(`http://www.w3.org/2000/svg`,`g`);s.setAttributeNS(null,`fill`,this._color);let c=W.createNS(`http://www.w3.org/2000/svg`,`path`);c.setAttributeNS(null,`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`),s.appendChild(c);let l=W.createNS(`http://www.w3.org/2000/svg`,`g`);l.setAttributeNS(null,`opacity`,`0.25`),l.setAttributeNS(null,`fill`,`#000000`);let u=W.createNS(`http://www.w3.org/2000/svg`,`path`);u.setAttributeNS(null,`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`),l.appendChild(u);let d=W.createNS(`http://www.w3.org/2000/svg`,`g`);d.setAttributeNS(null,`transform`,`translate(6.0, 7.0)`),d.setAttributeNS(null,`fill`,`#FFFFFF`);let f=W.createNS(`http://www.w3.org/2000/svg`,`g`);f.setAttributeNS(null,`transform`,`translate(8.0, 8.0)`);let p=W.createNS(`http://www.w3.org/2000/svg`,`circle`);p.setAttributeNS(null,`fill`,`#000000`),p.setAttributeNS(null,`opacity`,`0.25`),p.setAttributeNS(null,`cx`,`5.5`),p.setAttributeNS(null,`cy`,`5.5`),p.setAttributeNS(null,`r`,`5.4999962`);let m=W.createNS(`http://www.w3.org/2000/svg`,`circle`);m.setAttributeNS(null,`fill`,`#FFFFFF`),m.setAttributeNS(null,`cx`,`5.5`),m.setAttributeNS(null,`cy`,`5.5`),m.setAttributeNS(null,`r`,`5.4999962`),f.appendChild(p),f.appendChild(m),a.appendChild(o),a.appendChild(s),a.appendChild(l),a.appendChild(d),a.appendChild(f),n.appendChild(a),n.setAttributeNS(null,`height`,`${41*this._scale}px`),n.setAttributeNS(null,`width`,`${27*this._scale}px`),this._element.appendChild(n),this._offset=i.convert(t?.offset||[0,-14])}if(this._element.classList.add(`maplibregl-marker`),this._element.addEventListener(`dragstart`,t=>{t.preventDefault()}),this._element.addEventListener(`mousedown`,t=>{t.preventDefault()}),Tp(this._element,this._anchor,`marker`),t?.className)for(let n of t.className.split(` `))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute(`aria-label`)||this._element.setAttribute(`aria-label`,t._getUIString(`Marker.Title`)),this._element.hasAttribute(`role`)||this._element.setAttribute(`role`,`button`),t.getCanvasContainer().appendChild(this._element),t.on(`move`,this._update),t.on(`moveend`,this._update),t.on(`terrain`,this._update),t.on(`projectiontransition`,this._update),this._element.addEventListener(`click`,this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on(`click`,this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),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(`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.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=F.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener(`keypress`,this._onKeyPress),this._originalTabIndex||this._element.removeAttribute(`tabindex`)),t){if(!(`offset`in t.options)){let n=41-5.8/2,r=13.5,i=13.5/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[i,(n-r+i)*-1],"bottom-right":[-i,(n-r+i)*-1],left:[r,(n-r)*-1],right:[-13.5,(n-r)*-1]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute(`tabindex`),this._originalTabIndex||this._element.setAttribute(`tabindex`,`0`),this._element.addEventListener(`keypress`,this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){let t=this._popup;if(this._element.style.opacity===this._opacityWhenCovered)return this;if(t)t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map));else return this;return this}_updateOpacity(t=!1){let n=this._map?.terrain,r=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!n||r){let t=r?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==t&&(this._element.style.opacity=t,this._element.classList.toggle(`maplibregl-marker-covered`,r));return}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let a=this._map,o=a.terrain.depthAtPoint(this._pos),s=a.terrain.getElevationForLngLat(this._lngLat,a._camera.transform),c=a._camera.transform.lngLatToCameraDepth(this._lngLat,s),l=.006;if(c-ol;this._popup?.isOpen()&&p&&this._popup.remove(),this._element.style.opacity=p?this._opacityWhenCovered:this._opacity,this._element.classList.toggle(`maplibregl-marker-covered`,p)}getOffset(){return this._offset}setOffset(t){return this._offset=i.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(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}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||`auto`,this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!==`auto`?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,n){return(this._opacity===void 0||t===void 0&&n===void 0)&&(this._opacity=`1`,this._opacityWhenCovered=`0.2`),t!==void 0&&(this._opacity=String(t)),n!==void 0&&(this._opacityWhenCovered=String(n)),this._map&&this._updateOpacity(!0),this}};const Ep={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Dp=0,jp=!1;var Pp=class extends h{},Fp=class extends h{},Ip=class extends h{},Lp=class extends _{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t)){this._setErrorState(),this.fire(new Fp(`outofmaxbounds`,t)),this._updateMarker(),this._finish();return}if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`BACKGROUND`:case`BACKGROUND_ERROR`:this._watchState=`BACKGROUND`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`);break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!==`OFF`&&this._updateMarker(t),(!this.options.trackUserLocation||this._watchState===`ACTIVE_LOCK`)&&this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove(`maplibregl-user-location-dot-stale`),this.fire(new Fp(`geolocate`,t)),this._finish()}},this._updateCamera=t=>{let n=new F(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,i=a({bearing:this._map.getBearing()},this.options.fitBoundsOptions),o=Ii.fromLngLat(n,r);this._map.fitBounds(o,i,{geolocateSource:!0})},this._updateMarker=t=>{if(t){let n=new F(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(t.code===1){this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.disabled=!0;let t=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.title=t,this._geolocateButton.setAttribute(`aria-label`,t),this._geolocationWatchID!==void 0&&this._clearWatch()}else if(t.code===3&&jp)return;else this._setErrorState();this._watchState!==`OFF`&&this.options.showUserLocation&&this._dotElement.classList.add(`maplibregl-user-location-dot-stale`),this.fire(new Ip(`error`,t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=t=>{if(!this._map)return;let n=t?.[0]instanceof ResizeObserverEntry;!t.geolocateSource&&this._watchState===`ACTIVE_LOCK`&&!n&&!this._map.isZooming()&&(this._watchState=`BACKGROUND`,this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this.fire(new Pp(`trackuserlocationend`)),this.fire(new Pp(`userlocationlostfocus`)))},this._setupUI=()=>{this._map&&(this._container.addEventListener(`contextmenu`,t=>{t.preventDefault()}),this._geolocateButton=W.create(`button`,`maplibregl-ctrl-geolocate`,this._container),W.create(`span`,`maplibregl-ctrl-icon`,this._geolocateButton).setAttribute(`aria-hidden`,`true`),this._geolocateButton.type=`button`,this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){b(`Geolocation support is not available so the GeolocateControl will be disabled.`);let t=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute(`aria-label`,t)}else{let t=this._map._getUIString(`GeolocateControl.FindMyLocation`);this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute(`aria-label`,t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute(`aria-pressed`,`false`),this._watchState=`OFF`),this.options.showUserLocation&&(this._dotElement=W.create(`div`,`maplibregl-user-location-dot`),this._userLocationDotMarker=new Ap({element:this._dotElement}),this._circleElement=W.create(`div`,`maplibregl-user-location-accuracy-circle`),this._accuracyCircleMarker=new Ap({element:this._circleElement,pitchAlignment:`map`}),this.options.trackUserLocation&&(this._watchState=`OFF`),this._map.on(`zoom`,this._onUpdate),this._map.on(`move`,this._onUpdate),this._map.on(`rotate`,this._onUpdate),this._map.on(`pitch`,this._onUpdate)),this._geolocateButton.addEventListener(`click`,()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on(`movestart`,this._onMoveStart)}},this.options=a({},Ep,t)}onAdd(t){return this._map=t,this._container=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),bp().then(t=>this._finishSetupUI(t)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off(`movestart`,this._onMoveStart),this._map.off(`zoom`,this._onUpdate),this._map.off(`move`,this._onUpdate),this._map.off(`rotate`,this._onUpdate),this._map.off(`pitch`,this._onUpdate),this._map=void 0,Dp=0,jp=!1}_isOutOfMapMaxBounds(t){let n=this._map.getMaxBounds(),r=t.coords;return n&&(r.longituden.getEast()||r.latituden.getNorth())}_setErrorState(){switch(this._watchState){case`WAITING_ACTIVE`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`);break;case`ACTIVE_LOCK`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`BACKGROUND`:this._watchState=`BACKGROUND_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:break;case`OFF`:case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let t=this._userLocationDotMarker.getLngLat();if(!this.options.showUserLocation||!this.options.showAccuracyCircle||!this._accuracy||!t)return;let n=this._map.project(t),r=this._map.unproject([n.x+100,n.y]),i=t.distanceTo(r)/100,a=2*this._accuracy/i;this._circleElement.style.width=`${a.toFixed(2)}px`,this._circleElement.style.height=`${a.toFixed(2)}px`}trigger(){if(!this._setup)return b(`Geolocate control triggered before added to a map`),!1;if(this.options.trackUserLocation){switch(this._watchState){case`OFF`:this._watchState=`WAITING_ACTIVE`,this.fire(new Pp(`trackuserlocationstart`));break;case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:Dp--,jp=!1,this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this.fire(new Pp(`trackuserlocationend`));break;case`BACKGROUND`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new Pp(`trackuserlocationstart`)),this.fire(new Pp(`userlocationfocus`));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case`WAITING_ACTIVE`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`ACTIVE_LOCK`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`OFF`:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState===`OFF`&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`true`),Dp++;let t;Dp>1?(t={maximumAge:6e5,timeout:0},jp=!0):(t=this.options.positionOptions,jp=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`false`),this.options.showUserLocation&&this._updateMarker(null)}};const Mp={maxWidth:100,unit:`metric`};var zp=class{constructor(t){this._onMove=()=>{Np(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Np(this._map,this._container,this.options)},this.options={...Mp,...t}}getDefaultPosition(){return`bottom-left`}onAdd(t){return this._map=t,this._container=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-scale`,t.getContainer()),this._map.on(`move`,this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off(`move`,this._onMove),this._map=void 0}};function Np(t,n,r){let i=r?.maxWidth||100,a=t._container.clientHeight/2,o=t._container.clientWidth/2,s=t.unproject([o-i/2,a]),c=t.unproject([o+i/2,a]),l=Math.round(t.project(c).x-t.project(s).x),u=Math.min(i,l,t._container.clientWidth),d=s.distanceTo(c);if(r?.unit===`imperial`){let r=3.2808*d;r>5280?Rp(n,u,r/5280,t._getUIString(`ScaleControl.Miles`)):Rp(n,u,r,t._getUIString(`ScaleControl.Feet`))}else r?.unit===`nautical`?Rp(n,u,d/1852,t._getUIString(`ScaleControl.NauticalMiles`)):d>=1e3?Rp(n,u,d/1e3,t._getUIString(`ScaleControl.Kilometers`)):Rp(n,u,d,t._getUIString(`ScaleControl.Meters`))}function Rp(t,n,r,i){let a=Vp(r),o=a/r;t.style.width=`${n*o}px`,t.innerHTML=`${a} ${i}`}function Bp(t){let n=10**Math.ceil(-Math.log(t)/Math.LN10);return Math.round(t*n)/n}function Vp(t){let n=10**(`${Math.floor(t)}`.length-1),r=t/n;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:Bp(r),n*r}var Wp=class extends h{},Gp=class extends _{constructor(t={}){super(),this._onFullscreenChange=()=>{let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;t?.shadowRoot?.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=t.pseudo??!1,t?.container&&(t.container instanceof HTMLElement?this._container=t.container:b(`Full screen control 'container' must be a DOM element.`)),`onfullscreenchange`in document?this._fullscreenchange=`fullscreenchange`:`onmozfullscreenchange`in document?this._fullscreenchange=`mozfullscreenchange`:`onwebkitfullscreenchange`in document?this._fullscreenchange=`webkitfullscreenchange`:`onmsfullscreenchange`in document&&(this._fullscreenchange=`MSFullscreenChange`)}onAdd(t){return this._map=t,this._container||=this._map.getContainer(),this._controlContainer=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let t=this._fullscreenButton=W.create(`button`,`maplibregl-ctrl-fullscreen`,this._controlContainer);W.create(`span`,`maplibregl-ctrl-icon`,t).setAttribute(`aria-hidden`,`true`),t.type=`button`,this._updateTitle(),this._fullscreenButton.addEventListener(`click`,this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let t=this._getTitle();this._fullscreenButton.setAttribute(`aria-label`,t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?`FullscreenControl.Exit`:`FullscreenControl.Enter`)}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(`maplibregl-ctrl-shrink`),this._fullscreenButton.classList.toggle(`maplibregl-ctrl-fullscreen`),this._updateTitle(),this._fullscreen?(this.fire(new Wp(`fullscreenstart`)),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new Wp(`fullscreenend`)),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle(`maplibregl-pseudo-fullscreen`),this._handleFullscreenChange(),this._map.resize()}},Kp=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove(`maplibregl-ctrl-terrain`),this._terrainButton.classList.remove(`maplibregl-ctrl-terrain-enabled`),this._map.terrain?(this._terrainButton.classList.add(`maplibregl-ctrl-terrain-enabled`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Disable`)):(this._terrainButton.classList.add(`maplibregl-ctrl-terrain`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Enable`))},this.options=t}onAdd(t){return this._map=t,this._container=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._terrainButton=W.create(`button`,`maplibregl-ctrl-terrain`,this._container),W.create(`span`,`maplibregl-ctrl-icon`,this._terrainButton).setAttribute(`aria-hidden`,`true`),this._terrainButton.type=`button`,this._terrainButton.addEventListener(`click`,this._toggleTerrain),this._updateTerrainIcon(),this._map.on(`terrain`,this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off(`terrain`,this._updateTerrainIcon),this._map=void 0}},qp=class{constructor(){this._toggleProjection=()=>{let t=this._map.getProjection()?.type;t===`mercator`||!t?this._map.setProjection({type:`globe`}):this._map.setProjection({type:`mercator`}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove(`maplibregl-ctrl-globe`),this._globeButton.classList.remove(`maplibregl-ctrl-globe-enabled`),this._map.getProjection()?.type===`globe`?(this._globeButton.classList.add(`maplibregl-ctrl-globe-enabled`),this._globeButton.title=this._map._getUIString(`GlobeControl.Disable`)):(this._globeButton.classList.add(`maplibregl-ctrl-globe`),this._globeButton.title=this._map._getUIString(`GlobeControl.Enable`))}}onAdd(t){return this._map=t,this._container=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._globeButton=W.create(`button`,`maplibregl-ctrl-globe`,this._container),W.create(`span`,`maplibregl-ctrl-icon`,this._globeButton).setAttribute(`aria-hidden`,`true`),this._globeButton.type=`button`,this._globeButton.addEventListener(`click`,this._toggleProjection),this._updateGlobeIcon(),this._map.on(`styledata`,this._updateGlobeIcon),this._map.on(`projectiontransition`,this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off(`styledata`,this._updateGlobeIcon),this._map.off(`projectiontransition`,this._updateGlobeIcon),this._globeButton.removeEventListener(`click`,this._toggleProjection),this._map=void 0}};const Hp={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:``,maxWidth:`240px`,subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},Up=[`a[href]`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable]:not([contenteditable='false'])`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`].join(`, `);var Xp=class extends h{},Zp=class extends _{constructor(t){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._map._camera.transform.isLocationOccluded(this.getLngLat())?this._container.style.opacity=`${this.options.locationOccludedOpacity}`:this._container.style.opacity=``)},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off(`move`,this._update),this._map.off(`move`,this._onClose),this._map.off(`click`,this._onClose),this._map.off(`remove`,this.remove),this._map.off(`terrain`,this._update),this._map.off(`projectiontransition`,this._update),this._map.off(`mousemove`,this._update),this._map.off(`mouseup`,this._update),this._map.off(`drag`,this._update),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`),delete this._map,this.fire(new Xp(`close`))),this),this._update=t=>{let n=this._lngLat||this._trackPointer;if(!this._map||!n||!this._content)return;if(!this._container){if(this._container=W.create(`div`,`maplibregl-popup`,this._map.getContainer()),this._tip=W.create(`div`,`maplibregl-popup-tip`,this._container),this._container.appendChild(this._content),this.options.className)for(let t of this.options.className.split(` `))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute(`aria-label`,this._map._getUIString(`Popup.Close`)),this._trackPointer&&this._container.classList.add(`maplibregl-popup-track-pointer`)}this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Cp(this._lngLat,this._flatPos,this._map._camera.transform,this._trackPointer);let r;if(t&&`point`in t&&t.point&&(r=t.point),this._trackPointer&&!r)return;let i=this._flatPos=this._pos=this._trackPointer&&r?r:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&r?r:this._map._camera.transform.locationToScreenPoint(this._lngLat));let a=this.options.anchor,o=Jp(this.options.offset);if(!a){let t=this._container.offsetWidth,n=this._container.offsetHeight,r=Yp(this.options.padding),s;s=i.y+o.bottom.ythis._map._camera.transform.height-n-r.bottom?[`bottom`]:[],i.xthis._map._camera.transform.width-t/2-r.right&&s.push(`right`),a=s.length===0?`bottom`:s.join(`-`)}let s=i.add(o[a]);this.options.subpixelPositioning||(s=s.round()),this._container.style.transform=`${wp[a]} translate(${s.x}px,${s.y}px)`,Tp(this._container,a,`popup`),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=a(Object.create(Hp),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on(`click`,this._onClose),this.options.closeOnMove&&this._map.on(`move`,this._onClose),this._map.on(`remove`,this.remove),this._map.on(`terrain`,this._update),this._map.on(`projectiontransition`,this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on(`mousemove`,this._update),this._map.on(`mouseup`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)):this._map.on(`move`,this._update),this.fire(new Xp(`open`)),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=F.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on(`move`,this._update),this._map.off(`mousemove`,this._update),this._container&&this._container.classList.remove(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`)),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off(`move`,this._update),this._map.on(`mousemove`,this._update),this._map.on(`drag`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){let n=document.createDocumentFragment(),r=document.createElement(`body`),i;for(r.innerHTML=t;i=r.firstChild,i;)n.appendChild(i);return this.setDOMContent(n)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=W.create(`div`,`maplibregl-popup-content`,this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}setPadding(t){this.options.padding=t,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=W.create(`button`,`maplibregl-popup-close-button`,this._content),this._closeButton.type=`button`,this._closeButton.innerHTML=`×`,this._closeButton.addEventListener(`click`,this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let t=this._container.querySelector(Up);t&&t.focus()}};function Jp(t){if(!t)return Jp(new i(0,0));if(typeof t==`number`){let n=Math.round(Math.abs(t)/Math.SQRT2);return{center:new i(0,0),top:new i(0,t),"top-left":new i(n,n),"top-right":new i(-n,n),bottom:new i(0,-t),"bottom-left":new i(n,-n),"bottom-right":new i(-n,-n),left:new i(t,0),right:new i(-t,0)}}else if(t instanceof i||Array.isArray(t)){let n=i.convert(t);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}else return{center:i.convert(t.center||[0,0]),top:i.convert(t.top||[0,0]),"top-left":i.convert(t[`top-left`]||[0,0]),"top-right":i.convert(t[`top-right`]||[0,0]),bottom:i.convert(t.bottom||[0,0]),"bottom-left":i.convert(t[`bottom-left`]||[0,0]),"bottom-right":i.convert(t[`bottom-right`]||[0,0]),left:i.convert(t.left||[0,0]),right:i.convert(t.right||[0,0])}}function Yp(t){return t?{top:t.top??0,right:t.right??0,bottom:t.bottom??0,left:t.left??0}:{top:0,right:0,bottom:0,left:0}}const Qp=vr;function $p(t,n){return ha().setRTLTextPlugin(t,n)}function em(){return ha().getRTLTextPluginStatus()}function tm(){return Qp}function nm(){return gi.workerCount}function rm(t){gi.workerCount=t}function im(){return p.MAX_PARALLEL_IMAGE_REQUESTS}function am(t){p.MAX_PARALLEL_IMAGE_REQUESTS=t}function om(){return p.WORKER_URL}function sm(t){p.WORKER_URL=t}async function cm(t){await Ci().broadcast(`IS`,t)}export{cp as AttributionControl,gf as BoxZoomHandler,ca as CanvasSource,ep as CooperativeGesturesHandler,Jf as DoubleClickZoomHandler,Zf as DragPanHandler,Qf as DragRotateHandler,I as EXTENT,fs as EdgeInsets,y as ErrorEvent,h as Event,_ as Evented,Gp as FullscreenControl,Wp as FullscreenEvent,tf as GPUInitializationError,ra as GeoJSONSource,Lp as GeolocateControl,Ip as GeolocateErrorEvent,Pp as GeolocateEvent,Fp as GeolocatePositionEvent,qp as GlobeControl,rf as Hash,ia as ImageSource,Wf as KeyboardHandler,F as LngLat,Ii as LngLatBounds,lp as LogoControl,yp as Map,Br as MapBoxZoomEvent,Ur as MapContextEvent,Pr as MapLibreEvent,yp as MapLibreMap,Lr as MapMouseEvent,G as MapMovementEvent,Hr as MapProjectionEvent,K as MapSourceDataEvent,Ir as MapStyleDataEvent,Wr as MapStyleImageMissingEvent,Fr as MapStyleLoadEvent,Vr as MapTerrainEvent,Rr as MapTouchEvent,zr as MapWheelEvent,Ap as Marker,kp as MarkerClickEvent,Op as MarkerDragEvent,L as MercatorCoordinate,xp as NavigationControl,i as Point,Zp as Popup,Xp as PopupEvent,Hi as RasterDEMTileSource,Vi as RasterTileSource,zp as ScaleControl,qf as ScrollZoomHandler,bc as Style,Kp as TerrainControl,Hf as TwoFingersTouchPitchHandler,Bf as TwoFingersTouchRotateHandler,Rf as TwoFingersTouchZoomHandler,$f as TwoFingersTouchZoomRotateHandler,Bi as VectorTileSource,sa as VideoSource,da as addSourceType,xi as clearPrewarmedResources,p as config,zs as createTileMesh,Ci as getGlobalDispatcher,im as getMaxParallelImageRequests,em as getRTLTextPluginStatus,tm as getVersion,nm as getWorkerCount,om as getWorkerUrl,cm as importScriptInWorkers,kr as isTimeFrozen,U as now,bi as prewarm,Or as restoreNow,am as setMaxParallelImageRequests,Dr as setNow,$p as setRTLTextPlugin,rm as setWorkerCount,sm as setWorkerUrl}; +`),C=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}if(u.shaderSource(C,x),u.compileShader(C),!u.getShaderParameter(C,u.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${u.getShaderInfoLog(C)}`);u.attachShader(this.program,C);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost()){this.failedToCreate=!0;return}if(u.shaderSource(w,S),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`);u.attachShader(this.program,w),this.attributes={};let T={};this.numAttributes=p.length;for(let t=0;t=0&&(this.attributes[t]=n)}if(!u.getProgramParameter(this.program,u.LINK_STATUS))throw Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`);u.deleteShader(w),u.deleteShader(C);for(let t of y)if(t&&!T[t]){let n=u.getUniformLocation(this.program,t);n&&(T[t]=n)}this.fixedUniforms=i(t,T),this.terrainUniforms=fc(t,T),this.projectionUniforms=xc(t,T),this.binderUniforms=r?r.getUniforms(t,T):[]}draw(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y){let b=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(r),t.setStencilMode(i),t.setColorMode(a),t.setCullFace(o),c){t.activeTexture.set(b.TEXTURE2),b.bindTexture(b.TEXTURE_2D,c.depthTexture),t.activeTexture.set(b.TEXTURE3),b.bindTexture(b.TEXTURE_2D,c.texture);for(let t in this.terrainUniforms)this.terrainUniforms[t].set(c[t])}if(l){let t=Sc(l);for(let n in this.projectionUniforms)this.projectionUniforms[n].set(t[n])}if(s)for(let t in this.fixedUniforms)this.fixedUniforms[t].set(s[t]);g&&g.setUniforms(t,this.binderUniforms,m,{zoom:h});let x=0;switch(n){case b.LINES:x=2;break;case b.TRIANGLES:x=3;break;case b.LINE_STRIP:x=1;break}for(let r of p.get())r.vaos||={},r.vaos[u]||=new hc,r.vaos[u].bind(t,this,d,g?g.getPaintVertexBuffers():[],f,r.vertexOffset,_,v,y),b.drawElements(n,r.primitiveLength*x,b.UNSIGNED_SHORT,r.primitiveOffset*x*2)}};function wc(t,n,r){let i=1/rt(r,1,n.transform.tileZoom),a=2**r.tileID.overscaledZ,o=r.tileSize*2**n.transform.tileZoom/a,s=o*(r.tileID.canonical.x+r.tileID.wrap*a),c=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[s>>16,c>>16],u_pixel_coord_lower:[s&65535,c&65535]}}function Tc(t,n,r,i){let a=r.imageManager.getPattern(t.from.toString()),o=r.imageManager.getPattern(t.to.toString()),{width:s,height:c}=r.imageManager.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,d=u*(i.tileID.canonical.x+i.tileID.wrap*l),f=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,c],u_mix:n.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:n.fromScale,u_scale_b:n.toScale,u_tile_units_to_pixels:1/rt(i,1,r.transform.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[d&65535,f&65535]}}const Dc=(t,n)=>({u_lightpos:new jn(t,n.u_lightpos),u_lightpos_globe:new jn(t,n.u_lightpos_globe),u_lightintensity:new z(t,n.u_lightintensity),u_lightcolor:new jn(t,n.u_lightcolor),u_vertical_gradient:new z(t,n.u_vertical_gradient),u_opacity:new z(t,n.u_opacity),u_fill_translate:new H(t,n.u_fill_translate)}),Oc=(t,n)=>({u_lightpos:new jn(t,n.u_lightpos),u_lightpos_globe:new jn(t,n.u_lightpos_globe),u_lightintensity:new z(t,n.u_lightintensity),u_lightcolor:new jn(t,n.u_lightcolor),u_vertical_gradient:new z(t,n.u_vertical_gradient),u_height_factor:new z(t,n.u_height_factor),u_opacity:new z(t,n.u_opacity),u_fill_translate:new H(t,n.u_fill_translate),u_image:new B(t,n.u_image),u_texsize:new H(t,n.u_texsize),u_pixel_coord_upper:new H(t,n.u_pixel_coord_upper),u_pixel_coord_lower:new H(t,n.u_pixel_coord_lower),u_scale:new jn(t,n.u_scale),u_fade:new z(t,n.u_fade)}),kc=(t,n,r,i)=>{let a=t.style.light,o=a.getCartesianPosition(),s=Mn();a.properties.get(`anchor`)===`viewport`&&Nn(s,t.transform.bearingInRadians),Pn(o,o,s);let c=t.transform.transformLightDirection(o),l=a.properties.get(`color`);return{u_lightpos:o,u_lightpos_globe:c,u_lightintensity:a.properties.get(`intensity`),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+n,u_opacity:r,u_fill_translate:i}},Ac=(t,n,r,i,o,s,c)=>a(kc(t,n,r,i),wc(s,t,c),{u_height_factor:-(2**o.overscaledZ)/c.tileSize/8}),jc=(t,n)=>({u_fill_translate:new H(t,n.u_fill_translate)}),Mc=(t,n)=>({u_image:new B(t,n.u_image),u_texsize:new H(t,n.u_texsize),u_pixel_coord_upper:new H(t,n.u_pixel_coord_upper),u_pixel_coord_lower:new H(t,n.u_pixel_coord_lower),u_scale:new jn(t,n.u_scale),u_fade:new z(t,n.u_fade),u_fill_translate:new H(t,n.u_fill_translate)}),Nc=(t,n)=>({u_world:new H(t,n.u_world),u_fill_translate:new H(t,n.u_fill_translate)}),Pc=(t,n)=>({u_world:new H(t,n.u_world),u_image:new B(t,n.u_image),u_texsize:new H(t,n.u_texsize),u_pixel_coord_upper:new H(t,n.u_pixel_coord_upper),u_pixel_coord_lower:new H(t,n.u_pixel_coord_lower),u_scale:new jn(t,n.u_scale),u_fade:new z(t,n.u_fade),u_fill_translate:new H(t,n.u_fill_translate)}),Fc=(t,n,r,i)=>a(wc(n,t,r),{u_fill_translate:i}),Ic=t=>({u_fill_translate:t}),Lc=(t,n)=>({u_world:t,u_fill_translate:n}),Rc=(t,n,r,i,o)=>a(Fc(t,n,r,o),{u_world:i}),zc=(t,n)=>({u_camera_to_center_distance:new z(t,n.u_camera_to_center_distance),u_scale_with_map:new B(t,n.u_scale_with_map),u_pitch_with_map:new B(t,n.u_pitch_with_map),u_extrude_scale:new H(t,n.u_extrude_scale),u_device_pixel_ratio:new z(t,n.u_device_pixel_ratio),u_globe_extrude_scale:new z(t,n.u_globe_extrude_scale),u_translate:new H(t,n.u_translate)}),Bc=(t,n,r,i,a)=>{let o=t.transform,s,c,l=0;if(r.paint.get(`circle-pitch-alignment`)===`map`){let t=rt(n,1,o.zoom);s=!0,c=[t,t],l=t/(F*2**n.tileID.overscaledZ)*2*Math.PI*a}else s=!1,c=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(r.paint.get(`circle-pitch-scale`)===`map`),u_pitch_with_map:+s,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:c,u_globe_extrude_scale:l,u_translate:i}},Vc=(t,n)=>({u_pixel_extrude_scale:new H(t,n.u_pixel_extrude_scale)}),Hc=(t,n)=>({u_viewport_size:new H(t,n.u_viewport_size)}),Uc=t=>({u_pixel_extrude_scale:[1/t.width,1/t.height]}),Wc=t=>({u_viewport_size:[t.width,t.height]}),Gc=(t,n)=>({u_color:new An(t,n.u_color),u_overlay:new B(t,n.u_overlay),u_overlay_scale:new z(t,n.u_overlay_scale)}),Kc=(t,n=1)=>({u_color:t,u_overlay:0,u_overlay_scale:n}),qc=(t,n)=>({u_extrude_scale:new z(t,n.u_extrude_scale),u_intensity:new z(t,n.u_intensity),u_globe_extrude_scale:new z(t,n.u_globe_extrude_scale)}),Jc=(t,n)=>({u_matrix:new kn(t,n.u_matrix),u_world:new H(t,n.u_world),u_image:new B(t,n.u_image),u_color_ramp:new B(t,n.u_color_ramp),u_opacity:new z(t,n.u_opacity)}),Yc=(t,n,r,i)=>{let a=rt(t,1,n)/(F*2**t.tileID.overscaledZ)*2*Math.PI*i;return{u_extrude_scale:rt(t,1,n),u_intensity:r,u_globe_extrude_scale:a}},Xc=(t,n,r,i)=>{let a=ce();Fn(a,0,t.width,t.height,0,0,1);let o=t.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:r,u_color_ramp:i,u_opacity:n.paint.get(`heatmap-opacity`)}},Zc=(t,n)=>({u_image:new B(t,n.u_image),u_latrange:new H(t,n.u_latrange),u_exaggeration:new z(t,n.u_exaggeration),u_altitudes:new Ln(t,n.u_altitudes),u_azimuths:new Ln(t,n.u_azimuths),u_accent:new An(t,n.u_accent),u_method:new B(t,n.u_method),u_shadows:new In(t,n.u_shadows),u_highlights:new In(t,n.u_highlights)}),Qc=(t,n)=>({u_matrix:new kn(t,n.u_matrix),u_image:new B(t,n.u_image),u_dimension:new H(t,n.u_dimension),u_zoom:new z(t,n.u_zoom),u_unpack:new On(t,n.u_unpack)}),$c=(t,n,r)=>{let i=r.paint.get(`hillshade-accent-color`),a;switch(r.paint.get(`hillshade-method`)){case`basic`:a=4;break;case`combined`:a=1;break;case`igor`:a=2;break;case`multidirectional`:a=3;break;default:a=0;break}let o=r.getIlluminationProperties();for(let n=0;n{let r=n.stride,i=ce();return Fn(i,0,F,-F,0,0,1),N(i,i,[0,-F,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:n.getUnpackVector()}};function tl(t,n){let r=2**n.canonical.z,i=n.canonical.y;return[new I(0,i/r).toLngLat().lat,new I(0,(i+1)/r).toLngLat().lat]}const nl=(t,n)=>({u_image:new B(t,n.u_image),u_unpack:new On(t,n.u_unpack),u_dimension:new H(t,n.u_dimension),u_elevation_stops:new B(t,n.u_elevation_stops),u_color_stops:new B(t,n.u_color_stops),u_color_ramp_size:new B(t,n.u_color_ramp_size),u_opacity:new z(t,n.u_opacity)}),rl=(t,n,r=0)=>({u_image:0,u_unpack:n.getUnpackVector(),u_dimension:[n.stride,n.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:r,u_opacity:t.paint.get(`color-relief-opacity`)}),il=(t,n)=>({u_translation:new H(t,n.u_translation),u_ratio:new z(t,n.u_ratio),u_device_pixel_ratio:new z(t,n.u_device_pixel_ratio),u_units_to_pixels:new H(t,n.u_units_to_pixels)}),al=(t,n)=>({u_translation:new H(t,n.u_translation),u_ratio:new z(t,n.u_ratio),u_device_pixel_ratio:new z(t,n.u_device_pixel_ratio),u_units_to_pixels:new H(t,n.u_units_to_pixels),u_image:new B(t,n.u_image),u_image_height:new z(t,n.u_image_height)}),ol=(t,n)=>({u_translation:new H(t,n.u_translation),u_texsize:new H(t,n.u_texsize),u_ratio:new z(t,n.u_ratio),u_device_pixel_ratio:new z(t,n.u_device_pixel_ratio),u_image:new B(t,n.u_image),u_units_to_pixels:new H(t,n.u_units_to_pixels),u_scale:new jn(t,n.u_scale),u_fade:new z(t,n.u_fade)}),sl=(t,n)=>({u_translation:new H(t,n.u_translation),u_ratio:new z(t,n.u_ratio),u_device_pixel_ratio:new z(t,n.u_device_pixel_ratio),u_units_to_pixels:new H(t,n.u_units_to_pixels),u_image:new B(t,n.u_image),u_mix:new z(t,n.u_mix),u_tileratio:new z(t,n.u_tileratio),u_crossfade_from:new z(t,n.u_crossfade_from),u_crossfade_to:new z(t,n.u_crossfade_to),u_lineatlas_width:new z(t,n.u_lineatlas_width),u_lineatlas_height:new z(t,n.u_lineatlas_height)}),cl=(t,n)=>({u_translation:new H(t,n.u_translation),u_ratio:new z(t,n.u_ratio),u_device_pixel_ratio:new z(t,n.u_device_pixel_ratio),u_units_to_pixels:new H(t,n.u_units_to_pixels),u_image:new B(t,n.u_image),u_image_height:new z(t,n.u_image_height),u_tileratio:new z(t,n.u_tileratio),u_crossfade_from:new z(t,n.u_crossfade_from),u_crossfade_to:new z(t,n.u_crossfade_to),u_image_dash:new B(t,n.u_image_dash),u_mix:new z(t,n.u_mix),u_lineatlas_width:new z(t,n.u_lineatlas_width),u_lineatlas_height:new z(t,n.u_lineatlas_height)}),ll=(t,n,r,i)=>{let a=t.transform;return{u_translation:hl(t,n,r),u_ratio:i/rt(n,1,a.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},ul=(t,n,r,i,o)=>a(ll(t,n,r,i),{u_image:0,u_image_height:o}),dl=(t,n,r,i,a)=>{let o=t.transform,s=ml(n,o);return{u_translation:hl(t,n,r),u_texsize:n.imageAtlasTexture.size,u_ratio:i/rt(n,1,o.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},fl=(t,n,r,i,o)=>{let s=t.transform,c=ml(n,s);return a(ll(t,n,r,i),{u_tileratio:c,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image:0,u_mix:o.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})},pl=(t,n,r,i,o,s)=>{let c=t.transform,l=ml(n,c);return a(ll(t,n,r,i),{u_image:0,u_image_height:s,u_tileratio:l,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image_dash:1,u_mix:o.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})};function ml(t,n){return 1/rt(t,1,n.tileZoom)}function hl(t,n,r){return it(t.transform,n,r.paint.get(`line-translate`),r.paint.get(`line-translate-anchor`))}const gl=(t,n)=>({u_image:new B(t,n.u_image),u_opacity:new z(t,n.u_opacity)}),_l=(t,n)=>({u_image:n,u_opacity:t}),vl=(t,n)=>({u_tl_parent:new H(t,n.u_tl_parent),u_scale_parent:new z(t,n.u_scale_parent),u_buffer_scale:new z(t,n.u_buffer_scale),u_fade_t:new z(t,n.u_fade_t),u_opacity:new z(t,n.u_opacity),u_image0:new B(t,n.u_image0),u_image1:new B(t,n.u_image1),u_brightness_low:new z(t,n.u_brightness_low),u_brightness_high:new z(t,n.u_brightness_high),u_saturation_factor:new z(t,n.u_saturation_factor),u_contrast_factor:new z(t,n.u_contrast_factor),u_spin_weights:new jn(t,n.u_spin_weights),u_coords_top:new On(t,n.u_coords_top),u_coords_bottom:new On(t,n.u_coords_bottom)}),yl=(t,n,r,i,a)=>({u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get(`raster-opacity`),u_image0:0,u_image1:1,u_brightness_low:i.paint.get(`raster-brightness-min`),u_brightness_high:i.paint.get(`raster-brightness-max`),u_saturation_factor:Sl(i.paint.get(`raster-saturation`)),u_contrast_factor:xl(i.paint.get(`raster-contrast`)),u_spin_weights:bl(i.paint.get(`raster-hue-rotate`)),u_coords_top:[a[0].x,a[0].y,a[1].x,a[1].y],u_coords_bottom:[a[3].x,a[3].y,a[2].x,a[2].y]});function bl(t){t*=Math.PI/180;let n=Math.sin(t),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*n-r+1)/3,(Math.sqrt(3)*n-r+1)/3]}function xl(t){return t>0?1/(1-t):1+t}function Sl(t){return t>0?1-1/(1.001-t):-t}const Cl=(t,n)=>({u_is_size_zoom_constant:new B(t,n.u_is_size_zoom_constant),u_is_size_feature_constant:new B(t,n.u_is_size_feature_constant),u_size_t:new z(t,n.u_size_t),u_size:new z(t,n.u_size),u_camera_to_center_distance:new z(t,n.u_camera_to_center_distance),u_pitch:new z(t,n.u_pitch),u_rotate_symbol:new B(t,n.u_rotate_symbol),u_aspect_ratio:new z(t,n.u_aspect_ratio),u_fade_change:new z(t,n.u_fade_change),u_label_plane_matrix:new kn(t,n.u_label_plane_matrix),u_coord_matrix:new kn(t,n.u_coord_matrix),u_is_text:new B(t,n.u_is_text),u_pitch_with_map:new B(t,n.u_pitch_with_map),u_is_along_line:new B(t,n.u_is_along_line),u_is_variable_anchor:new B(t,n.u_is_variable_anchor),u_texsize:new H(t,n.u_texsize),u_texture:new B(t,n.u_texture),u_translation:new H(t,n.u_translation),u_pitched_scale:new z(t,n.u_pitched_scale),u_is_offset:new B(t,n.u_is_offset)}),wl=(t,n)=>({u_is_size_zoom_constant:new B(t,n.u_is_size_zoom_constant),u_is_size_feature_constant:new B(t,n.u_is_size_feature_constant),u_size_t:new z(t,n.u_size_t),u_size:new z(t,n.u_size),u_camera_to_center_distance:new z(t,n.u_camera_to_center_distance),u_pitch:new z(t,n.u_pitch),u_rotate_symbol:new B(t,n.u_rotate_symbol),u_aspect_ratio:new z(t,n.u_aspect_ratio),u_fade_change:new z(t,n.u_fade_change),u_label_plane_matrix:new kn(t,n.u_label_plane_matrix),u_coord_matrix:new kn(t,n.u_coord_matrix),u_is_text:new B(t,n.u_is_text),u_pitch_with_map:new B(t,n.u_pitch_with_map),u_is_along_line:new B(t,n.u_is_along_line),u_is_variable_anchor:new B(t,n.u_is_variable_anchor),u_texsize:new H(t,n.u_texsize),u_texture:new B(t,n.u_texture),u_gamma_scale:new z(t,n.u_gamma_scale),u_device_pixel_ratio:new z(t,n.u_device_pixel_ratio),u_is_halo:new B(t,n.u_is_halo),u_is_plain:new B(t,n.u_is_plain),u_translation:new H(t,n.u_translation),u_pitched_scale:new z(t,n.u_pitched_scale),u_is_offset:new B(t,n.u_is_offset)}),Tl=(t,n)=>({u_is_size_zoom_constant:new B(t,n.u_is_size_zoom_constant),u_is_size_feature_constant:new B(t,n.u_is_size_feature_constant),u_size_t:new z(t,n.u_size_t),u_size:new z(t,n.u_size),u_camera_to_center_distance:new z(t,n.u_camera_to_center_distance),u_pitch:new z(t,n.u_pitch),u_rotate_symbol:new B(t,n.u_rotate_symbol),u_aspect_ratio:new z(t,n.u_aspect_ratio),u_fade_change:new z(t,n.u_fade_change),u_label_plane_matrix:new kn(t,n.u_label_plane_matrix),u_coord_matrix:new kn(t,n.u_coord_matrix),u_is_text:new B(t,n.u_is_text),u_pitch_with_map:new B(t,n.u_pitch_with_map),u_is_along_line:new B(t,n.u_is_along_line),u_is_variable_anchor:new B(t,n.u_is_variable_anchor),u_texsize:new H(t,n.u_texsize),u_texsize_icon:new H(t,n.u_texsize_icon),u_texture:new B(t,n.u_texture),u_texture_icon:new B(t,n.u_texture_icon),u_gamma_scale:new z(t,n.u_gamma_scale),u_device_pixel_ratio:new z(t,n.u_device_pixel_ratio),u_is_halo:new B(t,n.u_is_halo),u_translation:new H(t,n.u_translation),u_pitched_scale:new z(t,n.u_pitched_scale),u_is_offset:new B(t,n.u_is_offset)}),El=(t,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let h=s.transform;return{u_is_size_zoom_constant:+(t===`constant`||t===`source`),u_is_size_feature_constant:+(t===`constant`||t===`camera`),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:h.cameraToCenterDistance,u_pitch:h.pitch/360*2*Math.PI,u_rotate_symbol:+r,u_aspect_ratio:h.width/h.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:c,u_coord_matrix:l,u_is_text:+d,u_pitch_with_map:+i,u_is_along_line:a,u_is_variable_anchor:o,u_texsize:f,u_texture:0,u_translation:u,u_pitched_scale:p,u_is_offset:m}},Dl=(t,n,r,i,o,s,c,l,u,d,f,p,m,h,g)=>{let _=c.transform;return a(El(t,n,r,i,o,s,c,l,u,d,f,p,h,g),{u_gamma_scale:i?Math.cos(_.pitch*Math.PI/180)*_.cameraToCenterDistance:1,u_device_pixel_ratio:c.pixelRatio,u_is_halo:+!!m,u_is_plain:1})},Ol=(t,n,r,i,o,s,c,l,u,d,f,p,m,h)=>a(Dl(t,n,r,i,o,s,c,l,u,d,!0,f,!0,m,h),{u_texsize_icon:p,u_texture_icon:1}),kl=(t,n)=>({u_opacity:new z(t,n.u_opacity),u_color:new An(t,n.u_color)}),Al=(t,n)=>({u_opacity:new z(t,n.u_opacity),u_image:new B(t,n.u_image),u_pattern_tl_a:new H(t,n.u_pattern_tl_a),u_pattern_br_a:new H(t,n.u_pattern_br_a),u_pattern_tl_b:new H(t,n.u_pattern_tl_b),u_pattern_br_b:new H(t,n.u_pattern_br_b),u_texsize:new H(t,n.u_texsize),u_mix:new z(t,n.u_mix),u_pattern_size_a:new H(t,n.u_pattern_size_a),u_pattern_size_b:new H(t,n.u_pattern_size_b),u_scale_a:new z(t,n.u_scale_a),u_scale_b:new z(t,n.u_scale_b),u_pixel_coord_upper:new H(t,n.u_pixel_coord_upper),u_pixel_coord_lower:new H(t,n.u_pixel_coord_lower),u_tile_units_to_pixels:new z(t,n.u_tile_units_to_pixels)}),jl=(t,n)=>({u_opacity:t,u_color:n}),Ml=(t,n,r,i,o)=>a(Tc(r,o,n,i),{u_opacity:t}),Nl=(t,n)=>({u_sun_pos:new jn(t,n.u_sun_pos),u_atmosphere_blend:new z(t,n.u_atmosphere_blend),u_globe_position:new jn(t,n.u_globe_position),u_globe_radius:new z(t,n.u_globe_radius),u_inv_proj_matrix:new kn(t,n.u_inv_proj_matrix)}),Pl=(t,n,r,i,a)=>({u_sun_pos:t,u_atmosphere_blend:n,u_globe_position:r,u_globe_radius:i,u_inv_proj_matrix:a}),Fl=(t,n)=>({u_sky_color:new An(t,n.u_sky_color),u_horizon_color:new An(t,n.u_horizon_color),u_horizon:new H(t,n.u_horizon),u_horizon_normal:new H(t,n.u_horizon_normal),u_sky_horizon_blend:new z(t,n.u_sky_horizon_blend),u_sky_blend:new z(t,n.u_sky_blend)}),Il=(t,n,r)=>{let i=Math.cos(n.rollInRadians),a=Math.sin(n.rollInRadians),o=Ca(n),s=n.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:t.properties.get(`sky-color`),u_horizon_color:t.properties.get(`horizon-color`),u_horizon:[(n.width/2-o*a)*r,(n.height/2+o*i)*r],u_horizon_normal:[-a,i],u_sky_horizon_blend:t.properties.get(`sky-horizon-blend`)*n.height/2*r,u_sky_blend:s}},Ll=(t,n)=>{},Rl={fillExtrusion:Dc,fillExtrusionPattern:Oc,fill:jc,fillPattern:Mc,fillOutline:Nc,fillOutlinePattern:Pc,circle:zc,collisionBox:Vc,collisionCircle:Hc,debug:Gc,depth:Ll,clippingMask:Ll,heatmap:qc,heatmapTexture:Jc,hillshade:Zc,hillshadePrepare:Qc,colorRelief:nl,line:il,lineGradient:al,linePattern:ol,lineSDF:sl,lineGradientSDF:cl,layerOpacity:gl,raster:vl,symbolIcon:Cl,symbolSDF:wl,symbolTextAndIcon:Tl,background:kl,backgroundPattern:Al,terrain:mc,terrainDepth:gc,terrainCoords:_c,atmosphere:Nl,sky:Fl};var Vl=class{constructor(t,n,r){this.context=t;let i=t.gl;this.buffer=i.createBuffer(),this.dynamicDraw=!!r,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||n.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let n=this.context.gl;if(!this.dynamicDraw)throw Error(`Attempted to update data while not in dynamic mode.`);this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){let t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}};const zl={Int8:`BYTE`,Uint8:`UNSIGNED_BYTE`,Int16:`SHORT`,Uint16:`UNSIGNED_SHORT`,Int32:`INT`,Uint32:`UNSIGNED_INT`,Float32:`FLOAT`};var Ul=class{constructor(t,n,r,i){this.length=n.length,this.attributes=r,this.itemSize=n.bytesPerElement,this.dynamicDraw=i,this.context=t;let a=t.gl;this.buffer=a.createBuffer(),t.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||n.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);let n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let r of this.attributes){let i=n.attributes[r.name];i!==void 0&&t.enableVertexAttribArray(i)}}setVertexAttribPointers(t,n,r){for(let i of this.attributes){let a=n.attributes[i.name];a!==void 0&&t.vertexAttribPointer(a,i.components,t[zl[i.type]],!1,this.itemSize,i.offset+this.itemSize*(r||0))}}destroy(){let t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}},Y=class{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}},Wl=class extends Y{getDefault(){return V.transparent}set(t){let n=this.current;t.r===n.r&&t.g===n.g&&t.b===n.b&&t.a===n.a&&!this.dirty||(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},Gl=class extends Y{getDefault(){return 1}set(t){t===this.current&&!this.dirty||(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}},Kl=class extends Y{getDefault(){return 0}set(t){t===this.current&&!this.dirty||(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}},ql=class extends Y{getDefault(){return[!0,!0,!0,!0]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&!this.dirty||(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},Jl=class extends Y{getDefault(){return!0}set(t){t===this.current&&!this.dirty||(this.gl.depthMask(t),this.current=t,this.dirty=!1)}},Yl=class extends Y{getDefault(){return 255}set(t){t===this.current&&!this.dirty||(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}},Xl=class extends Y{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let n=this.current;t.func===n.func&&t.ref===n.ref&&t.mask===n.mask&&!this.dirty||(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}},Zl=class extends Y{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&!this.dirty||(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}},Ql=class extends Y{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}},$l=class extends Y{getDefault(){return[0,1]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&!this.dirty||(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}},eu=class extends Y{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}},tu=class extends Y{getDefault(){return this.gl.LESS}set(t){t===this.current&&!this.dirty||(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}},nu=class extends Y{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}},ru=class extends Y{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&!this.dirty||(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}},iu=class extends Y{getDefault(){return V.transparent}set(t){let n=this.current;t.r===n.r&&t.g===n.g&&t.b===n.b&&t.a===n.a&&!this.dirty||(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},au=class extends Y{getDefault(){return this.gl.FUNC_ADD}set(t){t===this.current&&!this.dirty||(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}},ou=class extends Y{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}},su=class extends Y{getDefault(){return this.gl.BACK}set(t){t===this.current&&!this.dirty||(this.gl.cullFace(t),this.current=t,this.dirty=!1)}},cu=class extends Y{getDefault(){return this.gl.CCW}set(t){t===this.current&&!this.dirty||(this.gl.frontFace(t),this.current=t,this.dirty=!1)}},lu=class extends Y{getDefault(){return null}set(t){t===this.current&&!this.dirty||(this.gl.useProgram(t),this.current=t,this.dirty=!1)}},uu=class extends Y{getDefault(){return this.gl.TEXTURE0}set(t){t===this.current&&!this.dirty||(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}},du=class extends Y{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let n=this.current;t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&!this.dirty||(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},fu=class extends Y{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}},pu=class extends Y{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}},mu=class extends Y{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}},hu=class extends Y{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},gu=class extends Y{getDefault(){return null}set(t){let n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},_u=class extends Y{getDefault(){return null}set(t){t===this.current&&!this.dirty||(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}},vu=class extends Y{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}},yu=class extends Y{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}},bu=class extends Y{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}},xu=class extends Y{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}},Su=class extends xu{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}},Cu=class extends xu{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}},wu=class extends xu{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}},Tu=class{constructor(t,n,r,i,a){this.context=t,this.width=n,this.height=r;let o=t.gl,s=this.framebuffer=o.createFramebuffer();if(this.colorAttachment=new Su(t,s),i)this.depthAttachment=a?new wu(t,s):new Cu(t,s);else if(a)throw Error(`Stencil cannot be set without depth`)}destroy(){let t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){let n=this.depthAttachment.get();n&&t.deleteRenderbuffer(n)}t.deleteFramebuffer(this.framebuffer)}},X=class{constructor(t,n,r){this.blendFunction=t,this.blendColor=n,this.mask=r}};X.Replace=[1,0],X.disabled=new X(X.Replace,V.transparent,[!1,!1,!1,!1]),X.unblended=new X(X.Replace,V.transparent,[!0,!0,!0,!0]),X.alphaBlended=new X([1,771],V.transparent,[!0,!0,!0,!0]);var Eu=class{constructor(t){this.gl=t,this.clearColor=new Wl(this),this.clearDepth=new Gl(this),this.clearStencil=new Kl(this),this.colorMask=new ql(this),this.depthMask=new Jl(this),this.stencilMask=new Yl(this),this.stencilFunc=new Xl(this),this.stencilOp=new Zl(this),this.stencilTest=new Ql(this),this.depthRange=new $l(this),this.depthTest=new eu(this),this.depthFunc=new tu(this),this.blend=new nu(this),this.blendFunc=new ru(this),this.blendColor=new iu(this),this.blendEquation=new au(this),this.cullFace=new ou(this),this.cullFaceSide=new su(this),this.frontFace=new cu(this),this.program=new lu(this),this.activeTexture=new uu(this),this.viewport=new du(this),this.bindFramebuffer=new fu(this),this.bindRenderbuffer=new pu(this),this.bindTexture=new mu(this),this.bindVertexBuffer=new hu(this),this.bindElementBuffer=new gu(this),this.bindVertexArray=new _u(this),this.pixelStoreUnpack=new vu(this),this.pixelStoreUnpackPremultiplyAlpha=new yu(this),this.pixelStoreUnpackFlipY=new bu(this),this.extTextureFilterAnisotropic=t.getExtension(`EXT_texture_filter_anisotropic`),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),t.getExtension(`EXT_color_buffer_half_float`),t.getExtension(`EXT_color_buffer_float`)}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}createIndexBuffer(t,n){return new Vl(this,t,n)}createVertexBuffer(t,n,r){return new Ul(this,t,n,r)}createRenderbuffer(t,n,r){let i=this.gl,a=i.createRenderbuffer();return this.bindRenderbuffer.set(a),i.renderbufferStorage(i.RENDERBUFFER,t,n,r),this.bindRenderbuffer.set(null),a}createFramebuffer(t,n,r,i){return new Tu(this,t,n,r,i)}clear({color:t,depth:n,stencil:r}){let i=this.gl,a=0;t&&(a|=i.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(a|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),r!==void 0&&(a|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),i.clear(a)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func===this.gl.ALWAYS&&!t.mask?this.depthTest.set(!1):(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range))}setStencilMode(t){t.test.func===this.gl.ALWAYS&&!t.mask?this.stencilTest.set(!1):(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask}))}setColorMode(t){hn(t.blendFunction,X.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){return this.gl.createVertexArray()}deleteVertexArray(t){this.gl.deleteVertexArray(t)}unbindVAO(){this.bindVertexArray.set(null)}},Z=class{constructor(t,n,r){this.func=t,this.mask=n,this.range=r}};Z.ReadOnly=!1,Z.ReadWrite=!0,Z.disabled=new Z(519,Z.ReadOnly,[0,1]);const Bl=7680;var Q=class{constructor(t,n,r,i,a,o){this.test=t,this.ref=n,this.mask=r,this.fail=i,this.depthFail=a,this.pass=o}};Q.disabled=new Q({func:519,mask:0},0,0,Bl,Bl,Bl);const Hl=1029,Du=2305;var $=class{constructor(t,n,r){this.enable=t,this.mode=n,this.frontFace=r}};$.disabled=new $(!1,Hl,Du),$.backCCW=new $(!0,Hl,Du),$.frontCCW=new $(!0,1028,Du);let Ou;function ku(t,n,r,i,a){let o=t.context,s=t.transform,c=o.gl,l=t.useProgram(`collisionBox`),u=[],d=0,f=0;for(let p of i){let i=n.getTile(p).getBucket(r);if(!i)continue;let m=a?i.textCollisionBox:i.iconCollisionBox,h=i.collisionCircleArray;h.length>0&&(u.push({circleArray:h,circleOffset:f,coord:p}),d+=h.length/4,f=d),m&&l.draw(o,c.LINES,Z.disabled,Q.disabled,t.colorModeForRenderPass(),$.disabled,Uc(t.transform),t.style.map.terrain?.getTerrainData(p),s.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,t.transform.zoom,null,null,m.collisionVertexBuffer)}if(!a||!u.length)return;let p=t.useProgram(`collisionCircle`),m=new Rn;m.resize(d*4),m._trim();let h=0;for(let t of u)for(let n=0;nd.getElevation(a,t,n):null;Iu(o,f,p,l,u,_,n,h,v,it(u,t,s,c),a.toUnwrapped(),r)}}}function Fu(t,n,r,a,o,s){let c=n.tileAnchorPoint.add(new i(n.translation[0],n.translation[1]));if(n.pitchWithMap){let t=a.mult(s);r||(t=t.rotate(-o));let i=c.add(t);return no(i.x,i.y,n.pitchedLabelPlaneMatrix,n.getElevation).point}else if(r){let r=fo(n.tileAnchorPoint.x+1,n.tileAnchorPoint.y,n).point.sub(t),i=Math.atan(r.y/r.x)+(r.x<0?Math.PI:0);return t.add(a.rotate(i))}else return t.add(a)}function Iu(t,n,r,a,o,s,c,l,u,d,f,p){let m=t.text.placedSymbolArray,h=t.text.dynamicLayoutVertexArray,g=t.icon.dynamicLayoutVertexArray,_={};h.clear();for(let g=0;g=0&&(_[v.associatedIconIndex]={shiftedAnchor:k,angle:A})}}if(u){g.clear();let n=t.icon.placedSymbolArray;for(let t=0;tt.style.map.terrain.getElevation(c,n,r):null;ao(l,t,a,ae,n,v,u,r.layout.get(`text-rotation-alignment`)===`map`,c.toUnwrapped(),g.width,g.height,se,i)}let P=a&&w||ue,fe=v?ae:t.transform.clipSpaceToPixelsMatrix,pe=y||P?ju:fe,me=m&&r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(1)!==0,he;he=m?l.iconsInText?Ol(C.kind,k,b,v,y,P,t,pe,oe,se,j,ee,E,de):Dl(C.kind,k,b,v,y,P,t,pe,oe,se,a,j,me,E,de):El(C.kind,k,b,v,y,P,t,pe,oe,se,a,j,E,de);let ge={program:O,buffers:d,uniformValues:he,projectionData:N,atlasTexture:te,atlasTextureIcon:ne,atlasInterpolation:M,atlasInterpolationIcon:re,isSDF:m,hasHalo:me};if(x&&l.canOverlap){S=!0;let t=d.segments.get();for(let n of t)T.push({segments:new ft([n]),sortKey:n.sortKey,state:ge,terrainData:A})}else T.push({segments:d.segments,sortKey:0,state:ge,terrainData:A})}S&&T.sort((t,n)=>t.sortKey-n.sortKey);let D=r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(null)??1/0,O=r.layout.get(`text-letter-spacing`).constantOr(0)*24<0||D>1;for(let n of T){let i=n.state;m.activeTexture.set(h.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,h.CLAMP_TO_EDGE),i.atlasTextureIcon&&(m.activeTexture.set(h.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,h.CLAMP_TO_EDGE));let a=i.isSDF&&i.hasHalo;if(a){let a=i.uniformValues;a.u_is_halo=1,O&&(a.u_is_plain=0,zu(i.buffers,n.segments,r,t,i.program,C,d,f,a,i.projectionData,n.terrainData),a.u_is_halo=0,a.u_is_plain=1)}zu(i.buffers,n.segments,r,t,i.program,C,d,f,i.uniformValues,i.projectionData,n.terrainData),a&&!O&&(i.uniformValues.u_is_halo=0)}}function zu(t,n,r,i,a,o,s,c,l,u,d){let f=i.context,p=f.gl;a.draw(f,p.TRIANGLES,o,s,c,$.backCCW,l,d,u,r.id,t.layoutVertexBuffer,t.indexBuffer,n,r.paint,i.transform.zoom,t.programConfigurations.get(r.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Bu(t,n,r,i,a){if(t.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=r.paint.get(`circle-opacity`),c=r.paint.get(`circle-stroke-width`),l=r.paint.get(`circle-stroke-opacity`),u=!r.layout.get(`circle-sort-key`).isConstant();if(s.constantOr(1)===0&&(c.constantOr(1)===0||l.constantOr(1)===0))return;let d=t.context,f=d.gl,p=t.transform,m=t.getDepthModeForSublayer(0,Z.ReadOnly),h=Q.disabled,g=t.colorModeForRenderPass(),_=[],v=p.getCircleRadiusCorrection();for(let a of i){let i=n.getTile(a),s=i.getBucket(r);if(!s)continue;let c=it(p,i,r.paint.get(`circle-translate`),r.paint.get(`circle-translate-anchor`)),l=s.programConfigurations.get(r.id),d=t.useProgram(`circle`,l),f=s.layoutVertexBuffer,m=s.indexBuffer,h=t.style.map.terrain?.getTerrainData(a),g={programConfiguration:l,program:d,layoutVertexBuffer:f,indexBuffer:m,uniformValues:Bc(t,i,r,c,v),terrainData:h,projectionData:p.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!o,applyTerrainMatrix:!0})};if(u){let t=s.segments.get();for(let n of t)_.push({segments:new ft([n]),sortKey:n.sortKey,state:g})}else _.push({segments:s.segments,sortKey:0,state:g})}u&&_.sort((t,n)=>t.sortKey-n.sortKey);for(let n of _){let{programConfiguration:i,program:a,layoutVertexBuffer:o,indexBuffer:s,uniformValues:c,terrainData:l,projectionData:u}=n.state,p=n.segments;a.draw(d,f.TRIANGLES,m,h,g,$.backCCW,c,l,u,r.id,o,s,p,r.paint,t.transform.zoom,i)}}function Vu(t,n,r,i,a){if(r.paint.get(`heatmap-opacity`)===0)return;let o=t.context,{isRenderingToTexture:s,isRenderingGlobe:c}=a;if(t.style.map.terrain){for(let a of i){let i=n.getTile(a);n.hasRenderableParent(a)||(t.renderPass===`offscreen`?Wu(t,i,r,a,c):t.renderPass===`translucent`&&Gu(t,r,a,s,c))}o.viewport.set([0,0,t.width,t.height])}else t.renderPass===`offscreen`?Hu(t,n,r,i):t.renderPass===`translucent`&&Uu(t,r)}function Hu(t,n,r,i){let a=t.context,o=a.gl,s=t.transform,c=Q.disabled,l=new X([o.ONE,o.ONE],V.transparent,[!0,!0,!0,!0]);Ku(a,t,r),a.clear({color:V.transparent});for(let u of i){if(n.hasRenderableParent(u))continue;let i=n.getTile(u),d=i.getBucket(r);if(!d)continue;let f=d.programConfigurations.get(r.id),p=t.useProgram(`heatmap`,f),m=s.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),h=s.getCircleRadiusCorrection();p.draw(a,o.TRIANGLES,Z.disabled,c,l,$.backCCW,Yc(i,s.zoom,r.paint.get(`heatmap-intensity`),h),null,m,r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,s.zoom,f)}a.viewport.set([0,0,t.width,t.height])}function Uu(t,n){let r=t.context,i=r.gl;r.setColorMode(t.colorModeForRenderPass());let a=n.heatmapFbos.get(Vn);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),Ju(r,n).bind(i.LINEAR,i.CLAMP_TO_EDGE),t.useProgram(`heatmapTexture`).draw(r,i.TRIANGLES,Z.disabled,Q.disabled,t.colorModeForRenderPass(),$.disabled,Xc(t,n,0,1),null,null,n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,n.paint,t.transform.zoom))}function Wu(t,n,r,i,a){let o=t.context,s=o.gl,c=Q.disabled,l=new X([s.ONE,s.ONE],V.transparent,[!0,!0,!0,!0]),u=n.getBucket(r);if(!u)return;let d=i.key,f=r.heatmapFbos.get(d);f||(f=qu(o,n.tileSize,n.tileSize),r.heatmapFbos.set(d,f)),o.bindFramebuffer.set(f.framebuffer),o.viewport.set([0,0,n.tileSize,n.tileSize]),o.clear({color:V.transparent});let p=u.programConfigurations.get(r.id),m=t.useProgram(`heatmap`,p,!a),h=t.transform.getProjectionData({overscaledTileID:n.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=t.style.map.terrain.getTerrainData(i);m.draw(o,s.TRIANGLES,Z.disabled,c,l,$.disabled,Yc(n,t.transform.zoom,r.paint.get(`heatmap-intensity`),1),g,h,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,t.transform.zoom,p)}function Gu(t,n,r,i,a){let o=t.context,s=o.gl,c=t.transform;o.setColorMode(t.colorModeForRenderPass());let l=Ju(o,n),u=r.key,d=n.heatmapFbos.get(u);if(!d)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,d.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);let f=c.getProjectionData({overscaledTileID:r,applyTerrainMatrix:a,applyGlobeMatrix:!i});t.useProgram(`heatmapTexture`).draw(o,s.TRIANGLES,Z.disabled,Q.disabled,t.colorModeForRenderPass(),$.disabled,Xc(t,n,0,1),null,f,n.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,n.paint,c.zoom),d.destroy(),n.heatmapFbos.delete(u)}function Ku(t,n,r){let i=t.gl;t.activeTexture.set(i.TEXTURE1),t.viewport.set([0,0,n.width/4,n.height/4]);let a=r.heatmapFbos.get(Vn);a?(i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),t.bindFramebuffer.set(a.framebuffer)):(a=qu(t,n.width/4,n.height/4),r.heatmapFbos.set(Vn,a))}function qu(t,n,r){let i=t.gl,a=i.createTexture();i.bindTexture(i.TEXTURE_2D,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texStorage2D(i.TEXTURE_2D,1,i.RGBA16F,n,r);let o=t.createFramebuffer(n,r,!1,!1);return o.colorAttachment.set(a),o}function Ju(t,n){return n.colorRampTexture||=new S(t,n.colorRamp,t.gl.RGBA),n.colorRampTexture}function Yu(t,n,r,i){let a=t.context,o=a.bindFramebuffer.get(),s=a.viewport.get(),[,,c,l]=s;return Xu(t,c,l),a.viewport.set([0,0,c,l]),a.clear({color:V.transparent,depth:1,stencil:0}),t.currentStencilSource=void 0,t.renderTileClippingMasks(n,r,i),{compositeTarget:o,compositeViewport:s}}function Xu(t,n,r){let i=t.context.gl;if(!t.layerOpacityFbo){let a=t.context.createFramebuffer(n,r,!0,!0),o=i.createTexture();i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,r,0,i.RGBA,i.UNSIGNED_BYTE,null),a.colorAttachment.set(o),a.depthAttachment.set(t.context.createRenderbuffer(i.DEPTH_STENCIL,n,r)),t.layerOpacityFbo=a,t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer);return}if(t.layerOpacityFbo.width===n&&t.layerOpacityFbo.height===r){t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer);return}let a=t.layerOpacityFbo;i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,r,0,i.RGBA,i.UNSIGNED_BYTE,null),t.context.bindRenderbuffer.set(a.depthAttachment.get()),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,n,r),t.context.bindRenderbuffer.set(null),a.width=n,a.height=r,t.context.bindFramebuffer.set(a.framebuffer)}function Zu(t,n,r,i){let a=t.context,o=a.gl;a.bindFramebuffer.set(r.compositeTarget),a.viewport.set(r.compositeViewport),a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,t.layerOpacityFbo.colorAttachment.get()),t.useProgram(`layerOpacity`).draw(a,o.TRIANGLES,Z.disabled,Q.disabled,t.colorModeForRenderPass(),$.disabled,_l(n,0),null,null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom),t.currentStencilSource=void 0}function Qu(t,n,r,i,a,o,s,c){let l=256;if(a.stepInterpolant){let i=n.getSource().maxzoom,a=s.canonical.z===i?Math.ceil(1<t.options.anisotropicFilterPitch&&p.texParameterf(p.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);let k=t.getTerrainDataForTile(C,u),A=h.getProjectionData({overscaledTileID:C,aligned:v,applyGlobeMatrix:!u,applyTerrainMatrix:!0}),j=yl(D,E,O.fadeMix,r,c),ee=g.getMeshFromTileID(f,C.canonical,o,s,`raster`),te=a?a[C.overscaledZ]:Q.disabled;m.draw(f,p.TRIANGLES,i,te,_,l?$.frontCCW:$.backCCW,j,k,A,r.id,ee.vertexBuffer,ee.indexBuffer,ee.segments)}}function xd(t,n,r,i){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(r===0||i)return a;if(t.fadingParentID){let i=n.getLoadedTile(t.fadingParentID);if(!i)return a;let o=2**(i.tileID.overscaledZ-t.tileID.overscaledZ);return{parentTile:i,parentScaleBy:o,parentTopLeft:[t.tileID.canonical.x*o%1,t.tileID.canonical.y*o%1],fadeValues:Sd(t,i,r)}}return t.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:Cd(t,r)}:a}function Sd(t,n,r){let i=U(),a=(i-t.timeAdded)/r,o=(i-n.timeAdded)/r,s=t.fadingDirection===1,c=L(a,0,1),l=L(1-o,0,1),u=s?c:l;return{tileOpacity:u,parentTileOpacity:s?l:c,fadeMix:{opacity:1,mix:1-u}}}function Cd(t,n){let r=L((U()-t.timeAdded)/n,0,1);return{tileOpacity:r,fadeMix:{opacity:r,mix:0}}}function wd(t,n,r,i,a){let o=r.paint.get(`background-color`),s=r.paint.get(`background-opacity`);if(s===0)return;let{isRenderingToTexture:c}=a,l=t.context,u=l.gl,d=t.style.projection,f=t.transform,p=f.tileSize,m=r.paint.get(`background-pattern`);if(t.isPatternMissing(m))return;let h=!m&&o.a===1&&s===1&&t.opaquePassEnabledForLayer()?`opaque`:`translucent`;if(t.renderPass!==h)return;let g=Q.disabled,_=t.getDepthModeForSublayer(0,h===`opaque`?Z.ReadWrite:Z.ReadOnly),v=t.colorModeForRenderPass(),y=t.useProgram(m?`backgroundPattern`:`background`),b=i||Na(f,{tileSize:p,terrain:t.style.map.terrain});m&&(l.activeTexture.set(u.TEXTURE0),t.imageManager.bind(t.context));let x=r.getCrossfadeParameters();for(let n of b){let i=f.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),a=m?Ml(s,t,m,{tileID:n,tileSize:p},x):jl(s,o),h=t.getTerrainDataForTile(n,c),b=d.getMeshFromTileID(l,n.canonical,!1,!0,`raster`);y.draw(l,u.TRIANGLES,_,g,v,$.backCCW,a,h,i,r.id,b.vertexBuffer,b.indexBuffer,b.segments)}}const Td=new V(1,0,0,1),Ed=new V(0,1,0,1),Dd=new V(0,0,1,1),Od=new V(1,0,1,1),kd=new V(0,1,1,1);function Ad(t){let n=t.transform.padding;Md(t,t.transform.height-(n.top||0),3,Td),Md(t,n.bottom||0,3,Ed),Nd(t,n.left||0,3,Dd),Nd(t,t.transform.width-(n.right||0),3,Od);let r=t.transform.centerPoint;jd(t,r.x,t.transform.height-r.y,kd)}function jd(t,n,r,i){Pd(t,n-2/2,r-20/2,2,20,i),Pd(t,n-20/2,r-2/2,20,2,i)}function Md(t,n,r,i){Pd(t,0,n+r/2,t.transform.width,r,i)}function Nd(t,n,r,i){Pd(t,n-r/2,0,r,t.transform.height,i)}function Pd(t,n,r,i,a,o){let s=t.context,c=s.gl;c.enable(c.SCISSOR_TEST),c.scissor(n*t.pixelRatio,r*t.pixelRatio,i*t.pixelRatio,a*t.pixelRatio),s.clear({color:o}),c.disable(c.SCISSOR_TEST)}function Fd(t,n,r){for(let i of r)Id(t,n,i)}function Id(t,n,r){let i=t.context,a=i.gl,o=t.useProgram(`debug`),s=Z.disabled,c=Q.disabled,l=t.colorModeForRenderPass(),u=`$debug`,d=t.style.map.terrain?.getTerrainData(r);i.activeTexture.set(a.TEXTURE0);let f=n.getTileByID(r.key).latestRawTileData?.byteLength||0,p=Math.floor(f/1024),m=n.getTile(r).tileSize,h=512/Math.min(m,512)*(r.overscaledZ/t.transform.zoom)*.5,g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),Ld(t,`${g} ${p}kB`);let _=t.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(i,a.TRIANGLES,s,c,X.alphaBlended,$.disabled,Kc(V.transparent,h),null,_,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),o.draw(i,a.LINE_STRIP,s,c,l,$.disabled,Kc(V.red),d,_,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Ld(t,n){t.initDebugOverlayCanvas();let r=t.debugOverlayCanvas,i=t.context.gl,a=t.debugOverlayCanvas.getContext(`2d`);a.clearRect(0,0,r.width,r.height),a.shadowColor=`white`,a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle=`white`,a.textBaseline=`top`,a.font=`bold 36px Open Sans, sans-serif`,a.fillText(n,5,5),a.strokeText(n,5,5),t.debugOverlayTexture.update(r),t.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}function Rd(t,n){let r=null,i=Object.values(t._layers).flatMap(r=>r.source&&!r.isHidden(n)?[t.tileManagers[r.source]]:[]),a=i.filter(t=>t.getSource().type===`vector`),o=i.filter(t=>t.getSource().type!==`vector`),s=t=>{(!r||r.getSource().maxzooml.getProjectionData({overscaledTileID:new ye(t.tileID.canonical.z,t.tileID.wrap??0,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),aligned:t.aligned,applyGlobeMatrix:t.applyGlobeMatrix,applyTerrainMatrix:t.applyTerrainMatrix})},f=s.renderingMode?s.renderingMode:`2d`;if(t.renderPass===`offscreen`){let n=s.prerender;n&&(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),n.call(s,o.gl,d),o.setDirty(),t.setBaseState())}else if(t.renderPass===`translucent`){t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(Q.disabled);let n=f===`3d`?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,Z.ReadOnly);o.setDepthMode(n),s.render(o.gl,d),o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}function Bd(t,n){let r=t.context,i=r.gl,a=t.transform,o=X.unblended,s=new Z(i.LEQUAL,Z.ReadWrite,[0,1]),c=n.tileManager.getRenderableTiles(),l=t.useProgram(`terrainDepth`);r.bindFramebuffer.set(n.getFramebuffer(`depth`).framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:V.transparent,depth:1});for(let t of c){let c=n.getTerrainMesh(t.tileID),u=n.getTerrainData(t.tileID),d=a.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),f=yc(n.getSkirtLength(a.zoom));l.draw(r,i.TRIANGLES,s,Q.disabled,o,$.backCCW,f,u,d,`terrain`,c.vertexBuffer,c.indexBuffer,c.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}function Vd(t,n){let r=t.context,i=r.gl,a=t.transform,o=X.unblended,s=new Z(i.LEQUAL,Z.ReadWrite,[0,1]),c=n.getCoordsTexture(),l=n.tileManager.getRenderableTiles(),u=t.useProgram(`terrainCoords`);r.bindFramebuffer.set(n.getFramebuffer(`coords`).framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:V.transparent,depth:1}),n.coordsIndex=[];for(let t of l){let l=n.getTerrainMesh(t.tileID),d=n.getTerrainData(t.tileID);r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,c.texture);let f=bc(255-n.coordsIndex.length,n.getSkirtLength(a.zoom)),p=a.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(r,i.TRIANGLES,s,Q.disabled,o,$.backCCW,f,d,p,`terrain`,l.vertexBuffer,l.indexBuffer,l.segments),n.coordsIndex.push(t.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}function Hd(t,n,r,i){let{isRenderingGlobe:a}=i,o=t.context,s=o.gl,c=t.transform,l=t.colorModeForRenderPass(),u=t.getDepthModeFor3D(),d=t.useProgram(`terrain`);o.bindFramebuffer.set(null),o.viewport.set([0,0,t.width,t.height]);for(let i of r){let r=n.getTerrainMesh(i.tileID),f=t.renderToTexture.getTexture(i),p=n.getTerrainData(i.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,f.texture);let m=vc(n.getSkirtLength(c.zoom),c.calculateFogMatrix(i.tileID.toUnwrapped()),t.style.sky,c.pitch,a),h=c.getProjectionData({overscaledTileID:i.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});d.draw(o,s.TRIANGLES,u,Q.disabled,l,$.backCCW,m,p,h,`terrain`,r.vertexBuffer,r.indexBuffer,r.segments)}}function Ud(t,n){if(!n.mesh){let r=new dt;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new pt;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),n.mesh=new us(t.createVertexBuffer(r,cs.members),t.createIndexBuffer(i),ft.simpleSegment(0,0,r.length,i.length))}return n.mesh}function Wd(t,n){let r=t.context,i=r.gl,a=Il(n,t.transform,t.pixelRatio),o=new Z(i.LEQUAL,Z.ReadWrite,[0,1]),s=Q.disabled,c=t.colorModeForRenderPass(),l=t.useProgram(`sky`),u=Ud(r,n);l.draw(r,i.TRIANGLES,o,s,c,$.disabled,a,null,void 0,`sky`,u.vertexBuffer,u.indexBuffer,u.segments)}function Gd(t,n){let r=t.getCartesianPosition();Wn(r,r);let i=Ie(new Float64Array(16));return t.properties.get(`anchor`)===`map`&&(Pt(i,i,n.rollInRadians),Ft(i,i,-n.pitchInRadians),Pt(i,i,n.bearingInRadians),Ft(i,i,n.center.lat*Math.PI/180),sn(i,i,-n.center.lng*Math.PI/180)),Gn(r,r,i),r}function Kd(t,n,r){let i=t.context,a=i.gl,o=t.useProgram(`atmosphere`),s=new Z(a.LEQUAL,Z.ReadOnly,[0,1]),c=t.transform,l=Gd(r,t.transform),u=c.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),d=n.properties.get(`atmosphere-blend`)*u.projectionTransition;if(d===0)return;let f=Us(c.worldSize,c.center.lat),p=c.inverseProjectionMatrix,m=new Float64Array(4);m[3]=1,Je(m,m,c.modelViewProjectionMatrix),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1,Je(m,m,p),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1;let h=Pl(l,d,[m[0],m[1],m[2]],f,p),g=Ud(i,n);o.draw(i,a.TRIANGLES,s,Q.disabled,X.alphaBlended,$.disabled,h,null,null,`atmosphere`,g.vertexBuffer,g.indexBuffer,g.segments)}const qd={symbol:Mu,circle:Bu,heatmap:Vu,line:rd,fill:od,fillExtrusion:ud,hillshade:fd,colorRelief:hd,raster:yd,background:wd,sky:Wd,atmosphere:Kd,custom:zd,debug:Fd,debugPadding:Ad,terrainDepth:Bd,terrainCoords:Vd};var Jd=class e{constructor(t,n){this.drawFunctions=qd,this.context=new Eu(t),this.transform=n,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:Ie(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Wa.maxOverzooming+Wa.maxUnderzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new $o}resize(t,n,r){if(this.width=Math.floor(t*r),this.height=Math.floor(n*r),this.pixelRatio=r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let t of this.style._order)this.style._layers[t].resize()}setup(){let t=this.context,n=new dt;n.emplaceBack(0,0),n.emplaceBack(F,0),n.emplaceBack(0,F),n.emplaceBack(F,F),this.tileExtentBuffer=t.createVertexBuffer(n,cs.members),this.tileExtentSegments=ft.simpleSegment(0,0,4,2);let r=new dt;r.emplaceBack(0,0),r.emplaceBack(F,0),r.emplaceBack(0,F),r.emplaceBack(F,F),this.debugBuffer=t.createVertexBuffer(r,cs.members),this.debugSegments=ft.simpleSegment(0,0,4,5);let i=new Kn;i.emplaceBack(0,0,0,0),i.emplaceBack(F,0,F,0),i.emplaceBack(0,F,0,F),i.emplaceBack(F,F,F,F),this.rasterBoundsBuffer=t.createVertexBuffer(i,dc.members),this.rasterBoundsSegments=ft.simpleSegment(0,0,4,2);let a=new dt;a.emplaceBack(0,0),a.emplaceBack(F,0),a.emplaceBack(0,F),a.emplaceBack(F,F),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(a,cs.members),this.rasterBoundsSegmentsPosOnly=ft.simpleSegment(0,0,4,5);let o=new dt;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(o,cs.members),this.viewportSegments=ft.simpleSegment(0,0,4,2);let s=new qn;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(s);let c=new pt;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(c);let l=this.context.gl;this.stencilClearMode=new Q({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new us(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=ce();Fn(r,0,this.width,this.height,0,0,1),le(r,r,[n.drawingBufferWidth,n.drawingBufferHeight,0]);let i={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r,clipAntimeridian:!1};this.useProgram(`clippingMask`,null,!0).draw(t,n.TRIANGLES,Z.disabled,this.stencilClearMode,X.disabled,$.disabled,null,null,i,`$clipping`,this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(t,n,r){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n?.length)return;this.currentStencilSource=t.source,this.nextStencilID+n.length>256&&this.clearStencil();let i=this.context;i.setColorMode(X.disabled),i.setDepthMode(Z.disabled);let a={};for(let t of n)a[t.key]=this.nextStencilID++;this._renderTileMasks(a,n,r,!0),this._renderTileMasks(a,n,r,!1),this._tileClippingMaskIDs=a}_renderTileMasks(t,n,r,i){let a=this.context,o=a.gl,s=this.style.projection,c=this.transform,l=this.useProgram(`clippingMask`);for(let u of n){let n=t[u.key],d=this.getTerrainDataForTile(u,r),f=s.getMeshFromTileID(this.context,u.canonical,i,!0,`stencil`),p=c.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!r,applyTerrainMatrix:!0});l.draw(a,o.TRIANGLES,Z.disabled,new Q({func:o.ALWAYS,mask:0},n,255,o.KEEP,o.KEEP,o.REPLACE),X.disabled,r?$.disabled:$.backCCW,null,d,p,`$clipping`,f.vertexBuffer,f.indexBuffer,f.segments)}}getTerrainDataForTile(t,n){return n&&this.style.projection?.name===`mercator`?null:this.style.map.terrain?.getTerrainData(t)||null}_renderTilesDepthBuffer(){let t=this.context,n=t.gl,r=this.style.projection,i=this.transform,a=this.useProgram(`depth`),o=this.getDepthModeFor3D(),s=Na(i,{tileSize:i.tileSize});for(let c of s){let s=this.style.map.terrain?.getTerrainData(c),l=r.getMeshFromTileID(this.context,c.canonical,!0,!0,`raster`),u=i.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(t,n.TRIANGLES,o,Q.disabled,X.disabled,$.backCCW,null,s,u,`$clipping`,l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,n=this.context.gl;return new Q({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){let n=this.context.gl;return new Q({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){let n=this.context.gl,r=t.sort((t,n)=>n.overscaledZ-t.overscaledZ),i=r[r.length-1].overscaledZ,a=r[0].overscaledZ-i+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();let t={};for(let r=0;rn.overscaledZ-t.overscaledZ),i=r[r.length-1].overscaledZ,a=r[0].overscaledZ-i+1;if(this.clearStencil(),a>1){let t={},o={};for(let r=0;r0};for(let t in i){let n=i[t];n.used&&n.prepare(this.context),a[t]=n.getVisibleCoordinates(!1),o[t]=a[t].slice().reverse(),s[t]=n.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t=0;this.currentLayer--){let t=this.style._layers[r[this.currentLayer]],n=i[t.source],o=a[t.source];this.renderTileClippingMasks(t,o,!1),this.renderLayer(this,n,t,o,c)}this.renderPass=`translucent`;let l=!1;for(this.currentLayer=0;this.currentLayer0?n.pop():null}acquireRTT(t){let n=this.context.gl,r=this._rttObjectRecyclePool.pop();if(r)return r.size!==t&&(n.bindTexture(n.TEXTURE_2D,r.texture.texture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t,t,0,n.RGBA,n.UNSIGNED_BYTE,null),r.texture.size=[t,t],r.size=t),r;let i=new S(this.context,{width:t,height:t,data:null},n.RGBA);return i.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.context.extTextureFilterAnisotropic&&n.texParameterf(n.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:i,size:t}}bindRTT(t){let n=this.context.gl,r=t.size;if(!this._rttSharedFbo){let t=this.context.createFramebuffer(r,r,!0,!0),i=this.context.createRenderbuffer(n.DEPTH_STENCIL,r,r);t.depthAttachment.set(i),this._rttSharedFbo={fbo:t,depthRenderbuffer:i,size:r}}this._rttSharedFbo.size!==r&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),n.renderbufferStorage(n.RENDERBUFFER,n.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)}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let n=this.imageManager.getPattern(t.from.toString()),r=this.imageManager.getPattern(t.to.toString());return!n||!r}useProgram(t,n,r=!1,i=[]){this.cache||={};let a=!!this.style.map.terrain,o=this.style.projection,s=r?ss.projectionMercator:o.shaderPreludeCode,c=r?ls:o.shaderDefine,l=`/${r?ds:o.shaderVariantName}`,u=n?n.cacheKey:``,d=this._showOverdrawInspector?`/overdraw`:``,f=a?`/terrain`:``,p=i?`/${i.join(`/`)}`:``,m=t+u+l+d+f+p;return this.cache[m]||=new Ec(this.context,ss[t],n,Rl[t],this._showOverdrawInspector,a,s,c,i),this.cache[m]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){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 S(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){if(this._tileTextures){for(let t in this._tileTextures){let n=this._tileTextures[t];if(n)for(let t of n)t.destroy()}this._tileTextures={}}for(let t of this._rttObjectRecyclePool)t.texture.destroy();if(this._rttObjectRecyclePool=[],this._rttSharedFbo){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}if(this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(let t in this.cache){let n=this.cache[t];n?.program&&this.context.gl.deleteProgram(n.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}},Zd=class extends Error{constructor(t,n){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=t,this.statusMessage=n?.statusMessage??null}};function Yd(t,n){let r=!1,i=null,a,o=()=>{i=null,r&&=(t(...a),i=setTimeout(o,n),!1)};return(...t)=>(r=!0,a=t,i||o(),i)}var $d=class{constructor(t){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace(`#`,``)),this._getCurrentHash=()=>{let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||``).split(`/`):([...t.keys()][0]??``).split(`/`)},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let n=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:n,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 n=decodeURIComponent(t.toString()).replace(/=&/g,`&`).replace(/=$/g,``),r=n?`#${n}`:``,i=window.location.href.replace(/(#.+)?$/,r);i=i.replace(`&&`,`&`),window.history.replaceState(window.history.state,null,i)},this._updateHash=Yd(this._updateHashUnthrottled,30*1e3/100),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,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(t){let n=this._map.getCenter(),r=Math.round(this._map.getZoom()*100)/100,i=10**Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.round(n.lng*i)/i,o=Math.round(n.lat*i)/i,s=this._map.getBearing(),c=this._map.getPitch(),l=``;if(t?l+=`/${a}/${o}/${r}`:l+=`${r}/${o}/${a}`,(s||c)&&(l+=`/${Math.round(s*10)/10}`),c&&(l+=`/${Math.round(c)}`),this._hashName){let t=this._getHashParams();return t.set(this._hashName,l),`#${decodeURIComponent(t.toString()).replace(/=&/g,`&`).replace(/=$/g,``)}`}return`#${l}`}_isValidHash(t){if(t.length<3||t.some(t=>isNaN(+t)))return!1;try{new P(+t[2],+t[1])}catch{return!1}let n=+t[0],r=+(t[3]||0),i=+(t[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}};const Xd={linearity:.3,easing:or(0,0,.3,1)},Qd=a({deceleration:2500,maxSpeed:1400},Xd),ef=a({deceleration:20,maxSpeed:1400},Xd),tf=a({deceleration:1e3,maxSpeed:360},Xd),nf=a({deceleration:1e3,maxSpeed:90},Xd),rf=a({deceleration:1e3,maxSpeed:360},Xd);var sf=class{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:U(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,n=U();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,roll:0,pan:new i(0,0),pinchAround:void 0,around:void 0};for(let{settings:t}of this._inertiaBuffer)n.zoom+=t.zoomDelta||0,n.bearing+=t.bearingDelta||0,n.pitch+=t.pitchDelta||0,n.roll+=t.rollDelta||0,t.panDelta&&n.pan._add(t.panDelta),t.around&&(n.around=t.around),t.pinchAround&&(n.pinchAround=t.pinchAround);let r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(n.pan.mag()){let i=of(n.pan.mag(),r,a({},Qd,t||{})),s=n.pan.mult(i.amount/n.pan.mag()),c=this._map._camera.cameraHelper.handlePanInertia(s,this._map._camera.transform);o.center=c.easingCenter,o.offset=c.easingOffset,af(o,i)}if(n.zoom){let t=of(n.zoom,r,ef);o.zoom=sr(this._map.getZoom()+t.amount,this._map.getZoomSnap(),t.amount),af(o,t)}if(n.bearing){let t=of(n.bearing,r,tf);o.bearing=this._map.getBearing()+L(t.amount,-179,179),af(o,t)}if(n.pitch){let t=of(n.pitch,r,nf);o.pitch=this._map.getPitch()+t.amount,af(o,t)}if(n.roll){let t=of(n.roll,r,rf);o.roll=this._map.getRoll()+L(t.amount,-179,179),af(o,t)}if(o.zoom||o.bearing){let t=n.pinchAround===void 0?n.around:n.pinchAround;o.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),a(o,{noMoveStart:!0})}};function af(t,n){(!t.duration||t.duration=this._clickTolerance||this._map.fire(new Ir(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Ir(t.type,this._map,t))}mouseover(t){this._map.fire(new Ir(t.type,this._map,t))}mouseout(t){this._map.fire(new Ir(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Lr(t.type,this._map,t))}touchmove(t){this._map.fire(new Lr(t.type,this._map,t))}touchend(t){this._map.fire(new Lr(t.type,this._map,t))}touchcancel(t){this._map.fire(new Lr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},df=class{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Ir(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ir(`contextmenu`,this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Ir(t.type,this._map,t)),this._map.listens(`contextmenu`)&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},ff=class{constructor(t,n,r){this._map=t,this._tr=r,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1,n.boxZoom&&typeof n.boxZoom==`object`&&(this._boxZoomEnd=n.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(W.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;let r=n;if(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)t.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})}}}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent(`boxzoomcancel`,t))}reset(){this._active=!1,this._container.classList.remove(`maplibregl-crosshair`),this._box&&=(this._box.remove(),null),W.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new zr(t,{originalEvent:n}))}};function cf(t,n){if(t.length!==n.length)throw Error(`The number of touches and points are not equal - touches ${t.length}, points ${n.length}`);let r={};for(let i=0;ithis.numTouches)&&(this.aborted=!0),!this.aborted&&(this.startTime===void 0&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=lf(n),this.touches=cf(r,n)))}touchmove(t,n,r){if(this.aborted||!this.centroid)return;let i=cf(r,n);for(let t in this.touches){let n=this.touches[t],r=i[t];(!r||r.dist(n)>30)&&(this.aborted=!0)}}touchend(t,n,r){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),r.length===0){let t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}},gf=class{constructor(t){this.singleTap=new hf(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,r){this.singleTap.touchstart(t,n,r)}touchmove(t,n,r){this.singleTap.touchmove(t,n,r)}touchend(t,n,r){let i=this.singleTap.touchend(t,n,r);if(i){let n=t.timeStamp-this.lastTime<500,r=!this.lastTap||this.lastTap.dist(i)<30;if((!n||!r)&&this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}},_f=class{constructor(t,n){this._tr=n,this._zoomIn=new gf({numTouches:1,numTaps:2}),this._zoomOut=new gf({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,r){this._zoomIn.touchstart(t,n,r),this._zoomOut.touchstart(t,n,r)}touchmove(t,n,r){this._zoomIn.touchmove(t,n,r),this._zoomOut.touchmove(t,n,r)}touchend(t,n,r){let i=this._zoomIn.touchend(t,n,r),a=this._zoomOut.touchend(t,n,r),o=this._tr;if(i)return this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:n=>n.easeTo({duration:300,zoom:sr(o.zoom+1,n.getZoomSnap()),around:o.unproject(i)},{originalEvent:t})};if(a)return this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:n=>n.easeTo({duration:300,zoom:sr(o.zoom-1,n.getZoomSnap()),around:o.unproject(a)},{originalEvent:t})}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},vf=class{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){let n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.rollDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){!this.isEnabled()||this._lastPoint||this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;let r=this._lastPoint;if(!r)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t)){this.reset(t);return}let i=Array.isArray(n)?n[0]:n;if(!(!this._moved&&i.dist(r)!0}),n=new Sf){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(t,n,r){if(t instanceof MouseEvent)return n(t);if(typeof TouchEvent<`u`&&t instanceof TouchEvent)return r(t)}startMove(t){this._executeRelevantHandler(t,t=>{this.mouseMoveStateManager.startMove(t)},t=>{this.oneFingerTouchMoveStateManager.startMove(t)})}endMove(t){this._executeRelevantHandler(t,t=>{this.mouseMoveStateManager.endMove(t)},t=>{this.oneFingerTouchMoveStateManager.endMove(t)})}isValidStartEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidStartEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t))}isValidMoveEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidMoveEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t))}isValidEndEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidEndEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t))}};const yf=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};function bf({enable:t,clickTolerance:n}){return new vf({clickTolerance:n,move:(t,n)=>({around:n,panDelta:n.sub(t)}),activateOnStart:!0,moveStateManager:new xf({checkCorrectEvent:t=>t.button===0&&!t.ctrlKey}),enable:t,assignEvents:yf})}function wf({enable:t,clickTolerance:n,aroundCenter:r=!0,minPixelCenterThreshold:a=100,rotateSpeed:o=.8},s){return new vf({clickTolerance:n,move:(t,n)=>{let c=s();if(r&&Math.abs(c.y-t.y)>a)return{bearingDelta:cr(new i(t.x,n.y),n,c)};let l=(n.x-t.x)*o;return r&&n.yt.button===0&&t.ctrlKey||t.button===2&&!t.ctrlKey}),enable:t,assignEvents:yf})}function Tf({enable:t,clickTolerance:n,pitchSpeed:r=-.5}){return new vf({clickTolerance:n,move:(t,n)=>({pitchDelta:(n.y-t.y)*r}),moveStateManager:new xf({checkCorrectEvent:t=>t.button===0&&t.ctrlKey||t.button===2}),enable:t,assignEvents:yf})}function Ef({enable:t,clickTolerance:n,rollDegreesPerPixelMoved:r=.3},i){return new vf({clickTolerance:n,move:(t,n)=>{let a=i(),o=(n.x-t.x)*r;return n.yt.button===2&&t.ctrlKey}),enable:t,assignEvents:yf})}var kf=class{constructor(t,n){this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new i(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,n,r){return this._calculateTransform(t,n,r)}touchmove(t,n,r){if(this._active){if(this._shouldBePrevented(r.length)){this._map.cooperativeGestures.notifyGestureBlocked(`touch_pan`,t);return}return t.preventDefault(),this._calculateTransform(t,n,r)}}touchend(t,n,r){this._calculateTransform(t,n,r),this._active&&this._shouldBePrevented(r.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,r){r.length>0&&(this._active=!0);let a=cf(r,n),o=new i(0,0),s=new i(0,0),c=0;for(let t in a){let n=a[t],r=this._touches[t];r&&(o._add(n),s._add(n.sub(r)),c++,a[t]=n)}if(this._touches=a,this._shouldBePrevented(c)||!s.mag())return;let l=s.div(c);if(this._sum._add(l),!(this._sum.mag()Math.abs(t.x)}var Rf=class extends Af{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,r){super.touchstart(t,n,r),this._currentTouchCount=r.length}_start(t){this._lastPoints=t,Nf(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,r){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let i=t[0].sub(this._lastPoints[0]),a=t[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(i,a,r.timeStamp),this._valid)return this._lastPoints=t,this._active=!0,{pitchDelta:(i.y+a.y)/2*-.5}}gestureBeginsVertically(t,n,r){if(this._valid!==void 0)return this._valid;let i=t.mag()>=2,a=n.mag()>=2;if(!i&&!a)return;if(!i||!a)return this._firstMove===void 0&&(this._firstMove=r),r-this._firstMove<100&&void 0;let o=t.y>0==n.y>0;return Nf(t)&&Nf(n)&&o}};const Ff={panStep:100,bearingStep:15,pitchStep:10};var Bf=class{constructor(t,n){this._tr=n;let r=Ff;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,r=0,i=0,a=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),a=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),a=1);break;case 38:t.shiftKey?i=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?i=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{let c=this._tr;s.easeTo({duration:300,easeId:`keyboardHandler`,easing:Lf,zoom:n?sr(c.zoom+n*(t.shiftKey?2:1),s.getZoomSnap()):c.zoom,bearing:c.bearing+r*this._bearingStep,pitch:c.pitch+i*this._pitchStep,offset:[-a*this._panStep,-o*this._panStep],center:c.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function Lf(t){return t*(2-t)}const zf=4.000244140625;var Uf=class{constructor(t,n,r){this._onTimeout=t=>{this._type=`wheel`,this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=r,this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around===`center`)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return this._map.cooperativeGestures.isEnabled()?!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t)):!1}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t)){this._map.cooperativeGestures.notifyGestureBlocked(`wheel_zoom`,t);return}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*40:t.deltaY,r=U(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,n!==0&&n%zf==0?this._type=`wheel`:n!==0&&Math.abs(n)<4?this._type=`trackpad`:i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(i*n)<200?`trackpad`:`wheel`,this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=W.mousePos(this._map.getCanvas(),t),r=this._tr;this._aroundCenter?this._aroundPoint=r.transform.locationToScreenPoint(P.convert(r.center)):this._aroundPoint=n,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let t=this._tr.transform;if(typeof this._lastExpectedZoom==`number`){let n=t.zoom-this._lastExpectedZoom;typeof this._startZoom==`number`&&(this._startZoom+=n),typeof this._targetZoom==`number`&&(this._targetZoom+=n)}if(this._delta!==0){let n=this._type===`wheel`&&Math.abs(this._delta)>zf?this._wheelZoomRate:this._defaultZoomRate,r=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&r!==0&&(r=1/r);let i=typeof this._targetZoom==`number`?Fe(this._targetZoom):t.scale,a=t.applyConstrain(t.getCameraLngLat(),Re(i*r)).zoom,o=this._map.getZoomSnap();if(this._type===`wheel`&&o>0){let n=sr(t.zoom,o);this._targetZoom=sr(a,o,a-n)}else this._targetZoom=a;this._type===`wheel`&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom==`number`?this._targetZoom:t.zoom,r=this._startZoom,i=this._easing,a=!1,o;if(this._type===`wheel`&&r&&i){let t=U()-this._lastWheelEventTime,s=Math.min((t+5)/200,1),c=i(s);o=mt.number(r,n,c),s<1?this._needsRerender=!0:a=!0}else o=n,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=o,{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=lr;if(this._prevEase){let t=this._prevEase,r=(U()-t.start)/t.duration,i=t.easing(r+.01)-t.easing(r),a=.27/Math.sqrt(i*i+1e-4)*.01;n=or(a,Math.sqrt(.27*.27-a*a),.25,1)}return this._prevEase={start:U(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},Wf=class{constructor(t,n){this._clickZoom=t,this._tapZoom=n}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()}},Gf=class{constructor(t,n){this._tr=n,this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:sr(this._tr.zoom+(t.shiftKey?-1:1),r.getZoomSnap()),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Kf=class{constructor(){this._tap=new gf({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(t){this._zoomRate=t??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,r){if(!this._swipePoint)if(!this._tapTime)this._tap.touchstart(t,n,r);else{let i=n[0],a=t.timeStamp-this._tapTime<500,o=this._tapPoint.dist(i)<30;!a||!o?this.reset():r.length>0&&(this._swipePoint=i,this._swipeTouch=r[0].identifier)}}touchmove(t,n,r){if(!this._tapTime)this._tap.touchmove(t,n,r);else if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;let i=n[0],a=i.y-this._swipePoint.y;return this._swipePoint=i,t.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}touchend(t,n,r){if(this._tapTime)this._swipePoint&&r.length===0&&this.reset();else{let i=this._tap.touchend(t,n,r);i&&(this._tapTime=t.timeStamp,this._tapPoint=i)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},qf=class{constructor(t,n,r){this._el=t,this._mousePan=n,this._touchPan=r}enable(t){this._inertiaOptions=t||{},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()}},Jf=class{constructor(t,n,r,i){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=n,this._mousePitch=r,this._mouseRoll=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},Yf=class{constructor(t,n,r,i){this._el=t,this._touchZoom=n,this._touchRotate=r,this._tapDragZoom=i,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add(`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(t){this._touchZoom.setZoomRate(t),this._tapDragZoom.setZoomRate(t)}setZoomThreshold(t){this._touchZoom.setZoomThreshold(t)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},Xf=class{constructor(t,n){this._bypassKey=navigator.userAgent.includes(`Mac`)?`metaKey`:`ctrlKey`,this._map=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let t=this._map.getCanvasContainer();t.classList.add(`maplibregl-cooperative-gestures`),this._container=W.create(`div`,`maplibregl-cooperative-gesture-screen`,t);let n=this._map._getUIString(`CooperativeGesturesHandler.WindowsHelpText`);this._bypassKey===`metaKey`&&(n=this._map._getUIString(`CooperativeGesturesHandler.MacHelpText`));let r=this._map._getUIString(`CooperativeGesturesHandler.MobileHelpText`),i=document.createElement(`div`);i.className=`maplibregl-desktop-message`,i.textContent=n,this._container.appendChild(i);let a=document.createElement(`div`);a.className=`maplibregl-mobile-message`,a.textContent=r,this._container.appendChild(a),this._container.setAttribute(`aria-hidden`,`true`)}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove(`maplibregl-cooperative-gestures`)),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,n){this._enabled&&(this._map.fire(new Nr(`cooperativegestureprevented`,{gestureType:t,originalEvent:n})),this._container.classList.add(`maplibregl-show`),setTimeout(()=>{this._container.classList.remove(`maplibregl-show`)},100))}},Zf=class{constructor(t){this._camera=t}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(t){return this.transform.screenPointToLocation(i.convert(t),this._camera.terrain)}};const Vf=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;var $f=class extends h{};function Hf(t){return t.panDelta?.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}var tp=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(t,n,r){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,n)=>{if(t.type===`blur`){this.stop(!0);return}this._updatingCamera=!0;let r=t.type===`renderFrame`?void 0:t,i={needsRenderFrame:!1},a={},o={};for(let{handlerName:s,handler:c,allowed:l}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(o,l,s))c.reset();else if(c[n||t.type]){if(ur(t,n||t.type)){let r=W.mousePos(this._map.getCanvas(),t);u=c[n||t.type](t,r)}else if(dr(t,n||t.type)){let r=t.touches,i=this._getMapTouches(r),a=W.touchPos(this._map.getCanvas(),i);u=c[n||t.type](t,a,i)}else fr(n||t.type)||(u=c[n||t.type](t));this.mergeHandlerResult(i,a,u,s,r),u?.needsRenderFrame&&this._triggerRenderFrame()}(u||c.isActive())&&(o[s]=c)}let s={};for(let t in this._previousActiveHandlers)o[t]||(s[t]=r);this._previousActiveHandlers=o,(Object.keys(s).length||Hf(i))&&(this._changes.push([i,a,s]),this._triggerRenderFrame()),(Object.keys(o).length||Hf(i))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=t,this._camera=n,this._transformProvider=new Zf(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new sf(t),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r);let i=this._el;this._listeners=[[i,`touchstart`,{passive:!0}],[i,`touchmove`,{passive:!1}],[i,`touchend`,void 0],[i,`touchcancel`,void 0],[i,`mousedown`,void 0],[i,`mousemove`,void 0],[i,`mouseup`,void 0],[this._ownerDocument,`mousemove`,{capture:!0}],[this._ownerDocument,`mouseup`,void 0],[i,`mouseover`,void 0],[i,`mouseout`,void 0],[i,`dblclick`,void 0],[i,`click`,void 0],[i,`keydown`,{capture:!1}],[i,`keyup`,void 0],[i,`wheel`,{passive:!1}],[i,`contextmenu`,void 0],[this._ownerWindow,`blur`,void 0]];for(let[t,n,r]of this._listeners)t.addEventListener(n,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(let[t,n,r]of this._listeners)t.removeEventListener(n,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){let n=this._map,r=n.getCanvasContainer();this._add(`mapEvent`,new uf(n,t));let i=n.boxZoom=new ff(n,t,this._transformProvider);this._add(`boxZoom`,i),t.interactive&&t.boxZoom&&i.enable();let a=n.cooperativeGestures=new Xf(n,t.cooperativeGestures);this._add(`cooperativeGestures`,a),t.cooperativeGestures&&a.enable();let o=new _f(n,this._transformProvider),s=new Gf(n,this._transformProvider);n.doubleClickZoom=new Wf(s,o),this._add(`tapZoom`,o),this._add(`clickZoom`,s),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();let c=new Kf;this._add(`tapDragZoom`,c);let l=n.touchPitch=new Rf(n);this._add(`touchPitch`,l),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);let u=()=>n.project(n.getCenter()),d=wf(t,u),f=Tf(t),p=Ef(t,u);n.dragRotate=new Jf(t,d,f,p),this._add(`mouseRotate`,d,[`mousePitch`]),this._add(`mousePitch`,f,[`mouseRotate`,`mouseRoll`]),this._add(`mouseRoll`,p,[`mousePitch`]),t.interactive&&t.dragRotate&&n.dragRotate.enable();let m=bf(t),h=new kf(t,n);n.dragPan=new qf(r,m,h),this._add(`mousePan`,m),this._add(`touchPan`,h,[`touchZoom`,`touchRotate`]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);let g=new If,_=new Pf;n.touchZoomRotate=new Yf(r,_,g,c),this._add(`touchRotate`,g,[`touchPan`,`touchZoom`]),this._add(`touchZoom`,_,[`touchPan`,`touchRotate`]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate),this._add(`blockableMapEvent`,new df(n));let v=n.scrollZoom=new Uf(n,()=>this._triggerRenderFrame(),this._transformProvider);this._add(`scrollZoom`,v,[`mousePan`]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);let y=n.keyboard=new Bf(n,this._transformProvider);this._add(`keyboard`,y),t.interactive&&t.keyboard&&n.keyboard.enable()}_add(t,n,r){this._handlers.push({handlerName:t,handler:n,allowed:r}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Vf(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,r){for(let i in t)if(i!==r&&!n?.includes(i))return!0;return!1}_getMapTouches(t){let n=[];for(let r of t){let t=r.target;this._el.contains(t)&&n.push(r)}return n}mergeHandlerResult(t,n,r,i,o){if(!r)return;a(t,r);let s={handlerName:i,originalEvent:r.originalEvent||o};r.zoomDelta!==void 0&&(n.zoom=s),r.panDelta!==void 0&&(n.drag=s),r.rollDelta!==void 0&&(n.roll=s),r.pitchDelta!==void 0&&(n.pitch=s),r.bearingDelta!==void 0&&(n.rotate=s)}_applyChanges(){let t={},n={},r={};for(let[o,s,c]of this._changes)o.panDelta&&(t.panDelta=(t.panDelta||new i(0,0))._add(o.panDelta)),o.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(t.rollDelta=(t.rollDelta||0)+o.rollDelta),o.around!==void 0&&(t.around=o.around),o.pinchAround!==void 0&&(t.pinchAround=o.pinchAround),o.noInertia&&(t.noInertia=o.noInertia),a(n,s),a(r,c);this._updateMapTransform(t,n,r),this._changes=[]}_updateMapTransform(t,n,r){let i=this._map,a=this._camera.getTransformForUpdate(),o=i.terrain;if(!Hf(t)&&!(o&&this._terrainMovement)){this._fireEvents(n,r,!0);return}this._camera.stop(!0);let{panDelta:s,zoomDelta:c,bearingDelta:l,pitchDelta:u,rollDelta:d,around:f,pinchAround:p}=t;p!==void 0&&(f=p),f||=this._camera.transform.centerPoint,o&&!a.isPointOnMapSurface(f)&&(f=a.centerPoint);let m={panDelta:s,zoomDelta:c,rollDelta:d,pitchDelta:u,bearingDelta:l,around:f};this._camera.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(f)&&(f=a.centerPoint);let h=f.distSqr(a.centerPoint)<.01?a.center:a.screenPointToLocation(s?f.sub(s):f);this._handleMapControls({terrain:o,tr:a,deltasForHelper:m,preZoomAroundLoc:h,combinedEventsInProgress:n,panDelta:s}),this._camera.applyUpdatedTransform(a),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,r,!0)}_handleMapControls({terrain:t,tr:n,deltasForHelper:r,preZoomAroundLoc:i,combinedEventsInProgress:a,panDelta:o}){let s=this._camera.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(r,n),!t){s.handleMapControlsPan(r,n,i);return}if(s.useGlobeControls){!this._terrainMovement&&(a.drag||a.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),s.handleMapControlsPan(r,n,i);return}if(!this._terrainMovement&&(a.drag||a.zoom)){this._terrainMovement=!0,this._camera.elevationFreeze=!0,s.handleMapControlsPan(r,n,i);return}if(a.drag&&this._terrainMovement&&o){n.setCenter(n.screenPointToLocation(n.centerPoint.sub(o)));return}s.handleMapControlsPan(r,n,i)}_fireEvents(t,n,r){let i=Vf(this._eventsInProgress),a=Vf(t),o={};for(let n in t){let{originalEvent:r}=t[n];this._eventsInProgress[n]||(o[`${n}start`]=r),this._eventsInProgress[n]=t[n]}!i&&a&&this._fireEvent(`movestart`,a.originalEvent);for(let t in o)this._fireEvent(t,o[t]);a&&this._fireEvent(`move`,a.originalEvent);for(let n in t){let{originalEvent:r}=t[n];this._fireEvent(n,r)}let s={},c;for(let t in this._eventsInProgress){let{handlerName:r,originalEvent:i}=this._eventsInProgress[t];this._handlersById[r].isActive()||(delete this._eventsInProgress[t],c=n[r]||i,s[`${t}end`]=c)}for(let t in s)this._fireEvent(t,s[t]);let l=Vf(this._eventsInProgress),u=(i||a)&&!l;if(u&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1;let t=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(t)}if(r&&u){this._updatingCamera=!0;let t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=t=>t!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new $f(`renderFrame`,{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}},np=class extends _{constructor(t){super(),this._renderFrameCallback=()=>{let t=Math.min((U()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new ws,this.cameraHelper=new As,t.minZoom!==void 0&&this.transform.setMinZoom(t.minZoom),t.maxZoom!==void 0&&this.transform.setMaxZoom(t.maxZoom),t.minPitch!==void 0&&this.transform.setMinPitch(t.minPitch),t.maxPitch!==void 0&&this.transform.setMaxPitch(t.maxPitch),t.renderWorldCopies!==void 0&&this.transform.setRenderWorldCopies(t.renderWorldCopies),t.transformConstrain!==null&&this.transform.setConstrainOverride(t.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=t.bearingSnap,this._zoomSnap=t.zoomSnap,this._requestRenderFrame=t.requestRenderFrame,this._cancelRenderFrame=t.cancelRenderFrame,this.terrain=t.terrain,this._centerClampedToGround=t.centerClampedToGround??!0,this.transformCameraUpdate=t.transformCameraUpdate??null,this._stopHandlers=t.stopHandlers??(()=>{}),this.on(`moveend`,()=>{delete this._requestedCameraState})}migrateProjection(t,n){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=n}getCenter(){return new P(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,n){return this.jumpTo({elevation:t},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,n,r){return t=i.convert(t).mult(-1),this.panTo(this.transform.center,a({offset:t},n),r)}panTo(t,n,r){return this.easeTo(a({center:t},n),r)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,r){return this.easeTo(a({zoom:t},n),r)}zoomIn(t,n){return this.zoomTo(sr(this.getZoom()+1,this._zoomSnap),t,n),this}zoomOut(t,n){return this.zoomTo(sr(this.getZoom()-1,this._zoomSnap),t,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,n){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new G(`movestart`,n)).fire(new G(`move`,n)).fire(new G(`moveend`,n))),this}getBearing(){return this.transform.bearing}setZoomSnap(t){return this._zoomSnap=t,this}getZoomSnap(){return this._zoomSnap}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,r){return this.easeTo(a({bearing:t},n),r)}resetNorth(t,n){return this.rotateTo(0,a({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(a({bearing:0,pitch:0,roll:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing()){_.easeFunc(i),this.terrain&&!t.freezeElevation&&this._updateElevation(i),this.applyUpdatedTransform(r),this._fireMoveEvents(n)},r=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n,r)},t),this}_prepareEase(t,n,r={}){this._moving=!0,!n&&!r.moving&&this.fire(new G(`movestart`,t)),this._zooming&&!r.zooming&&this.fire(new G(`zoomstart`,t)),this._rotating&&!r.rotating&&this.fire(new G(`rotatestart`,t)),this._pitching&&!r.pitching&&this.fire(new G(`pitchstart`,t)),this._rolling&&!r.rolling&&this.fire(new G(`rollstart`,t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this.elevationFreeze=!0}_updateElevation(t){(this._elevationStart===void 0||this._elevationCenter===void 0)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){let r=this._elevationTarget-this._elevationStart,i=(n-(r*t+this._elevationStart))/(1-t);this._elevationStart+=t*(r-i),this._elevationTarget=n}this.transform.setElevation(mt.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}getTransformForUpdate(){return!this.transformCameraUpdate&&!this.terrain?this.transform:(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState)}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};let n=t.getCameraLngLat(),r=t.getCameraAltitude(),i=this.terrain?this.terrain.getElevationForLngLatZoom(n,t.zoom):0;if(rthis._elevateCameraIfInsideTerrain(t)),this.transformCameraUpdate&&n.push(t=>this.transformCameraUpdate(t)),!n.length)return;let r=t.clone();for(let t of n){let n=r.clone(),{center:i,zoom:a,roll:o,pitch:s,bearing:c,elevation:l}=t(n);i&&n.setCenter(i),l!==void 0&&n.setElevation(l),a!==void 0&&n.setZoom(a),o!==void 0&&n.setRoll(o),s!==void 0&&n.setPitch(s),c!==void 0&&n.setBearing(c),r.apply(n,!1)}this.transform.apply(r,!1)}_fireMoveEvents(t){this.fire(new G(`move`,t)),this._zooming&&this.fire(new G(`zoom`,t)),this._rotating&&this.fire(new G(`rotate`,t)),this._pitching&&this.fire(new G(`pitch`,t)),this._rolling&&this.fire(new G(`roll`,t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let r=this._zooming,i=this._rotating,a=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new G(`zoomend`,t)),i&&this.fire(new G(`rotateend`,t)),a&&this.fire(new G(`pitchend`,t)),o&&this.fire(new G(`rollend`,t)),this.fire(new G(`moveend`,t))}flyTo(t,n){if(!t.essential&&wr.prefersReducedMotion){let r=de(t,[`center`,`zoom`,`bearing`,`pitch`,`roll`,`elevation`,`padding`]);return this.jumpTo(r,n)}this.stop(),t=a({offset:[0,0],speed:1.2,curve:1.42,easing:lr},t),`zoom`in t&&this._zoomSnap&&(t.zoom=sr(t.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),o=r.bearing,s=r.pitch,c=r.roll,l=r.padding,u=`bearing`in t?this._normalizeBearing(t.bearing,o):o,d=`pitch`in t?+t.pitch:s,f=`roll`in t?this._normalizeBearing(t.roll,c):c,p=`padding`in t?t.padding:r.padding,m=i.convert(t.offset),h=r.centerPoint.add(m),g=r.screenPointToLocation(h),_=this.cameraHelper.handleFlyTo(r,{bearing:u,pitch:d,roll:f,padding:p,locationAtOffset:g,offsetAsPoint:m,center:t.center,minZoom:t.minZoom,zoom:t.zoom}),v=t.curve,y=Math.max(r.width,r.height),b=y/_.scaleOfZoom,x=_.pixelPathLength,S=y/_.scaleOfMinZoom;v=Math.min(v,Math.sqrt(S/x*2));let C=v*v;function w(t){let n=(b*b-y*y+(t?-1:1)*C*C*x*x)/(2*(t?b:y)*C*x);return Math.log(Math.sqrt(n*n+1)-n)}function T(t){return(Math.exp(t)-Math.exp(-t))/2}function E(t){return(Math.exp(t)+Math.exp(-t))/2}function D(t){return T(t)/E(t)}let O=w(!1),k=function(t){return E(O)/E(O+v*t)},A=function(t){return y*((E(O)*D(O+v*t)-T(O))/C)/x},j=(w(!0)-O)/v;if(Math.abs(x)<2e-6||!isFinite(j)){if(Math.abs(y-b)<1e-6)return this.easeTo(t,n);let r=b0,k=t=>Math.exp(r*v*t)}if(`duration`in t)t.duration=+t.duration;else{let n=`screenSpeed`in t?+t.screenSpeed/v:+t.speed;t.duration=1e3*j/n}return t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=o!==u,this._pitching=d!==s,this._rolling=f!==c,this._padding=!r.isPaddingEqual(p),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(_.targetCenter),this._ease(i=>{let a=i*j,g=1/k(a),v=A(a);this._rotating&&r.setBearing(mt.number(o,u,i)),this._pitching&&r.setPitch(mt.number(s,d,i)),this._rolling&&r.setRoll(mt.number(c,f,i)),this._padding&&(r.interpolatePadding(l,p,i),h=r.centerPoint.add(m)),_.easeFunc(i,g,v,h),this.terrain&&!t.freezeElevation&&this._updateElevation(i),this.applyUpdatedTransform(r),this._fireMoveEvents(n)},()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},t),this}isEasing(){return!!this._easeFrameId}stop(t){return this._stop(t)}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,n)}return t||this._stopHandlers(),this}_ease(t,n,r){r.animate===!1||r.duration===0?(t(1),n()):(this._easeStart=U(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=fe(t,-180,180);let r=Math.abs(t-n);return Math.abs(t-360-n)MapLibre`};var ip=class{constructor(t=Qf){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=t}getDefaultPosition(){return`bottom-right`}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=W.create(`details`,`maplibregl-ctrl maplibregl-ctrl-attrib`),this._compactButton=W.create(`summary`,`maplibregl-ctrl-attrib-button`,this._container),this._compactButton.addEventListener(`click`,this._toggleAttribution),this._setElementTitle(this._compactButton,`ToggleAttribution`),this._innerContainer=W.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(t,n){let r=this._map._getUIString(`AttributionControl.${n}`);t.title=r,t.setAttribute(`aria-label`,r)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(t=>typeof t==`string`?t:``)):typeof this.options.customAttribution==`string`&&t.push(this.options.customAttribution)),this._map.style.stylesheet){let t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}let n=this._map.style.tileManagers;for(let r in n){let i=n[r];if(i.used||i.usedForTerrain){let n=i.getSource();n.attribution&&!t.includes(n.attribution)&&t.push(n.attribution)}}t=t.filter(t=>String(t).trim()),t.sort((t,n)=>t.length-n.length),t=t.filter((n,r)=>{for(let i=r+1;i{let t=this._container.children;if(t.length){let n=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&n.classList.add(`maplibregl-compact`):n.classList.remove(`maplibregl-compact`)}},this.options=t}getDefaultPosition(){return`bottom-left`}onAdd(t){this._map=t,this._compact=this.options?.compact,this._container=W.create(`div`,`maplibregl-ctrl`);let n=W.create(`a`,`maplibregl-ctrl-logo`);return n.target=`_blank`,n.rel=`noopener nofollow`,n.href=`https://maplibre.org/`,n.setAttribute(`aria-label`,this._map._getUIString(`LogoControl.Title`)),n.setAttribute(`rel`,`noopener nofollow`),this._container.appendChild(n),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}},op=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){let n=this._currentlyRunning,r=n?this._queue.concat(n):this._queue;for(let n of r)if(n.id===t){n.cancelled=!0;return}}run(t=0){if(this._currentlyRunning)throw Error(`Attempting to run(), but is already running.`);let n=this._currentlyRunning=this._queue;this._queue=[];for(let r of n)if(!r.cancelled&&(r.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const ep=lt([{name:`a_pos3d`,type:`Int16`,components:3}]);var cp=class extends _{constructor(t){super(),this._lastTilesetChange=U(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(t,n){this.tileManager.update(t,n),this._renderableTilesKeys=[];let r={};for(let i of Na(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[i.key]=!0,this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.terrainRttPosMatrix32f=new Float32Array(16),Fn(i.terrainRttPosMatrix32f,0,F,F,0,0,1),this._tiles[i.key]=new va(i,this.tileSize),this._lastTilesetChange=U());for(let t in this._tiles)r[t]||(this._tiles[t].releaseRTT(this.tileManager.map.painter),delete this._tiles[t])}releaseRTT(t){for(let n in this._tiles){let r=this._tiles[n];(r.tileID.equals(t)||r.tileID.isChildOf(t)||t.isChildOf(r.tileID))&&r.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let t in this._tiles)this._tiles[t].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,n){return n?this._getTerrainCoordsForTileRanges(t,n):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){let n={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID,a=t.clone(),o=Rt();if(i.canonical.equals(t.canonical))Fn(o,0,F,F,0,0,1);else if(i.canonical.isChildOf(t.canonical)){let n=i.canonical.z-t.canonical.z,r=i.canonical.x-(i.canonical.x>>n<>n<>n;Fn(o,0,s,s,0,0,1),N(o,o,[-r*s,-a*s,0])}else if(t.canonical.isChildOf(i.canonical)){let n=t.canonical.z-i.canonical.z,r=t.canonical.x-(t.canonical.x>>n<>n<>n;Fn(o,0,F,F,0,0,1),N(o,o,[r*s,a*s,0]),le(o,o,[1/2**n,1/2**n,0])}else continue;a.terrainRttPosMatrix32f=new Float32Array(o),n[r]=a}return n}_getTerrainCoordsForTileRanges(t,n){let r={};for(let i of this._renderableTilesKeys){let a=this._tiles[i].tileID;if(!this._isWithinTileRanges(a,n))continue;let o=t.clone(),s=Rt();if(a.canonical.z===t.canonical.z){let n=t.canonical.x-a.canonical.x+t.wrap*(1<t.canonical.z){let n=a.canonical.z-t.canonical.z,r=a.canonical.x-(a.canonical.x>>n<>n<>n),c=t.canonical.y-(a.canonical.y>>n),l=F>>n;Fn(s,0,l,l,0,0,1),N(s,s,[-r*l+o*F,-i*l+c*F,0])}else{let n=t.canonical.z-a.canonical.z,r=t.canonical.x-(t.canonical.x>>n<>n<>n)-a.canonical.x,c=(t.canonical.y>>n)-a.canonical.y,l=F<r.maxzoom&&(i=r.maxzoom),i=r.minzoom&&!a?.dem;)a=this.findTileInCaches(t.scaledTo(i--).key);return a}findTileInCaches(t){let n=this.tileManager.getTileByID(t);return n||(n=this.tileManager._outOfViewCache.getByKey(t),n)}anyTilesAfterTime(t=U()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,n){let r=n[t.canonical.z];return!!r&&(t.wrap>r.minWrap||t.wrap=r.minTileXWrapped&&t.canonical.x<=r.maxTileXWrapped&&t.canonical.y>=r.minTileY&&t.canonical.y<=r.maxTileY)}},lp=class{constructor(t,n,r,i=`auto`){this._meshCache={},this.painter=t,this.tileManager=new cp(n),this.options=r,this.exaggeration=typeof r.exaggeration==`number`?r.exaggeration:1,this._terrainSkirtLength=i,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboCoordsTexture&&=(this._fboCoordsTexture.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null),this._coordsTexture&&=(this._coordsTexture.destroy(),null);for(let t in this._meshCache)this._meshCache[t].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(t,n,r,i=F){let a=t.normalizeCoordinates(n,r,i);if(!a)return 0;let o=this.getTerrainData(a.tileID),s=o.tile?.dem;if(!s)return 0;let c=pr([],[a.x/i*F,a.y/i*F],o.u_terrain_matrix),l=[c[0]*s.dim,c[1]*s.dim];return s.sampleBilinear(l[0],l[1])}getElevationForLngLatZoom(t,n){if(!mr(n,t.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(r,i%F,a%F,F)}getElevationForLngLat(t,n){let r=Na(n,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),i=0;for(let t of r)t.canonical.z>i&&(i=Math.min(t.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,i)}getElevation(t,n,r,i=F){return this.getDEMElevation(t,n,r,i)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){let t=this.painter.context,n=new v({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new S(t,n,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new S(t,new v({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=Ie([])}let n=this.tileManager.getSourceTile(t,!0);if(n?.dem&&(!n.demTexture||n.needsTerrainPrepare)){let t=this.painter.context;n.demTexture||=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new S(t,n.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),n.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}let r=n&&n.toString()+n.tileID.key+t.key;if(r&&!this._demMatrixCache[r]){let i=this.tileManager.getSource().maxzoom,a=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=i?a=t.canonical.z-i:b(`cannot calculate elevation if elevation maxzoom > source.maxzoom`));let o=t.canonical.x-(t.canonical.x>>a<>a<>8<<4|t>>8,n[r+3]=0;let r=new S(t,new v({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),t.gl.RGBA,{premultiply:!1});return r.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(t){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();let n=new Uint8Array(4),r=this.painter.context,i=r.gl,a=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer(`coords`).framebuffer),i.readPixels(a,s-o-1,1,1,i.RGBA,i.UNSIGNED_BYTE,n),r.bindFramebuffer.set(null);let c=n[0]+(n[2]>>4<<8),l=n[1]+((n[2]&15)<<8),u=this.coordsIndex[255-n[3]],d=u&&this.tileManager.getTileByID(u);if(!d)return null;let f=this._coordsTextureSize,p=(1<0,r=n&&t.canonical.y===0,i=n&&t.canonical.y===(1<!t._layers[r].isHidden(n));let r=/* @__PURE__ */ new Set;for(let n of this._renderableLayerIds){let i=t._layers[n],a=i.source;a&&rp[i.type]&&r.add(a)}this._coordsAscending={},this._rttFingerprints={};for(let n of r){let r=t.tileManagers[n];if(!r)continue;this._coordsAscending[n]={};let i=this._coordsAscending[n],a=r.getSource(),o=a instanceof ra?a.terrainTileRanges:null;for(let t of r.getVisibleCoordinates()){let n=this.terrain.tileManager.getTerrainCoords(t,o);for(let t in n)i[t]||=[],i[t].push(n[t])}this._rttFingerprints[n]={};let s=this._rttFingerprints[n],c=r.getState().revision;for(let t in i)s[t]=`${i[t].map(t=>t.key).sort().join()}#${c}`}for(let t of this._renderableTiles)for(let n in this._rttFingerprints){let r=this._rttFingerprints[n][t.tileID.key];r&&r!==t.rttFingerprint[n]&&t.releaseRTT(this.painter)}}renderLayer(t,n){if(t.isHidden(this.painter.transform.zoom))return!1;let r={...n,isRenderingToTexture:!0},i=t.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(rp[i]&&((!this._prevType||!rp[this._prevType])&&this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(t.id),!o))return!0;if(rp[this._prevType]||rp[i]&&o){this._prevType=i;let t=this._stacks.length-1,n=this._stacks[t]||[];for(let i of this._renderableTiles){if(this._rttTiles.push(i),i.getRTT(t))continue;let o=i.acquireRTT(a,t,this.rttSize);a.bindRTT(o),a.context.clear({color:V.transparent,stencil:0}),a.currentStencilSource=void 0;for(let t of n){let n=a.style._layers[t],o=n.source?this._coordsAscending[n.source][i.tileID.key]:[i.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),a.renderTileClippingMasks(n,o,!0),a.renderLayer(a,a.style.tileManagers[n.source],n,o,r),n.source&&(i.rttFingerprint[n.source]=this._rttFingerprints[n.source][i.tileID.key])}}return Hd(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],rp[i]}return!1}};const sp={"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`},up=_r,fp={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Qf,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:p.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:`sans-serif`,pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:`auto`,zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var hp=class extends _{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(t){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new op,this._controls=[],this._mapId=Ee(),this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=t=>{if(t.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),!this.style){this.fire(new Hr(`webglcontextlost`,{originalEvent:t}));return}for(let t of Object.values(this.style._layers))if(t.type===`custom`&&console.warn(`Custom layer with id '${t.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),t._listeners)for(let[n]of Object.entries(t._listeners))console.warn(`Custom layer with id '${t.id}' had event listeners for event '${n}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new Hr(`webglcontextlost`,{originalEvent:t}))},this._contextRestored=t=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.painter&&(this.resize(),this._update(),this._resizeInternal(),this.fire(new Hr(`webglcontextrestored`,{originalEvent:t})))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let n={...fp,...t,canvasContextAttributes:{...fp.canvasContextAttributes,...t.canvasContextAttributes}};if(n.minZoom!=null&&n.maxZoom!=null&&n.minZoom>n.maxZoom)throw Error(`maxZoom must be greater than or equal to minZoom`);if(n.minPitch!=null&&n.maxPitch!=null&&n.minPitch>n.maxPitch)throw Error(`maxPitch must be greater than or equal to minPitch`);if(n.minPitch!=null&&n.minPitch<0)throw Error(`minPitch must be greater than or equal to 0`);if(n.maxPitch!=null&&n.maxPitch>180)throw Error(`maxPitch must be less than or equal to 180`);if(this._camera=new np({minZoom:n.minZoom,maxZoom:n.maxZoom,minPitch:n.minPitch,maxPitch:n.maxPitch,bearingSnap:n.bearingSnap,zoomSnap:n.zoomSnap,renderWorldCopies:n.renderWorldCopies,centerClampedToGround:n.centerClampedToGround,terrain:this.terrain,transformConstrain:n.transformConstrain,requestRenderFrame:t=>this._requestRenderFrame(t),cancelRenderFrame:t=>this._cancelRenderFrame(t),transformCameraUpdate:n.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes={...n.canvasContextAttributes},this._trackResize=n.trackResize===!0,this._terrainSkirtLength=n.terrainSkirtLength,this._refreshExpiredTiles=n.refreshExpiredTiles===!0,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=n.crossSourceCollisions===!0,this._collectResourceTiming=n.collectResourceTiming===!0,this._locale={...sp,...n.locale},this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this._zoomLevelsToOverscale=n.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=n.cancelPendingTileRequestsWhileZooming===!0,this.setAnisotropicFilterPitch(n.anisotropicFilterPitch),n.reduceMotion!==void 0&&(wr.prefersReducedMotion=n.reduceMotion),this._imageQueueHandle=kr.addThrottleControl(()=>this.isMoving()),this._requestManager=new Mr(n.transformRequest),this._container=this._resolveContainer(n.container),n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),!this.painter)return;this.on(`move`,()=>this._update(!1)),this.on(`moveend`,()=>this._update(!1)),this.on(`zoom`,()=>this._update(!0)),this.on(`terrain`,()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)}),this.once(`idle`,()=>this._idleTriggered=!0),this._handlers=new tp(this,this._camera,n),typeof window<`u`&&(this._ownerWindow.addEventListener(`online`,this._onWindowOnline,!1),this._setupResizeObserver());let r=typeof n.hash==`string`&&n.hash||void 0;this._hash=n.hash?new $d(r).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,a({},n.fitBoundsOptions,{duration:0}))));let i=typeof n.style==`string`||n.style?.projection?.type!==`globe`;this.resize(null,i),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style&&this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}),n.attributionControl&&this.addControl(new ip(typeof n.attributionControl==`boolean`?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new ap,n.logoPosition),this.on(`style.load`,()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let t=de(this.style.stylesheet,[`center`,`zoom`,`bearing`,`pitch`,`roll`]);this.jumpTo(t)}}),this.on(`data`,t=>{this._update(t.dataType===`style`),this.fire(t.dataType===`style`?new Fr(`styledata`,t):new K(`sourcedata`,t))}),this.on(`dataloading`,t=>{this.fire(t.dataType===`style`?new Fr(`styledataloading`,t):new K(`sourcedataloading`,t))}),this.on(`dataabort`,t=>{this.fire(new K(`sourcedataabort`,t))})}_getMapId(){return this._mapId}setGlobalStateProperty(t,n){return this.style.setGlobalStateProperty(t,n),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(t,n){if(n===void 0&&(n=t.getDefaultPosition?t.getDefaultPosition():`top-right`),!t?.onAdd)return this.fire(new y(Error(`Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.`)));let r=t.onAdd(this);this._controls.push(t);let i=this._controlPositions[n];return n.includes(`bottom`)?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(t){if(!t?.onRemove)return this.fire(new y(Error(`Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.`)));let n=this._controls.indexOf(t);return n>-1&&this._controls.splice(n,1),t.onRemove(this),this}hasControl(t){return this._controls.includes(t)}coveringTiles(t){return Na(this._camera.transform,t)}setTransformCameraUpdate(t){this._camera.transformCameraUpdate=t}getCenter(){return new P(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(t,n){return this._camera.setCenter(t,n),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(t,n){return this._camera.setCenterElevation(t,n),this}setCenterClampedToGround(t){this._camera.setCenterClampedToGround(t)}panBy(t,n,r){return this._camera.panBy(t,n,r),this}panTo(t,n,r){return this._camera.panTo(t,n,r),this}getZoom(){return this._camera.transform.zoom}setZoom(t,n){return this._camera.setZoom(t,n),this}zoomTo(t,n,r){return this._camera.zoomTo(t,n,r),this}zoomIn(t,n){return this._camera.zoomIn(t,n),this}zoomOut(t,n){return this._camera.zoomOut(t,n),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(t,n){return this._camera.setVerticalFieldOfView(t,n),this}getBearing(){return this._camera.transform.bearing}setBearing(t,n){return this._camera.setBearing(t,n),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(t){return this._camera.setZoomSnap(t),this}getPadding(){return this._camera.transform.padding}setPadding(t,n){return this._camera.setPadding(t,n),this}rotateTo(t,n,r){return this._camera.rotateTo(t,n,r),this}resetNorth(t,n){return this._camera.resetNorth(t,n),this}resetNorthPitch(t,n){return this._camera.resetNorthPitch(t,n),this}snapToNorth(t,n){return this._camera.snapToNorth(t,n),this}getPitch(){return this._camera.transform.pitch}setPitch(t,n){return this._camera.setPitch(t,n),this}getRoll(){return this._camera.transform.roll}setRoll(t,n){return this._camera.setRoll(t,n),this}cameraForBounds(t,n){return this._camera.cameraForBounds(t,n)}fitBounds(t,n,r){return this._camera.fitBounds(t,n,r),this}fitScreenCoordinates(t,n,r,i,a){return this._camera.fitScreenCoordinates(t,n,r,i,a),this}jumpTo(t,n){return this._camera.jumpTo(t,n),this}calculateCameraOptionsFromCameraLngLatAltRotation(t,n,r,i,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(t,n,r,i,a)}easeTo(t,n){return this._camera.easeTo(t,n),this}flyTo(t,n){return this._camera.flyTo(t,n),this}stop(){return this._camera.stop(),this}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(P.convert(t),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(t,n,r,i){return i==null&&this.terrain&&(i=this.terrain.getElevationForLngLat(r,this._camera.transform)),this._camera.calculateCameraOptionsFromTo(t,n,r,i)}resize(t,n=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(n);let r=!this._camera._moving;return r&&(this.stop(),this.fire(new G(`movestart`,t)).fire(new G(`move`,t))),this.fire(new Nr(`resize`,t)),r&&this.fire(new G(`moveend`,t)),this}_resizeInternal(t=!0){let[n,r]=this._containerDimensions(),i=this._getClampedPixelRatio(n,r);if(this._resizeCanvas(n,r,i),this.painter.resize(n,r,i),this.painter.overLimit()){let t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];let i=this._getClampedPixelRatio(n,r);this._resizeCanvas(n,r,i),this.painter.resize(n,r,i)}this._resizeTransform(t)}_resizeTransform(t=!0){let[n,r]=this._containerDimensions();this._camera.transform.resize(n,r,t),this._camera._requestedCameraState?.resize(n,r,t)}_getClampedPixelRatio(t,n){let{0:r,1:i}=this._maxCanvasSize,a=this.getPixelRatio(),o=t*a,s=n*a,c=o>r?r/o:1,l=s>i?i/s:1;return Math.min(c,l)*a}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(t){return this._camera.transform.setMaxBounds(Fi.convert(t)),this._update()}setMinZoom(t){if(t??=-2,t>=-2&&t<=this._camera.transform.maxZoom){let n=this._camera.transform.zoom,r=this._camera.getTransformForUpdate();return r.setMinZoom(t),this._camera.applyUpdatedTransform(r),this._update(),n!==this._camera.transform.zoom&&this.fire(new G(`zoomstart`)).fire(new G(`zoom`)).fire(new G(`zoomend`)).fire(new G(`movestart`)).fire(new G(`move`)).fire(new G(`moveend`)),this}else throw Error(`minZoom must be between -2 and the current maxZoom, inclusive`)}getMinZoom(){return this._camera.transform.minZoom}setMaxZoom(t){if(t??=22,t>=this._camera.transform.minZoom){let n=this._camera.transform.zoom,r=this._camera.getTransformForUpdate();return r.setMaxZoom(t),this._camera.applyUpdatedTransform(r),this._update(),n!==this._camera.transform.zoom&&this.fire(new G(`zoomstart`)).fire(new G(`zoom`)).fire(new G(`zoomend`)).fire(new G(`movestart`)).fire(new G(`move`)).fire(new G(`moveend`)),this}else throw Error(`maxZoom must be greater than the current minZoom`)}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(t){if(t??=0,t<0)throw Error(`minPitch must be greater than or equal to 0`);if(t>=0&&t<=this._camera.transform.maxPitch){let n=this._camera.transform.pitch,r=this._camera.getTransformForUpdate();return r.setMinPitch(t),this._camera.applyUpdatedTransform(r),this._update(),n!==this._camera.transform.pitch&&this.fire(new G(`pitchstart`)).fire(new G(`pitch`)).fire(new G(`pitchend`)).fire(new G(`movestart`)).fire(new G(`move`)).fire(new G(`moveend`)),this}else throw Error(`minPitch must be between 0 and the current maxPitch, inclusive`)}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(t){if(t??=60,t>180)throw Error(`maxPitch must be less than or equal to 180`);if(t>=this._camera.transform.minPitch){let n=this._camera.transform.pitch,r=this._camera.getTransformForUpdate();return r.setMaxPitch(t),this._camera.applyUpdatedTransform(r),this._update(),n!==this._camera.transform.pitch&&this.fire(new G(`pitchstart`)).fire(new G(`pitch`)).fire(new G(`pitchend`)).fire(new G(`movestart`)).fire(new G(`move`)).fire(new G(`moveend`)),this}else throw Error(`maxPitch must be greater than the current minPitch`)}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(t){if(t??=20,t>180)throw Error(`anisotropicFilterPitch must be less than or equal to 180`);if(t<0)throw Error(`anisotropicFilterPitch must be greater than or equal to 0`);return this._anisotropicFilterPitch=t,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(t){return this._camera.transform.setRenderWorldCopies(t),this._update()}setTransformConstrain(t){return this._camera.transform.setConstrainOverride(t),this._update()}project(t){return this._camera.transform.locationToScreenPoint(P.convert(t),this.style&&this.terrain)}unproject(t){return this._camera.transform.screenPointToLocation(i.convert(t),this.terrain)}isMoving(){return this._camera.isMoving()||this._handlers?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlers?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlers?.isRotating()||!1}_createDelegatedListener(t,n,r){if(t===`mouseenter`||t===`mouseover`){let i=!1;return{layers:n,listener:r,delegates:{mousemove:a=>{let o=n.filter(t=>this.getLayer(t)),s=o.length===0?[]:this.queryRenderedFeatures(a.point,{layers:o});s.length?i||(i=!0,r.call(this,new Ir(t,this,a.originalEvent,{features:s}))):i=!1},mouseout:()=>{i=!1}}}}else if(t===`mouseleave`||t===`mouseout`){let i=!1;return{layers:n,listener:r,delegates:{mousemove:a=>{let o=n.filter(t=>this.getLayer(t));(o.length===0?[]:this.queryRenderedFeatures(a.point,{layers:o})).length?i=!0:i&&(i=!1,r.call(this,new Ir(t,this,a.originalEvent)))},mouseout:n=>{i&&(i=!1,r.call(this,new Ir(t,this,n.originalEvent)))}}}}else{let i=t=>{let i=n.filter(t=>this.getLayer(t)),a=i.length===0?[]:this.queryRenderedFeatures(t.point,{layers:i});a.length&&(t.features=a,r.call(this,t),delete t.features)};return{layers:n,listener:r,delegates:{[t]:i}}}}_saveDelegatedListener(t,n){this._delegatedListeners||={},this._delegatedListeners[t]||=[],this._delegatedListeners[t].push(n)}_removeDelegatedListener(t,n,r){if(!this._delegatedListeners?.[t])return;let i=this._delegatedListeners[t];for(let t=0;tn.includes(t))){for(let t in a.delegates)this.off(t,a.delegates[t]);i.splice(t,1);return}}}on(t,n,r){if(r===void 0)return super.on(t,n);let i=typeof n==`string`?[n]:n,a=this._createDelegatedListener(t,i,r);this._saveDelegatedListener(t,a);for(let t in a.delegates)this.on(t,a.delegates[t]);return{unsubscribe:()=>{this._removeDelegatedListener(t,i,r)}}}once(t,n,r){if(r===void 0)return super.once(t,n);let i=typeof n==`string`?[n]:n,a=this._createDelegatedListener(t,i,r);for(let n in a.delegates){let o=a.delegates[n];a.delegates[n]=(...n)=>{this._removeDelegatedListener(t,i,r),o(...n)}}this._saveDelegatedListener(t,a);for(let t in a.delegates)this.once(t,a.delegates[t]);return this}off(t,n,r){if(r===void 0)return super.off(t,n);let i=typeof n==`string`?[n]:n;return this._removeDelegatedListener(t,i,r),this}queryRenderedFeatures(t,n){if(!this.style)return[];let r,a=t instanceof i||Array.isArray(t),o=a?t:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(n||=(a?{}:t)||{},o instanceof i||typeof o[0]==`number`)r=[i.convert(o)];else{let t=i.convert(o[0]),n=i.convert(o[1]);r=[t,new i(n.x,t.y),n,new i(t.x,n.y),t]}return this.style.queryRenderedFeatures(r,n,this._camera.transform)}querySourceFeatures(t,n){return this.style.querySourceFeatures(t,n)}setStyle(t,n){return n=a({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},n),n.diff!==!1&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(t,n))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){let n=this._locale[t];if(n==null)throw Error(`Missing UI string '${t}'`);return n}_updateStyle(t,n){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,n.transformStyle&&this.style&&!this.style._loaded){this.style.once(`style.load`,()=>this._updateStyle(t,n));return}let r=this.style&&n.transformStyle?this.style.serialize():void 0;if(this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t)this.style=new pc(this,n||{});else return this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style,this;return this.style.setEventedParent(this,{style:this.style}),typeof t==`string`?this.style.loadURL(t,n,r):this.style.loadJSON(t,n,r),this}_lazyInitEmptyStyle(){this.style||(this.style=new pc(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(t,n){if(this._diffStyleRequest?.abort(),typeof t==`string`){let r=t;this._diffStyleRequest=new AbortController;let i=this._diffStyleRequest;try{let t=await this._requestManager.transformRequest(r,`Style`);if(i.signal.aborted){this._diffStyleRequest=null;return}let a=await g(t,i);this._diffStyleRequest=null,this._updateDiff(a.data,n)}catch(t){this._diffStyleRequest=null,he(t)||this.fire(new y(f(t)))}}else typeof t==`object`&&(this._diffStyleRequest=null,this._updateDiff(t,n))}_updateDiff(t,n){try{this.style.setState(t,n)&&this._update(!0)}catch(r){b(`Unable to perform style diff: ${f(r).message}. Rebuilding the style from scratch.`),this._updateStyle(t,n)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(!this.style){b(`There is no style added to the map.`);return}return this.style.loaded()}addSource(t,n){return this._lazyInitEmptyStyle(),this.style.addSource(t,n),this._update(!0)}isSourceLoaded(t){let n=this.style?.tileManagers[t];if(n===void 0){this.fire(new y(Error(`There is no tile manager with ID '${t}'`)));return}return n.loaded()}setTerrain(t,n={}){if(this.style._checkLoaded(),t&&re(this,M.terrain,{value:t},n))return this;if(this._terrainDataCallback&&this.style.off(`data`,this._terrainDataCallback),!t)this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this._camera.terrain=null,this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0);else{let n=this.style.tileManagers[t.source];if(!n)throw Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);this.terrain===null&&n.reload();for(let n in this.style._layers){let r=this.style._layers[n];r.type===`hillshade`&&r.source===t.source&&b(`You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`),r.type===`color-relief`&&r.source===t.source&&b(`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 lp(this.painter,n,t,this._terrainSkirtLength),this.painter.renderToTexture=new dp(this.painter,this.terrain),this._camera.terrain=this.terrain,this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._terrainDataCallback=n=>{n.dataType===`style`?this.terrain.tileManager.releaseAllRTT():n.dataType===`source`&&n.tile&&(n.sourceId===t.source&&!this._camera.elevationFreeze&&(this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom))),n.source?.type===`image`?this.terrain.tileManager.releaseAllRTT():this.terrain.tileManager.releaseRTT(n.tile.tileID))},this.style.on(`data`,this._terrainDataCallback)}return this.fire(new Br({terrain:t})),this}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let t=this.style?.tileManagers;for(let n of Object.values(t))if(!n.areTilesLoaded())return!1;return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style?.getSource(t)}setSourceTileLodParams(t,n,r){if(r){let i=this.getSource(r);if(!i)throw Error(`There is no source with ID "${r}", cannot set LOD parameters`);i.calculateTileZoom=ka(Math.max(1,t),Math.max(1,n))}else for(let r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=ka(Math.max(1,t),Math.max(1,n));return this._update(!0),this}refreshTiles(t,n){let r=this.style.tileManagers[t];if(!r)throw Error(`There is no tile manager with ID "${t}", cannot refresh tile`);n===void 0?r.reload(!0):r.refreshTiles(n.map(t=>new Ce(t.z,t.x,t.y)))}addImage(t,n,r={}){this._lazyInitEmptyStyle();let i=this._createStyleImage(n,r);return i?(this.style.addImage(t,i),i.userImage?.onAdd&&i.userImage.onAdd(this,t),this):this}setMissingStyleImageResolver(t){return this._missingStyleImageResolver=t,this.style?.setMissingImageResolver(t),this}_createStyleImage(t,n={}){let{pixelRatio:r=1,sdf:i=!1,stretchX:a,stretchY:o,content:s,textFitWidth:c,textFitHeight:l}=n;if(t instanceof HTMLImageElement||d(t)){let{width:n,height:u,data:d}=wr.getImageData(t);return{data:new v({width:n,height:u},d),pixelRatio:r,stretchX:a,stretchY:o,content:s,textFitWidth:c,textFitHeight:l,sdf:i,version:0}}else if(t.width===void 0||t.height===void 0)return this.fire(new y(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;else{let{width:n,height:u,data:d}=t,f=t;return{data:new v({width:n,height:u},new Uint8Array(d)),pixelRatio:r,stretchX:a,stretchY:o,content:s,textFitWidth:c,textFitHeight:l,sdf:i,version:0,userImage:f}}}updateImage(t,n){let r=this.style.getImage(t);if(!r)return this.fire(new y(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:a,data:o}=n instanceof HTMLImageElement||d(n)?wr.getImageData(n):n;if(i===void 0||a===void 0)return this.fire(new y(Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(i!==r.data.width||a!==r.data.height)return this.fire(new y(Error(`The width and height of the updated image must be that same as the previous version of the image`)));let s=!(n instanceof HTMLImageElement||d(n));return r.data.replace(o,s),this.style.updateImage(t,r),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new y(Error(`Missing required image id`))),!1)}removeImage(t){this.style.removeImage(t)}async loadImage(t){return kr.getImage(await this._requestManager.transformRequest(t,`Image`),new AbortController)}listImages(){return this.style?.listImages()??[]}addLayer(t,n){return this._lazyInitEmptyStyle(),this.style.addLayer(t,n),this._update(!0)}moveLayer(t,n){return this.style.moveLayer(t,n),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style?.getLayer(t)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(t,n,r){return this.style.setLayerZoomRange(t,n,r),this._update(!0)}setFilter(t,n,r={}){return this.style?.setFilter(t,n,r),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,n,r,i={}){return this.style?.setPaintProperty(t,n,r,i),this._update(!0)}getPaintProperty(t,n){return this.style.getPaintProperty(t,n)}setLayoutProperty(t,n,r,i={}){return this.style.setLayoutProperty(t,n,r,i),this._update(!0)}getLayoutProperty(t,n){return this.style.getLayoutProperty(t,n)}setGlyphs(t,n={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,n),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,n,r={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,n,r,t=>{t||this._update(!0)}),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,n={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,n,t=>{t||this._update(!0)}),this}setLight(t,n={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,n),this._update(!0)}getLight(){return this.style.getLight()}setSky(t,n={}){return this._lazyInitEmptyStyle(),this.style.setSky(t,n),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,n){return this.style.setFeatureState(t,n),this._update()}removeFeatureState(t,n){return this.style.removeFeatureState(t,n),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,n=0;return this._container&&(t=this._container.clientWidth||400,n=this._container.clientHeight||300),[t,n]}_setupResizeObserver(){let t=!1,n=Yd(t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())},50),r=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new r(r=>{if(!t){t=!0;return}n(r)}),this._resizeObserver.observe(this._container)}_resolveContainer(t){if(typeof t==`string`){let n=document.getElementById(t);if(!n)throw Error(`Container '${t}' not found.`);return n}if(t instanceof HTMLElement||t&&typeof t==`object`&&t.nodeType===1)return t;throw Error(`Invalid type: 'container' must be a String or HTMLElement.`)}_setupContainer(){let t=this._container;t.classList.add(`maplibregl-map`);let n=this._canvasContainer=W.create(`div`,`maplibregl-canvas-container`,t);this._interactive&&n.classList.add(`maplibregl-interactive`),this._canvas=W.create(`canvas`,`maplibregl-canvas`,n),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`);let r=this._containerDimensions(),i=this._getClampedPixelRatio(r[0],r[1]);this._resizeCanvas(r[0],r[1],i);let a=this._controlContainer=W.create(`div`,`maplibregl-control-container`,t),o=this._controlPositions={};for(let t of[`top-left`,`top-right`,`bottom-left`,`bottom-right`])o[t]=W.create(`div`,`maplibregl-ctrl-${t} `,a);this._container.addEventListener(`scroll`,this._onMapScroll,!1)}_resizeCanvas(t,n,r){this._canvas.width=Math.floor(r*t),this._canvas.height=Math.floor(r*n),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${n}px`}_setupPainter(){let t={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},n=null;this._canvas.addEventListener(`webglcontextcreationerror`,t=>{n=t},{once:!0});let r=this._canvas.getContext(`webgl2`,t);if(!r){this.fire(new y(new Zd(t,n)));return}this.painter=new Jd(r,this._camera.transform)}migrateProjection(t,n){this._camera.migrateProjection(t,n),this.painter.transform=t,this.fire(new Vr({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?._loaded?(this._styleDirty||=t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){let n=this._idleTriggered?this._fadeDuration:0,r=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let i=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let t=this._camera.transform.zoom,r=U();this.style.zoomHistory.update(t,r);let a=new ie(t,{now:r,fadeDuration:n,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=a.crossFadingFactor();(o!==1||o!==this._crossFadingFactor)&&(i=!0,this._crossFadingFactor=o),this.style.update(a)}let a=this.style.projection?.transitionState>0!==r;this._camera.transform.setTransitionState(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||a)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,n,this._crossSourceCollisions,a),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:n,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new Nr(`render`)),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Nr(`load`))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let o=this._sourcesDirty||this._styleDirty||this._placementDirty;return o||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new Nr(`idle`)),this._loaded&&!this._fullyLoaded&&!o&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<`u`&&this._ownerWindow.removeEventListener(`online`,this._onWindowOnline,!1),kr.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let t=this.painter.context.gl.getExtension(`WEBGL_lose_context`);t?.loseContext&&t.loseContext(),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`),this._removed=!0,this.fire(new Nr(`remove`))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,wr.frame(this._frameRequest,t=>{this._frameRequest=null;try{this._render(t)}catch(t){if(!he(t))throw t}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return up}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}};const pp={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var _p=class{constructor(t){this._updateZoomButtons=()=>{let t=this._map.getZoom(),n=t===this._map.getMaxZoom(),r=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute(`aria-disabled`,n.toString()),this._zoomOutButton.setAttribute(`aria-disabled`,r.toString())},this._rotateCompassArrow=()=>{let t=this._map.getPitch(),n=this._map.getRoll(),r=this._map.getBearing(),i=1/Math.cos(Pe(t))**.5;if(this.options.visualizePitch&&this.options.visualizeRoll){this._compassIcon.style.transform=`scale(${i}) rotateZ(${-n}deg) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizePitch){this._compassIcon.style.transform=`scale(${i}) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizeRoll){this._compassIcon.style.transform=`rotate(${-r-n}deg)`;return}this._compassIcon.style.transform=`rotate(${-r}deg)`},this._setButtonTitle=(t,n)=>{let r=this._map._getUIString(`NavigationControl.${n}`);t.title=r,t.setAttribute(`aria-label`,r)},this.options=a({},pp,t),this._container=W.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})),W.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})),W.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=W.create(`span`,`maplibregl-ctrl-icon`,this._compass),this._compassIcon.setAttribute(`aria-hidden`,`true`))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,`ZoomIn`),this._setButtonTitle(this._zoomOutButton,`ZoomOut`),this._map.on(`zoom`,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 vp(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off(`zoom`,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(t,n){let r=W.create(`button`,t,this._container);return r.type=`button`,r.addEventListener(`click`,n),r}},vp=class{constructor(t,n,r=!1){this.mousedown=t=>{this.startMove(t,W.mousePos(this.element,t)),window.addEventListener(`mousemove`,this.mousemove),window.addEventListener(`mouseup`,this.mouseup)},this.mousemove=t=>{this.move(t,W.mousePos(this.element,t))},this.mouseup=t=>{this._rotatePitchHandler.dragEnd(t),this.offTemp()},this.touchstart=t=>{t.targetTouches.length===1?(this._startPos=this._lastPos=W.touchPos(this.element,t.targetTouches)[0],this.startMove(t,this._startPos),window.addEventListener(`touchmove`,this.touchmove,{passive:!1}),window.addEventListener(`touchend`,this.touchend)):this.reset()},this.touchmove=t=>{t.targetTouches.length===1?(this._lastPos=W.touchPos(this.element,t.targetTouches)[0],this.move(t,this._lastPos)):this.reset()},this.touchend=t=>{t.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n;let a=new Cf;this._rotatePitchHandler=new vf({clickTolerance:3,move:(t,a)=>{let o=n.getBoundingClientRect(),s=new i((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:cr(new i(t.x,a.y),a,s),pitchDelta:r?(a.y-t.y)*-.5:void 0}},moveStateManager:a,enable:!0,assignEvents:()=>{}}),this.map=t,n.addEventListener(`mousedown`,this.mousedown),n.addEventListener(`touchstart`,this.touchstart,{passive:!1}),n.addEventListener(`touchcancel`,this.reset)}startMove(t,n){this._rotatePitchHandler.dragStart(t,n),W.disableDrag()}move(t,n){let r=this.map,{bearingDelta:i,pitchDelta:a}=this._rotatePitchHandler.dragMove(t,n)||{};i&&r.setBearing(r.getBearing()+i),a&&r.setPitch(r.getPitch()+a)}off(){let t=this.element;t.removeEventListener(`mousedown`,this.mousedown),t.removeEventListener(`touchstart`,this.touchstart),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend),t.removeEventListener(`touchcancel`,this.reset),this.offTemp()}offTemp(){W.enableDrag(),window.removeEventListener(`mousemove`,this.mousemove),window.removeEventListener(`mouseup`,this.mouseup),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend)}};let mp;async function gp(t=!1){if(mp!==void 0&&!t)return mp;if(window.navigator.permissions===void 0)return mp=!!window.navigator.geolocation,mp;try{mp=(await window.navigator.permissions.query({name:`geolocation`})).state!==`denied`}catch{mp=!!window.navigator.geolocation}return mp}function yp(t,n,r,i=!1){if(i||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return t?.wrap();let a=new P(t.lng,t.lat);if(t=new P(t.lng,t.lat),n){let i=new P(t.lng-360,t.lat),a=new P(t.lng+360,t.lat),o=r.locationToScreenPoint(t).distSqr(n);r.locationToScreenPoint(i).distSqr(n)180;){let n=r.locationToScreenPoint(t);if(n.x>=0&&n.y>=0&&n.x<=r.width&&n.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(t))?t:a}const bp={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 xp(t,n,r){let i=t.classList;for(let t in bp)i.remove(`maplibregl-${r}-anchor-${t}`);i.add(`maplibregl-${r}-anchor-${n}`)}var wp=class extends h{},Tp=class extends h{},Ep=class extends _{constructor(t){if(super(),this._onClick=t=>{this.fire(new Tp(`click`,{originalEvent:t}))},this._onKeyPress=t=>{(t.code===`Space`||t.code===`Enter`)&&this.togglePopup()},this._onMapClick=t=>{let n=t.originalEvent.target,r=this._element;this._popup&&(n===r||r.contains(n))&&this.togglePopup()},this._update=t=>{if(!this._map)return;let n=this._map.loaded()&&!this._map.isMoving();(t?.type===`terrain`||t?.type===`render`&&!n)&&this._map.once(`render`,this._update),this._lngLat=yp(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r=``;this._rotationAlignment===`viewport`||this._rotationAlignment===`auto`?r=`rotateZ(${this._rotation}deg)`:this._rotationAlignment===`map`&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let i=``;this._pitchAlignment===`viewport`||this._pitchAlignment===`auto`?i=`rotateX(0deg)`:this._pitchAlignment===`map`&&(i=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(!t||t.type===`moveend`)&&(this._pos=this._pos.round()),this._element.style.transform=`${bp[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${i} ${r}`,wr.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity(t?.type===`moveend`)}).catch(()=>{})},this._onMove=t=>{if(!this._isDragging){let n=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=n}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 wp(`dragstart`))),this.fire(new wp(`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 wp(`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=t?.anchor||`center`,this._color=t?.color||`#3FB1CE`,this._scale=t?.scale||1,this._draggable=t?.draggable||!1,this._clickTolerance=t?.clickTolerance||0,this._subpixelPositioning=t?.subpixelPositioning||!1,this._isDragging=!1,this._roleManaged=!1,this._state=`inactive`,this._rotation=t?.rotation||0,this._rotationAlignment=t?.rotationAlignment||`auto`,this._pitchAlignment=t?.pitchAlignment&&t.pitchAlignment!==`auto`?t.pitchAlignment:this._rotationAlignment,this.setOpacity(t?.opacity,t?.opacityWhenCovered),t?.element)this._element=t.element,this._offset=i.convert(t?.offset||[0,0]);else{this._defaultMarker=!0,this._element=W.create(`div`);let n=W.createNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttributeNS(null,`display`,`block`),n.setAttributeNS(null,`height`,`41px`),n.setAttributeNS(null,`width`,`27px`),n.setAttributeNS(null,`viewBox`,`0 0 27 41`);let r=W.createNS(`http://www.w3.org/2000/svg`,`g`);r.setAttributeNS(null,`stroke`,`none`),r.setAttributeNS(null,`stroke-width`,`1`),r.setAttributeNS(null,`fill`,`none`),r.setAttributeNS(null,`fill-rule`,`evenodd`);let a=W.createNS(`http://www.w3.org/2000/svg`,`g`);a.setAttributeNS(null,`fill-rule`,`nonzero`);let o=W.createNS(`http://www.w3.org/2000/svg`,`g`);o.setAttributeNS(null,`transform`,`translate(3.0, 29.0)`),o.setAttributeNS(null,`fill`,`#000000`);for(let t of[{rx:`10.5`,ry:`5.25002273`},{rx:`10.5`,ry:`5.25002273`},{rx:`9.5`,ry:`4.77275007`},{rx:`8.5`,ry:`4.29549936`},{rx:`7.5`,ry:`3.81822308`},{rx:`6.5`,ry:`3.34094679`},{rx:`5.5`,ry:`2.86367051`},{rx:`4.5`,ry:`2.38636864`}]){let n=W.createNS(`http://www.w3.org/2000/svg`,`ellipse`);n.setAttributeNS(null,`opacity`,`0.04`),n.setAttributeNS(null,`cx`,`10.5`),n.setAttributeNS(null,`cy`,`5.80029008`),n.setAttributeNS(null,`rx`,t.rx),n.setAttributeNS(null,`ry`,t.ry),o.appendChild(n)}let s=W.createNS(`http://www.w3.org/2000/svg`,`g`);s.setAttributeNS(null,`fill`,this._color);let c=W.createNS(`http://www.w3.org/2000/svg`,`path`);c.setAttributeNS(null,`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`),s.appendChild(c);let l=W.createNS(`http://www.w3.org/2000/svg`,`g`);l.setAttributeNS(null,`opacity`,`0.25`),l.setAttributeNS(null,`fill`,`#000000`);let u=W.createNS(`http://www.w3.org/2000/svg`,`path`);u.setAttributeNS(null,`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`),l.appendChild(u);let d=W.createNS(`http://www.w3.org/2000/svg`,`g`);d.setAttributeNS(null,`transform`,`translate(6.0, 7.0)`),d.setAttributeNS(null,`fill`,`#FFFFFF`);let f=W.createNS(`http://www.w3.org/2000/svg`,`g`);f.setAttributeNS(null,`transform`,`translate(8.0, 8.0)`);let p=W.createNS(`http://www.w3.org/2000/svg`,`circle`);p.setAttributeNS(null,`fill`,`#000000`),p.setAttributeNS(null,`opacity`,`0.25`),p.setAttributeNS(null,`cx`,`5.5`),p.setAttributeNS(null,`cy`,`5.5`),p.setAttributeNS(null,`r`,`5.4999962`);let m=W.createNS(`http://www.w3.org/2000/svg`,`circle`);m.setAttributeNS(null,`fill`,`#FFFFFF`),m.setAttributeNS(null,`cx`,`5.5`),m.setAttributeNS(null,`cy`,`5.5`),m.setAttributeNS(null,`r`,`5.4999962`),f.appendChild(p),f.appendChild(m),a.appendChild(o),a.appendChild(s),a.appendChild(l),a.appendChild(d),a.appendChild(f),n.appendChild(a),n.setAttributeNS(null,`height`,`${41*this._scale}px`),n.setAttributeNS(null,`width`,`${27*this._scale}px`),this._element.appendChild(n),this._offset=i.convert(t?.offset||[0,-14])}if(this._element.classList.add(`maplibregl-marker`),this._element.addEventListener(`dragstart`,t=>{t.preventDefault()}),this._element.addEventListener(`mousedown`,t=>{t.preventDefault()}),xp(this._element,this._anchor,`marker`),t?.className)for(let n of t.className.split(` `))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,this._defaultMarker&&!this._element.hasAttribute(`aria-label`)&&this._element.setAttribute(`aria-label`,t._getUIString(`Marker.Title`)),this._updateAccessibilityRole(),t.getCanvasContainer().appendChild(this._element),t.on(`move`,this._update),t.on(`moveend`,this._update),t.on(`terrain`,this._update),t.on(`projectiontransition`,this._update),this._element.addEventListener(`click`,this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on(`click`,this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),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(`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.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=P.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener(`keypress`,this._onKeyPress),this._originalTabIndex||this._element.removeAttribute(`tabindex`)),t){if(!(`offset`in t.options)){let n=41-5.8/2,r=13.5,i=13.5/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[i,(n-r+i)*-1],"bottom-right":[-i,(n-r+i)*-1],left:[r,(n-r)*-1],right:[-13.5,(n-r)*-1]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute(`tabindex`),this._originalTabIndex||this._element.setAttribute(`tabindex`,`0`),this._element.addEventListener(`keypress`,this._onKeyPress)}return this._updateAccessibilityRole(),this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){let t=this._popup;if(this._element.style.opacity===this._opacityWhenCovered)return this;if(t)t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map));else return this;return this}_updateOpacity(t=!1){let n=this._map?.terrain,r=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!n||r){let t=r?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==t&&(this._element.style.opacity=t,this._element.classList.toggle(`maplibregl-marker-covered`,r));return}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let a=this._map,o=a.terrain.depthAtPoint(this._pos),s=a.terrain.getElevationForLngLat(this._lngLat,a._camera.transform),c=a._camera.transform.lngLatToCameraDepth(this._lngLat,s),l=.006;if(c-ol;this._popup?.isOpen()&&p&&this._popup.remove(),this._element.style.opacity=p?this._opacityWhenCovered:this._opacity,this._element.classList.toggle(`maplibregl-marker-covered`,p)}getOffset(){return this._offset}setOffset(t){return this._offset=i.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._element.classList.toggle(`maplibregl-marker-draggable`,this._draggable),this._map&&(t?(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._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateAccessibilityRole(){if(!this._defaultMarker||this._element.hasAttribute(`role`)&&!this._roleManaged)return;let t=this._draggable||this._popup?`button`:`img`;this._element.setAttribute(`role`,t),this._roleManaged=!0}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||`auto`,this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!==`auto`?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,n){return(this._opacity===void 0||t===void 0&&n===void 0)&&(this._opacity=`1`,this._opacityWhenCovered=`0.2`),t!==void 0&&(this._opacity=String(t)),n!==void 0&&(this._opacityWhenCovered=String(n)),this._map&&this._updateOpacity(!0),this}};const Sp={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Cp=0,Dp=!1;var Ap=class extends h{},jp=class extends h{},Mp=class extends h{},Np=class extends _{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t)){this._setErrorState(),this.fire(new jp(`outofmaxbounds`,t)),this._updateMarker(),this._finish();return}if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`BACKGROUND`:case`BACKGROUND_ERROR`:this._watchState=`BACKGROUND`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`);break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!==`OFF`&&this._updateMarker(t),(!this.options.trackUserLocation||this._watchState===`ACTIVE_LOCK`)&&this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove(`maplibregl-user-location-dot-stale`),this.fire(new jp(`geolocate`,t)),this._finish()}},this._updateCamera=t=>{let n=new P(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,i=a({bearing:this._map.getBearing()},this.options.fitBoundsOptions),o=Fi.fromLngLat(n,r);this._map.fitBounds(o,i,{geolocateSource:!0})},this._updateMarker=t=>{if(t){let n=new P(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(t.code===1){this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.disabled=!0;let t=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.title=t,this._geolocateButton.setAttribute(`aria-label`,t),this._geolocationWatchID!==void 0&&this._clearWatch()}else if(t.code===3&&Dp)return;else this._setErrorState();this._watchState!==`OFF`&&this.options.showUserLocation&&this._dotElement.classList.add(`maplibregl-user-location-dot-stale`),this.fire(new Mp(`error`,t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=t=>{if(!this._map)return;let n=t?.[0]instanceof ResizeObserverEntry;!t.geolocateSource&&this._watchState===`ACTIVE_LOCK`&&!n&&!this._map.isZooming()&&(this._watchState=`BACKGROUND`,this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this.fire(new Ap(`trackuserlocationend`)),this.fire(new Ap(`userlocationlostfocus`)))},this._setupUI=()=>{this._map&&(this._container.addEventListener(`contextmenu`,t=>{t.preventDefault()}),this._geolocateButton=W.create(`button`,`maplibregl-ctrl-geolocate`,this._container),W.create(`span`,`maplibregl-ctrl-icon`,this._geolocateButton).setAttribute(`aria-hidden`,`true`),this._geolocateButton.type=`button`,this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){b(`Geolocation support is not available so the GeolocateControl will be disabled.`);let t=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute(`aria-label`,t)}else{let t=this._map._getUIString(`GeolocateControl.FindMyLocation`);this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute(`aria-label`,t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute(`aria-pressed`,`false`),this._watchState=`OFF`),this.options.showUserLocation&&(this._dotElement=W.create(`div`,`maplibregl-user-location-dot`),this._userLocationDotMarker=new Ep({element:this._dotElement}),this._circleElement=W.create(`div`,`maplibregl-user-location-accuracy-circle`),this._accuracyCircleMarker=new Ep({element:this._circleElement,pitchAlignment:`map`}),this.options.trackUserLocation&&(this._watchState=`OFF`),this._map.on(`zoom`,this._onUpdate),this._map.on(`move`,this._onUpdate),this._map.on(`rotate`,this._onUpdate),this._map.on(`pitch`,this._onUpdate)),this._geolocateButton.addEventListener(`click`,()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on(`movestart`,this._onMoveStart)}},this.options=a({},Sp,t)}onAdd(t){return this._map=t,this._container=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),gp().then(t=>this._finishSetupUI(t)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off(`movestart`,this._onMoveStart),this._map.off(`zoom`,this._onUpdate),this._map.off(`move`,this._onUpdate),this._map.off(`rotate`,this._onUpdate),this._map.off(`pitch`,this._onUpdate),this._map=void 0,Cp=0,Dp=!1}_isOutOfMapMaxBounds(t){let n=this._map.getMaxBounds(),r=t.coords;return n&&(r.longituden.getEast()||r.latituden.getNorth())}_setErrorState(){switch(this._watchState){case`WAITING_ACTIVE`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`);break;case`ACTIVE_LOCK`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`BACKGROUND`:this._watchState=`BACKGROUND_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:break;case`OFF`:case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let t=this._userLocationDotMarker.getLngLat();if(!this.options.showUserLocation||!this.options.showAccuracyCircle||!this._accuracy||!t)return;let n=this._map.project(t),r=this._map.unproject([n.x+100,n.y]),i=t.distanceTo(r)/100,a=2*this._accuracy/i;this._circleElement.style.width=`${a.toFixed(2)}px`,this._circleElement.style.height=`${a.toFixed(2)}px`}trigger(){if(!this._setup)return b(`Geolocate control triggered before added to a map`),!1;if(this.options.trackUserLocation){switch(this._watchState){case`OFF`:this._watchState=`WAITING_ACTIVE`,this.fire(new Ap(`trackuserlocationstart`));break;case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:Cp--,Dp=!1,this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this.fire(new Ap(`trackuserlocationend`));break;case`BACKGROUND`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new Ap(`trackuserlocationstart`)),this.fire(new Ap(`userlocationfocus`));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case`WAITING_ACTIVE`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`ACTIVE_LOCK`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`OFF`:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState===`OFF`&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`true`),Cp++;let t;Cp>1?(t={maximumAge:6e5,timeout:0},Dp=!0):(t=this.options.positionOptions,Dp=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`false`),this.options.showUserLocation&&this._updateMarker(null)}};const Op={maxWidth:100,unit:`metric`};var Fp=class{constructor(t){this._onMove=()=>{kp(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,kp(this._map,this._container,this.options)},this.options={...Op,...t}}getDefaultPosition(){return`bottom-left`}onAdd(t){return this._map=t,this._container=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-scale`,t.getContainer()),this._map.on(`move`,this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off(`move`,this._onMove),this._map=void 0}};function kp(t,n,r){let i=r?.maxWidth||100,a=t._container.clientHeight/2,o=t._container.clientWidth/2,s=t.unproject([o-i/2,a]),c=t.unproject([o+i/2,a]),l=Math.round(t.project(c).x-t.project(s).x),u=Math.min(i,l,t._container.clientWidth),d=s.distanceTo(c);if(r?.unit===`imperial`){let r=3.2808*d;r>5280?Pp(n,u,r/5280,t._getUIString(`ScaleControl.Miles`)):Pp(n,u,r,t._getUIString(`ScaleControl.Feet`))}else r?.unit===`nautical`?Pp(n,u,d/1852,t._getUIString(`ScaleControl.NauticalMiles`)):d>=1e3?Pp(n,u,d/1e3,t._getUIString(`ScaleControl.Kilometers`)):Pp(n,u,d,t._getUIString(`ScaleControl.Meters`))}function Pp(t,n,r,i){let a=Lp(r),o=a/r;t.style.width=`${n*o}px`,t.innerHTML=`${a} ${i}`}function Ip(t){let n=10**Math.ceil(-Math.log(t)/Math.LN10);return Math.round(t*n)/n}function Lp(t){let n=10**(`${Math.floor(t)}`.length-1),r=t/n;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:Ip(r),n*r}var Bp=class extends h{},Vp=class extends _{constructor(t={}){super(),this._onFullscreenChange=()=>{let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;t?.shadowRoot?.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=t.pseudo??!1,t?.container&&(t.container instanceof HTMLElement?this._container=t.container:b(`Full screen control 'container' must be a DOM element.`)),`onfullscreenchange`in document?this._fullscreenchange=`fullscreenchange`:`onmozfullscreenchange`in document?this._fullscreenchange=`mozfullscreenchange`:`onwebkitfullscreenchange`in document?this._fullscreenchange=`webkitfullscreenchange`:`onmsfullscreenchange`in document&&(this._fullscreenchange=`MSFullscreenChange`)}onAdd(t){return this._map=t,this._container||=this._map.getContainer(),this._controlContainer=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let t=this._fullscreenButton=W.create(`button`,`maplibregl-ctrl-fullscreen`,this._controlContainer);W.create(`span`,`maplibregl-ctrl-icon`,t).setAttribute(`aria-hidden`,`true`),t.type=`button`,this._updateTitle(),this._fullscreenButton.addEventListener(`click`,this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let t=this._getTitle();this._fullscreenButton.setAttribute(`aria-label`,t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?`FullscreenControl.Exit`:`FullscreenControl.Enter`)}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(`maplibregl-ctrl-shrink`),this._fullscreenButton.classList.toggle(`maplibregl-ctrl-fullscreen`),this._updateTitle(),this._fullscreen?(this.fire(new Bp(`fullscreenstart`)),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new Bp(`fullscreenend`)),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle(`maplibregl-pseudo-fullscreen`),this._handleFullscreenChange(),this._map.resize()}},Hp=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove(`maplibregl-ctrl-terrain`),this._terrainButton.classList.remove(`maplibregl-ctrl-terrain-enabled`),this._map.terrain?(this._terrainButton.classList.add(`maplibregl-ctrl-terrain-enabled`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Disable`)):(this._terrainButton.classList.add(`maplibregl-ctrl-terrain`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Enable`))},this.options=t}onAdd(t){return this._map=t,this._container=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._terrainButton=W.create(`button`,`maplibregl-ctrl-terrain`,this._container),W.create(`span`,`maplibregl-ctrl-icon`,this._terrainButton).setAttribute(`aria-hidden`,`true`),this._terrainButton.type=`button`,this._terrainButton.addEventListener(`click`,this._toggleTerrain),this._updateTerrainIcon(),this._map.on(`terrain`,this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off(`terrain`,this._updateTerrainIcon),this._map=void 0}},Up=class{constructor(){this._toggleProjection=()=>{let t=this._map.getProjection()?.type;t===`mercator`||!t?this._map.setProjection({type:`globe`}):this._map.setProjection({type:`mercator`}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove(`maplibregl-ctrl-globe`),this._globeButton.classList.remove(`maplibregl-ctrl-globe-enabled`),this._map.getProjection()?.type===`globe`?(this._globeButton.classList.add(`maplibregl-ctrl-globe-enabled`),this._globeButton.title=this._map._getUIString(`GlobeControl.Disable`)):(this._globeButton.classList.add(`maplibregl-ctrl-globe`),this._globeButton.title=this._map._getUIString(`GlobeControl.Enable`))}}onAdd(t){return this._map=t,this._container=W.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._globeButton=W.create(`button`,`maplibregl-ctrl-globe`,this._container),W.create(`span`,`maplibregl-ctrl-icon`,this._globeButton).setAttribute(`aria-hidden`,`true`),this._globeButton.type=`button`,this._globeButton.addEventListener(`click`,this._toggleProjection),this._updateGlobeIcon(),this._map.on(`styledata`,this._updateGlobeIcon),this._map.on(`projectiontransition`,this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off(`styledata`,this._updateGlobeIcon),this._map.off(`projectiontransition`,this._updateGlobeIcon),this._globeButton.removeEventListener(`click`,this._toggleProjection),this._map=void 0}};const Rp={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:``,maxWidth:`240px`,subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},zp=[`a[href]`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable]:not([contenteditable='false'])`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`].join(`, `);var Kp=class extends h{},qp=class extends _{constructor(t){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._map._camera.transform.isLocationOccluded(this.getLngLat())?this._container.style.opacity=`${this.options.locationOccludedOpacity}`:this._container.style.opacity=``)},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off(`move`,this._update),this._map.off(`move`,this._onClose),this._map.off(`click`,this._onClose),this._map.off(`remove`,this.remove),this._map.off(`terrain`,this._update),this._map.off(`projectiontransition`,this._update),this._map.off(`mousemove`,this._update),this._map.off(`mouseup`,this._update),this._map.off(`drag`,this._update),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`),delete this._map,this.fire(new Kp(`close`))),this),this._update=t=>{let n=this._lngLat||this._trackPointer;if(!this._map||!n||!this._content)return;if(!this._container){if(this._container=W.create(`div`,`maplibregl-popup`,this._map.getContainer()),this._tip=W.create(`div`,`maplibregl-popup-tip`,this._container),this._container.appendChild(this._content),this.options.className)for(let t of this.options.className.split(` `))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute(`aria-label`,this._map._getUIString(`Popup.Close`)),this._trackPointer&&this._container.classList.add(`maplibregl-popup-track-pointer`)}this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=yp(this._lngLat,this._flatPos,this._map._camera.transform,this._trackPointer);let r;if(t&&`point`in t&&t.point&&(r=t.point),this._trackPointer&&!r)return;let i=this._flatPos=this._pos=this._trackPointer&&r?r:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&r?r:this._map._camera.transform.locationToScreenPoint(this._lngLat));let a=this.options.anchor,o=Wp(this.options.offset);if(!a){let t=this._container.offsetWidth,n=this._container.offsetHeight,r=Gp(this.options.padding),s;s=i.y+o.bottom.ythis._map._camera.transform.height-n-r.bottom?[`bottom`]:[],i.xthis._map._camera.transform.width-t/2-r.right&&s.push(`right`),a=s.length===0?`bottom`:s.join(`-`)}let s=i.add(o[a]);this.options.subpixelPositioning||(s=s.round()),this._container.style.transform=`${bp[a]} translate(${s.x}px,${s.y}px)`,xp(this._container,a,`popup`),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=a(Object.create(Rp),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on(`click`,this._onClose),this.options.closeOnMove&&this._map.on(`move`,this._onClose),this._map.on(`remove`,this.remove),this._map.on(`terrain`,this._update),this._map.on(`projectiontransition`,this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on(`mousemove`,this._update),this._map.on(`mouseup`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)):this._map.on(`move`,this._update),this.fire(new Kp(`open`)),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=P.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on(`move`,this._update),this._map.off(`mousemove`,this._update),this._container&&this._container.classList.remove(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`)),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off(`move`,this._update),this._map.on(`mousemove`,this._update),this._map.on(`drag`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){let n=document.createDocumentFragment(),r=document.createElement(`body`),i;for(r.innerHTML=t;i=r.firstChild,i;)n.appendChild(i);return this.setDOMContent(n)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=W.create(`div`,`maplibregl-popup-content`,this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}setPadding(t){this.options.padding=t,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=W.create(`button`,`maplibregl-popup-close-button`,this._content),this._closeButton.type=`button`,this._closeButton.innerHTML=`×`,this._closeButton.addEventListener(`click`,this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let t=this._container.querySelector(zp);t&&t.focus()}};function Wp(t){if(!t)return Wp(new i(0,0));if(typeof t==`number`){let n=Math.round(Math.abs(t)/Math.SQRT2);return{center:new i(0,0),top:new i(0,t),"top-left":new i(n,n),"top-right":new i(-n,n),bottom:new i(0,-t),"bottom-left":new i(n,-n),"bottom-right":new i(-n,-n),left:new i(t,0),right:new i(-t,0)}}else if(t instanceof i||Array.isArray(t)){let n=i.convert(t);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}else return{center:i.convert(t.center||[0,0]),top:i.convert(t.top||[0,0]),"top-left":i.convert(t[`top-left`]||[0,0]),"top-right":i.convert(t[`top-right`]||[0,0]),bottom:i.convert(t.bottom||[0,0]),"bottom-left":i.convert(t[`bottom-left`]||[0,0]),"bottom-right":i.convert(t[`bottom-right`]||[0,0]),left:i.convert(t.left||[0,0]),right:i.convert(t.right||[0,0])}}function Gp(t){return t?{top:t.top??0,right:t.right??0,bottom:t.bottom??0,left:t.left??0}:{top:0,right:0,bottom:0,left:0}}const Jp=_r;function Yp(t,n){return ma().setRTLTextPlugin(t,n)}function Xp(){return ma().getRTLTextPluginStatus()}function Zp(){return Jp}function Qp(){return hi.workerCount}function $p(t){hi.workerCount=t}function em(){return p.MAX_PARALLEL_IMAGE_REQUESTS}function tm(t){p.MAX_PARALLEL_IMAGE_REQUESTS=t}function nm(){return p.WORKER_URL}function rm(t){p.WORKER_URL=t}async function im(t){await Si().broadcast(`IS`,t)}export{ip as AttributionControl,ff as BoxZoomHandler,sa as CanvasSource,Xf as CooperativeGesturesHandler,Wf as DoubleClickZoomHandler,qf as DragPanHandler,Jf as DragRotateHandler,F as EXTENT,fs as EdgeInsets,y as ErrorEvent,h as Event,_ as Evented,Vp as FullscreenControl,Bp as FullscreenEvent,Zd as GPUInitializationError,na as GeoJSONSource,Np as GeolocateControl,Mp as GeolocateErrorEvent,Ap as GeolocateEvent,jp as GeolocatePositionEvent,Up as GlobeControl,$d as Hash,ra as ImageSource,Bf as KeyboardHandler,P as LngLat,Fi as LngLatBounds,ap as LogoControl,hp as Map,zr as MapBoxZoomEvent,Hr as MapContextEvent,Nr as MapLibreEvent,hp as MapLibreMap,Ir as MapMouseEvent,G as MapMovementEvent,Vr as MapProjectionEvent,K as MapSourceDataEvent,Fr as MapStyleDataEvent,Ur as MapStyleImageMissingEvent,Pr as MapStyleLoadEvent,Br as MapTerrainEvent,Lr as MapTouchEvent,Rr as MapWheelEvent,Ep as Marker,Tp as MarkerClickEvent,wp as MarkerDragEvent,I as MercatorCoordinate,_p as NavigationControl,i as Point,qp as Popup,Kp as PopupEvent,Vi as RasterDEMTileSource,Bi as RasterTileSource,Fp as ScaleControl,Uf as ScrollZoomHandler,pc as Style,Hp as TerrainControl,Rf as TwoFingersTouchPitchHandler,If as TwoFingersTouchRotateHandler,Pf as TwoFingersTouchZoomHandler,Yf as TwoFingersTouchZoomRotateHandler,zi as VectorTileSource,oa as VideoSource,ua as addSourceType,bi as clearPrewarmedResources,p as config,Ns as createTileMesh,Si as getGlobalDispatcher,em as getMaxParallelImageRequests,Xp as getRTLTextPluginStatus,Zp as getVersion,Qp as getWorkerCount,nm as getWorkerUrl,im as importScriptInWorkers,Or as isTimeFrozen,U as now,yi as prewarm,Dr as restoreNow,tm as setMaxParallelImageRequests,Er as setNow,Yp as setRTLTextPlugin,$p as setWorkerCount,rm as setWorkerUrl};