@graphhopper/graphhopper-maps-bundle 0.0.0-dafe37c1 → 0.0.0-db2c83c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/assets/android-chrome-144x144.png +0 -0
- package/dist/assets/android-chrome-192x192.png +0 -0
- package/dist/assets/android-chrome-256x256.png +0 -0
- package/dist/assets/android-chrome-36x36.png +0 -0
- package/dist/assets/android-chrome-384x384.png +0 -0
- package/dist/assets/android-chrome-48x48.png +0 -0
- package/dist/assets/android-chrome-512x512.png +0 -0
- package/dist/assets/android-chrome-96x96.png +0 -0
- package/dist/assets/apple-touch-icon-1024x1024.png +0 -0
- package/dist/assets/apple-touch-icon-114x114.png +0 -0
- package/dist/assets/apple-touch-icon-120x120.png +0 -0
- package/dist/assets/apple-touch-icon-144x144.png +0 -0
- package/dist/assets/apple-touch-icon-152x152.png +0 -0
- package/dist/assets/apple-touch-icon-167x167.png +0 -0
- package/dist/assets/apple-touch-icon-180x180.png +0 -0
- package/dist/assets/apple-touch-icon-57x57.png +0 -0
- package/dist/assets/apple-touch-icon-60x60.png +0 -0
- package/dist/assets/apple-touch-icon-precomposed.png +0 -0
- package/dist/assets/apple-touch-icon.png +0 -0
- package/dist/assets/favicon-16x16.png +0 -0
- package/dist/assets/favicon-32x32.png +0 -0
- package/dist/assets/favicon-48x48.png +0 -0
- package/dist/assets/mstile-144x144.png +0 -0
- package/dist/assets/mstile-150x150.png +0 -0
- package/dist/assets/mstile-310x150.png +0 -0
- package/dist/assets/mstile-310x310.png +0 -0
- package/dist/assets/mstile-70x70.png +0 -0
- package/dist/bundle.31d9465dfaf7ec6b2a49.js +2 -0
- package/dist/bundle.31d9465dfaf7ec6b2a49.js.LICENSE.txt +4 -0
- package/dist/bundle.efd3cfd1da0be0deb202.js +2 -0
- package/dist/bundle.f8145f093c653b051d7f.js +1 -0
- package/dist/config.js +1 -1
- package/dist/index.html +2 -2
- package/dist/manifest.json +1 -1
- package/dist/maplibre-gl-shared.mjs +2 -0
- package/dist/maplibre-gl-shared.mjs.LICENSE.txt +4 -0
- package/dist/maplibre-gl-worker.mjs +2 -0
- package/dist/maplibre-gl-worker.mjs.LICENSE.txt +4 -0
- package/package.json +10 -1
- package/dist/bundle.8944531bcbbc36cf4c39.js +0 -2
- package/dist/ceb05254cedfa895b512.ttf +0 -0
- package/dist/eae34fa8f1e0c4c6d797.ttf +0 -0
- package/dist/fc2b5060f7accec5cf74.ttf +0 -0
- package/dist/fc3d2f2e3a203d0037c1.ttf +0 -0
- /package/dist/{bundle.8944531bcbbc36cf4c39.js.LICENSE.txt → bundle.efd3cfd1da0be0deb202.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see bundle.31d9465dfaf7ec6b2a49.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.webpackChunk_graphhopper_graphhopper_maps_bundle=self.webpackChunk_graphhopper_graphhopper_maps_bundle||[]).push([[849],{849(e,t,i){i.d(t,{T5:()=>jD,QE:()=>VD});var r=Object.create,a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),h=(e,t,i,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var s,u=o(t),h=0,c=u.length;h<c;h++)s=u[h],!l.call(e,s)&&s!==i&&a(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=n(t,s))||r.enumerable});return e};function c(e,t){this.x=e,this.y=t}let d,p;function f(){return d??=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap,d}function m(){if(null==p&&(p=!1,f())){let e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let t=0;t<25;t++){let i=4*t;e.fillStyle=`rgb(${i},${i+1},${i+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}c.prototype={clone(){return new c(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let t=e[0]*this.x+e[1]*this.y,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),i=Math.sin(e),r=t*this.x-i*this.y,a=i*this.x+t*this.y;return this.x=r,this.y=a,this},_rotateAround(e,t){let i=Math.cos(e),r=Math.sin(e),a=t.x+i*(this.x-t.x)-r*(this.y-t.y),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=a,this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:c},c.convert=function(e){if(e instanceof c)return e;if(Array.isArray(e))return new c(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new c(+e.x,+e.y);throw Error("Expected [x, y] or {x, y} point format")};var g=typeof Float32Array<"u"?Float32Array:Array;function _(){var e=new g(9);return g!=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 y(){var e=new g(16);return g!=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 g(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 v(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 b(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=t[4],s=t[5],l=t[6],u=t[7],h=t[8],c=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],y=i*s-r*o,x=i*l-a*o,v=i*u-n*o,b=r*l-a*s,w=r*u-n*s,T=a*u-n*l,D=h*m-c*f,E=h*g-d*f,S=h*_-p*f,P=c*g-d*m,I=c*_-p*m,A=d*_-p*g,C=y*A-x*I+v*P+b*S-w*E+T*D;return C?(C=1/C,e[0]=(s*A-l*I+u*P)*C,e[1]=(a*I-r*A-n*P)*C,e[2]=(m*T-g*w+_*b)*C,e[3]=(d*w-c*T-p*b)*C,e[4]=(l*S-o*A-u*E)*C,e[5]=(i*A-a*S+n*E)*C,e[6]=(g*v-f*T-_*x)*C,e[7]=(h*T-d*v+p*x)*C,e[8]=(o*I-s*S+u*D)*C,e[9]=(r*S-i*I-n*D)*C,e[10]=(f*w-m*v+_*y)*C,e[11]=(c*v-h*w-p*y)*C,e[12]=(s*E-o*P-l*D)*C,e[13]=(i*P-r*E+a*D)*C,e[14]=(m*x-f*b-g*y)*C,e[15]=(h*b-c*x+d*y)*C,e):null}function w(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*s+b*c+w*m,e[1]=x*a+v*l+b*d+w*g,e[2]=x*n+v*u+b*p+w*_,e[3]=x*o+v*h+b*f+w*y,x=i[4],v=i[5],b=i[6],w=i[7],e[4]=x*r+v*s+b*c+w*m,e[5]=x*a+v*l+b*d+w*g,e[6]=x*n+v*u+b*p+w*_,e[7]=x*o+v*h+b*f+w*y,x=i[8],v=i[9],b=i[10],w=i[11],e[8]=x*r+v*s+b*c+w*m,e[9]=x*a+v*l+b*d+w*g,e[10]=x*n+v*u+b*p+w*_,e[11]=x*o+v*h+b*f+w*y,x=i[12],v=i[13],b=i[14],w=i[15],e[12]=x*r+v*s+b*c+w*m,e[13]=x*a+v*l+b*d+w*g,e[14]=x*n+v*u+b*p+w*_,e[15]=x*o+v*h+b*f+w*y,e}function T(e,t,i){var r,a,n,o,s,l,u,h,c,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[0],a=t[1],n=t[2],o=t[3],s=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=t[9],p=t[10],f=t[11],e[0]=r,e[1]=a,e[2]=n,e[3]=o,e[4]=s,e[5]=l,e[6]=u,e[7]=h,e[8]=c,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+s*g+c*_+t[12],e[13]=a*m+l*g+d*_+t[13],e[14]=n*m+u*g+p*_+t[14],e[15]=o*m+h*g+f*_+t[15]),e}function D(e,t,i){var r=i[0],a=i[1],n=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function E(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[4],o=t[5],s=t[6],l=t[7],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=n*a+u*r,e[5]=o*a+h*r,e[6]=s*a+c*r,e[7]=l*a+d*r,e[8]=u*a-n*r,e[9]=h*a-o*r,e[10]=c*a-s*r,e[11]=d*a-l*r,e}function S(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],o=t[1],s=t[2],l=t[3],u=t[8],h=t[9],c=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a-u*r,e[1]=o*a-h*r,e[2]=s*a-c*r,e[3]=l*a-d*r,e[8]=n*r+u*a,e[9]=o*r+h*a,e[10]=s*r+c*a,e[11]=l*r+d*a,e}function P(e,t,i){var r=Math.sin(i),a=Math.cos(i),n=t[0],o=t[1],s=t[2],l=t[3],u=t[4],h=t[5],c=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*a+u*r,e[1]=o*a+h*r,e[2]=s*a+c*r,e[3]=l*a+d*r,e[4]=u*a-n*r,e[5]=h*a-o*r,e[6]=c*a-s*r,e[7]=d*a-l*r,e}Math.PI,Math.PI;var I=function(e,t,i,r,a){var n=1/Math.tan(t/2);if(e[0]=n/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=a&&a!==1/0){var o=1/(r-a);e[10]=(a+r)*o,e[14]=2*a*r*o}else e[10]=-1,e[14]=-2*r;return e},A=function(e,t,i,r,a,n,o){var s=1/(t-i),l=1/(r-a),u=1/(n-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+i)*s,e[13]=(a+r)*l,e[14]=(o+n)*u,e[15]=1,e};function C(){var e=new g(3);return g!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function M(e){var t=new g(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function z(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function F(e,t,i){var r=new g(3);return r[0]=e,r[1]=t,r[2]=i,r}function R(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function k(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function L(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function B(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function O(e,t){var i=t[0],r=t[1],a=t[2],n=i*i+r*r+a*a;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function j(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function V(e,t,i){var r=t[0],a=t[1],n=t[2],o=i[0],s=i[1],l=i[2];return e[0]=a*l-n*s,e[1]=n*o-r*l,e[2]=r*s-a*o,e}function N(e,t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=t[0],l=t[1],u=t[2],h=a*u-n*l,c=n*s-r*u,d=r*l-a*s;return h+=h,c+=c,d+=d,e[0]=s+o*h+a*d-n*c,e[1]=l+o*c+n*h-r*d,e[2]=u+o*d+r*c-a*h,e}function U(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0],n[1]=a[1]*Math.cos(r)-a[2]*Math.sin(r),n[2]=a[1]*Math.sin(r)+a[2]*Math.cos(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function $(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[2]*Math.sin(r)+a[0]*Math.cos(r),n[1]=a[1],n[2]=a[2]*Math.cos(r)-a[0]*Math.sin(r),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function G(e,t,i,r){var a=[],n=[];return a[0]=t[0]-i[0],a[1]=t[1]-i[1],a[2]=t[2]-i[2],n[0]=a[0]*Math.cos(r)-a[1]*Math.sin(r),n[1]=a[0]*Math.sin(r)+a[1]*Math.cos(r),n[2]=a[2],e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}var Z=k,q=z;function W(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3];return e[0]=i[0]*r+i[4]*a+i[8]*n+i[12]*o,e[1]=i[1]*r+i[5]*a+i[9]*n+i[13]*o,e[2]=i[2]*r+i[6]*a+i[10]*n+i[14]*o,e[3]=i[3]*r+i[7]*a+i[11]*n+i[15]*o,e}C();function X(){var e=new g(4);return g!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function H(e,t,i,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",n=Math.PI/360;t*=n,r*=n,i*=n;var o=Math.sin(t),s=Math.cos(t),l=Math.sin(i),u=Math.cos(i),h=Math.sin(r),c=Math.cos(r);switch(a){case"xyz":e[0]=o*u*c+s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c-o*l*h;break;case"xzy":e[0]=o*u*c-s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c+o*l*h;break;case"yxz":e[0]=o*u*c+s*l*h,e[1]=s*l*c-o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c+o*l*h;break;case"yzx":e[0]=o*u*c+s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c-o*l*h;break;case"zxy":e[0]=o*u*c-s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h+o*l*c,e[3]=s*u*c-o*l*h;break;case"zyx":e[0]=o*u*c-s*l*h,e[1]=s*l*c+o*u*h,e[2]=s*u*h-o*l*c,e[3]=s*u*c+o*l*h;break;default:throw Error("Unknown angle order "+a)}return e}!function(){var e=new g(4);g!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0)}();var Y=function(e,t,i,r){var a=new g(4);return a[0]=e,a[1]=t,a[2]=i,a[3]=r,a};function K(){var e=new g(2);return g!=Float32Array&&(e[0]=0,e[1]=0),e}function J(e,t){var i=new g(2);return i[0]=e,i[1]=t,i}function Q(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function ee(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function te(e){return e[0]=0,e[1]=0,e}C(),F(1,0,0),F(0,1,0),X(),X(),_();var ie=function(e){var t=e[0],i=e[1];return t*t+i*i};K();const re=8192;function ae(e,t,i){return t*(re/(e.tileSize*2**(i-e.tileID.overscaledZ)))}function ne(e){return e instanceof Error?e:Error("string"==typeof e?e:String(e))}function oe(){return new Float64Array(4)}function se(){return new Float64Array(3)}function le(){return new Float64Array(16)}function ue(){let e=new Float64Array(16);return v(e),e}function he(){let e=new Float32Array(16);return v(e),e}function ce(e,t,i,r,a=!1){if(!i[0]&&!i[1])return[0,0];let n=a?"map"===r?-e.bearingInRadians:0:"viewport"===r?e.bearingInRadians:0;if(n){let e=Math.sin(n),t=Math.cos(n);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}return[a?i[0]:ae(t,i[0],e.zoom),a?i[1]:ae(t,i[1],e.zoom)]}function de(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function pe(e,t,i){let r=function(e){var t=e[3],i=e[4],r=e[5],a=e[6],n=e[7],o=e[8];return e[0]*(o*i-r*n)+e[1]*(-o*t+r*a)+e[2]*(n*t-i*a)}([e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]]);if(0===r)return null;let a=V([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),n=V([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),o=V([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),s=L([],a,-e[3]);return R(s,s,L([],n,-t[3])),R(s,s,L([],o,-i[3])),L(s,s,1/r),s}function fe(e,t,i){let r=e[0]*i[0]+e[1]*i[1]+e[2]*i[2],a=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===a?null:(-r-i[3])/a}function me(e,t,i,r){let a=Math.sqrt(e*e+t*t),n=Math.sqrt(i*i+r*r),o=(e/=a)*(i/=n)+(t/=a)*(r/=n),s=Math.acos(o);return-t*i+e*r>0?s:-s}function ge(e,t){let i=ye(e,360),r=ye(t,360),a=r-i,n=r>i?a-360:a+360;return Math.abs(a)<Math.abs(n)?a:n}function _e(e,t){let i=ye(e,2*Math.PI),r=ye(t,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))}function ye(e,t){return(e%t+t)%t}function xe(e,t,i,r,a){return ve(r,a,De((e-t)/(i-t),0,1))}function ve(e,t,i){return e*(1-i)+t*i}function be(e){let t=1/0,i=1/0,r=-1/0,a=-1/0;for(let n of e)t=Math.min(t,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),a=Math.max(a,n.y);return[t,i,r,a]}function we(e,t,i,r){return function(e,t,i,r){let a=3*e,n=3*(i-e)-a,o=1-a-n,s=3*t,l=3*(r-t)-s,u=1-s-l;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let r=0;r<8;r++){let r=((o*i+n)*i+a)*i-e;if(Math.abs(r)<t)return((u*i+l)*i+s)*i;let h=(3*o*i+2*n)*i+a;if(Math.abs(h)<1e-6)break;i-=r/h}let r=0,h=1;i=e;for(let s=0;s<20;s++){let s=((o*i+n)*i+a)*i;if(Math.abs(s-e)<t)break;e>s?r=i:h=i,i=.5*(r+h)}return((u*i+l)*i+s)*i}}(e,t,i,r)}const Te=we(.25,.1,.25,1);function De(e,t,i){return Math.min(i,Math.max(t,e))}function Ee(e,t,i){let r=i-t,a=((e-t)%r+r)%r+t;return a===t?i:a}function Se(e,...t){for(let i of t)for(let t in i)e[t]=i[t];return e}function Pe(e,t){let i={};for(let r of t)r in e&&(i[r]=e[r]);return i}let Ie=1;function Ae(){return Ie++}function Ce(e){return 2**e}function Me(e){return Math.log(e)/Math.LN2}function ze(e,t,i){if(t<=0)return e;let r=1/t;return void 0===i||Math.abs(i)<1e-10?Math.round(e*r)/r:(i>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r}function Fe(e,t,i){let r={};for(let a in e)r[a]=t.call(i||this,e[a],a,e);return r}function Re(e,t,i){let r={};for(let a in e)t.call(i||this,e[a],a,e)&&(r[a]=e[a]);return r}function ke(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!ke(e[i],t[i]))return!1;return!0}if("object"==typeof e&&e&&null!==t){if("object"!=typeof t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(!ke(e[i],t[i]))return!1;return!0}return e===t}function Le(e){return Array.isArray(e)?e.map(Le):"object"==typeof e&&e?Fe(e,Le):e}const Be={};function Oe(e){Be[e]||(typeof console<"u"&&console.warn(e),Be[e]=!0)}function je(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function Ve(e){return typeof WorkerGlobalScope<"u"&&void 0!==e&&e instanceof WorkerGlobalScope}let Ne=null;function Ue(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap}function $e(e,t,i,r){return e.addEventListener(t,i,r),{unsubscribe:()=>{e.removeEventListener(t,i,r)}}}function Ge(e){return e*Math.PI/180}function Ze(e){return e/Math.PI*180}function qe(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function We(e,t,i){let r=J(t.x-i.x,t.y-i.y),a=J(e.x-i.x,e.y-i.y),n=r[0]*a[1]-r[1]*a[0];return Ze(Math.atan2(n,function(e,t){return e[0]*t[0]+e[1]*t[1]}(r,a)))}function Xe(e,t,i){let r=new Float64Array(4);return H(r,e,t-90,i),r}const He=85.051129,Ye={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Ke={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Je(e,t){return Ye[t]&&"touches"in e}function Qe(e,t){if(!Ke[t])return!1;let i=e,r=(i?.target)?.ownerDocument?.defaultView||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function et(e){return Ye[e]||Ke[e]}const tt="AbortError";var it=class extends Error{constructor(e=tt){super(e instanceof Error?e.message:e),this.name=tt,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function rt(e){return e instanceof Error&&"AbortError"===e.name}function at(e){if(e.aborted)throw new it(e.reason)}const nt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ot(e){return nt.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const st="global-dispatcher";var lt=class extends Error{constructor(e,t,i,r){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=r}};function ut(){if(Ve(self))return self.worker?.referrer;if("blob:"===window.location.protocol)try{return window.parent.location.href}catch{}return window.location.href}const ht=async function(e,t){if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){let i=ot(e.url);if(i){let r=await i(e,t);return r.data||"arrayBuffer"!==e.type?r:Se(r,{data:new ArrayBuffer(0)})}if(Ve(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:st},t)}if(!(e=>e.startsWith("file:")||ut()?.startsWith("file:")&&!/^\w+:/.test(e))(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return async function(e,t){let i,r,a=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:ut(),referrerPolicy:e.referrerPolicy,signal:t.signal});"json"===e.type&&!a.headers.has("Accept")&&a.headers.set("Accept","application/json");try{i=await fetch(a)}catch(t){throw rt(t)?t:new lt(0,ne(t).message,e.url,new Blob)}if(!i.ok){let t=await i.blob();throw new lt(i.status,i.statusText,e.url,t)}r="arrayBuffer"===e.type||"image"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text();let n=await r;return at(t.signal),{data:n,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}(e,t);if(Ve(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:st},t)}return function(e,t){return new Promise((i,r)=>{let a=new XMLHttpRequest;a.open(e.method||"GET",e.url,!0),("arrayBuffer"===e.type||"image"===e.type)&&(a.responseType="arraybuffer");for(let t in e.headers)a.setRequestHeader(t,e.headers[t]);"json"===e.type&&(a.responseType="text",e.headers?.Accept||a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===e.credentials,a.onerror=()=>{r(Error(a.statusText))},a.onload=()=>{if(!t.signal.aborted)if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let t=a.response;if("json"===e.type)try{t=JSON.parse(a.response)}catch(e){return void r(e)}i({data:t,cacheControl:a.getResponseHeader("Cache-Control"),expires:a.getResponseHeader("Expires"),etag:a.getResponseHeader("ETag")})}else{let t=new Blob([a.response],{type:a.getResponseHeader("Content-Type")});r(new lt(a.status,a.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{a.abort(),r(new it(t.signal.reason))}),a.send(e.body)})}(e,t)},ct=(e,t)=>ht(Se(e,{type:"json"}),t),dt=(e,t)=>ht(Se(e,{type:"arrayBuffer"}),t);function pt(e){if(!e||e.startsWith("data:image/"))return!0;if(e.startsWith("blob:")&&(e=e.slice(5)).startsWith("null"))return!1;if(e.indexOf("://")<=0)return!0;let t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function ft(e,t,i){i[e]?.includes(t)||(i[e]||=[],i[e].push(t))}function mt(e,t,i){if(i?.[e]){let r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}var gt=class{constructor(e,t={}){Se(this,t),this.type=e}},_t=class extends gt{constructor(e,t={}){super("error",Se({error:e},t))}},yt=class{on(e,t){return this._listeners||={},ft(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return mt(e,t,this._listeners),mt(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||={},ft(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){let i="string"==typeof e?new gt(e,t||{}):e,r=i.type;if(this.listens(r)){i.target=this;let e=this._listeners?.[r]?.slice()??[];for(let t of e)t.call(this,i);let t=this._oneTimeListeners?.[r]?.slice()??[];for(let e of t)mt(r,e,this._oneTimeListeners),e.call(this,i);let a=this._eventedParent;a&&(Se(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),a.fire(i))}else i instanceof _t&&console.error(i.error);return this}listens(e){return!!(this._listeners?.[e]?.length||this._oneTimeListeners?.[e]?.length||this._eventedParent?.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},xt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"},"fill-extrusion-rounded-corner-distance":{type:"number",default:0,minimum:0,units:"meters","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-height-offset":{type:"number",default:0,units:"meters",requires:[{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-height-anchor":{type:"enum",values:{ground:{},absolute:{}},default:"ground",requires:["symbol-height-offset"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const vt=xt,bt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];var wt=class{constructor(e,t,i,r,a="error"){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),this.severity=a,null!=t&&t.__line__&&(this.line=t.__line__)}};const Tt={kind:"null"},Dt={kind:"number"},Et={kind:"string"},St={kind:"boolean"},Pt={kind:"color"},It={kind:"projectionDefinition"},At={kind:"object"},Ct={kind:"value"},Mt={kind:"collator"},zt={kind:"formatted"},Ft={kind:"padding"},Rt={kind:"colorArray"},kt={kind:"numberArray"},Lt={kind:"resolvedImage"},Bt={kind:"variableAnchorOffsetCollection"};function Ot(e,t){return{kind:"array",itemType:e,N:t}}function jt(e){if("array"===e.kind){let t=jt(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Vt=[Tt,Dt,Et,St,Pt,It,zt,At,Ot(Ct),Ft,kt,Rt,Lt,Bt];function Nt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Nt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(let e of Vt)if(!Nt(e,t))return null}return`Expected ${jt(e)} but found ${jt(t)} instead.`}function Ut(e,t){return t.some(t=>t.kind===e.kind)}function $t(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function Gt(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const Zt=.96422,qt=.82521,Wt=4/29,Xt=6/29,Ht=3*Xt*Xt,Yt=Math.PI/180,Kt=180/Math.PI;function Jt(e){return(e%=360)<0&&(e+=360),e}function Qt([e,t,i,r]){let a,n,o=ti((.2225045*(e=ei(e))+.7168786*(t=ei(t))+.0606169*(i=ei(i)))/1);e===t&&t===i?a=n=o:(a=ti((.4360747*e+.3850649*t+.1430804*i)/Zt),n=ti((.0139322*e+.0971045*t+.7141733*i)/qt));let s=116*o-16;return[s<0?0:s,500*(a-o),200*(o-n),r]}function ei(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function ti(e){return e>.008856451679035631?e**(1/3):e/Ht+Wt}function ii([e,t,i,r]){let a=(e+16)/116,n=isNaN(t)?a:a+t/500,o=isNaN(i)?a:a-i/200;return a=1*ai(a),n=Zt*ai(n),o=qt*ai(o),[ri(3.1338561*n-1.6168667*a-.4906146*o),ri(-.9787684*n+1.9161415*a+.033454*o),ri(.0719453*n-.2289914*a+1.4052427*o),r]}function ri(e){return(e=e<=.00304?12.92*e:1.055*e**(1/2.4)-.055)<0?0:e>1?1:e}function ai(e){return e>Xt?e*e*e:Ht*(e-Wt)}const ni=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function oi(e,t){return ni(e,t)?e[t]:void 0}function si(e){return parseInt(e.padEnd(2,e),16)/255}function li(e,t){return ui(t?e/100:e,0,1)}function ui(e,t,i){return Math.min(Math.max(t,e),i)}function hi(e){return!e.some(Number.isNaN)}const ci={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 di(e,t,i){return e+i*(t-e)}function pi(e,t,i){return e.map((e,r)=>di(e,t[r],i))}var fi=class e{constructor(e,t,i,r=1,a=!0){this.r=e,this.g=t,this.b=i,this.a=r,a||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[e,t,i,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("string"!=typeof t)return;let i=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];let t=oi(ci,e);if(t){let[e,i,r]=t;return[e/255,i/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,i=1;return[si(e.slice(i,i+=t)),si(e.slice(i,i+=t)),si(e.slice(i,i+=t)),si(e.slice(i,i+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,i,r,a,n,o,s,l,u,h,c,d]=t,p=[a||" ",s||" ",h].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){let e=[r,o,u].join(""),t="%%%"===e?100:""===e?255:0;if(t){let e=[ui(+i/t,0,1),ui(+n/t,0,1),ui(+l/t,0,1),c?li(+c,d):1];if(hi(e))return e}}return}}let i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[e,t,r,a,n,o,s,l,u]=i,h=[r||" ",n||" ",s].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){let e=[+t,ui(+a,0,100),ui(+o,0,100),l?li(+l,u):1];if(hi(e))return function([e,t,i,r]){function a(r){let a=(r+e/30)%12,n=t*Math.min(i,1-i);return i-n*Math.max(-1,Math.min(a-3,9-a,1))}return e=Jt(e),t/=100,i/=100,[a(0),a(8),a(4),r]}(e)}}}(t);return i?new e(...i,!1):void 0}get rgb(){let{r:e,g:t,b:i,a:r}=this,a=r||1/0;return this.overwriteGetter("rgb",[e/a,t/a,i/a,r])}get hcl(){return this.overwriteGetter("hcl",function(e){let[t,i,r,a]=Qt(e),n=Math.sqrt(i*i+r*r);return[Math.round(1e4*n)?Jt(Math.atan2(r,i)*Kt):NaN,n,t,a]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Qt(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){let[e,t,i,r]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${r})`}static interpolate(t,i,r,a="rgb"){switch(a){case"rgb":{let[a,n,o,s]=pi(t.rgb,i.rgb,r);return new e(a,n,o,s,!1)}case"hcl":{let a,n,[o,s,l,u]=t.hcl,[h,c,d,p]=i.hcl;if(isNaN(o)||isNaN(h))isNaN(o)?isNaN(h)?a=NaN:(a=h,(1===l||0===l)&&(n=c)):(a=o,(1===d||0===d)&&(n=s));else{let e=h-o;h>o&&e>180?e-=360:h<o&&o-h>180&&(e+=360),a=o+r*e}let[f,m,g,_]=function([e,t,i,r]){return e=isNaN(e)?0:e*Yt,ii([i,Math.cos(e)*t,Math.sin(e)*t,r])}([a,n??di(s,c,r),di(l,d,r),di(u,p,r)]);return new e(f,m,g,_,!1)}case"lab":{let[a,n,o,s]=ii(pi(t.lab,i.lab,r));return new e(a,n,o,s,!1)}}}};const mi=["bottom","center","top"];var gi=class{constructor(e,t,i,r,a,n){this.text=e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=a,this.verticalAlign=n}},_i=class e{constructor(e){this.sections=e}static fromString(t){return new e([new gi(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(t){return t instanceof e?t:e.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}},yi=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if("number"==typeof t)return new e([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new e(pi(t.values,i.values,r))}},xi=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if("number"==typeof t)return new e([t]);if(Array.isArray(t)){for(let e of t)if("number"!=typeof e)return;return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r){return new e(pi(t.values,i.values,r))}},vi=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if("string"==typeof t){let i=fi.parse(t);return i?new e([i]):void 0}if(!Array.isArray(t))return;let i=[];for(let e of t){if("string"!=typeof e)return;let t=fi.parse(e);if(!t)return;i.push(t)}return new e(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a="rgb"){let n=[];if(t.values.length!=i.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let e=0;e<t.values.length;e++)n.push(fi.interpolate(t.values[e],i.values[e],r,a));return new e(n)}},bi=class extends Error{constructor(e,t){super(e),this.name="RuntimeError",this.path=t}toJSON(){return this.message}};const wi=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var Ti=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e<t.length;e+=2){let i=t[e],r=t[e+1];if("string"!=typeof i||!wi.has(i)||!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,r,a){let n=t.values,o=i.values;if(n.length!==o.length)throw new bi(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`,a);let s=[];for(let e=0;e<n.length;e+=2){if(n[e]!==o[e])throw new bi(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${n[e]}, to[${e}]: ${o[e]}`,a);s.push(n[e]);let[t,i]=n[e+1],[l,u]=o[e+1];s.push([di(t,l,r),di(i,u,r)])}return new e(s)}},Di=class e{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(t){return t?new e({name:t,available:!1}):null}},Ei=class e{constructor(e,t,i){this.from=e,this.to=t,this.transition=i}toString(){return this.from===this.to&&1===this.transition?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(t,i,r){return new e(t,i,r)}static parse(t){return t instanceof e?t:Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]?new e(t[0],t[1],t[2]):"object"==typeof t&&"string"==typeof t.from&&"string"==typeof t.to&&"number"==typeof t.transition?new e(t.from,t.to,t.transition):"string"==typeof t?new e(t,t,1):void 0}},Si=class{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};function Pi(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ii(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Ei||e instanceof fi||e instanceof Si||e instanceof _i||e instanceof yi||e instanceof xi||e instanceof vi||e instanceof Ti||e instanceof Di)return!0;if(Array.isArray(e)){for(let t of e)if(!Ii(t))return!1;return!0}if("object"==typeof e){for(let t in e)if(!Ii(e[t]))return!1;return!0}return!1}function Ai(e){if(null===e)return Tt;if("string"==typeof e)return Et;if("boolean"==typeof e)return St;if("number"==typeof e)return Dt;if(e instanceof fi)return Pt;if(e instanceof Ei)return It;if(e instanceof Si)return Mt;if(e instanceof _i)return zt;if(e instanceof yi)return Ft;if(e instanceof xi)return kt;if(e instanceof vi)return Rt;if(e instanceof Ti)return Bt;if(e instanceof Di)return Lt;if(Array.isArray(e)){let t,i=e.length;for(let i of e){let e=Ai(i);if(t){if(t===e)continue;t=Ct;break}t=e}return Ot(t||Ct,i)}return At}function Ci(e){let t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof fi||e instanceof Ei||e instanceof _i||e instanceof yi||e instanceof xi||e instanceof vi||e instanceof Ti||e instanceof Di?e.toString():JSON.stringify(e)}var Mi=class e{constructor(e,t){this.type=e,this.value=t}static parse(t,i){if(2!==t.length)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ii(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=Ai(r),n=i.expectedType;return"array"===a.kind&&0===a.N&&n&&"array"===n.kind&&("number"!=typeof n.N||0===n.N)&&(a=n),new e(a,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const zi=["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?"number"==typeof this.feature.type?zi[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=fi.parse(e),this._parseColorCache.set(e,t)),t}};function Ri(e,t,i){let r,a,n=e.length-1,o=0,s=n,l=0;for(;o<=s;)if(l=Math.floor((o+s)/2),r=e[l],a=e[l+1],r<=t){if(l===n||t<a)return l;o=l+1}else{if(!(r>t))throw new bi("Input is not a number.",i);s=l-1}return 0}var ki=class e{constructor(e,t,i,r){this.type=e,this.input=t,this.key=r,this.labels=[],this.outputs=[];for(let[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(t[1],1,Dt);if(!r)return null;let a=[],n=null;i.expectedType&&"value"!==i.expectedType.kind&&(n=i.expectedType);for(let e=1;e<t.length;e+=2){let r=1===e?-1/0:t[e],o=t[e+1],s=e,l=e+1;if("number"!=typeof r)return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',s);if(a.length&&a[a.length-1][0]>=r)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);let u=i.parse(o,l,n);if(!u)return null;n||=u.type,a.push([r,u])}return new e(n,r,a,i.key)}evaluate(e){let t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);let a=t.length;return r>=t[a-1]?i[a-1].evaluate(e):i[Ri(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())}},Li=class e{constructor(e,t,i,r,a,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.key=n,this.labels=[],this.outputs=[];for(let[e,t]of a)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let a=0;if("exponential"===e.name)a=Bi(t,e.base,i,r);else if("linear"===e.name)a=Bi(t,1,i,r);else if("cubic-bezier"===e.name){let n=e.controlPoints;a=function(e,t,i,r){let a=3*e,n=3*(i-e)-a,o=1-a-n,s=3*t,l=3*(r-t)-s,u=1-s-l;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let r=0;r<8;r++){let r=((o*i+n)*i+a)*i-e;if(Math.abs(r)<t)return((u*i+l)*i+s)*i;let h=(3*o*i+2*n)*i+a;if(Math.abs(h)<1e-6)break;i-=r/h}let r=0,h=1;i=e;for(let s=0;s<20;s++){let s=((o*i+n)*i+a)*i;if(Math.abs(s-e)<t)break;e>s?r=i:h=i,i=.5*(r+h)}return((u*i+l)*i+s)*i}}(n[0],n[1],n[2],n[3])(Bi(t,1,i,r))}return a}static parse(t,i){let[r,a,n,...o]=t;if(!Array.isArray(a)||0===a.length)return i.error("Expected an interpolation type expression.",1);if("linear"===a[0])a={name:"linear"};else if("exponential"===a[0]){let e=a[1];if("number"!=typeof e)return i.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:e}}else{if("cubic-bezier"!==a[0])return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);{let e=a.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:e}}}if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(n=i.parse(n,2,Dt),!n)return null;let s=[],l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||i.expectedType==Rt?i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType):l=Pt;for(let e=0;e<o.length;e+=2){let t=o[e],r=o[e+1],a=e+3,n=e+4;if("number"!=typeof t)return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(s.length&&s[s.length-1][0]>=t)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',a);let u=i.parse(r,n,l);if(!u)return null;l||=u.type,s.push([t,u])}return Gt(l,Dt)||Gt(l,It)||Gt(l,Pt)||Gt(l,Ft)||Gt(l,kt)||Gt(l,Rt)||Gt(l,Bt)||Gt(l,Ot(Dt))?new e(l,r,a,n,s,i.key):i.error(`Type ${jt(l)} is not interpolatable.`)}evaluate(t){let i=this.labels,r=this.outputs;if(1===i.length)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;if(a>=i[n-1])return r[n-1].evaluate(t);let o=Ri(i,a,this.key),s=i[o],l=i[o+1],u=e.interpolationFactor(this.interpolation,a,s,l),h=r[o].evaluate(t),c=r[o+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return di(h,c,u);case"color":return fi.interpolate(h,c,u);case"padding":return yi.interpolate(h,c,u);case"colorArray":return vi.interpolate(h,c,u);case"numberArray":return xi.interpolate(h,c,u);case"variableAnchorOffsetCollection":return Ti.interpolate(h,c,u,this.key);case"array":return pi(h,c,u);case"projectionDefinition":return Ei.interpolate(h,c,u)}case"interpolate-hcl":switch(this.type.kind){case"color":return fi.interpolate(h,c,u,"hcl");case"colorArray":return vi.interpolate(h,c,u,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return fi.interpolate(h,c,u,"lab");case"colorArray":return vi.interpolate(h,c,u,"lab")}}}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function Bi(e,t,i,r){let a=r-i,n=e-i;return 0===a?0:1===t?n/a:(t**+n-1)/(t**+a-1)}const Oi={color:fi.interpolate,number:di,padding:yi.interpolate,numberArray:xi.interpolate,colorArray:vi.interpolate,variableAnchorOffsetCollection:Ti.interpolate,array:pi};var ji=class e{constructor(e){this.type=zt,this.sections=e}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return i.error("First argument must be an image or text section.");let a=[],n=!1;for(let e=1;e<=t.length-1;++e){let r=t[e];if(n&&"object"==typeof r&&!Array.isArray(r)){n=!1;let e=null;if(r["font-scale"]&&(e=i.parse(r["font-scale"],1,Dt),!e))return null;let t=null;if(r["text-font"]&&(t=i.parse(r["text-font"],1,Ot(Et)),!t))return null;let o=null;if(r["text-color"]&&(o=i.parse(r["text-color"],1,Pt),!o))return null;let s=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!mi.includes(r["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r["vertical-align"]}' instead.`);if(s=i.parse(r["vertical-align"],1,Et),!s)return null}let l=a[a.length-1];l.scale=e,l.font=t,l.textColor=o,l.verticalAlign=s}else{let r=i.parse(t[e],1,Ct);if(!r)return null;let o=r.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,a.push({content:r,scale:null,font:null,textColor:null,verticalAlign:null})}}return new e(a)}evaluate(e){return new _i(this.sections.map(t=>{let i=t.content.evaluate(e);return Ai(i)===Lt?new gi("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new gi(Ci(i),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}};function Vi(e,t,i=0,r=e.length-1,a=Ui){for(;r>i;){if(r-i>600){let n=r-i+1,o=t-i+1,s=Math.log(n),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(n-l)/n)*(o-n/2<0?-1:1);Vi(e,t,Math.max(i,Math.floor(t-o*l/n+u)),Math.min(r,Math.floor(t+(n-o)*l/n+u)),a)}let n=e[t],o=i,s=r;for(Ni(e,i,t),a(e[r],n)>0&&Ni(e,i,r);o<s;){for(Ni(e,o,s),o++,s--;a(e[o],n)<0;)o++;for(;a(e[s],n)>0;)s--}0===a(e[i],n)?Ni(e,i,s):(s++,Ni(e,s,r)),s<=t&&(i=s+1),t<=s&&(r=s-1)}}function Ni(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function Ui(e,t){return e<t?-1:+(e>t)}function $i(e,t){if(e.length<=1)return[e];let i,r,a=[];for(let t of e){let e=Zi(t);0!==e&&(t.area=Math.abs(e),void 0===r&&(r=e<0),r===e<0?(i&&a.push(i),i=[t]):i.push(t))}if(i&&a.push(i),t>1)for(let e=0;e<a.length;e++)a[e].length<=t||(Vi(a[e],t,1,a[e].length-1,Gi),a[e]=a[e].slice(0,t));return a}function Gi(e,t){return t.area-e.area}function Zi(e){let t=0;for(let i,r,a=0,n=e.length,o=n-1;a<n;o=a++)i=e[a],r=e[o],t+=(r.x-i.x)*(i.y+r.y);return t}const qi={string:Et,number:Dt,boolean:St,object:At};var Wi=class e{constructor(e,t,i){this.type=e,this.args=t,this.key=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r,a=1,n=t[0];if("array"===n){let e,n;if(t.length>2){let r=t[1];if("string"!=typeof r||!(r in qi)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);e=qi[r],a++}else e=Ct;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);n=t[2],a++}r=Ot(e,n)}else{if(!qi[n])throw Error(`Types doesn't contain name = ${n}`);r=qi[n]}let o=[];for(;a<t.length;a++){let e=i.parse(t[a],a,Ct);if(!e)return null;o.push(e)}return new e(r,o,i.key)}evaluate(e){for(let t=0;t<this.args.length;t++){let i=this.args[t].evaluate(e);if(!Nt(this.type,Ai(i)))return i;if(t===this.args.length-1)throw new bi(`Expected value to be of type ${jt(this.type)}, but found ${jt(Ai(i))} instead.`,this.key)}throw Error()}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}};const Xi={"to-boolean":St,"to-color":Pt,"to-number":Dt,"to-string":Et};var Hi=class e{constructor(e,t,i){this.type=e,this.args=t,this.key=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[0];if(!Xi[r])throw Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return i.error("Expected one argument.");let a=Xi[r],n=[];for(let e=1;e<t.length;e++){let r=i.parse(t[e],e,Ct);if(!r)return null;n.push(r)}return new e(a,n,i.key)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let t,i;for(let r of this.args){if(t=r.evaluate(e),i=null,t instanceof fi)return t;if("string"==typeof t){let i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Pi(t[0],t[1],t[2],t[3]),!i))return new fi(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new bi(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"padding":{let t;for(let i of this.args){t=i.evaluate(e);let r=yi.parse(t);if(r)return r}throw new bi(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"numberArray":{let t;for(let i of this.args){t=i.evaluate(e);let r=xi.parse(t);if(r)return r}throw new bi(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"colorArray":{let t;for(let i of this.args){t=i.evaluate(e);let r=vi.parse(t);if(r)return r}throw new bi(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"variableAnchorOffsetCollection":{let t;for(let i of this.args){t=i.evaluate(e);let r=Ti.parse(t);if(r)return r}throw new bi(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}case"number":{let t=null;for(let i of this.args){if(t=i.evaluate(e),null===t)return 0;let r=Number(t);if(!isNaN(r))return r}throw new bi(`Could not convert ${JSON.stringify(t)} to number.`,this.key)}case"formatted":return _i.fromString(Ci(this.args[0].evaluate(e)));case"resolvedImage":return Di.fromString(Ci(this.args[0].evaluate(e)));case"projectionDefinition":{let t=this.args[0].evaluate(e);if(Ei.parse(t))return t;throw new bi(`Could not parse projectionDefinition from value '${"string"==typeof t?t:JSON.stringify(t)}'`,this.key)}default:return Ci(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}},Yi=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,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let e=1;e<t.length-1;e+=2){let a=t[e];if("string"!=typeof a)return i.error(`Expected string, but found ${typeof a} instead.`,e);if(/[^a-zA-Z0-9_]/.test(a))return i.error("Variable names must contain only alphanumeric characters or '_'.",e);let n=i.parse(t[e+1],e+1);if(!n)return null;r.push([a,n])}let a=i.parse(t[t.length-1],t.length-1,i.expectedType,r);return a?new e(r,a):null}outputDefined(){return this.result.outputDefined()}},Ki=class e{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(t,i){if(2!==t.length||"string"!=typeof t[1])return i.error("'var' expression requires exactly one string literal argument.");let r=t[1];return i.scope.has(r)?new e(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}},Ji=class e{constructor(e,t){this.type=e,this.args=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=null,a=i.expectedType;a&&"value"!==a.kind&&(r=a);let n=[];for(let e of t.slice(1)){let t=i.parse(e,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r||=t.type,n.push(t)}if(!r)throw Error("No output type");return a&&n.some(e=>Nt(a,e.type))?new e(Ct,n):new e(r,n)}evaluate(e){let t,i=null,r=0;for(let a of this.args)if(r++,i=a.evaluate(e),i&&i instanceof Di&&!i.available&&(t||=i.name,i=null,r===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}};function Qi(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function er(e,t,i,r){return 0===r.compare(t,i)}function tr(e,t,i){let r="=="!==e&&"!="!==e;return class a{constructor(e,t,i,r){this.lhs=e,this.rhs=t,this.key=i,this.collator=r,this.type=St,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");let i=e[0],n=t.parse(e[1],1,Ct);if(!n)return null;if(!Qi(i,n.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${jt(n.type)}'.`);let o=t.parse(e[2],2,Ct);if(!o)return null;if(!Qi(i,o.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${jt(o.type)}'.`);if(n.type.kind!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${jt(n.type)}' and '${jt(o.type)}'.`);r&&("value"===n.type.kind&&"value"!==o.type.kind?n=new Wi(o.type,[n],t.key):"value"!==n.type.kind&&"value"===o.type.kind&&(o=new Wi(n.type,[o],t.key)));let s=null;if(4===e.length){if("string"!==n.type.kind&&"string"!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,Mt),!s)return null}return new a(n,o,t.key,s)}evaluate(a){let n=this.lhs.evaluate(a),o=this.rhs.evaluate(a);if(r&&this.hasUntypedArgument){let t=Ai(n),i=Ai(o);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new bi(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`,this.key)}if(this.collator&&!r&&this.hasUntypedArgument){let e=Ai(n),i=Ai(o);if("string"!==e.kind||"string"!==i.kind)return t(a,n,o)}return this.collator?i(a,n,o,this.collator.evaluate(a)):t(a,n,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const ir=tr("==",function(e,t,i){return t===i},er),rr=tr("!=",function(e,t,i){return t!==i},function(e,t,i,r){return!er(0,t,i,r)}),ar=tr("<",function(e,t,i){return t<i},function(e,t,i,r){return r.compare(t,i)<0}),nr=tr(">",function(e,t,i){return t>i},function(e,t,i,r){return r.compare(t,i)>0}),or=tr("<=",function(e,t,i){return t<=i},function(e,t,i,r){return r.compare(t,i)<=0}),sr=tr(">=",function(e,t,i){return t>=i},function(e,t,i,r){return r.compare(t,i)>=0});var lr=class e{constructor(e,t,i){this.type=Mt,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(t,i){if(2!==t.length)return i.error("Expected one argument.");let r=t[1];if("object"!=typeof r||Array.isArray(r))return i.error("Collator options argument must be an object.");let a=i.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,St);if(!a)return null;let n=i.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,St);if(!n)return null;let o=null;return r.locale&&(o=i.parse(r.locale,1,Et),!o)?null:new e(a,n,o)}evaluate(e){return new Si(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}};const ur=8192;function hr(e,t){let i=function(e){return(180+e)/360}(e[0]),r=function(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}(e[1]),a=2**t.z;return[Math.round(i*a*ur),Math.round(r*a*ur)]}function cr(e,t){let i=2**t.z,r=(e[0]/ur+t.x)/i,a=(e[1]/ur+t.y)/i;return[dr(r),pr(a)]}function dr(e){return 360*e-180}function pr(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function fr(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 mr(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function gr(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function _r(e,t,i){let r=e[0]-t[0],a=e[1]-t[1],n=e[0]-i[0],o=e[1]-i[1];return r*o-n*a===0&&r*n<=0&&a*o<=0}function yr(e,t,i,r){let a=[t[0]-e[0],t[1]-e[1]];return 0!==function(e,t){return e[0]*t[1]-e[1]*t[0]}([r[0]-i[0],r[1]-i[1]],a)&&!(!Dr(e,t,i,r)||!Dr(i,r,e,t))}function xr(e,t,i){for(let r of i)for(let i=0;i<r.length-1;++i)if(yr(e,t,r[i],r[i+1]))return!0;return!1}function vr(e,t,i=!1){let r=!1;for(let a of t)for(let t=0;t<a.length-1;t++){if(_r(e,a[t],a[t+1]))return i;gr(e,a[t],a[t+1])&&(r=!r)}return r}function br(e,t){for(let i of t)if(vr(e,i))return!0;return!1}function wr(e,t){for(let i of e)if(!vr(i,t))return!1;for(let i=0;i<e.length-1;++i)if(xr(e[i],e[i+1],t))return!1;return!0}function Tr(e,t){for(let i of t)if(wr(e,i))return!0;return!1}function Dr(e,t,i,r){let a=e[0]-i[0],n=e[1]-i[1],o=t[0]-i[0],s=t[1]-i[1],l=r[0]-i[0],u=r[1]-i[1],h=a*u-l*n,c=o*u-l*s;return h>0&&c<0||h<0&&c>0}function Er(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=[];for(let r=0;r<e[a].length;r++){let o=hr(e[a][r],i);fr(t,o),n.push(o)}r.push(n)}return r}function Sr(e,t,i){let r=[];for(let a=0;a<e.length;a++){let n=Er(e[a],t,i);r.push(n)}return r}function Pr(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){let t=.5*r,a=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===a&&(a=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=a}fr(t,e)}function Ir(e,t,i,r){let a=2**r.z*ur,n=[r.x*ur,r.y*ur],o=[];for(let r of e)for(let e of r){let r=[e.x+n[0],e.y+n[1]];Pr(r,t,i,a),o.push(r)}return o}function Ar(e,t,i,r){let a=2**r.z*ur,n=[r.x*ur,r.y*ur],o=[];for(let i of e){let e=[];for(let r of i){let i=[r.x+n[0],r.y+n[1]];fr(t,i),e.push(i)}o.push(e)}if(t[2]-t[0]<=a/2){!function(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}(t);for(let e of o)for(let r of e)Pr(r,t,i,a)}return o}var Cr=class e{constructor(e,t){this.type=St,this.geojson=e,this.geometries=t}static parse(t,i){if(2!==t.length)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ii(t[1])){let i=t[1];if("FeatureCollection"===i.type){let t=[];for(let e of i.features){let{type:i,coordinates:r}=e.geometry;"Polygon"===i&&t.push(r),"MultiPolygon"===i&&t.push(...r)}if(t.length)return new e(i,{type:"MultiPolygon",coordinates:t})}else if("Feature"===i.type){let t=i.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new e(i,i.geometry)}else if("Polygon"===i.type||"MultiPolygon"===i.type)return new e(i,i)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if("Polygon"===t.type){let n=Er(t.coordinates,r,a),o=Ir(e.geometry(),i,r,a);if(!mr(i,r))return!1;for(let e of o)if(!vr(e,n))return!1}if("MultiPolygon"===t.type){let n=Sr(t.coordinates,r,a),o=Ir(e.geometry(),i,r,a);if(!mr(i,r))return!1;for(let e of o)if(!br(e,n))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],a=e.canonicalID();if("Polygon"===t.type){let n=Er(t.coordinates,r,a),o=Ar(e.geometry(),i,r,a);if(!mr(i,r))return!1;for(let e of o)if(!wr(e,n))return!1}if("MultiPolygon"===t.type){let n=Sr(t.coordinates,r,a),o=Ar(e.geometry(),i,r,a);if(!mr(i,r))return!1;for(let e of o)if(!Tr(e,n))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},Mr=class{constructor(e=[],t=(e,t)=>e<t?-1:+(e>t)){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(0===this.length)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(i(r,n)>=0)break;t[e]=n,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let r=1+(e<<1),n=r+1;if(n<this.length&&i(t[n],t[r])<0&&(r=n),i(t[r],a)>=0)break;t[e]=t[r],e=r}t[e]=a}};const zr=Math.PI/180;var Fr=class{constructor(e){let t=6378.137*zr*1e3,i=Math.cos(e*zr),r=1/(1-.0066943799901413165*(1-i*i)),a=Math.sqrt(r);this.kx=t*a*i,this.ky=t*a*r*.9933056200098587}distance(e,t){let i=this.wrap(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(e,t){let i,r,a,n,o=1/0;for(let s=0;s<e.length-1;s++){let l=e[s][0],u=e[s][1],h=this.wrap(e[s+1][0]-l)*this.kx,c=(e[s+1][1]-u)*this.ky,d=0;(0!==h||0!==c)&&(d=(this.wrap(t[0]-l)*this.kx*h+(t[1]-u)*this.ky*c)/(h*h+c*c),d>1?(l=e[s+1][0],u=e[s+1][1]):d>0&&(l+=h/this.kx*d,u+=c/this.ky*d)),h=this.wrap(t[0]-l)*this.kx,c=(t[1]-u)*this.ky;let p=h*h+c*c;p<o&&(o=p,i=l,r=u,a=s,n=d)}return{point:[i,r],index:a,t:Math.max(0,Math.min(1,n))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}};function Rr(e,t){return t[0]-e[0]}function kr(e){return e[1]-e[0]+1}function Lr(e,t){return e[1]>=e[0]&&e[1]<t}function Br(e,t){if(e[0]>e[1])return[null,null];let i=kr(e);if(t){if(2===i)return[e,null];let t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(1===i)return[e,null];let r=Math.floor(i/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function Or(e,t){if(!Lr(t,e.length))return[1/0,1/0,-1/0,-1/0];let i=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)fr(i,e[r]);return i}function jr(e){let t=[1/0,1/0,-1/0,-1/0];for(let i of e)for(let e of i)fr(t,e);return t}function Vr(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Nr(e,t,i){if(!Vr(e)||!Vr(t))return NaN;let r=0,a=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(a=e[1]-t[3]),e[3]<t[1]&&(a=t[1]-e[3]),i.distance([0,0],[r,a])}function Ur(e,t,i){let r=i.pointOnLine(t,e);return i.distance(e,r.point)}function $r(e,t,i,r,a){let n=Math.min(Ur(e,[i,r],a),Ur(t,[i,r],a)),o=Math.min(Ur(i,[e,t],a),Ur(r,[e,t],a));return Math.min(n,o)}function Gr(e,t,i,r,a){if(!Lr(t,e.length)||!Lr(r,i.length))return 1/0;let n=1/0;for(let o=t[0];o<t[1];++o){let t=e[o],s=e[o+1];for(let e=r[0];e<r[1];++e){let r=i[e],o=i[e+1];if(yr(t,s,r,o))return 0;n=Math.min(n,$r(t,s,r,o,a))}}return n}function Zr(e,t,i,r,a){if(!Lr(t,e.length)||!Lr(r,i.length))return NaN;let n=1/0;for(let o=t[0];o<=t[1];++o)for(let t=r[0];t<=r[1];++t)if(n=Math.min(n,a.distance(e[o],i[t])),0===n)return n;return n}function qr(e,t,i){if(vr(e,t,!0))return 0;let r=1/0;for(let a of t){let t=a[0],n=a[a.length-1];if(t!==n&&(r=Math.min(r,Ur(e,[n,t],i)),0===r))return r;let o=i.pointOnLine(a,e);if(r=Math.min(r,i.distance(e,o.point)),0===r)return r}return r}function Wr(e,t,i,r){if(!Lr(t,e.length))return NaN;for(let r=t[0];r<=t[1];++r)if(vr(e[r],i,!0))return 0;let a=1/0;for(let n=t[0];n<t[1];++n){let t=e[n],o=e[n+1];for(let e of i)for(let i=0,n=e.length,s=n-1;i<n;s=i++){let n=e[s],l=e[i];if(yr(t,o,n,l))return 0;a=Math.min(a,$r(t,o,n,l,r))}}return a}function Xr(e,t){for(let i of e)for(let e of i)if(vr(e,t,!0))return!0;return!1}function Hr(e,t,i,r=1/0){let a=jr(e),n=jr(t);if(r!==1/0&&Nr(a,n,i)>=r)return r;if(mr(a,n)){if(Xr(e,t))return 0}else if(Xr(t,e))return 0;let o=1/0;for(let r of e)for(let e=0,a=r.length,n=a-1;e<a;n=e++){let a=r[n],s=r[e];for(let e of t)for(let t=0,r=e.length,n=r-1;t<r;n=t++){let r=e[n],l=e[t];if(yr(a,s,r,l))return 0;o=Math.min(o,$r(a,s,r,l,i))}}return o}function Yr(e,t,i,r,a,n){if(!n)return;let o=Nr(Or(r,n),a,i);o<t&&e.push([o,n,[0,0]])}function Kr(e,t,i,r,a,n,o){if(!n||!o)return;let s=Nr(Or(r,n),Or(a,o),i);s<t&&e.push([s,n,o])}function Jr(e,t,i,r,a=1/0){let n=Math.min(r.distance(e[0],i[0][0]),a);if(0===n)return n;let o=new Mr([[0,[0,e.length-1],[0,0]]],Rr),s=jr(i);for(;o.length>0;){let a=o.pop();if(a[0]>=n)continue;let l=a[1],u=t?50:100;if(kr(l)<=u){if(!Lr(l,e.length))return NaN;if(t){let t=Wr(e,l,i,r);if(isNaN(t)||0===t)return t;n=Math.min(n,t)}else for(let t=l[0];t<=l[1];++t){let a=qr(e[t],i,r);if(n=Math.min(n,a),0===n)return 0}}else{let i=Br(l,t);Yr(o,n,r,e,s,i[0]),Yr(o,n,r,e,s,i[1])}}return n}function Qr(e,t,i,r,a,n=1/0){let o=Math.min(n,a.distance(e[0],i[0]));if(0===o)return o;let s=new Mr([[0,[0,e.length-1],[0,i.length-1]]],Rr);for(;s.length>0;){let n=s.pop();if(n[0]>=o)continue;let l=n[1],u=n[2],h=t?50:100,c=r?50:100;if(kr(l)<=h&&kr(u)<=c){if(!Lr(l,e.length)&&Lr(u,i.length))return NaN;let n;if(t&&r)n=Gr(e,l,i,u,a),o=Math.min(o,n);else if(t&&!r){let t=e.slice(l[0],l[1]+1);for(let e=u[0];e<=u[1];++e)if(n=Ur(i[e],t,a),o=Math.min(o,n),0===o)return o}else if(!t&&r){let t=i.slice(u[0],u[1]+1);for(let i=l[0];i<=l[1];++i)if(n=Ur(e[i],t,a),o=Math.min(o,n),0===o)return o}else n=Zr(e,l,i,u,a),o=Math.min(o,n)}else{let n=Br(l,t),h=Br(u,r);Kr(s,o,a,e,i,n[0],h[0]),Kr(s,o,a,e,i,n[0],h[1]),Kr(s,o,a,e,i,n[1],h[0]),Kr(s,o,a,e,i,n[1],h[1])}}return o}function ea(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}var ta=class e{constructor(e,t){this.type=Dt,this.geojson=e,this.geometries=t}static parse(t,i){if(2!==t.length)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ii(t[1])){let i=t[1];if("FeatureCollection"===i.type)return new e(i,i.features.map(e=>ea(e.geometry)).flat());if("Feature"===i.type)return new e(i,ea(i.geometry));if("type"in i&&"coordinates"in i)return new e(i,ea(i))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){let i=e.geometry(),r=i.flat().map(t=>cr([t.x,t.y],e.canonical));if(0===i.length)return NaN;let a=new Fr(r[0][1]),n=1/0;for(let e of t){switch(e.type){case"Point":n=Math.min(n,Qr(r,!1,[e.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,Qr(r,!1,e.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Jr(r,!1,e.coordinates,a,n))}if(0===n)return n}return n}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){let i=e.geometry(),r=i.flat().map(t=>cr([t.x,t.y],e.canonical));if(0===i.length)return NaN;let a=new Fr(r[0][1]),n=1/0;for(let e of t){switch(e.type){case"Point":n=Math.min(n,Qr(r,!0,[e.coordinates],!1,a,n));break;case"LineString":n=Math.min(n,Qr(r,!0,e.coordinates,!0,a,n));break;case"Polygon":n=Math.min(n,Jr(r,!0,e.coordinates,a,n))}if(0===n)return n}return n}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){let i=e.geometry();if(0===i.length||0===i[0].length)return NaN;let r=$i(i,0).map(t=>t.map(t=>t.map(t=>cr([t.x,t.y],e.canonical)))),a=new Fr(r[0][0][0][1]),n=1/0;for(let e of t)for(let t of r){switch(e.type){case"Point":n=Math.min(n,Jr([e.coordinates],!1,t,a,n));break;case"LineString":n=Math.min(n,Jr(e.coordinates,!0,t,a,n));break;case"Polygon":n=Math.min(n,Hr(t,e.coordinates,a,n))}if(0===n)return n}return n}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},ia=class e{constructor(e){this.key=e,this.type=Ct}static parse(t,i){if(2!==t.length)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=t[1];return null==r?i.error("Global state property must be defined."):"string"==typeof r?new e(r):i.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(e){let t=e.globals?.globalState;return t&&0!==Object.keys(t).length?oi(t,this.key)??null:null}eachChild(){}outputDefined(){return!1}};const ra={"==":ir,"!=":rr,">":nr,"<":ar,">=":sr,"<=":or,array:Wi,at:class e{constructor(e,t,i,r){this.type=e,this.index=t,this.input=i,this.key=r}static parse(t,i){if(3!==t.length)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,Dt),a=i.parse(t[2],2,Ot(i.expectedType||Ct));if(!r||!a)return null;let n=a.type;return new e(n.itemType,r,a,i.key)}evaluate(e){let t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new bi(`Array index out of bounds: ${t} < 0.`,this.key);if(t>=i.length)throw new bi(`Array index out of bounds: ${t} > ${i.length-1}.`,this.key);if(t!==Math.floor(t))throw new bi(`Array index must be an integer, but found ${t} instead.`,this.key);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}},boolean:Wi,case:class e{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&"value"!==i.expectedType.kind&&(r=i.expectedType);let a=[];for(let e=1;e<t.length-1;e+=2){let n=i.parse(t[e],e,St);if(!n)return null;let o=i.parse(t[e+1],e+1,r);if(!o)return null;a.push([n,o]),r||=o.type}let n=i.parse(t[t.length-1],t.length-1,r);if(!n)return null;if(!r)throw Error("Can't infer output type");return new e(r,a,n)}evaluate(e){for(let[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}},coalesce:Ji,collator:lr,format:ji,image:class e{constructor(e){this.type=Lt,this.input=e}static parse(t,i){if(2!==t.length)return i.error("Expected two arguments.");let r=i.parse(t[1],1,Et);return r?new e(r):i.error("No image name provided.")}evaluate(e){let t=this.input.evaluate(e),i=Di.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}},in:class e{constructor(e,t,i){this.needle=e,this.haystack=t,this.key=i,this.type=St}static parse(t,i){if(3!==t.length)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,Ct),a=i.parse(t[2],2,Ct);return r&&a?Ut(r.type,[St,Et,Dt,Tt,Ct])?new e(r,a,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${jt(r.type)} instead`):null}evaluate(e){let t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!$t(t,["boolean","string","number","null"]))throw new bi(`Expected first argument to be of type boolean, string, number or null, but found ${jt(Ai(t))} instead.`,this.key);if(!$t(i,["string","array"]))throw new bi(`Expected second argument to be of type array or string, but found ${jt(Ai(i))} instead.`,this.key);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}},"index-of":class e{constructor(e,t,i,r){this.needle=e,this.haystack=t,this.key=i,this.fromIndex=r,this.type=Dt}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,Ct),a=i.parse(t[2],2,Ct);if(!r||!a)return null;if(!Ut(r.type,[St,Et,Dt,Tt,Ct]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${jt(r.type)} instead`);if(4===t.length){let n=i.parse(t[3],3,Dt);return n?new e(r,a,i.key,n):null}return new e(r,a,i.key)}evaluate(e){let t,i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!$t(i,["boolean","string","number","null"]))throw new bi(`Expected first argument to be of type boolean, string, number or null, but found ${jt(Ai(i))} instead.`,this.key);if(this.fromIndex&&(t=this.fromIndex.evaluate(e)),$t(r,["string"])){let e=r.indexOf(i,t);return-1===e?-1:[...r.slice(0,e)].length}if($t(r,["array"]))return r.indexOf(i,t);throw new bi(`Expected second argument to be of type array or string, but found ${jt(Ai(r))} instead.`,this.key)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}},interpolate:Li,"interpolate-hcl":Li,"interpolate-lab":Li,length:class e{constructor(e,t){this.input=e,this.key=t,this.type=Dt}static parse(t,i){if(2!==t.length)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=i.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?i.error(`Expected argument of type string or array, but found ${jt(r.type)} instead.`):new e(r,i.key):null}evaluate(e){let t=this.input.evaluate(e);if("string"==typeof t)return[...t].length;if(Array.isArray(t))return t.length;throw new bi(`Expected value to be of type string or array, but found ${jt(Ai(t))} instead.`,this.key)}eachChild(e){e(this.input)}outputDefined(){return!1}},let:Yi,literal:Mi,match:class e{constructor(e,t,i,r,a,n){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=a,this.otherwise=n}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let r,a;i.expectedType&&"value"!==i.expectedType.kind&&(a=i.expectedType);let n={},o=[];for(let e=2;e<t.length-1;e+=2){let s=t[e],l=t[e+1];Array.isArray(s)||(s=[s]);let u=i.concat(e);if(0===s.length)return u.error("Expected at least one branch label.");for(let e of s){if("number"!=typeof e&&"string"!=typeof e)return u.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>2**53-1)return u.error(`Branch labels must be integers no larger than ${2**53-1}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,Ai(e)))return null}else r=Ai(e);if(void 0!==n[String(e)])return u.error("Branch labels must be unique.");n[String(e)]=o.length}let h=i.parse(l,e,a);if(!h)return null;a||=h.type,o.push(h)}let s=i.parse(t[1],1,Ct);if(!s)return null;let l=i.parse(t[t.length-1],t.length-1,a);return!l||"value"!==s.type.kind&&i.concat(1).checkSubtype(r,s.type)?null:new e(r,a,s,n,o,l)}evaluate(e){let t=this.input.evaluate(e);return(Ai(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()}},number:Wi,"number-format":class e{constructor(e,t,i,r,a,n){this.type=Et,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=a,this.maxFractionDigits=n}static parse(t,i){if(3!==t.length)return i.error("Expected two arguments.");let r=i.parse(t[1],1,Dt);if(!r)return null;let a=t[2];if("object"!=typeof a||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&(n=i.parse(a.locale,1,Et),!n))return null;let o=null;if(a.currency&&(o=i.parse(a.currency,1,Et),!o))return null;let s=null;if(a.unit&&(s=i.parse(a.unit,1,Et),!s))return null;if(o&&s)return i.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(a["min-fraction-digits"]&&(l=i.parse(a["min-fraction-digits"],1,Dt),!l))return null;let u=null;return a["max-fraction-digits"]&&(u=i.parse(a["max-fraction-digits"],1,Dt),!u)?null:new e(r,n,o,s,l,u)}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}},object:Wi,semiliteral:class e{constructor(e){let t=null;for(let i of e){if(t){if(t===i.type)continue;t=Ct;break}t=i.type}this.type=Ot(t??Ct,e.length),this.arr=e}static parse(t,i){if(2!==t.length)return i.error(`'semiliteral' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ii(t[1]))return i.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],a=Ai(r);if("array"===a.kind){let t=r.map(e=>i.parse(e,null,Ct));return new e(t)}return new Mi(a,r)}evaluate(e){return this.arr.map(t=>t.evaluate(e))}eachChild(e){this.arr.forEach(e)}outputDefined(){return this.arr.every(e=>e.outputDefined())}},slice:class e{constructor(e,t,i,r,a){this.type=e,this.input=t,this.beginIndex=i,this.key=r,this.endIndex=a}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,Ct),a=i.parse(t[2],2,Dt);if(!r||!a)return null;if(!Ut(r.type,[Ot(Ct),Et,Ct]))return i.error(`Expected first argument to be of type array or string, but found ${jt(r.type)} instead`);if(4===t.length){let n=i.parse(t[3],3,Dt);return n?new e(r.type,r,a,i.key,n):null}return new e(r.type,r,a,i.key)}evaluate(e){let t,i=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(this.endIndex&&(t=this.endIndex.evaluate(e)),$t(i,["string"]))return[...i].slice(r,t).join("");if($t(i,["array"]))return i.slice(r,t);throw new bi(`Expected first argument to be of type array or string, but found ${jt(Ai(i))} instead.`,this.key)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}},step:ki,string:Wi,"to-boolean":Hi,"to-color":Hi,"to-number":Hi,"to-string":Hi,var:Ki,within:Cr,distance:ta,"global-state":ia};var aa=class extends Error{constructor(e,t){super(t),this.message=t,this.key=e}},na=class e{constructor(e,t=[]){this.parent=e,this.bindings={};for(let[e,i]of t)this.bindings[e]=i}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]||!!this.parent&&this.parent.has(e)}},oa=class e{constructor(e,t,i=[],r,a=new na,n=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=a,this.errors=n,this.expectedType=r,this._isConstant=t}parse(e,t,i,r,a={}){return t?this.concat(t,i,r)._parse(e,a):this._parse(e,a)}_parse(e,t){(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e)&&(e=["literal",e]);let i=this.key;function r(e,t,r){return"assert"===r?new Wi(t,[e],i):"coerce"===r?new Hi(t,[e],i):e}if(Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let i=e[0];if("string"!=typeof i)return this.error(`Expression name must be a string, but found ${typeof i} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let a=this.registry[i];if(a){let i=a.parse(e,this);if(!i)return null;if(this.expectedType){let e=this.expectedType,a=i.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==a.kind){if("projectionDefinition"===e.kind&&["string","array","value"].includes(a.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(a.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(a.kind)||"colorArray"===e.kind&&["value","string","array"].includes(a.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(a.kind))i=r(i,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,a))return null}else i=r(i,e,t.typeAnnotation||"assert")}if(!(i instanceof Mi)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){let t=new Fi;try{i=new Mi(i.type,i.evaluate(t))}catch(e){return this.error(e.message),null}}return i}return this.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0)}return void 0===e?this.error("'undefined' value invalid. Use null instead."):"object"==typeof e?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(t,i,r){let a="number"==typeof t?this.path.concat(t):this.path,n=r?this.scope.concat(r):this.scope;return new e(this.registry,this._isConstant,a,i||null,n,this.errors)}error(e,...t){let i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new aa(i,e))}checkSubtype(e,t){let i=Nt(e,t);return i&&this.error(i),i}},sa=class e{constructor(e,t,i,r,a){this.name=e,this.type=t,this._evaluate=i,this.args=r,this.key=a}evaluate(e){return this._evaluate(e,this.args,this.key)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(t,i){let r=t[0],a=e.definitions[r];if(!a)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,o=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,s=o.filter(([e])=>!Array.isArray(e)||e.length===t.length-1),l=null;for(let[a,o]of s){l=new oa(i.registry,da,i.path,null,i.scope);let s=[],u=!1;for(let e=1;e<t.length;e++){let i=t[e],r=Array.isArray(a)?a[e-1]:a.type,n=l.parse(i,1+s.length,r);if(!n){u=!0;break}s.push(n)}if(!u){if(Array.isArray(a)&&a.length!==s.length){l.error(`Expected ${a.length} arguments, but found ${s.length} instead.`);continue}for(let e=0;e<s.length;e++){let t=Array.isArray(a)?a[e]:a.type,i=s[e];l.concat(e+1).checkSubtype(t,i.type)}if(0===l.errors.length)return new e(r,n,o,s,i.key)}}if(1===s.length)i.errors.push(...l.errors);else{let e=(s.length?s:o).map(([e])=>function(e){return Array.isArray(e)?`(${e.map(jt).join(", ")})`:`(${jt(e.type)}...)`}(e)).join(" | "),r=[];for(let e=1;e<t.length;e++){let a=i.parse(t[e],1+r.length);if(!a)return null;r.push(jt(a.type))}i.error(`Expected arguments of type ${e}, but found (${r.join(", ")}) instead.`)}return null}static register(t,i){e.definitions=i;for(let r in i)t[r]=e}};function la(e,[t,i,r,a],n){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);let o=a?a.evaluate(e):1,s=Pi(t,i,r,o);if(s)throw new bi(s,n);return new fi(t/255,i/255,r/255,o,!1)}function ua(e,t){return e in t&&void 0!==t[e]}function ha(e,t){let i=t[e];return void 0===i?null:i}function ca(e){return{type:e}}function da(e){if(e instanceof Ki)return da(e.boundExpression);if(e instanceof sa&&"error"===e.name||e instanceof lr||e instanceof Cr||e instanceof ta||e instanceof ia)return!1;let t=e instanceof Hi||e instanceof Wi,i=!0;return e.eachChild(e=>{i&&=t?da(e):e instanceof Mi}),!!i&&pa(e)&&ma(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function pa(e){if(e instanceof sa&&("get"===e.name&&1===e.args.length||"feature-state"===e.name||"has"===e.name&&1===e.args.length||"properties"===e.name||"geometry-type"===e.name||"id"===e.name||/^filter-/.test(e.name))||e instanceof Cr||e instanceof ta)return!1;let t=!0;return e.eachChild(e=>{t&&!pa(e)&&(t=!1)}),t}function fa(e){if(e instanceof sa&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!fa(e)&&(t=!1)}),t}function ma(e,t){if(e instanceof sa&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!ma(e,t)&&(i=!1)}),i}function ga(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function _a(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function ya(e){return!!e.expression&&e.expression.interpolated}sa.register(ra,{error:[{kind:"error"},[Et],(e,[t],i)=>{throw new bi(t.evaluate(e),i)}],typeof:[Et,[Ct],(e,[t])=>jt(Ai(t.evaluate(e)))],"to-rgba":[Ot(Dt,4),[Pt],(e,[t])=>{let[i,r,a,n]=t.evaluate(e).rgb;return[255*i,255*r,255*a,n]}],rgb:[Pt,[Dt,Dt,Dt],la],rgba:[Pt,[Dt,Dt,Dt,Dt],la],has:{type:St,overloads:[[[Et],(e,[t])=>ua(t.evaluate(e),e.properties())],[[Et,At],(e,[t,i])=>ua(t.evaluate(e),i.evaluate(e))]]},get:{type:Ct,overloads:[[[Et],(e,[t])=>ha(t.evaluate(e),e.properties())],[[Et,At],(e,[t,i])=>ha(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ct,[Et],(e,[t])=>ha(t.evaluate(e),e.featureState||{})],properties:[At,[],e=>e.properties()],"geometry-type":[Et,[],e=>e.geometryType()],id:[Ct,[],e=>e.id()],zoom:[Dt,[],e=>e.globals.zoom],"heatmap-density":[Dt,[],e=>e.globals.heatmapDensity||0],elevation:[Dt,[],e=>e.globals.elevation||0],"line-progress":[Dt,[],e=>e.globals.lineProgress||0],accumulated:[Ct,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Dt,ca(Dt),(e,t)=>{let i=0;for(let r of t)i+=r.evaluate(e);return i}],"*":[Dt,ca(Dt),(e,t)=>{let i=1;for(let r of t)i*=r.evaluate(e);return i}],"-":{type:Dt,overloads:[[[Dt,Dt],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Dt],(e,[t])=>-t.evaluate(e)]]},"/":[Dt,[Dt,Dt],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Dt,[Dt,Dt],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Dt,[],()=>Math.LN2],pi:[Dt,[],()=>Math.PI],e:[Dt,[],()=>Math.E],"^":[Dt,[Dt,Dt],(e,[t,i])=>t.evaluate(e)**+i.evaluate(e)],sqrt:[Dt,[Dt],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Dt,[Dt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Dt,[Dt],(e,[t])=>Math.log(t.evaluate(e))],log2:[Dt,[Dt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Dt,[Dt],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Dt,[Dt],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Dt,[Dt],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Dt,[Dt],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Dt,[Dt],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Dt,[Dt],(e,[t])=>Math.atan(t.evaluate(e))],min:[Dt,ca(Dt),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Dt,ca(Dt),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Dt,[Dt],(e,[t])=>Math.abs(t.evaluate(e))],round:[Dt,[Dt],(e,[t])=>{let i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Dt,[Dt],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Dt,[Dt],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[St,[Et,Ct],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[St,[Ct],(e,[t])=>e.id()===t.value],"filter-type-==":[St,[Et],(e,[t])=>e.geometryType()===t.value],"filter-<":[St,[Et,Ct],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<a}],"filter-id-<":[St,[Ct],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[St,[Et,Ct],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>a}],"filter-id->":[St,[Ct],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[St,[Et,Ct],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r<=a}],"filter-id-<=":[St,[Ct],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[St,[Et,Ct],(e,[t,i])=>{let r=e.properties()[t.value],a=i.value;return typeof r==typeof a&&r>=a}],"filter-id->=":[St,[Ct],(e,[t])=>{let i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[St,[Ct],(e,[t])=>{let i=t.value,r=e.properties();return i in r&&void 0!==r[i]}],"filter-has-id":[St,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[St,[Ot(Et)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[St,[Ot(Ct)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[St,[Et,Ot(Ct)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[St,[Et,Ot(Ct)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){let a=i+r>>1;if(t[a]===e)return!0;t[a]>e?r=a-1:i=a+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:St,overloads:[[[St,St],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[ca(St),(e,t)=>{for(let i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:St,overloads:[[[St,St],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[ca(St),(e,t)=>{for(let i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[St,[St],(e,[t])=>!t.evaluate(e)],"is-supported-script":[St,[Et],(e,[t])=>{let i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Et,[Et],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Et,[Et],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Et,ca(Ct),(e,t)=>t.map(t=>Ci(t.evaluate(e))).join("")],split:[Ot(Et),[Et,Et],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[Et,[Ot(Et),Et],(e,[t,i])=>t.evaluate(e).join(i.evaluate(e))],"resolved-locale":[Et,[Mt],(e,[t])=>t.evaluate(e).resolvedLocale()]});const xa=/^(.*)-transition$/;function va(e,...t){for(let i of t)for(let t in i)e[t]=i[t];return e}function ba(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function wa(e){return"object"==typeof e&&!!e&&!Array.isArray(e)&&Ai(e)===At}function Ta(e){return e}function Da(e,t){let i=e.stops&&"object"==typeof e.stops[0][0],r=i||void 0!==e.property,a=i||!r,n=e.type||(ya(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return fi.parse;case"padding":return yi.parse;case"numberArray":return xi.parse;case"colorArray":return vi.parse;default:return null}}(t);if(o&&((e=va({},e)).stops&&(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&&!function(e){return"rgb"===e||"hcl"===e||"lab"===e}(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let s,l,u=function(e){switch(e){case"exponential":return Ia;case"interval":return Pa;case"categorical":return Sa;case"identity":return Aa;default:throw Error(`Unknown function type "${e}"`)}}(n);if("categorical"===n){s=Object.create(null);for(let t of e.stops)s[t[0]]=t[1];l=typeof e.stops[0][0]}if(i){let i={},r=[];for(let t=0;t<e.stops.length;t++){let a=e.stops[t],n=a[0].zoom;void 0===i[n]&&(i[n]={zoom:n,type:e.type,property:e.property,default:e.default,stops:[]},r.push(n)),i[n].stops.push([a[0].value,a[1]])}let a=[];for(let e of r)a.push([i[e].zoom,Da(i[e],t)]);let n={name:"linear"};return{kind:"composite",interpolationType:n,interpolationFactor:Li.interpolationFactor.bind(void 0,n),zoomStops:a.map(e=>e[0]),evaluate:({zoom:i},r)=>Ia({stops:a,base:e.base},t,i).evaluate(i,r)}}if(a){let i="exponential"===n?{name:"exponential",base:void 0===e.base?1:e.base}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Li.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>u(e,t,i,s,l)}}return{kind:"source",evaluate(i,r){let a=r&&r.properties?r.properties[e.property]:void 0;return void 0===a?Ea(e.default,t.default):u(e,t,a,s,l)}}}function Ea(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Sa(e,t,i,r,a){return Ea(typeof i===a?r[i]:void 0,e.default,t.default)}function Pa(e,t,i){if("number"!==ba(i))return Ea(e.default,t.default);let r=e.stops.length;if(1===r||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];let a=Ri(e.stops.map(e=>e[0]),i,"");return e.stops[a][1]}function Ia(e,t,i){let r=void 0===e.base?1:e.base;if("number"!==ba(i))return Ea(e.default,t.default);let a=e.stops.length;if(1===a||i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[a-1][0])return e.stops[a-1][1];let n=Ri(e.stops.map(e=>e[0]),i,""),o=function(e,t,i,r){let a=r-i,n=e-i;return 0===a?0:1===t?n/a:(t**+n-1)/(t**+a-1)}(i,r,e.stops[n][0],e.stops[n+1][0]),s=e.stops[n][1],l=e.stops[n+1][1],u=Oi[t.type]||Ta;return"function"==typeof s.evaluate?{evaluate(...t){let i=s.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==r)return u(i,r,o,e.colorSpace)}}:u(s,l,o,e.colorSpace)}function Aa(e,t,i){switch(t.type){case"color":i=fi.parse(i);break;case"formatted":i=_i.fromString(i.toString());break;case"resolvedImage":i=Di.fromString(i.toString());break;case"padding":i=yi.parse(i);break;case"colorArray":i=vi.parse(i);break;case"numberArray":i=xi.parse(i);break;default:ba(i)!==t.type&&("enum"!==t.type||!t.values[i])&&(i=void 0)}return Ea(i,e.default,t.default)}function Ca(e){return{result:"success",value:e}}function Ma(e){return{result:"error",value:e}}var za=class{constructor(e,t,i,r){this.expression=e,this._warningHistory={},this._evaluator=new Fi,this._defaultValue=i?$a(i):null,this._enumValues=i&&"enum"===i.type?i.values:null,this._globalState=r,this._rootKey=t}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ga(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=a||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,a,n){this._globalState&&(e=Ga(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=a||null,this._evaluator.formattedSection=n||null;try{let e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new bi(`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 bi?e.path:"",i=`${t}|${e.message}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(Fa(this._rootKey,t,e.message,this._defaultValue))),this._defaultValue}}};function Fa(e,t,i,r){return`${e}${t}: ${i}${null==r?"":` Falling back to ${String(r)}.`}`}function Ra(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 ka(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in ra}function La(e,t,i,r){Ra(t);let a=new oa(ra,da,[],i?function(e){let t={color:Pt,string:Et,number:Dt,enum:Et,boolean:St,formatted:zt,padding:Ft,numberArray:kt,colorArray:Rt,projectionDefinition:It,resolvedImage:Lt,variableAnchorOffsetCollection:Bt};return"array"===e.type?Ot(t[e.value]||Ct,e.length):t[e.type]}(i):void 0),n=a.parse(e,void 0,void 0,void 0,i&&"string"===i.type?{typeAnnotation:"coerce"}:void 0);return n?Ca(new za(n,t,i,r)):Ma(a.errors)}var Ba=class{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!fa(t.expression),this.globalStateRefs=Ua(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ga(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Ga(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}},Oa=class{constructor(e,t,i,r,a){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!fa(t.expression),this.globalStateRefs=Ua(t.expression),this.interpolationType=r,this._globalState=a}evaluateWithoutErrorHandling(e,t,i,r,a,n){return this._globalState&&(e=Ga(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,a,n)}evaluate(e,t,i,r,a,n){return this._globalState&&(e=Ga(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,a,n)}interpolationFactor(e,t,i){return this.interpolationType?Li.interpolationFactor(this.interpolationType,e,t,i):0}};function ja(e,t,i,r){let a=La(e,t,i,r);if("error"===a.result)return a;let n=a.value.expression,o=pa(n);if(!o&&!ga(i))return Ma([new aa("","data expressions not supported")]);let s=ma(n,["zoom"]);if(!s&&!_a(i))return Ma([new aa("","zoom expressions not supported")]);let l=Na(n);if(!l&&!s)return Ma([new aa("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof aa)return Ma([l]);if(l instanceof Li&&!ya(i))return Ma([new aa("",'"interpolate" expressions cannot be used with this property')]);if(!l)return Ca(new Ba(o?"constant":"source",a.value,r));let u=l instanceof Li?l.interpolation:void 0;return Ca(new Oa(o?"camera":"composite",a.value,l.labels,u,r))}var Va=class e{constructor(e,t,i){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,Ra(t),this._parameters=e,this._specification=i,this._rootKey=t,this._defaultValue=$a(i),this._warningHistory={};let r=Da(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),i=`|${t}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(Fa(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 Na(e){let t=null;if(e instanceof Yi)t=Na(e.result);else if(e instanceof Ji){for(let i of e.args)if(t=Na(i),t)break}else(e instanceof ki||e instanceof Li)&&e.input instanceof sa&&"zoom"===e.input.name&&(t=e);return t instanceof aa||e.eachChild(e=>{let i=Na(e);i instanceof aa?t=i:!t&&i?t=new aa("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new aa("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Ua(e,t=new Set){return e instanceof ia&&t.add(e.key),e.eachChild(e=>{Ua(e,t)}),t}function $a(e){if("color"===e.type&&wa(e.default))return new fi(0,0,0,0);switch(e.type){case"color":return fi.parse(e.default)||null;case"padding":return yi.parse(e.default)||null;case"numberArray":return xi.parse(e.default)||null;case"colorArray":return vi.parse(e.default)||null;case"variableAnchorOffsetCollection":return Ti.parse(e.default)||null;case"projectionDefinition":return Ei.parse(e.default)||null;default:return void 0===e.default?null:e.default}}function Ga(e,t){let{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:o,accumulated:s}=e??{};return{zoom:i,heatmapDensity:r,elevation:a,lineProgress:n,isSupportedScript:o,accumulated:s,globalState:t}}function Za(e){if("boolean"==typeof e)return"neutral";if(!Array.isArray(e)||0===e.length)return"legacy";switch(e[0]){case"has":return e.length<2||"$id"===e[1]||"$type"===e[1]?"legacy":2===e.length?"neutral":"expression";case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]))?"expression":"legacy";case"!in":case"!has":case"none":return"legacy";case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2])?"expression":"legacy";case"any":case"all":return function(e){let t=!1;for(let i of e){let e=Za(i);if("expression"===e)return"expression";"legacy"===e&&(t=!0)}return t?"legacy":"neutral"}(e.slice(1));default:return"expression"}}function qa(e){return"legacy"!==Za(e)}function Wa(e){return"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e]}function Xa(e){if(("<"===e[0]||"<="===e[0]||">"===e[0]||">="===e[0])&&"$type"===e[1])return`"$type" cannot be use with operator "${e[0]}"`;let t=function(e){switch(e[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return 3!==e.length||"string"!=typeof e[1]?null:[e[0],Wa(e[1]),e[2]];case"in":case"!in":{if(e.length<2||"string"!=typeof e[1])return null;let t=["in",Wa(e[1]),["literal",e.slice(2)]];return"!in"===e[0]?["!",t]:t}case"has":case"!has":{if(2!==e.length||"string"!=typeof e[1]||"$type"===e[1]||"$id"===e[1])return null;let t=["has",e[1]];return"!has"===e[0]?["!",t]:t}default:return null}}(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 Ha(e,t,i){let r=i[e];return Array.isArray(r)?qa(r)?Ya(r,t.concat(e)):{path:t.concat(e),legacyFilter:r}:null}function Ya(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case"all":case"any":case"none":for(let i=1;i<e.length;i++){let r=Ha(i,t,e);if(r)return r}break;case"!":{let i=Ha(1,t,e);if(i)return i;break}case"case":for(let i=1;i<e.length-1;i+=2){let r=Ha(i,t,e);if(r)return r}}return null}const Ka={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Ja(e,t,i){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};qa(e)?function(e,t){let i=Ya(e);if(!i||typeof console>"u")return;let r=i.path.map(e=>`[${e}]`).join("");console.warn(`${t}${r}: ${Xa(i.legacyFilter)}`)}(e,t):e=tn(e);let r=La(e,t,Ka,i);if("error"===r.result)throw Error(r.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,t,i)=>r.value.evaluate(e,t,{},i),needGeometry:en(e),getGlobalStateRefs:()=>Ua(r.value.expression)}}function Qa(e,t){return e<t?-1:+(e>t)}function en(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t<e.length;t++)if(en(e[t]))return!0;return!1}function tn(e){if(!e)return!0;let t=e[0];return e.length<=1?"any"!==t:"=="===t?rn(e[1],e[2],"=="):"!="===t?on(rn(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?rn(e[1],e[2],t):"any"===t?function(e){return["any"].concat(e.map(tn))}(e.slice(1)):"all"===t?["all"].concat(e.slice(1).map(tn)):"none"===t?["all"].concat(e.slice(1).map(tn).map(on)):"in"===t?an(e[1],e.slice(2)):"!in"===t?on(an(e[1],e.slice(2))):"has"===t?nn(e[1]):"!has"!==t||on(nn(e[1]))}function rn(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function an(e,t){if(0===t.length)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(Qa)]]:["filter-in-small",e,["literal",t]]}}function nn(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function on(e){return["!",e]}function sn(e){let t=e.key,i=e.value;return i?[new wt(t,i,"constants have been deprecated as of v8")]:[]}function ln(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function un(e){if(Array.isArray(e))return e.map(un);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){let t={};for(let i in e)t[i]=un(e[i]);return t}return ln(e)}function hn(e){let t=e.key,i=e.value,r=e.valueSpec||{},a=e.objectElementValidators||{},n=e.style,o=e.styleSpec,s=e.validateSpec,l=[],u=ba(i);if("object"!==u)return[new wt(t,i,`object expected, ${u} found`)];for(let e in i){let u,h=e.split(".")[0],c=oi(r,h)||r["*"];if(oi(a,h))u=a[h];else if(oi(r,h)){if(void 0===i[e])continue;u=s}else if(a["*"])u=a["*"];else{if(!r["*"]){l.push(new wt(t,i[e],`unknown property "${e}"`));continue}u=s}l=l.concat(u({key:(t&&`${t}.`)+e,value:i[e],valueSpec:c,style:n,styleSpec:o,object:i,objectKey:e,validateSpec:s},i))}for(let e in r)a[e]||r[e].required&&void 0===r[e].default&&void 0===i[e]&&l.push(new wt(t,i,`missing required property "${e}"`));return l}function cn(e){let t=e.value,i=e.valueSpec,r=e.validateSpec,a=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||r;if("array"!==ba(t))return[new wt(o,t,`array expected, ${ba(t)} found`)];if(i.length&&t.length!==i.length)return[new wt(o,t,`array length ${i.length} expected, length ${t.length} found`)];let l={type:i.value,values:i.values};n.$version<7&&(l.function=i.function),"object"===ba(i.value)&&(l=i.value);let u=[];for(let i=0;i<t.length;i++)u=u.concat(s({array:t,arrayIndex:i,value:t[i],valueSpec:l,validateSpec:e.validateSpec,style:a,styleSpec:n,key:`${o}[${i}]`}));return u}function dn(e){let t=e.key,i=e.value,r=e.valueSpec,a=ba(i);return"number"===a&&i!=i&&(a="NaN"),"number"===a?"minimum"in r&&i<r.minimum?[new wt(t,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new wt(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new wt(t,i,`number expected, ${a} found`)]}function pn(e){let t,i,r,a=e.valueSpec,n=ln(e.value.type),o={},s="categorical"!==n&&void 0===e.value.property,l=!s,u="array"===ba(e.value.stops)&&"array"===ba(e.value.stops[0])&&"object"===ba(e.value.stops[0][0]),h=hn({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return[new wt(e.key,e.value,'identity function may not have a "stops" property')];let t=[],i=e.value;return t=t.concat(cn({key:e.key,value:i,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:c})),"array"===ba(i)&&0===i.length&&t.push(new wt(e.key,i,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:a,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&s&&h.push(new wt(e.key,e.value,'missing required property "property"')),"identity"!==n&&!e.value.stops&&h.push(new wt(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!ya(e.valueSpec)&&h.push(new wt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!ga(e.valueSpec)?h.push(new wt(e.key,e.value,"property functions not supported")):s&&!_a(e.valueSpec)&&h.push(new wt(e.key,e.value,"zoom functions not supported"))),("categorical"===n||u)&&void 0===e.value.property&&h.push(new wt(e.key,e.value,'"property" property is required')),h;function c(e){let t=[],n=e.value,s=e.key;if("array"!==ba(n))return[new wt(s,n,`array expected, ${ba(n)} found`)];if(2!==n.length)return[new wt(s,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==ba(n[0]))return[new wt(s,n,`object expected, ${ba(n[0])} found`)];if(void 0===n[0].zoom)return[new wt(s,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new wt(s,n,"object stop key must have value")];if(r&&r>ln(n[0].zoom))return[new wt(s,n[0].zoom,"stop zoom values must appear in ascending order")];ln(n[0].zoom)!==r&&(r=ln(n[0].zoom),i=void 0,o={}),t=t.concat(hn({key:`${s}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:dn,value:d}}))}else t=t.concat(d({key:`${s}[0]`,value:n[0],valueSpec:{},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return ka(un(n[1]))?t.concat([new wt(`${s}[1]`,n[1],"expressions are not allowed in function stops.")]):t.concat(e.validateSpec({key:`${s}[1]`,value:n[1],valueSpec:a,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,r){let s=ba(e.value),l=ln(e.value),u=null===e.value?r:e.value;if(t){if(s!==t)return[new wt(e.key,u,`${s} stop domain type must match previous stop domain type ${t}`)]}else t=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new wt(e.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==n){let t=`number expected, ${s} found`;return ga(a)&&void 0===n&&(t+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new wt(e.key,u,t)]}return"categorical"!==n||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===s&&void 0!==i&&l<i?[new wt(e.key,u,"stop domain values must appear in ascending order")]:(i=l,"categorical"===n&&l in o?[new wt(e.key,u,"stop domain values must be unique")]:(o[l]=!0,[])):[new wt(e.key,u,`integer expected, found ${l}`)]}}function fn(e){let t=("property"===e.expressionContext?ja:La)(un(e.value),e.key,e.valueSpec);if("error"===t.result)return t.value.map(t=>new wt(`${e.key}${t.key}`,e.value,t.message));let i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new wt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!fa(i))return[new wt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!fa(i))return[new wt(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!ma(i,["zoom","feature-state"]))return[new wt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!pa(i))return[new wt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function mn(e){let t=e.key,i=e.value,r=ba(i);return"string"===r?fi.parse(String(i))?[]:[new wt(t,i,`color expected, "${i}" found`)]:[new wt(t,i,`color expected, ${r} found`)]}function gn(e){let t=e.key,i=e.value,r=e.valueSpec,a=[];return Array.isArray(r.values)?-1===r.values.indexOf(ln(i))&&a.push(new wt(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(ln(i))&&a.push(new wt(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),a}function _n(e,t){let i=e;for(let e of t)i=i[e];return i}function yn(e,t){let i=Ya(t);return i?[new wt(`${e.key}${i.path.map(e=>`[${e}]`).join("")}`,_n(e.value,i.path),Xa(i.legacyFilter),null,"warning")]:[]}function xn(e){let t=un(e.value);return qa(t)?[...yn(e,t),...fn(va({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:vn(e)}function vn(e){let t=e.value,i=e.key;if("array"!==ba(t))return[new wt(i,t,`array expected, ${ba(t)} found`)];let r,a=e.styleSpec,n=[];if(t.length<1)return[new wt(i,t,"filter array must have at least 1 element")];switch(n=n.concat(gn({key:`${i}[0]`,value:t[0],valueSpec:a.filter_operator,style:e.style,styleSpec:e.styleSpec})),ln(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===ln(t[1])&&n.push(new wt(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&n.push(new wt(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=ba(t[1]),"string"!==r&&n.push(new wt(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let o=2;o<t.length;o++)r=ba(t[o]),"$type"===ln(t[1])?n=n.concat(gn({key:`${i}[${o}]`,value:t[o],valueSpec:a.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==r&&"number"!==r&&"boolean"!==r&&n.push(new wt(`${i}[${o}]`,t[o],`string, number, or boolean expected, ${r} found`));break;case"any":case"all":case"none":for(let r=1;r<t.length;r++)n=n.concat(vn({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":r=ba(t[1]),2===t.length?"string"!==r&&n.push(new wt(`${i}[1]`,t[1],`string expected, ${r} found`)):n.push(new wt(i,t,`filter array for "${t[0]}" operator must have 2 elements`))}return n}function bn(e,t){let i=e.key,r=e.validateSpec,a=e.style,n=e.styleSpec,o=e.value,s=e.objectKey,l=n[`${t}_${e.layerType}`];if(!l)return[];let u=s.match(xa);if("paint"===t&&u&&l[u[1]]&&l[u[1]].transition)return r({key:i,value:o,valueSpec:n.transition,style:a,styleSpec:n});let h,c=e.valueSpec||l[s];if(!c)return[new wt(i,o,`unknown property "${s}"`)];if("string"===ba(o)&&ga(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(o)))return[new wt(i,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];let d=[];return"symbol"===e.layerType&&"text-font"===s&&wa(un(o))&&"identity"===ln(o.type)&&d.push(new wt(i,o,'"text-font" does not support identity functions')),d.concat(r({key:e.key,value:o,valueSpec:c,style:a,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:s}))}function wn(e){return bn(e,"paint")}function Tn(e){return bn(e,"layout")}function Dn(e){let t=[],i=e.value,r=e.key,a=e.style,n=e.styleSpec;if("object"!==ba(i))return[new wt(r,i,`object expected, ${ba(i)} found`)];!i.type&&!i.ref&&t.push(new wt(r,i,'either "type" or "ref" is required'));let o=ln(i.type),s=ln(i.ref);if(i.id){let n=ln(i.id);for(let o=0;o<e.arrayIndex;o++){let e=a.layers[o];ln(e.id)===n&&t.push(new wt(r,i.id,`duplicate layer id "${i.id}", previously used at line ${e.id.__line__}`))}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach(e=>{e in i&&t.push(new wt(r,i[e],`"${e}" is prohibited for ref layers`))}),a.layers.forEach(t=>{ln(t.id)===s&&(e=t)}),e?e.ref?t.push(new wt(r,i.ref,"ref cannot reference another ref layer")):o=ln(e.type):t.push(new wt(r,i.ref,`ref layer "${s}" not found`))}else if("background"!==o)if(i.source){let e=a.sources&&a.sources[i.source],n=e&&ln(e.type);e?"vector"===n&&"raster"===o?t.push(new wt(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==n&&"hillshade"===o||"raster-dem"!==n&&"color-relief"===o?t.push(new wt(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===n&&"raster"!==o?t.push(new wt(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==o&&"color-relief"!==o?t.push(new wt(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"===o&&i.paint&&i.paint["line-gradient"]&&("geojson"!==n||!e.lineMetrics)&&t.push(new wt(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new wt(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new wt(r,i.source,`source "${i.source}" not found`))}else t.push(new wt(r,i,'missing required property "source"'));return"raster"===o&&i.paint?.resampling&&i.paint?.["raster-resampling"]&&t.push(new wt(r,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(hn({key:r,value:i,valueSpec:n.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:xn,layout:e=>hn({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Tn(va({layerType:o},e))}}),paint:e=>hn({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>wn(va({layerType:o},e))}})}})),t}function En(e){let t=e.value,i=e.key,r=ba(t);return"string"===r?[]:[new wt(i,t,`string expected, ${r} found`)]}const Sn={promoteId:function({key:e,value:t}){if("string"===ba(t))return En({key:e,value:t});{let i=[];for(let r in t)i.push(...En({key:`${e}.${r}`,value:t[r]}));return i}}};function Pn(e){let t=e.value,i=e.key,r=e.styleSpec,a=e.style,n=e.validateSpec;if(!t.type)return[new wt(i,t,'"type" is required')];let o,s=ln(t.type);switch(s){case"vector":case"raster":return o=hn({key:i,value:t,valueSpec:r[`source_${s.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Sn,validateSpec:n}),o;case"raster-dem":return o=function(e){let t=e.sourceName??"",i=e.value,r=e.styleSpec,a=r.source_raster_dem,n=e.style,o=[],s=ba(i);if(void 0===i)return o;if("object"!==s)return o.push(new wt("source_raster_dem",i,`object expected, ${s} found`)),o;let l="custom"===ln(i.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(let s in i)!l&&u.includes(s)?o.push(new wt(s,i[s],`In "${t}": "${s}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):a[s]?o=o.concat(e.validateSpec({key:s,value:i[s],valueSpec:a[s],validateSpec:e.validateSpec,style:n,styleSpec:r})):o.push(new wt(s,i[s],`unknown property "${s}"`));return o}({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:n}),o;case"geojson":if(o=hn({key:i,value:t,valueSpec:r.source_geojson,style:a,styleSpec:r,validateSpec:n,objectElementValidators:Sn}),t.cluster)for(let e in t.clusterProperties){let[r,a]=t.clusterProperties[e],s="string"==typeof r?[r,["accumulated"],["get",e]]:r;o.push(...fn({key:`${i}.${e}.map`,value:a,validateSpec:n,expressionContext:"cluster-map"})),o.push(...fn({key:`${i}.${e}.reduce`,value:s,validateSpec:n,expressionContext:"cluster-reduce"}))}return o;case"video":return hn({key:i,value:t,valueSpec:r.source_video,style:a,validateSpec:n,styleSpec:r});case"image":return hn({key:i,value:t,valueSpec:r.source_image,style:a,validateSpec:n,styleSpec:r});case"canvas":return[new wt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return gn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,validateSpec:n,styleSpec:r})}}function In(e){let t=e.value,i=e.styleSpec,r=i.light,a=e.style,n=[],o=ba(t);if(void 0===t)return n;if("object"!==o)return n=n.concat([new wt("light",t,`object expected, ${o} found`)]),n;for(let o in t){let s=o.match(xa);n=s&&r[s[1]]&&r[s[1]].transition?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:i.transition,validateSpec:e.validateSpec,style:a,styleSpec:i})):r[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new wt(o,t[o],`unknown property "${o}"`)])}return n}function An(e){let t=e.value,i=e.styleSpec,r=i.sky,a=e.style,n=ba(t);if(void 0===t)return[];if("object"!==n)return[new wt("sky",t,`object expected, ${n} found`)];let o=[];for(let n in t){let s=n.match(xa);o=s&&r[s[1]]&&r[s[1]].transition?o.concat(e.validateSpec({key:n,value:t[n],valueSpec:i.transition,style:a,styleSpec:i})):r[n]?o.concat(e.validateSpec({key:n,value:t[n],valueSpec:r[n],style:a,styleSpec:i})):o.concat([new wt(n,t[n],`unknown property "${n}"`)])}return o}function Cn(e){let t=e.value,i=e.styleSpec,r=i.terrain,a=e.style,n=[],o=ba(t);if(void 0===t)return n;if("object"!==o)return n=n.concat([new wt("terrain",t,`object expected, ${o} found`)]),n;for(let o in t)n=r[o]?n.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:a,styleSpec:i})):n.concat([new wt(o,t[o],`unknown property "${o}"`)]);return n}function Mn(e){let t=[],i=e.value,r=e.key;if(Array.isArray(i)){let a=[],n=[];for(let o in i)i[o].id&&a.includes(i[o].id)&&t.push(new wt(r,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),a.push(i[o].id),i[o].url&&n.includes(i[o].url)&&t.push(new wt(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),n.push(i[o].url),t=t.concat(hn({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return En({key:r,value:i})}function zn(e){return!!e&&e.constructor===Object}function Fn(e){return zn(e.value)?[]:[new wt(e.key,e.value,`object expected, ${ba(e.value)} found`)]}const Rn=1114111,kn=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function Ln(e,t){if("string"!==ba(t))return[];let i=`${t}`,r=()=>[new wt(e,t,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],a=i.match(kn);if(!a)return r();let[,n,o,s]=a;if(void 0!==s)return s.length>6?r():[];let l=parseInt(n,16),u=void 0===o?l:parseInt(o,16);return l>Rn||u>Rn?[new wt(e,t,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>u?[new wt(e,t,`unicode range start must not be greater than its end, but ${i} is`)]:[]}function Bn(e){let t=e.key??"font-faces",i=e.value,r=e.validateSpec,a=e.styleSpec??xt,n=e.style;if(!zn(i))return[new wt(t,i,`object expected, ${ba(i)} found`)];let o=[];for(let e in i){let s=i[e],l=ba(s);if("string"===l)o.push(...En({key:`${t}.${e}`,value:s}));else if("array"===l){let i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[l,u]of s.entries()){let s=`${t}.${e}[${l}]`;o.push(...hn({key:s,value:u,valueSpec:i,styleSpec:a,style:n,validateSpec:r}));let h=zn(u)?u["unicode-range"]:void 0;if("array"===ba(h))for(let[e,t]of h.entries())o.push(...Ln(`${s}.unicode-range[${e}]`,t))}}else o.push(new wt(`${t}.${e}`,s,`string or array expected, ${l} found`))}return o}const On={"*":()=>[],array:cn,boolean:function(e){let t=e.value,i=e.key,r=ba(t);return"boolean"===r?[]:[new wt(i,t,`boolean expected, ${r} found`)]},number:dn,color:mn,constants:sn,enum:gn,filter:xn,function:pn,layer:Dn,object:hn,source:Pn,light:In,sky:An,terrain:Cn,projection:function(e){let t=e.value,i=e.styleSpec,r=i.projection,a=e.style,n=ba(t);if(void 0===t)return[];if("object"!==n)return[new wt("projection",t,`object expected, ${n} found`)];let o=[];for(let n in t)o=r[n]?o.concat(e.validateSpec({key:n,value:t[n],valueSpec:r[n],style:a,styleSpec:i})):o.concat([new wt(n,t[n],`unknown property "${n}"`)]);return o},projectionDefinition:function(e){let t=e.key,i=e.value;i=i instanceof String?i.valueOf():i;let r=ba(i);return"array"!==r||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(r)?[]:[new wt(t,i,`projection expected, invalid type "${r}" found`)]:[new wt(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:En,formatted:function(e){return 0===En(e).length?[]:fn(e)},resolvedImage:function(e){return 0===En(e).length?[]:fn(e)},padding:function(e){let t=e.key,i=e.value;if("array"===ba(i)){if(i.length<1||i.length>4)return[new wt(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];let r={type:"number"},a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return dn({key:t,value:i,valueSpec:{}})},numberArray:function(e){let t=e.key,i=e.value;if("array"===ba(i)){let r={type:"number"};if(i.length<1)return[new wt(t,i,"array length at least 1 expected, length 0 found")];let a=[];for(let n=0;n<i.length;n++)a=a.concat(e.validateSpec({key:`${t}[${n}]`,value:i[n],validateSpec:e.validateSpec,valueSpec:r}));return a}return dn({key:t,value:i,valueSpec:{}})},colorArray:function(e){let t=e.key,i=e.value;if("array"===ba(i)){if(i.length<1)return[new wt(t,i,"array length at least 1 expected, length 0 found")];let e=[];for(let r=0;r<i.length;r++)e=e.concat(mn({key:`${t}[${r}]`,value:i[r],valueSpec:{}}));return e}return mn({key:t,value:i,valueSpec:{}})},variableAnchorOffsetCollection:function(e){let t=e.key,i=e.value,r=ba(i),a=e.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new wt(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let r=0;r<i.length;r+=2)n=n.concat(gn({key:`${t}[${r}]`,value:i[r],valueSpec:a.layout_symbol["text-anchor"]})),n=n.concat(cn({key:`${t}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:a}));return n},sprite:Mn,state:Fn,fontFaces:Bn};function jn(e){let t=e.value,i=e.valueSpec,r=e.styleSpec;return e.validateSpec=jn,i.expression&&wa(ln(t))?pn(e):i.expression&&ka(un(t))?fn(e):i.type&&On[i.type]?On[i.type](e):hn(va({},e,{valueSpec:i.type?r[i.type]:i}))}function Vn(e){let t=e.value,i=e.key,r=En(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new wt(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new wt(i,t,'"glyphs" url must include a "{range}" token'))),r}function Nn(e,t=vt){let i=[];return i=i.concat(jn({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:jn,objectElementValidators:{glyphs:Vn,"*":()=>[]}})),e.constants&&(i=i.concat(sn({key:"constants",value:e.constants,style:e,styleSpec:t,validateSpec:jn}))),$n(i)}function Un(e){return function(t){return e(Object.assign({},t,{validateSpec:jn}))}}function $n(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Gn(e){return function(...t){return $n(e.apply(this,t))}}Nn.source=Gn(Un(Pn)),Nn.sprite=Gn(Un(Mn)),Nn.glyphs=Gn(Un(Vn)),Nn.fontFaces=Gn(Un(Bn)),Nn.light=Gn(Un(In)),Nn.sky=Gn(Un(An)),Nn.terrain=Gn(Un(Cn)),Nn.state=Gn(Un(Fn)),Nn.layer=Gn(Un(Dn)),Nn.filter=Gn(Un(xn)),Nn.paintProperty=Gn(Un(wn)),Nn.layoutProperty=Gn(Un(Tn));const Zn={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var qn=class{constructor(e,t,i){this._rootKey=t,this._globalState=i,this.setValue(e)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(e){if(null==e||"visible"===e||"none"===e)return this._literalValue="none"===e?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);let t=La(e,this._rootKey,Zn,this._globalState);if("error"===t.result)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=Ua(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};const Wn=Nn,Xn=new Set(Object.keys(vt).filter(e=>e.startsWith("source_")).map(e=>e.slice(7).replaceAll("_","-")));function Hn(e,t){let i=function(e){return Object.entries(e.sources??{}).filter(([,e])=>!Xn.has(e.type)).map(([e])=>`sources.${e}`)}(t);return Yn(e,Wn(t).filter(({message:e})=>!i.some(t=>e.startsWith(`${t}:`)||e.startsWith(`${t}.`))))}function Yn(e,t){let i=!1;for(let r of t)"warning"!==r.severity?(e.fire(new _t(Error(r.message))),i=!0):Oe(r.message);return i}function Kn(e,t,i,r){return!1!==r?.validate&&Yn(e,t({styleSpec:vt,...i}))}var Jn=class e{constructor(e,t,i){let r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let a=new Int32Array(this.arrayBuffer);e=a[0],t=a[1],i=a[2],this.d=t+2*i;for(let e=0;e<this.d*this.d;e++){let t=a[3+e],i=a[3+e+1];r.push(t===i?null:a.subarray(t,i))}let n=a[3+r.length],o=a[3+r.length+1];this.keys=a.subarray(n,o),this.bboxes=a.subarray(o),this.insert=this._insertReadonly}else{this.d=t+2*i;for(let e=0;e<this.d*this.d;e++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;let a=i/t*e;this.min=-a,this.max=e+a}insert(e,t,i,r,a){this._forEachCell(t,i,r,a,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,t,i,r,a,n){this.cells[a].push(n)}query(e,t,i,r,a){let n=this.min,o=this.max;if(e<=n&&t<=n&&o<=i&&o<=r&&!a)return[...this.keys];{let n=[];return this._forEachCell(e,t,i,r,this._queryCell,n,{},a),n}}_queryCell(e,t,i,r,a,n,o,s){let l=this.cells[a];if(null!==l){let a=this.keys,u=this.bboxes;for(let h of l)if(void 0===o[h]){let l=4*h;(s?s(u[l+0],u[l+1],u[l+2],u[l+3]):e<=u[l+2]&&t<=u[l+3]&&i>=u[l+0]&&r>=u[l+1])?(o[h]=!0,n.push(a[h])):o[h]=!1}}}_forEachCell(e,t,i,r,a,n,o,s){let l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),h=this._convertToCellCoord(i),c=this._convertToCellCoord(r);for(let d=l;d<=h;d++)for(let l=u;l<=c;l++){let u=this.d*l+d;if((!s||s(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&a.call(this,e,t,i,r,u,n,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,i=0;for(let e of this.cells)i+=e.length;let r=new Int32Array(t+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let a=t;for(let t=0;t<e.length;t++){let i=e[t];r[3+t]=a,r.set(i,a),a+=i.length}return r[3+e.length]=a,r.set(this.keys,a),a+=this.keys.length,r[3+e.length+1]=a,r.set(this.bboxes,a),a+=this.bboxes.length,r.buffer}static serialize(e,t){let i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}}static deserialize(t){return new e(t.buffer)}};const Qn={};function eo(e,t,i={}){if(Qn[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),Qn[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}eo("Object",Object),eo("Set",Set),eo("TransferableGridIndex",Jn),eo("Color",fi),eo("Error",Error),eo("AJAXError",lt),eo("ResolvedImage",Di),eo("StylePropertyFunction",Va),eo("StyleExpression",za,{omit:["_evaluator"]}),eo("ZoomDependentExpression",Oa),eo("ZoomConstantExpression",Ba),eo("CompoundExpression",sa,{omit:["_evaluate"]});for(let e in ra)ra[e]._classRegistryKey||eo(`Expression_${e}`,ra[e]);function to(e){return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||"ArrayBuffer"===e.constructor?.name)}function io(e){let t=e.constructor;return e.$name||t._classRegistryKey}function ro(e){return!function(e){if("object"!=typeof e||!e)return!1;let t=io(e);return t&&"Object"!==t}(e)&&(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||to(e)||Ue(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function ao(e,t){if(ro(e))return(to(e)||Ue(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){let i=[];for(let r of e)i.push(ao(r,t));return i}if("object"!=typeof e)throw Error("can't serialize object of type "+typeof e);let i=io(e);if(!i)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!Qn[i])throw Error(`${i} is not registered.`);let{klass:r}=Qn[i],a=r.serialize?r.serialize(e,t):{};if(r.serialize){if(a===t?.[t.length-1])throw Error("statically serialized object won't survive transfer of $name property")}else{for(let r in e){if(!e.hasOwnProperty(r)||Qn[i].omit.includes(r))continue;let n=e[r];void 0!==n&&(a[r]=Qn[i].shallow.includes(r)?n:ao(n,t))}e instanceof Error&&(a.message=e.message)}if(a.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(a.$name=i),a}function no(e){if(ro(e))return e;if(Array.isArray(e))return e.map(no);if("object"!=typeof e)throw Error("can't deserialize object of type "+typeof e);let t=io(e)||"Object";if(!Qn[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:i}=Qn[t];if(!i)throw Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);let r=Object.create(i.prototype);for(let i of Object.keys(e)){if("$name"===i)continue;let a=e[i];r[i]=Qn[t].shallow.includes(i)?a:no(a)}return r}var oo=class{constructor(){this.first=!0}update(e,t){let i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}},so=class{constructor(e,t){this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new oo,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new oo,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}};var lo=class{constructor(e,t,i,r){this.property=e,this.value=t,this.expression=function(e,t,i,r){if(wa(e))return new Va(e,t,i);if(ka(e)){let a=ja(e,t,i,r);if("error"===a.result)throw Error(a.value.map(e=>`${e.key}: ${e.message}`).join(", "));return a.value}{let t=e;return"color"===i.type&&"string"==typeof e?t=fi.parse(e):"padding"!==i.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==i.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==i.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===i.type&&Array.isArray(e)?t=Ti.parse(e):"projectionDefinition"===i.type&&"string"==typeof e&&(t=Ei.parse(e)):t=vi.parse(e):t=xi.parse(e):t=yi.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>t}}}(void 0===t?e.specification.default:t,i,e.specification,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}},uo=class{constructor(e,t,i){this.property=e,this.value=new lo(e,void 0,t,i)}transitioned(e,t){return new co(this.property,this.value,t,Se({},e.transition,this.transition),e.now)}untransitioned(){return new co(this.property,this.value,null,{},0)}},ho=class{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=i,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return Le(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new uo(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].value=new lo(this._values[e].property,null===t?void 0:Le(t),this._propertyRootKey(e),this._globalState)}getTransition(e){return Le(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new uo(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].transition=Le(t)||void 0}serialize(){let e={};for(let t of Object.keys(this._values)){let i=this.getValue(t);void 0!==i&&(e[t]=i);let r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){let i=new po(this._properties);for(let r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){let e=new po(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}},co=class{constructor(e,t,i,r,a){this.property=e,this.value=t,this.begin=a+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){let r=e.now||0,a=this.value.possiblyEvaluate(e,t,i),n=this.prior;if(!n)return a;if(r>this.end||this.value.isDataDriven())return this.prior=null,a;if(r<this.begin)return n.possiblyEvaluate(e,t,i);{let o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(e,t,i),a,function(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}(o))}}},po=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){let r=new go(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}},fo=class{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=i,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasValue(e){return void 0!==this._values[e].value}hasProperty(e){return e in this._properties.defaultPropertyValues}getValue(e){return Le(this._values[e].value)}setValue(e,t){this._values[e]=new lo(this._values[e].property,null===t?void 0:Le(t),this._propertyRootKey(e),this._globalState)}serialize(){let e={};for(let t of Object.keys(this._values)){let i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){let r=new go(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].possiblyEvaluate(e,t,i);return r}},mo=class{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}},go=class{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}};function _o(e){if(Array.isArray(e))return e.length;let t=e?.values;return Array.isArray(t)?t.length:void 0}function yo(e,t){let i=_o(e),r=_o(t);return void 0!==i&&void 0!==r&&i!==r}var xo=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t){if(e.isDataDriven())throw Error("Value should not be data driven");return e.expression.evaluate(t)}interpolate(e,t,i){if(yo(e,t))return Oe(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=Oi[r];return a?a(e,t,i):e}},vo=class{constructor(e,t,i){this.specification=e,this.name=t,this.overrides=i}possiblyEvaluate(e,t,i,r){return"constant"===e.expression.kind||"camera"===e.expression.kind?new mo(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)},t):new mo(this,e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new mo(this,{kind:"constant",value:void 0},e.parameters);if(yo(e.value.value,t.value.value))return Oe(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),t;let r=this.specification.type,a=Oi[r];if(a){let r=a(e.value.value,t.value.value,i);return new mo(this,{kind:"constant",value:r},e.parameters)}return e}evaluate(e,t,i,r,a,n){return"constant"===e.kind?e.value:e.evaluate(t,i,r,a,n)}},bo=class extends vo{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new mo(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){let a=e.expression.evaluate(t,null,{},i,r),n="resolvedImage"===e.property.specification.type&&"string"!=typeof a?a.name:a,o=this._calculate(n,n,n,t);return new mo(this,{kind:"constant",value:o},t)}if("camera"===e.expression.kind){let i=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new mo(this,{kind:"constant",value:i},t)}return new mo(this,e.expression,t)}evaluate(e,t,i,r,a,n){if("source"===e.kind){let o=e.evaluate(t,i,r,a,n);return this._calculate(o,o,o,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}},wo=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){let a=e.expression.evaluate(t,null,{},i,r);return this._calculate(a,a,a,t)}return this._calculate(e.expression.evaluate(new so(Math.floor(t.zoom-1),t)),e.expression.evaluate(new so(Math.floor(t.zoom),t)),e.expression.evaluate(new so(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}},To=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}},Do=class{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let i=e[t];i.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new lo(i,void 0,i.name,void 0),a=this.defaultTransitionablePropertyValues[t]=new uo(i,i.name,void 0);this.defaultTransitioningPropertyValues[t]=a.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}};eo("DataDrivenProperty",vo),eo("DataConstantProperty",xo),eo("CrossFadedDataDrivenProperty",bo),eo("CrossFadedProperty",wo),eo("ColorRampProperty",To);const Eo=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",So=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var Po=class extends yt{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,t,i){return new qn(e,t,i)}(this.visibility,`layers[${this.id}].layout.visibility`,i),"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=Ja(e.filter,`layers[${this.id}].filter`,i)),t.layout&&(this._unevaluatedLayout=new fo(t.layout,`layers[${this.id}].layout`,i)),t.paint)){this._transitionablePaint=new ho(t.paint,`layers[${this.id}].paint`,i);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 go(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=Ja(e,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){if("visibility"===e)return this.visibility;if(this._transitionablePaint?.hasProperty(e))throw Error(e+Eo);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=new Set;for(let t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(let t in this._unevaluatedLayout._values){let i=this._unevaluatedLayout._values[t];for(let t of i.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 i=this._transitionablePaint._values[t].value;for(let r of i.getGlobalStateRefs()){let a=e.get(r)??[];a.push({name:t,value:i.value}),e.set(r,a)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,i={}){if("visibility"===e)return this.visibility=t,this._visibilityExpression.setValue(t),void this.recalculateVisibility();this._transitionablePaint?.hasProperty(e)?this.fire(new _t(Error(e+Eo))):null!=t&&this._validate(Wn.layoutProperty,`layers.${this.id}.layout.${e}`,e,t,i)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){if(e.endsWith("-transition")){let t=e.slice(0,-11);if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))throw Error(e+So);return this._transitionablePaint.getTransition(t)}if("visibility"===e||this._unevaluatedLayout?.hasProperty(e))throw Error(e+So);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if("visibility"===e||this._unevaluatedLayout?.hasProperty(e))return this.fire(new _t(Error(e+So))),!1;if(null!=t&&this._validate(Wn.paintProperty,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith("-transition"))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],a=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let o=this._transitionablePaint._values[e].value;return o.isDataDriven()||a||r||this._handleOverridablePaintPropertyUpdate(e,n,o)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e=this.minzoom,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&e>=this.maxzoom)||"none"===this._evaluatedVisibility}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),Re(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,r,a={}){return Kn(this,e,{key:t,layerType:this.type,objectKey:i,value:r},a)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let t=this.paint.get(e);if(t instanceof mo&&ga(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}};let Io;var Ao={get paint(){return Io||=new Do({"raster-opacity":new xo(vt.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new xo(vt.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new xo(vt.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new xo(vt.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new xo(vt.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new xo(vt.paint_raster["raster-contrast"],"raster-contrast"),resampling:new xo(vt.paint_raster.resampling,"resampling"),"raster-resampling":new xo(vt.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new xo(vt.paint_raster["raster-fade-duration"],"raster-fade-duration")})}};const Co=e=>"raster"===e.type;var Mo=class extends Po{constructor(e,t){super(e,Ao,t)}};const zo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var Fo=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}},Ro=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(5*this.capacity),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 ko(e,t=1){let i=0,r=0;return{members:e.map(e=>{let a=function(e){return zo[e].BYTES_PER_ELEMENT}(e.type),n=i=Lo(i,Math.max(t,a)),o=e.components||1;return r=Math.max(r,a),i+=a*o,{name:e.name,type:e.type,components:o,offset:n}}),size:Lo(i,Math.max(r,t)),alignment:t}}function Lo(e,t){return Math.ceil(e/t)*t}var Bo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}};Bo.prototype.bytesPerElement=4,eo("StructArrayLayout2i4",Bo);var Oo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=3*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,e}};Oo.prototype.bytesPerElement=6,eo("StructArrayLayout3i6",Oo);var jo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r)}emplace(e,t,i,r,a){let n=4*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=a,e}};jo.prototype.bytesPerElement=8,eo("StructArrayLayout4i8",jo);var Vo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=a,this.int16[s+4]=n,this.int16[s+5]=o,e}};Vo.prototype.bytesPerElement=12,eo("StructArrayLayout2i4i12",Vo);var No=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=4*e,l=8*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=a,this.uint8[l+6]=n,this.uint8[l+7]=o,e}};No.prototype.bytesPerElement=8,eo("StructArrayLayout2i4ub8",No);var Uo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}};Uo.prototype.bytesPerElement=8,eo("StructArrayLayout2f8",Uo);var $o=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u){let h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,a,n,o,s,l,u)}emplace(e,t,i,r,a,n,o,s,l,u,h){let c=10*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=a,this.uint16[c+4]=n,this.uint16[c+5]=o,this.uint16[c+6]=s,this.uint16[c+7]=l,this.uint16[c+8]=u,this.uint16[c+9]=h,e}};$o.prototype.bytesPerElement=20,eo("StructArrayLayout10ui20",$o);var Go=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,a,n,o,s)}emplace(e,t,i,r,a,n,o,s,l){let u=8*e;return this.uint16[u+0]=t,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=a,this.uint16[u+4]=n,this.uint16[u+5]=o,this.uint16[u+6]=s,this.uint16[u+7]=l,e}};Go.prototype.bytesPerElement=16,eo("StructArrayLayout8ui16",Go);var Zo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,a,n,o,s,l,u,h,c,d)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=14*e,m=7*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=a,this.uint16[f+4]=n,this.uint16[f+5]=o,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=h,this.int16[f+10]=c,this.int16[f+11]=d,this.float32[m+6]=p,e}};Zo.prototype.bytesPerElement=28,eo("StructArrayLayout4i4ui4i1f28",Zo);var qo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=3*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,e}};qo.prototype.bytesPerElement=12,eo("StructArrayLayout3f12",qo);var Wo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=1*e;return this.uint32[i+0]=t,e}};Wo.prototype.bytesPerElement=4,eo("StructArrayLayout1ul4",Wo);var Xo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,a,n,o,s,l)}emplace(e,t,i,r,a,n,o,s,l,u){let h=10*e,c=5*e;return this.int16[h+0]=t,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=a,this.int16[h+4]=n,this.int16[h+5]=o,this.uint32[c+3]=s,this.uint16[h+8]=l,this.uint16[h+9]=u,e}};Xo.prototype.bytesPerElement=20,eo("StructArrayLayout6i1ul2ui20",Xo);var Ho=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=6*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=a,this.int16[s+4]=n,this.int16[s+5]=o,e}};Ho.prototype.bytesPerElement=12,eo("StructArrayLayout2i2i2i12",Ho);var Yo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r,a)}emplace(e,t,i,r,a,n){let o=4*e,s=8*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[s+6]=a,this.int16[s+7]=n,e}};Yo.prototype.bytesPerElement=16,eo("StructArrayLayout2f1f2i16",Yo);var Ko=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,a,n)}emplace(e,t,i,r,a,n,o){let s=16*e,l=4*e,u=8*e;return this.uint8[s+0]=t,this.uint8[s+1]=i,this.float32[l+1]=r,this.float32[l+2]=a,this.int16[u+6]=n,this.int16[u+7]=o,e}};Ko.prototype.bytesPerElement=16,eo("StructArrayLayout2ub2f2i16",Ko);var Jo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=i,this.uint16[a+2]=r,e}};Jo.prototype.bytesPerElement=6,eo("StructArrayLayout3ui6",Jo);var Qo=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_){let y=this.length;return this.resize(y+1),this.emplace(y,e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y){let x=26*e,v=13*e,b=52*e;return this.int16[x+0]=t,this.int16[x+1]=i,this.uint16[x+2]=r,this.uint16[x+3]=a,this.uint32[v+2]=n,this.uint32[v+3]=o,this.uint32[v+4]=s,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=h,this.float32[v+7]=c,this.float32[v+8]=d,this.uint8[b+36]=p,this.uint8[b+37]=f,this.uint8[b+38]=m,this.uint32[v+10]=g,this.int16[x+22]=_,this.float32[v+12]=y,e}};Qo.prototype.bytesPerElement=52,eo("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",Qo);var es=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,x,v,b,w,T,D,E,S,P,I){let A=this.length;return this.resize(A+1),this.emplace(A,e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,x,v,b,w,T,D,E,S,P,I)}emplace(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,x,v,b,w,T,D,E,S,P,I,A){let C=34*e,M=17*e;return this.int16[C+0]=t,this.int16[C+1]=i,this.int16[C+2]=r,this.int16[C+3]=a,this.int16[C+4]=n,this.int16[C+5]=o,this.int16[C+6]=s,this.int16[C+7]=l,this.uint16[C+8]=u,this.uint16[C+9]=h,this.uint16[C+10]=c,this.uint16[C+11]=d,this.uint16[C+12]=p,this.uint16[C+13]=f,this.uint16[C+14]=m,this.uint16[C+15]=g,this.uint16[C+16]=_,this.uint16[C+17]=y,this.uint16[C+18]=x,this.uint16[C+19]=v,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=T,this.uint32[M+12]=D,this.float32[M+13]=E,this.float32[M+14]=S,this.uint16[C+30]=P,this.uint16[C+31]=I,this.float32[M+16]=A,e}};es.prototype.bytesPerElement=68,eo("StructArrayLayout8i15ui1ul2f2ui1f68",es);var ts=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=1*e;return this.float32[i+0]=t,e}};ts.prototype.bytesPerElement=4,eo("StructArrayLayout1f4",ts);var is=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=6*e,n=3*e;return this.uint16[a+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}};is.prototype.bytesPerElement=12,eo("StructArrayLayout1ui2f12",is);var rs=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){let a=2*e,n=4*e;return this.uint32[a+0]=t,this.uint16[n+2]=i,this.uint16[n+3]=r,e}};rs.prototype.bytesPerElement=8,eo("StructArrayLayout1ul2ui8",rs);var as=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){let r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}};as.prototype.bytesPerElement=4,eo("StructArrayLayout2ui4",as);var ns=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let i=1*e;return this.uint16[i+0]=t,e}};ns.prototype.bytesPerElement=2,eo("StructArrayLayout1ui2",ns);var os=class extends Ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r)}emplace(e,t,i,r,a){let n=4*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=a,e}};os.prototype.bytesPerElement=16,eo("StructArrayLayout4f16",os);var ss=class extends Fo{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new c(this.anchorPointX,this.anchorPointY)}};ss.prototype.size=20;var ls=class extends Xo{get(e){return new ss(this,e)}};eo("CollisionBoxArray",ls);var us=class extends Fo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}get heightOffset(){return this._structArray.float32[this._pos4+12]}};us.prototype.size=52;var hs=class extends Qo{get(e){return new us(this,e)}};eo("PlacedSymbolArray",hs);var cs=class extends Fo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}get heightOffset(){return this._structArray.float32[this._pos4+16]}};cs.prototype.size=68;var ds=class extends es{get(e){return new cs(this,e)}};eo("SymbolInstanceArray",ds);var ps=class extends ts{getoffsetX(e){return this.float32[1*e+0]}};eo("GlyphOffsetArray",ps);var fs=class extends Oo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}};eo("SymbolLineVertexArray",fs);var ms=class extends Fo{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]}};ms.prototype.size=12;var gs=class extends is{get(e){return new ms(this,e)}};eo("TextAnchorOffsetArray",gs);var _s=class extends Fo{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]}};_s.prototype.size=8;var ys=class extends rs{get(e){return new _s(this,e)}};eo("FeatureIndexArray",ys);var xs=class extends Bo{},vs=class extends Oo{},bs=class extends jo{},ws=class extends Bo{},Ts=class extends Bo{},Ds=class extends Vo{},Es=class extends No{},Ss=class extends Uo{},Ps=class extends $o{},Is=class extends Go{},As=class extends Zo{},Cs=class extends qo{},Ms=class extends Wo{},zs=class extends Ho{},Fs=class extends Yo{},Rs=class extends Ko{},ks=class extends Jo{},Ls=class extends Jo{},Bs=class extends as{},Os=class extends ns{};const js=ko([{name:"a_pos",components:2,type:"Int16"}],4),Vs=js.members;js.size,js.alignment;var Ns=class e{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(t,i,r,a){let n=this.segments[this.segments.length-1];return t>e.MAX_VERTEX_ARRAY_LENGTH&&Oe(`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||!n||n.vertexLength+t>e.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==a?this.createNewSegment(i,r,a):n}createNewSegment(e,t,i){let r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}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,i,r,a){return new e([{vertexOffset:t,primitiveOffset:i,vertexLength:r,primitiveLength:a,vaos:{},sortKey:0}])}};function Us(e,t){return 256*(e=De(Math.floor(e),0,255))+De(Math.floor(t),0,255)}Ns.MAX_VERTEX_ARRAY_LENGTH=65535,eo("SegmentVector",Ns);const $s=ko([{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"}]),Gs=ko([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Zs=u((e,t)=>{void 0!==t&&(t.exports=function(e,t){for(var i,r,a=3&e.length,n=e.length-a,o=t,s=3432918353,l=461845907,u=0;u<n;)r=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24,++u,o=27492+(65535&(i=5*(65535&(o=(o^=r=(65535&(r=(r=(65535&r)*s+(((r>>>16)*s&65535)<<16)&4294967295)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)&4294967295)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)&4294967295))+(((i>>>16)+58964&65535)<<16);switch(r=0,a){case 3:r^=(255&e.charCodeAt(u+2))<<16;case 2:r^=(255&e.charCodeAt(u+1))<<8;case 1:o^=r=(65535&(r=(r=(65535&(r^=255&e.charCodeAt(u)))*s+(((r>>>16)*s&65535)<<16)&4294967295)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)&4294967295}return o^=e.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)&4294967295,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)&4294967295,(o^=o>>>16)>>>0})}),qs=u((e,t)=>{t.exports=function(e,t){for(var i,r=e.length,a=t^r,n=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:a^=(255&e.charCodeAt(n+2))<<16;case 2:a^=(255&e.charCodeAt(n+1))<<8;case 1:a=1540483477*(65535&(a^=255&e.charCodeAt(n)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0}}),Ws=((e,t,i)=>(i=null==e?{}:r(s(e)),h(a(i,"default",{value:e,enumerable:!0}),e)))(u((e,t)=>{var i=Zs(),r=qs();t.exports=i,t.exports.murmur3=i,t.exports.murmur2=r})()),Xs=class e{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(Hs(e)),this.positions.push(t,i,r)}getPositions(e){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let t=Hs(e),i=0,r=this.ids.length-1;for(;i<r;){let e=i+r>>1;this.ids[e]>=t?r=e:i=e+1}let a=[];for(;this.ids[i]===t;){let e=this.positions[3*i],t=this.positions[3*i+1],r=this.positions[3*i+2];a.push({index:e,start:t,end:r}),i++}return a}static serialize(e,t){let i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Ys(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){let i=new e;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}};function Hs(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,Ws.default)(String(e))}function Ys(e,t,i,r){for(;i<r;){let a=e[i+r>>1],n=i-1,o=r+1;for(;;){do{n++}while(e[n]<a);do{o--}while(e[o]>a);if(n>=o)break;Ks(e,n,o),Ks(t,3*n,3*o),Ks(t,3*n+1,3*o+1),Ks(t,3*n+2,3*o+2)}o-i<r-o?(Ys(e,t,i,o),i=o+1):(Ys(e,t,o+1,r),r=o)}}function Ks(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}eo("FeaturePositionMap",Xs);var Js=class{constructor(e,t){this.gl=e.gl,this.location=t}},Qs=class extends Js{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},el=class extends Js{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}},tl=class extends Js{constructor(e,t){super(e,t),this.current=[0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1])&&(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},il=class extends Js{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1]||e[2]!==this.current[2])&&(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},rl=class extends Js{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){(e[0]!==this.current[0]||e[1]!==this.current[1]||e[2]!==this.current[2]||e[3]!==this.current[3])&&(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}},al=class extends Js{constructor(e,t){super(e,t),this.current=fi.transparent}set(e){(e.r!==this.current.r||e.g!==this.current.g||e.b!==this.current.b||e.a!==this.current.a)&&(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}},nl=class extends Js{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(4*e.length);for(let i=0;i<e.length;i++)t[4*i]=e[i].r,t[4*i+1]=e[i].g,t[4*i+2]=e[i].b,t[4*i+3]=e[i].a;this.gl.uniform4fv(this.location,t)}}},ol=class extends Js{constructor(e,t){super(e,t),this.current=[]}set(e){if(e!=this.current){this.current=e;let t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}};const sl=new Float32Array(16);var ll=class extends Js{constructor(e,t){super(e,t),this.current=sl}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}};function ul(e){return[Us(255*e.r,255*e.g),Us(255*e.b,255*e.a)]}var hl=class{constructor(e,t,i){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new al(e,t):new el(e,t)}},cl=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,i,r){let a=null;"u_pattern_to"===r?a=this.patternTo:"u_pattern_from"===r?a=this.patternFrom:"u_dasharray_to"===r?a=this.dashTo:"u_dasharray_from"===r?a=this.dashFrom:"u_pixel_ratio_to"===r?a=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(a=this.pixelRatioFrom),null!==a&&e.set(a)}getBinding(e,t,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new rl(e,t):new el(e,t)}},dl=class{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i){let r=this.paintVertexArray.length,a=this.expression.evaluate(new so(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,a)}updatePaintArray(e,t,i,r,a){let n=this.expression.evaluate(new so(0,a),i,r);this._setPaintValue(e,t,n)}_setPaintValue(e,t,i){if("color"===this.type){let r=ul(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},pl=class{constructor(e,t,i,r,a,n){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=a,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new n}populatePaintArray(e,t,i){let r=this.expression.evaluate(new so(this.zoom,i),t,{},i.canonical,[],i.formattedSection),a=this.expression.evaluate(new so(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),n=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(n,e,r,a)}updatePaintArray(e,t,i,r,a){let n=this.expression.evaluate(new so(this.zoom,a),i,r),o=this.expression.evaluate(new so(this.zoom+1,a),i,r);this._setPaintValue(e,t,n,o)}_setPaintValue(e,t,i,r){if("color"===this.type){let a=ul(i),n=ul(r);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,a[0],a[1],n[0],n[1])}else{for(let a=e;a<t;a++)this.paintVertexArray.emplace(a,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){let i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=De(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new el(e,t)}},fl=class{constructor(e,t,i,r,a,n){this.expression=e,this.type=t,this.useIntegerZoom=i,this.zoom=r,this.layerId=n,this.zoomInPaintVertexArray=new a,this.zoomOutPaintVertexArray=new a}populatePaintArray(e,t,i){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,this.getPositionIds(t),i)}updatePaintArray(e,t,i,r,a){this._setPaintValues(e,t,this.getPositionIds(i),a)}_setPaintValues(e,t,i,r){let a=this.getPositions(r);if(!a||!i)return;let n=a[i.min],o=a[i.mid],s=a[i.max];if(n&&o&&s)for(let i=e;i<t;i++)this.emplace(this.zoomInPaintVertexArray,i,n,o),this.emplace(this.zoomOutPaintVertexArray,i,s,o)}upload(e){if(this.zoomInPaintVertexArray?.arrayBuffer.byteLength&&this.zoomOutPaintVertexArray?.arrayBuffer.byteLength){let t=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,t,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,t,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}},ml=class extends fl{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns?.[this.layerId]}getVertexAttributes(){return $s.members}emplace(e,t,i,r){e.emplace(t,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.pixelRatio,r.pixelRatio)}},gl=class extends fl{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes?.[this.layerId]}getVertexAttributes(){return Gs.members}emplace(e,t,i,r){e.emplace(t,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},_l=class{constructor(e,t,i){this.binders={},this._buffers=[];let r=[];for(let a in e.paint._values){if(!i(a))continue;let n=e.paint.get(a);if(!(n instanceof mo&&ga(n.property.specification)))continue;let o=xl(a,e.type),s=n.value,l=n.property.specification.type,u=n.property.useIntegerZoom,h=n.property.specification["property-type"],c="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===s.kind)this.binders[a]=c?new cl(s.value,o):new hl(s.value,o,l),r.push(`/u_${a}`);else if("source"===s.kind||c){let i=vl(a,l,"source");this.binders[a]=c?"line-dasharray"===a?new gl(s,l,u,t,i,e.id):new ml(s,l,u,t,i,e.id):new dl(s,o,l,i),r.push(`/a_${a}`)}else{let e=vl(a,l,"composite");this.binders[a]=new pl(s,o,l,u,t,e),r.push(`/z_${a}`)}}this.cacheKey=r.sort().join("")}getMaxValue(e){let t=this.binders[e];return t instanceof dl||t instanceof pl?t.maxValue:0}populatePaintArrays(e,t,i){for(let r in this.binders){let a=this.binders[r];(a instanceof dl||a instanceof pl||a instanceof fl)&&a.populatePaintArray(e,t,i)}}setConstantPatternPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof cl&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(let i in this.binders){let r=this.binders[i];r instanceof cl&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,i,r,a){let n=!1;for(let o of e){let e=t.getPositions(o.id);for(let t of e){let e=i.feature(t.index);for(let i in this.binders){let s=this.binders[i];(s instanceof dl||s instanceof pl||s instanceof fl)&&!0===s.expression.isStateDependent&&(s.expression=r.paint.get(i).value,s.updatePaintArray(t.start,t.end,e,o.state,a),n=!0)}}}return n}defines(){let e=[];for(let t in this.binders){let i=this.binders[t];(i instanceof hl||i instanceof cl)&&e.push(...i.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let i=this.binders[t];if(i instanceof dl||i instanceof pl)for(let t of i.paintVertexAttributes)e.push(t.name);else if(i instanceof fl){let t=i.getVertexAttributes();for(let i of t)e.push(i.name)}}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let i=this.binders[t];if(i instanceof hl||i instanceof cl||i instanceof pl)for(let t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let i=[];for(let r in this.binders){let a=this.binders[r];if(a instanceof hl||a instanceof cl||a instanceof pl)for(let n of a.uniformNames)if(t[n]){let o=a.getBinding(e,t[n],n);i.push({name:n,property:r,binding:o})}}return i}setUniforms(e,t,i,r){for(let{name:e,property:a,binding:n}of t)this.binders[a].setUniform(n,r,i.get(a),e)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let i=this.binders[t];if(e&&i instanceof fl){let t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof dl||i instanceof pl)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(let t in this.binders){let i=this.binders[t];(i instanceof dl||i instanceof pl||i instanceof fl)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof dl||t instanceof pl||t instanceof fl)&&t.destroy()}}},yl=class{constructor(e,t,i=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new _l(r,t,i);this.needsUpload=!1,this._featureMap=new Xs,this._bufferOffset=0}populatePaintArrays(e,t,i,r){for(let i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r){for(let a of i)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,t,a,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}};function xl(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 vl(e,t,i){let r={color:{source:Uo,composite:os},number:{source:ts,composite:Uo}};return function(e){return{"line-pattern":{source:Ps,composite:Ps},"fill-pattern":{source:Ps,composite:Ps},"fill-extrusion-pattern":{source:Ps,composite:Ps},"line-dasharray":{source:Is,composite:Is}}[e]}(e)?.[i]||r[t][i]}eo("ConstantBinder",hl),eo("CrossFadedConstantBinder",cl),eo("SourceExpressionBinder",dl),eo("CrossFadedPatternBinder",ml),eo("CrossFadedDasharrayBinder",gl),eo("CompositeExpressionBinder",pl),eo("ProgramConfiguration",_l,{omit:["_buffers"]}),eo("ProgramConfigurationSet",yl);const bl=16383,wl=-bl-1;function Tl(e){let t=re/e.extent,i=e.loadGeometry();for(let e of i)for(let i of e){let e=Math.round(i.x*t),r=Math.round(i.y*t);i.x=De(e,wl,bl),i.y=De(r,wl,bl),(e<i.x||e>i.x+1||r<i.y||r>i.y+1)&&Oe("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function Dl(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Tl(e):[]}}const El=-32768;function Sl(e,t,i,r,a){e.emplaceBack(El+8*t+r,El+8*i+a)}var Pl=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 ws,this.indexArray=new Ls,this.segments=new Ns,this.programConfigurations=new yl(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){let r=this.layers[0],a=[],n=null,o=!1,s="heatmap"===r.type;if("circle"===r.type){let e=r;n=e.layout.get("circle-sort-key"),o=!n.isConstant(),s||="map"===e.paint.get("circle-pitch-alignment")}let l=s?t.subdivisionGranularity.circle:1,u=new so(this.zoom),h=this.layers[0]._featureFilter.needGeometry;for(let{feature:t,id:r,index:s,sourceLayerIndex:l}of e){let e=Dl(t,h);if(!this.layers[0]._featureFilter.filter(u,e,i))continue;let c=o?n.evaluate(e,{},i):void 0,d={id:r,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:h?e.geometry:Tl(t),patterns:{},sortKey:c};a.push(d)}o&&a.sort((e,t)=>e.sortKey-t.sortKey);for(let r of a){let{geometry:a,index:n,sourceLayerIndex:o}=r,s=e[n].feature;this.addFeature(r,a,n,i,l),t.featureIndex.insert(s,a,n,o,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e){}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Vs),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,a=1){let n;switch(a){case 1:n=[0,7];break;case 3:n=[0,2,5,7];break;case 5:n=[0,1,3,4,6,7];break;case 7:n=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${a}; valid values are 1, 3, 5, 7.`)}let o=n.length;for(let i of t)for(let t of i){let i=t.x,r=t.y;if(i<0||i>=8192||r<0||r>=8192)continue;let a=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;for(let e=0;e<o;e++)for(let t=0;t<o;t++)Sl(this.layoutVertexArray,i,r,n[t],n[e]);for(let e=0;e<o-1;e++)for(let t=0;t<o-1;t++){let i=s+e*o+t,r=s+(e+1)*o+t;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}a.vertexLength+=o*o,a.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:{},canonical:r})}};function Il(e,t){for(let i of e)if(Bl(t,i))return!0;for(let i of t)if(Bl(e,i))return!0;return zl(e,t)}function Al(e,t,i){return!!Bl(e,t)||Rl(t,e,i)}function Cl(e,t){if(1===e.length)return Ll(t,e[0]);for(let i of t)for(let t of i)if(Bl(e,t))return!0;for(let i of e)if(Ll(t,i))return!0;for(let i of t)if(zl(e,i))return!0;return!1}function Ml(e,t,i){if(e.length>1){if(zl(e,t))return!0;for(let r of t)if(Rl(r,e,i))return!0}for(let r of e)if(Rl(r,t,i))return!0;return!1}function zl(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){let r=e[i],a=e[i+1];for(let e=0;e<t.length-1;e++)if(Fl(r,a,t[e],t[e+1]))return!0}return!1}function Fl(e,t,i,r){return je(e,i,r)!==je(t,i,r)&&je(e,t,i)!==je(e,t,r)}function Rl(e,t,i){let r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let i=1;i<t.length;i++)if(kl(e,t[i-1],t[i])<r)return!0;return!1}function kl(e,t,i){let r=t.distSqr(i);if(0===r)return e.distSqr(t);let a=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return a<0?e.distSqr(t):a>1?e.distSqr(i):e.distSqr(i.sub(t)._mult(a)._add(t))}function Ll(e,t){let i,r,a,n=!1;for(let o of e){i=o;for(let e=0,o=i.length-1;e<i.length;o=e++)r=i[e],a=i[o],r.y>t.y!=a.y>t.y&&t.x<(a.x-r.x)*(t.y-r.y)/(a.y-r.y)+r.x&&(n=!n)}return n}function Bl(e,t){let i=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){let n=e[r],o=e[a];n.y>t.y!=o.y>t.y&&t.x<(o.x-n.x)*(t.y-n.y)/(o.y-n.y)+n.x&&(i=!i)}return i}function Ol(e,t,i){let r=i[0],a=i[2];if(e.x<r.x&&t.x<r.x||e.x>a.x&&t.x>a.x||e.y<r.y&&t.y<r.y||e.y>a.y&&t.y>a.y)return!1;let n=je(e,t,i[0]);return n!==je(e,t,i[1])||n!==je(e,t,i[2])||n!==je(e,t,i[3])}function jl(e,t,i){let r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Vl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Nl(e,t,i,r,a){if(!t[0]&&!t[1])return e;let n=c.convert(t)._mult(a);"viewport"===i&&n._rotate(-r);let o=[];for(let t of e)o.push(t.sub(n));return o}function Ul(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],a=t.at(-1);(0===i||a&&!r.equals(a))&&t.push(r)}return t}function $l({queryGeometry:e,size:t},i){return Al(e,i,t)}function Gl({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Al(e,n,t*(i.projectTileCoordinates(n.x,n.y,r,a?.(n.x,n.y)).signedDistanceFromCamera/i.cameraToCenterDistance))}function Zl({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){let o=i.projectTileCoordinates(n.x,n.y,r,a?.(n.x,n.y)).signedDistanceFromCamera,s=t*(i.cameraToCenterDistance/o);return Al(e,Xl(n,i,r,a),s)}function ql({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a},n){return Al(e,Xl(n,i,r,a),t)}function Wl({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a,pitchAlignment:n="map",pitchScale:o="map"},s){let l="map"===n?"map"===o?$l:Gl:"map"===o?Zl:ql,u={queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:a};for(let e of s)for(let t of e)if(l(u,t))return!0;return!1}function Xl(e,t,i,r){let a=t.projectTileCoordinates(e.x,e.y,i,r?.(e.x,e.y)).point;return new c((.5*a.x+.5)*t.width,(.5*-a.y+.5)*t.height)}let Hl,Yl;eo("CircleBucket",Pl,{omit:["layers"]});var Kl={get paint(){return Yl||=new Do({"circle-radius":new vo(vt.paint_circle["circle-radius"],"circle-radius"),"circle-color":new vo(vt.paint_circle["circle-color"],"circle-color"),"circle-blur":new vo(vt.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new vo(vt.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new xo(vt.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new xo(vt.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new xo(vt.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new xo(vt.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new vo(vt.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new vo(vt.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new vo(vt.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})},get layout(){return Hl||=new Do({"circle-sort-key":new vo(vt.layout_circle["circle-sort-key"],"circle-sort-key")})}},Jl=class extends Po{constructor(e,t){super(e,Kl,t)}createBucket(e){return new Pl(e)}queryRadius(e){let t=e;return jl("circle-radius",this,t)+jl("circle-stroke-width",this,t)+Vl(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:s}){let l,u,h=Nl(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-a.bearingInRadians,n),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i),d=this.paint.get("circle-pitch-scale"),p=this.paint.get("circle-pitch-alignment");return"map"===p?(l=h,u=c*n):(l=function(e,t,i,r){return e.map(e=>Xl(e,t,i,r))}(h,a,o,s),u=c),Wl({queryGeometry:l,size:u,transform:a,unwrappedTileID:o,getElevation:s,pitchAlignment:p,pitchScale:d},r)}},Ql=class extends Pl{};let eu;eo("HeatmapBucket",Ql,{omit:["layers"]});var tu={get paint(){return eu||=new Do({"heatmap-radius":new vo(vt.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new vo(vt.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new xo(vt.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new To(vt.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new xo(vt.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})}};function iu(e,{width:t,height:i},r,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==t*i*r)throw RangeError(`mismatched image size. expected: ${a.length} but got: ${t*i*r}`)}else a=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=a,e}function ru(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;let a=iu({},{width:t,height:i},r);au(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},r),e.width=t,e.height=i,e.data=a.data}function au(e,t,i,r,a,n){if(0===a.width||0===a.height)return t;if(a.width>e.width||a.height>e.height||i.x>e.width-a.width||i.y>e.height-a.height)throw RangeError("out of range source coordinates for image copy");if(a.width>t.width||a.height>t.height||r.x>t.width-a.width||r.y>t.height-a.height)throw RangeError("out of range destination coordinates for image copy");let o=e.data,s=t.data;if(o===s)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<a.height;l++){let u=((i.y+l)*e.width+i.x)*n,h=((r.y+l)*t.width+r.x)*n;for(let e=0;e<a.width*n;e++)s[h+e]=o[u+e]}return t}var nu=class e{constructor(e,t){iu(this,e,1,t)}resize(e){ru(this,e,1)}clone(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,a){au(e,t,i,r,a,1)}},ou=class e{constructor(e,t){iu(this,e,4,t)}resize(e){ru(this,e,4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,a){au(e,t,i,r,a,4)}setPixel(e,t,i){let r=4*(e*this.width+t);this.data[r+0]=Math.round(255*i.r/i.a),this.data[r+1]=Math.round(255*i.g/i.a),this.data[r+2]=Math.round(255*i.b/i.a),this.data[r+3]=Math.round(255*i.a)}};function su(e){let t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=4){let r=e[i+3];t[i+0]=Math.round(e[i+0]*r/255),t[i+1]=Math.round(e[i+1]*r/255),t[i+2]=Math.round(e[i+2]*r/255),t[i+3]=r}return t}function lu(e){let t={},i=e.resolution||256,r=e.clips?e.clips.length:1,a=e.image||new ou({width:i,height:r});if(!function(e){return Math.log(e)/Math.LN2%1==0}(i))throw Error(`width is not a power of 2 - ${i}`);let n=(r,n,o)=>{t[e.evaluationKey]=o;let s=e.expression.evaluate(t);a.setPixel(r/4/i,n/4,s)};if(e.clips)for(let t=0,a=0;t<r;++t,a+=4*i)for(let r=0,o=0;r<i;r++,o+=4){let s=r/(i-1),{start:l,end:u}=e.clips[t];n(a,o,l*(1-s)+u*s)}else for(let e=0,t=0;e<i;e++,t+=4)n(0,t,e/(i-1));return a}eo("AlphaImage",nu),eo("RGBAImage",ou);const uu="big-fb";var hu=class extends Po{createBucket(e){return new Ql(e)}constructor(e,t){super(e,tu,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){let e=this._transitionablePaint._values["heatmap-color"].value.expression;this.colorRamp=lu({expression:e,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(uu)}queryRadius(e){return jl("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:s}){return Wl({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(t,i)*n,transform:a,unwrappedTileID:o,getElevation:s},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}};let cu;var du={get paint(){return cu||=new Do({"hillshade-illumination-direction":new xo(vt.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new xo(vt.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new xo(vt.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new xo(vt.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new xo(vt.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new xo(vt.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new xo(vt.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new xo(vt.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new xo(vt.paint_hillshade.resampling,"resampling")})}},pu=class extends Po{constructor(e,t){super(e,du,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,t=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,r=this.paint.get("hillshade-shadow-color").values,a=Math.max(e.length,t.length,i.length,r.length);e=e.concat(Array(a-e.length).fill(e.at(-1))),t=t.concat(Array(a-t.length).fill(t.at(-1))),i=i.concat(Array(a-i.length).fill(i.at(-1))),r=r.concat(Array(a-r.length).fill(r.at(-1)));let n=t.map(Ge);return{directionRadians:e.map(Ge),altitudeRadians:n,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}};let fu;var mu={get paint(){return fu||=new Do({"color-relief-opacity":new xo(vt["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new To(vt["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new xo(vt["paint_color-relief"].resampling,"resampling")})}};function gu(e){return"data"in e}var _u=class{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,i){let{width:r,height:a}=e,n=(this.size?.[0]!==r||this.size[1]!==a)&&!i,{context:o}=this,{gl:s}=o;this.useMipmap=!!t?.useMipmap,n&&this.size&&this.format===s.RGBA&&(s.deleteTexture(this.texture),this.texture=s.createTexture(),this._ownedHandle=this.texture,this.magFilter=void 0,this.minFilter=void 0,this.wrap=void 0),s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let l=this.format===s.RGBA&&!1!==t?.premultiply;if(n)if(this.size=[r,a],this.format===s.RGBA&&r>0&&a>0){let t=this.useMipmap?Math.floor(Math.log2(Math.max(r,a)))+1:1;if(s.texStorage2D(s.TEXTURE_2D,t,s.RGBA8,r,a),gu(e)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:t}=e;l&&t&&(t=su(t)),t&&s.texSubImage2D(s.TEXTURE_2D,0,0,0,r,a,s.RGBA,s.UNSIGNED_BYTE,t)}else o.pixelStoreUnpackPremultiplyAlpha.set(l),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,e)}else gu(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,l,r,a,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(e,s));else{let{x:t,y:n}=i||{x:0,y:0};gu(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,l,t,n,r,a,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(e,t,n,s))}this.useMipmap&&!(gu(e)&&null===e.data)&&s.generateMipmap(s.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,i,r,a){let{data:n}=e;t&&n&&(n=su(n)),a.texImage2D(a.TEXTURE_2D,0,this.format,i,r,0,this.format,a.UNSIGNED_BYTE,n)}_updateDomImage(e,t,i,r){r.texSubImage2D(r.TEXTURE_2D,0,t,i,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,i,r,a,n,o){let{data:s}=e;t&&s&&(s=su(s)),o.texSubImage2D(o.TEXTURE_2D,0,i,r,a,n,o.RGBA,o.UNSIGNED_BYTE,s)}bind(e,t,i){let{context:r}=this,{gl:a}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),a.bindTexture(a.TEXTURE_2D,this.texture),(i===a.LINEAR_MIPMAP_NEAREST||i===a.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(i=a.LINEAR);let n=i||e;e!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),this.magFilter=e),n!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,n),this.minFilter=n),t!==this.wrap&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,t),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,t),this.wrap=t)}generateMipmap(){if(!this.useMipmap)return;let{gl:e}=this.context;e.bindTexture(e.TEXTURE_2D,this.texture),e.generateMipmap(e.TEXTURE_2D)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},yu=class e{static{this.byteViewCache=new WeakMap}constructor(t,i,r,a=1,n=1,o=1,s=0){if(this.uid=t,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r))return void Oe(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;let l=this.dim=i.height-4;switch(this.data=new Uint32Array(i.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=n,this.blueFactor=o,this.baseShift=s;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=-2;e<l+2;e++){let t=this._idx(0,Math.max(0,Math.min(l-1,e)));(e<0||e>=l)&&this.data.copyWithin(this._idx(0,e),t,t+l),this.data.fill(this.data[t],this._idx(-2,e),this._idx(0,e)),this.data.fill(this.data[t+l-1],this._idx(l,e),this._idx(l+1,e)+1)}let u=this._getByteView();this.min=2**53-1,this.max=-(2**53-1);for(let e=0;e<l;e++)for(let t=0;t<l;t++){let i=4*this._idx(e,t),r=this._unpackAtIndex(u,i);r>this.max&&(this.max=r),r<this.min&&(this.min=r)}}get(e,t){let i=this._getByteView(),r=4*this._idx(e,t);return this._unpackAtIndex(i,r)}sampleBilinear(e,t){let i=Math.floor(e),r=Math.floor(t);if(i<-1||i>=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 a=this._getByteView(),n=4*((r+2)*this.stride+i+2),o=4*this.stride,s=e-i,l=t-r;return this._unpackAtIndex(a,n)*(1-s)*(1-l)+this._unpackAtIndex(a,n+4)*s*(1-l)+this._unpackAtIndex(a,n+o)*(1-s)*l+this._unpackAtIndex(a,n+o+4)*s*l}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-2||e>=this.dim+2||t<-2||t>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+2)*this.stride+(e+2)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return xu(e,this.getUnpackVector())}getPixels(){return new ou({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(e,t,i){if(this.dim!==e.dim)throw Error("dem dimension mismatch");let r=t*this.dim,a=t*this.dim+this.dim,n=i*this.dim,o=i*this.dim+this.dim;switch(t){case-1:r=a-2;break;case 1:a=r+2}switch(i){case-1:n=o-2;break;case 1:o=n+2}let s=-t*this.dim,l=-i*this.dim;for(let t=n;t<o;t++)for(let i=r;i<a;i++)this.data[this._idx(i,t)]=e.data[this._idx(i+s,t+l)]}_getByteView(){let t=e.byteViewCache.get(this);return t?.buffer!==this.data.buffer&&(t=new Uint8Array(this.data.buffer),e.byteViewCache.set(this,t)),t}_unpackAtIndex(e,t){return this.unpack(e[t],e[t+1],e[t+2])}};function xu(e,t){let i=t[0],r=t[1],a=t[2],n=t[3],o=Math.min(i,r,a),s=Math.round((e+n)/o);return{r:Math.floor(s*o/i)%256,g:Math.floor(s*o/r)%256,b:Math.floor(s*o/a)%256}}eo("DEMData",yu);var vu=class extends Po{constructor(e,t){super(e,mu,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof Ba&&i._styleExpression.expression instanceof Li){this.colorRampExpression=i;let e=i._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(let i of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:i}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[fi.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;let r={elevationStops:[],colorStops:[]},a=(t.elevationStops.length-1)/(e-1);for(let e=0;e<t.elevationStops.length-.5;e+=a)r.elevationStops.push(t.elevationStops[Math.round(e)]),r.colorStops.push(t.colorStops[Math.round(e)]);return Oe(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${t.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,t,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(t),a=new ou({width:r.colorStops.length,height:1}),n=new ou({width:r.colorStops.length,height:1});for(let e=0;e<r.elevationStops.length;e++){let t=xu(r.elevationStops[e],i);n.setPixel(0,e,new fi(t.r/255,t.g/255,t.b/255,1)),a.setPixel(0,e,r.colorStops[e])}return this.colorRampTextures={elevationTexture:new _u(e,n,e.gl.RGBA),colorTexture:new _u(e,a,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const bu=ko([{name:"a_pos",components:2,type:"Int16"}],4),wu=bu.members;function Tu(e,t,i){let r=i.patternDependencies,a=!1;for(let i of t){let t=i.paint.get(`${e}-pattern`);t.isConstant()||(a=!0);let n=t.constantOr(null);n&&(a=!0,r[n.to]=!0,r[n.from]=!0)}return a}function Du(e,t,i,r,a){let{zoom:n}=r,o=a.patternDependencies;for(let r of t){let t=r.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:n-1},i,{},a.availableImages),s=t.evaluate({zoom:n},i,{},a.availableImages),l=t.evaluate({zoom:n+1},i,{},a.availableImages);e=e?.name?e.name:e,s=s?.name?s.name:s,l=l?.name?l.name:l,o[e]=!0,o[s]=!0,o[l]=!0,i.patterns[r.id]={min:e,mid:s,max:l}}}return i}bu.size,bu.alignment;const Eu=new Set;let Su=!1;function Pu(e,t,i,r,a){let n=null;if(a===function(e,t,i,r){let a=0;for(let n=t,o=i-r;n<i;n+=r)a+=(e[o]-e[n])*(e[n+1]+e[o+1]),o=n;return a}(e,t,i,r)>0)for(let a=t;a<i;a+=r)n=sh(a/r|0,e[a],e[a+1],n);else for(let a=i-r;a>=t;a-=r)n=sh(a/r|0,e[a],e[a+1],n);return n&&ih(n,n.next)&&(lh(n),n=n.next),n}function Iu(e,t=e){let i,r=t===e,a=e;do{i=!1,a===a.next||0!==Eu.size&&Eu.has(a)||!ih(a,a.next)&&0!==th(a.prev,a,a.next)?(r||a!==t)&&(a=a.next,i=!r):((r||a===t)&&(t=a.prev),Su=!0,lh(a),a=a.prev,i=!0)}while(i||a!==t);return t}function Au(e,t,i,r,a){a&&function(e,t,i,r){let a=e,n=0;do{a.z=Ku(a.x,a.y,t,i,r),Zu[n++]=a,a=a.next}while(a!==e);!function(e){if(e<=32)for(let t=1;t<e;t++){let e=Zu[t],i=e.z,r=t-1;for(;r>=0&&Zu[r].z>i;)Zu[r+1]=Zu[r],r--;Zu[r+1]=e}else{Wu.length<e&&(Wu=new Uint32Array(e),Xu=new Uint32Array(e),qu=Array(e));for(let t=0;t<e;t++)Wu[t]=Zu[t].z;Yu(e,Zu,Wu,qu,Xu,0),Yu(e,qu,Xu,Zu,Wu,8),Yu(e,Zu,Wu,qu,Xu,16),Yu(e,qu,Xu,Zu,Wu,24)}}(n);let o=null;for(let e=0;e<n;e++){let t=Zu[e];t.prevZ=o,o&&(o.nextZ=t),o=t}o.nextZ=null}(e,i,r,a);let n=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,l=e.next;if(th(s,e,l)<0&&(a?Mu(e,i,r,a):Cu(e)))t.push(s.i,e.i,l.i),lh(e),e=l,n=l;else if((e=l)===n){if(Su=!1,e=Iu(e),Su){n=e;continue}if(!o){n=e=zu(e,t),o=!0;continue}Fu(e,t,i,r,a);break}}}function Cu(e){let t=e.prev,i=e,r=e.next,a=t.x,n=i.x,o=r.x,s=t.y,l=i.y,u=r.y,h=Math.min(a,n,o),c=Math.min(s,l,u),d=Math.max(a,n,o),p=Math.max(s,l,u),f=r.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&(a!==f.x||s!==f.y)&&Qu(a,s,n,l,o,u,f.x,f.y)&&th(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Mu(e,t,i,r){let a=e.prev,n=e,o=e.next,s=a.x,l=n.x,u=o.x,h=a.y,c=n.y,d=o.y,p=Math.min(s,l,u),f=Math.min(h,c,d),m=Math.max(s,l,u),g=Math.max(h,c,d),_=Ku(p,f,t,i,r),y=Ku(m,g,t,i,r),x=e.prevZ;for(;x&&x.z>=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==o&&(s!==x.x||h!==x.y)&&Qu(s,h,l,c,u,d,x.x,x.y)&&th(x.prev,x,x.next)>=0)return!1;x=x.prevZ}let v=e.nextZ;for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==o&&(s!==v.x||h!==v.y)&&Qu(s,h,l,c,u,d,v.x,v.y)&&th(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function zu(e,t){let i=e,r=!1;do{let a=i.prev,n=i.next.next;rh(a,i,i.next,n,!1)&&nh(a,n)&&nh(n,a)&&(t.push(a.i,i.i,n.i),lh(i),lh(i.next),i=e=n,r=!0),i=i.next}while(i!==e);return r?Iu(i):i}function Fu(e,t,i,r,a){let n=e;do{let e=n.next.next;for(;e!==n.prev;){if(n.i!==e.i&&eh(n,e)){let o=oh(n,e);return n=Iu(n,n.next),o=Iu(o,o.next),Au(n,t,i,r,a),void Au(o,t,i,r,a)}e=e.next}n=n.next}while(n!==e)}let Ru=!1;function ku(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function Lu(e,t){let i=function(e,t){let i,r=t,a=e.x,n=e.y,o=-1/0;if(ih(e,r))return r;for(let t=0,s=0;t<Ou;t++,s+=4){if(n<Bu[s+1]||n>Bu[s+3]||Bu[s]>a||Bu[s+2]<=o)continue;let l=Uu(t);r=$u(t);do{if(r.prev.next===r){if(ih(e,r.next))return r.next;if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let e=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=a&&e>o&&(o=e,i=r.x<r.next.x?r:r.next,e===a))return i}}r=r.next}while(r!==l)}if(!i)return null;let s=i.x,l=i.y,u=Math.min(n,l),h=Math.max(n,l),c=1/0;for(let t=0,d=0;t<Ou;t++,d+=4){if(Bu[d+2]<s||Bu[d]>a||Bu[d+3]<u||Bu[d+1]>h)continue;let p=Uu(t);r=$u(t);do{if(r.prev.next===r&&a>=r.x&&r.x>=s&&a!==r.x&&Qu(n<l?a:o,n,s,l,n<l?o:a,n,r.x,r.y)){let t=Math.abs(n-r.y)/(a-r.x);(nh(r,e)||r.y===n&&r.next.y===n&&r.next.x>a)&&(t<c||t===c&&(r.x>i.x||r.x===i.x&&Gu(i,r)))&&(i=r,c=t)}r=r.next}while(r!==p)}return i}(e,t);if(!i)return t;let r=oh(i,e);return Nu(i,r.next.next),Iu(r,r.next),Iu(i,i.next)}let Bu=new Float64Array,Ou=0;const ju=[],Vu=[];function Nu(e,t){let i=e;do{let e=Ou++;ju[e]=i;let r=1/0,a=1/0,n=-1/0,o=-1/0,s=0;do{let t=i.next;i.z=e,i.x<r&&(r=i.x),i.x>n&&(n=i.x),i.y<a&&(a=i.y),i.y>o&&(o=i.y),t.x<r&&(r=t.x),t.x>n&&(n=t.x),t.y<a&&(a=t.y),t.y>o&&(o=t.y),i=t}while(++s<16&&i!==t);Vu[e]=i;let l=4*e;Bu[l]=r,Bu[l+1]=a,Bu[l+2]=n,Bu[l+3]=o}while(i!==t)}function Uu(e){let t=Vu[e];for(;t.prev.next!==t;)t=t.next;return Vu[e]=t,t}function $u(e){let t=ju[e];for(;t.prev.next!==t;)t=t.next;return ju[e]=t,t}function Gu(e,t){return th(e.prev,e,t.prev)<0&&th(t.next,e,e.next)<0}const Zu=[];let qu=[],Wu=new Uint32Array,Xu=new Uint32Array;const Hu=new Uint32Array(256);function Yu(e,t,i,r,a,n){Hu.fill(0);for(let t=0;t<e;t++)Hu[i[t]>>>n&255]++;let o=0;for(let e=0;e<256;e++){let t=Hu[e];Hu[e]=o,o+=t}for(let o=0;o<e;o++){let e=i[o],s=Hu[e>>>n&255]++;r[s]=t[o],a[s]=e}}function Ku(e,t,i,r,a){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*a|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*a|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ju(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Qu(e,t,i,r,a,n,o,s){return(a-o)*(t-s)>=(e-o)*(n-s)&&(e-o)*(r-s)>=(i-o)*(t-s)&&(i-o)*(n-s)>=(a-o)*(r-s)}function eh(e,t){let i=ih(e,t)&&th(e.prev,e,e.next)>0&&th(t.prev,t,t.next)>0;return e.next.i!==t.i&&(i||nh(e,t)&&nh(t,e)&&(0!==th(e.prev,e,t.prev)||0!==th(e,t.prev,t)))&&!function(e,t){let i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),a=Math.min(e.y,t.y),n=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.x<i&&s.x<i||o.y>n&&s.y>n||o.y<a&&s.y<a)o=s;else{if(o.i!==e.i&&s.i!==e.i&&o.i!==t.i&&s.i!==t.i&&rh(o,s,e,t))return!0;o=s}}while(o!==e);return!1}(e,t)&&(i||function(e,t){let i=e,r=!1,a=(e.x+t.x)/2,n=(e.y+t.y)/2;do{let e=i.next;i.y>n!=e.y>n&&a<(e.x-i.x)*(n-i.y)/(e.y-i.y)+i.x&&(r=!r),i=e}while(i!==e);return r}(e,t))}function th(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function ih(e,t){return e.x===t.x&&e.y===t.y}function rh(e,t,i,r,a=!0){let n=th(e,t,i),o=th(e,t,r),s=th(i,r,e),l=th(i,r,t);return(n>0&&o<0||n<0&&o>0)&&(s>0&&l<0||s<0&&l>0)||!!a&&!!(0===n&&ah(e,i,t)||0===o&&ah(e,r,t)||0===s&&ah(i,e,r)||0===l&&ah(i,t,r))}function ah(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function nh(e,t){return th(e.prev,e,e.next)<0?th(e,t,e.next)>=0&&th(e,e.prev,t)>=0:th(e,t,e.prev)<0||th(e,e.next,t)<0}function oh(e,t){let i=uh(e.i,e.x,e.y),r=uh(t.i,t.x,t.y),a=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function sh(e,t,i,r){let a=uh(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function lh(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),Ru&&function(e,t){let i=4*e.z;t.x<Bu[i]&&(Bu[i]=t.x),t.y<Bu[i+1]&&(Bu[i+1]=t.y),t.x>Bu[i+2]&&(Bu[i+2]=t.x),t.y>Bu[i+3]&&(Bu[i+3]=t.y)}(e.prev,e.next)}function uh(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var hh=class{constructor(e,t){if(t>e)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){let t=1<<e;return Math.max(Math.floor(this._baseZoomGranularity/t),this._minGranularity,1)}},ch=class e{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}static{this.noSubdivision=new e({fill:new hh(0,0),line:new hh(0,0),tile:new hh(0,0),stencil:new hh(0,0),circle:1})}};eo("SubdivisionGranularityExpression",hh),eo("SubdivisionGranularitySetting",ch);const dh=-32768,ph=32767;var fh=class{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=re/e,this._canonical=t}_getKey(e,t){return(e+=32768)<<16|t+32768}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let i=0|Math.round(e),r=0|Math.round(t),a=this._getKey(i,r);if(this._vertexDictionary.has(a))return this._vertexDictionary.get(a);let n=this._vertexBuffer.length/2;return this._vertexDictionary.set(a,n),this._vertexBuffer.push(i,r),n}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){let i=[];for(let r=0;r<t.length;r+=3){let a=t[r],n=t[r+1],o=t[r+2],s=e[2*a],l=e[2*a+1],u=e[2*n],h=e[2*n+1],c=e[2*o];(u-s)*(e[2*o+1]-l)-(h-l)*(c-s)>0?(i.push(a),i.push(o),i.push(n)):(i.push(a),i.push(n),i.push(o))}return i}(this._vertexBuffer,e);let t=[],i=e.length;for(let r=0;r<i;r+=3){let i=[e[r+0],e[r+1],e[r+2]],a=[this._vertexBuffer[2*e[r+0]+0],this._vertexBuffer[2*e[r+0]+1],this._vertexBuffer[2*e[r+1]+0],this._vertexBuffer[2*e[r+1]+1],this._vertexBuffer[2*e[r+2]+0],this._vertexBuffer[2*e[r+2]+1]],n=1/0,o=1/0,s=-1/0,l=-1/0;for(let e=0;e<3;e++){let t=a[2*e],i=a[2*e+1];n=Math.min(n,t),s=Math.max(s,t),o=Math.min(o,i),l=Math.max(l,i)}if(n===s||o===l)continue;let u=Math.floor(n/this._granularityCellSize),h=Math.ceil(s/this._granularityCellSize),c=Math.floor(o/this._granularityCellSize),d=Math.ceil(l/this._granularityCellSize);if(u!==h||c!==d)for(let e=c;e<d;e++){let r=this._scanlineGenerateVertexRingForCellRow(e,a,i);_h(this._vertexBuffer,r,t)}else t.push(...i)}return t}_scanlineGenerateVertexRingForCellRow(e,t,i){let r=e*this._granularityCellSize,a=r+this._granularityCellSize,n=[];for(let e=0;e<3;e++){let o=t[2*e],s=t[2*e+1],l=t[2*(e+1)%6],u=t[(2*(e+1)+1)%6],h=t[2*(e+2)%6],c=t[(2*(e+2)+1)%6],d=l-o,p=u-s,f=0===d,m=0===p,g=(r-s)/p,_=(a-s)/p,y=Math.min(g,_),x=Math.max(g,_);if(!m&&(y>=1||x<=0)||m&&(s<r||s>a)){u>=r&&u<=a&&n.push(i[(e+1)%3]);continue}if(!m&&y>0){let e=o+d*y,t=s+p*y;n.push(this._vertexToIndex(e,t))}let v=o+d*Math.max(y,0),b=o+d*Math.min(x,1);if(f||this._generateIntraEdgeVertices(n,o,s,l,u,v,b),!m&&x<1){let e=o+d*x,t=s+p*x;n.push(this._vertexToIndex(e,t))}(m||u>=r&&u<=a)&&n.push(i[(e+1)%3]),!m&&(u<=r||u>=a)&&this._generateInterEdgeVertices(n,o,s,l,u,h,c,b,r,a)}return n}_generateIntraEdgeVertices(e,t,i,r,a,n,o){let s=r-t,l=a-i,u=0===l,h=u?Math.min(t,r):Math.min(n,o),c=u?Math.max(t,r):Math.max(n,o),d=Math.floor(h/this._granularityCellSize)+1,p=Math.ceil(c/this._granularityCellSize)-1;if(u?t<r:n<o)for(let r=d;r<=p;r++){let a=r*this._granularityCellSize,n=i+l*(a-t)/s;e.push(this._vertexToIndex(a,n))}else for(let r=p;r>=d;r--){let a=r*this._granularityCellSize,n=i+l*(a-t)/s;e.push(this._vertexToIndex(a,n))}}_generateInterEdgeVertices(e,t,i,r,a,n,o,s,l,u){let h=a-i,c=n-r,d=o-a,p=(l-a)/d,f=(u-a)/d,m=Math.min(p,f),g=Math.max(p,f),_=r+c*m,y=Math.floor(Math.min(_,s)/this._granularityCellSize)+1,x=Math.ceil(Math.max(_,s)/this._granularityCellSize)-1,v=s<_,b=0===d;if(b&&(o===l||o===u))return;if(b||m>=1||g<=0){let e=i-o,r=(l-o)/e,a=(u-o)/e,h=n+(t-n)*Math.min(r,a);y=Math.floor(Math.min(h,s)/this._granularityCellSize)+1,x=Math.ceil(Math.max(h,s)/this._granularityCellSize)-1,v=s<h}let w=h>0?u:l;if(v)for(let t=y;t<=x;t++){let i=t*this._granularityCellSize;e.push(this._vertexToIndex(i,w))}else for(let t=x;t>=y;t--){let i=t*this._granularityCellSize;e.push(this._vertexToIndex(i,w))}}_generateOutline(e){let t=[];for(let i of e){let e=gh(i,this._granularity,!0),r=this._pointArrayToIndices(e),a=[];for(let e=1;e<r.length;e++)a.push(r[e-1]),a.push(r[e]);t.push(a)}return t}_handlePoles(e){let t=!1,i=!1;this._canonical&&(0===this._canonical.y&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(t||i)&&this._fillPoles(e,t,i)}_ensureNoPoleVertices(){let e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){let i=e[t+1];-32768===i&&(e[t+1]=-32767),32767===i&&(e[t+1]=32766)}}_generatePoleQuad(e,t,i,r,a,n){r>a==(-32768===n)?(e.push(i),e.push(t),e.push(this._vertexToIndex(r,n)),e.push(this._vertexToIndex(a,n)),e.push(i),e.push(this._vertexToIndex(r,n))):(e.push(t),e.push(i),e.push(this._vertexToIndex(r,n)),e.push(i),e.push(this._vertexToIndex(a,n)),e.push(this._vertexToIndex(r,n)))}_fillPoles(e,t,i){let r=this._vertexBuffer,a=re,n=e.length;for(let o=2;o<n;o+=3){let n=e[o-2],s=e[o-1],l=e[o],u=r[2*n],h=r[2*n+1],c=r[2*s],d=r[2*s+1],p=r[2*l],f=r[2*l+1];t&&(0===h&&0===d&&this._generatePoleQuad(e,n,s,u,c,dh),0===d&&0===f&&this._generatePoleQuad(e,s,l,c,p,dh),0===f&&0===h&&this._generatePoleQuad(e,l,n,p,u,dh)),i&&(h===a&&d===a&&this._generatePoleQuad(e,n,s,u,c,ph),d===a&&f===a&&this._generatePoleQuad(e,s,l,c,p,ph),f===a&&h===a&&this._generatePoleQuad(e,l,n,p,u,ph))}}_initializeVertices(e){for(let t=0;t<e.length;t+=2)this._vertexToIndex(e[t],e[t+1])}subdividePolygonInternal(e,t){if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let i,{flattened:r,holeIndices:a}=function(e){let t=[],i=[];for(let r of e)if(0!==r.length){r!==e[0]&&t.push(i.length/2);for(let e of r)i.push(e.x),i.push(e.y)}return{flattened:i,holeIndices:t}}(e);this._initializeVertices(r);try{let e=function(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length;Eu.size&&Eu.clear();let n=Pu(e,0,a,i,!0),o=[];if(!n||n.next===n.prev)return o;let s=0,l=0,u=0;if(r&&(n=function(e,t,i,r){let a=[];for(let i=0,n=t.length;i<n;i++){let o=Pu(e,t[i]*r,i<n-1?t[i+1]*r:e.length,r,!1);o===o.next&&Eu.add(o),a.push(Ju(o))}a.sort(ku),function(e,t){let i=Math.ceil((e+2*t)/16)+t+2;Bu.length<4*i&&(Bu=new Float64Array(4*i)),Ou=0}(e.length/r,t.length),Nu(i,i),Ru=!0;for(let e=0;e<a.length;e++)i=Lu(a[e],i);return Ru=!1,Iu(i)}(e,t,n,i)),e.length>80*i){s=e[0],l=e[1];let t=s,r=l;for(let n=i;n<a;n+=i){let i=e[n],a=e[n+1];i<s&&(s=i),a<l&&(l=a),i>t&&(t=i),a>r&&(r=a)}u=Math.max(t-s,r-l),u=0===u?0:32767/u}return Au(n,o,s,l,u),o}(r,a),t=this._convertIndices(r,e);i=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let n=[];return t&&(n=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(i),this._granularity>=2&&0===this._canonical?.z&&(i=this._removeTrianglesOutsideTileX(i),n=n.map(e=>this._removeLinesOutsideTileX(e))),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:n}}_vertexOutsideTileX(e){let t=this._vertexBuffer[2*e];return t<0||t>8192}_removeTrianglesOutsideTileX(e){let t=[];for(let i=0;i<e.length;i+=3)this._vertexOutsideTileX(e[i])||this._vertexOutsideTileX(e[i+1])||this._vertexOutsideTileX(e[i+2])||t.push(e[i],e[i+1],e[i+2]);return t}_removeLinesOutsideTileX(e){let t=[];for(let i=0;i<e.length;i+=2)this._vertexOutsideTileX(e[i])||this._vertexOutsideTileX(e[i+1])||t.push(e[i],e[i+1]);return t}_convertIndices(e,t){let i=[];for(let r of t){let t=e[2*r],a=e[2*r+1];i.push(this._vertexToIndex(t,a))}return i}_pointArrayToIndices(e){let t=[];for(let i of e)t.push(this._vertexToIndex(i.x,i.y));return t}};function mh(e,t,i,r=!0){return new fh(i,t).subdividePolygonInternal(e,r)}function gh(e,t,i=!1){if(!e||e.length<1||e.length<2)return[];let r=e[0],a=e[e.length-1],n=i&&(r.x!==a.x||r.y!==a.y);if(t<2)return n?[...e,e[0]]:[...e];let o=Math.floor(re/t),s=[];s.push(new c(e[0].x,e[0].y));let l=e.length,u=n?l:l-1;for(let t=0;t<u;t++){let i=e[t],r=t<l-1?e[t+1]:e[0],a=i.x,n=i.y,u=r.x,h=r.y,d=a!==u,p=n!==h;if(!d&&!p)continue;let f=u-a,m=h-n,g=Math.abs(f),_=Math.abs(m),y=a,x=n;for(;;){let e=f>0?(Math.floor(y/o)+1)*o:(Math.ceil(y/o)-1)*o,t=m>0?(Math.floor(x/o)+1)*o:(Math.ceil(x/o)-1)*o,i=Math.abs(y-e),r=Math.abs(x-t),a=Math.abs(y-u),n=Math.abs(x-h),l=d?i/g:1/0,v=p?r/_:1/0;if((a<=i||!d)&&(n<=r||!p))break;if(l<v&&d||!p){y=e,x+=m*l;let t=new c(y,Math.round(x));(s[s.length-1].x!==t.x||s[s.length-1].y!==t.y)&&s.push(t)}else{y+=f*v,x=t;let e=new c(Math.round(y),x);(s[s.length-1].x!==e.x||s[s.length-1].y!==e.y)&&s.push(e)}}let v=new c(u,h);(s[s.length-1].x!==v.x||s[s.length-1].y!==v.y)&&s.push(v)}return s}function _h(e,t,i){if(0===t.length)throw Error("Subdivision vertex ring is empty.");let r=0,a=e[2*t[0]];for(let i=1;i<t.length;i++){let n=e[2*t[i]];n<a&&(a=n,r=i)}let n=t.length,o=r,s=(o+1)%n;for(;;){let r=o-1>=0?o-1:n-1,a=(s+1)%n,l=e[2*t[r]],u=e[2*t[r]+1],h=e[2*t[a]],c=e[2*t[a]+1],d=e[2*t[o]],p=e[2*t[o]+1],f=e[2*t[s]],m=e[2*t[s]+1],g=!1;if(l<h)g=!0;else if(l>h)g=!1;else{let e=m-p,t=-(f-d),i=p<m?1:-1;((l-d)*e+(u-p)*t)*i>((h-d)*e+(c-p)*t)*i&&(g=!0)}if(g){let e=t[r],a=t[o],l=t[s];e!==a&&e!==l&&a!==l&&i.push(l,a,e),o--,o<0&&(o=n-1)}else{let e=t[a],r=t[o],l=t[s];e!==r&&e!==l&&r!==l&&i.push(l,r,e),s++,s>=n&&(s=0)}if(r===a)break}}function yh(e,t,i,r,a,n,o,s,l){let u=a.length/2,h=o&&s&&l;if(u<Ns.MAX_VERTEX_ARRAY_LENGTH){let c,d,p=t.prepareSegment(u,i,r),f=p.vertexLength;for(let e=0;e<n.length;e+=3)r.emplaceBack(f+n[e],f+n[e+1],f+n[e+2]);p.vertexLength+=u,p.primitiveLength+=n.length/3,h&&(d=o.prepareSegment(u,i,s),c=d.vertexLength,d.vertexLength+=u);for(let t=0;t<a.length;t+=2)e(a[t],a[t+1]);if(h)for(let e of l){for(let t=1;t<e.length;t+=2)s.emplaceBack(c+e[t-1],c+e[t]);d.primitiveLength+=e.length/2}}else(function(e,t,i,r,a,n){let o=[];for(let e=0;e<r.length/2;e++)o.push(-1);let s={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),h=u.vertexLength;for(let c=2;c<a.length;c+=3){let d=a[c-2],p=a[c-1],f=a[c],m=o[d]<l,g=o[p]<l,_=o[f]<l,y=+!!m+ +!!g+ +!!_;u.vertexLength+y>Ns.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=s.count,m=!0,g=!0,_=!0,h=0);let x=xh(o,r,n,s,d,m,u),v=xh(o,r,n,s,p,g,u),b=xh(o,r,n,s,f,_,u);i.emplaceBack(h+x-l,h+v-l,h+b-l),u.primitiveLength++}})(t,i,r,a,n,e),h&&function(e,t,i,r,a,n){let o=[];for(let e=0;e<r.length/2;e++)o.push(-1);let s={count:0},l=0,u=e.getOrCreateLatestSegment(t,i),h=u.vertexLength;for(let c of a)for(let a=1;a<c.length;a+=2){let d=c[a-1],p=c[a],f=o[d]<l,m=o[p]<l,g=+!!f+ +!!m;u.vertexLength+g>Ns.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,i),l=s.count,f=!0,m=!0,h=0);let _=xh(o,r,n,s,d,f,u),y=xh(o,r,n,s,p,m,u);i.emplaceBack(h+_-l,h+y-l),u.primitiveLength++}}(o,i,s,a,l,e),t.forceNewSegmentOnNextPrepare(),o?.forceNewSegmentOnNextPrepare()}function xh(e,t,i,r,a,n,o){if(n){let n=r.count;return i(t[2*a],t[2*a+1]),e[a]=r.count,r.count++,o.vertexLength++,n}return e[a]}var vh=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.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new Ts,this.indexArray=new Ls,this.indexArray2=new Bs,this.programConfigurations=new yl(e.layers,e.zoom),this.segments=new Ns,this.segments2=new Ns,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Tu("fill",this.layers,t);let r=this.layers[0].layout.get("fill-sort-key"),a=!r.isConstant(),n=[],o=new so(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:u,index:h,sourceLayerIndex:c}of e){let e=Dl(l,s);if(!this.layers[0]._featureFilter.filter(o,e,i))continue;let d=a?r.evaluate(e,{},i,t.availableImages):void 0,p={id:u,properties:l.properties,type:l.type,sourceLayerIndex:c,index:h,geometry:s?e.geometry:Tl(l),patterns:{},sortKey:d};n.push(p)}a&&n.sort((e,t)=>e.sortKey-t.sortKey);for(let r of n){let{geometry:a,index:n,sourceLayerIndex:o}=r;if(this.hasDependencies){let e=Du("fill",this.layers,r,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(r,a,n,i,{},t.subdivisionGranularity);let s=e[n].feature;t.featureIndex.insert(s,a,n,o,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures({options:e,canonical:t,patternPositions:i,patternMap:r}){this.detectSdfPatterns(r);for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,e.subdivisionGranularity)}detectSdfPatterns(e){for(let t of this.patternFeatures)for(let i in t.patterns){let r=t.patterns[i];this.recordSdfPattern(i,e[r.min]),this.recordSdfPattern(i,e[r.mid]),this.recordSdfPattern(i,e[r.max])}for(let t of this.layers){let i=t.paint.get("fill-pattern").constantOr(null);i&&(this.recordSdfPattern(t.id,e[i.from.toString()]),this.recordSdfPattern(t.id,e[i.to.toString()]))}}recordSdfPattern(e,t){if(!t)return;let i=!0===t.sdf,r=this.sdfPatterns[e];void 0===r?this.sdfPatterns[e]=i:r!==i&&Oe(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${e}"`)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,r,a,n){for(let e of $i(t,500)){let t=mh(e,r,n.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;yh((e,t)=>{i.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,i,{imagePositions:a,canonical:r})}};let bh,wh;eo("FillBucket",vh,{omit:["layers","patternFeatures"]});var Th={get paint(){return wh||=new Do({"fill-antialias":new xo(vt.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new vo(vt.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new xo(vt.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new vo(vt.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new vo(vt.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new xo(vt.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new xo(vt.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new bo(vt.paint_fill["fill-pattern"],"fill-pattern")})},get layout(){return bh||=new Do({"fill-sort-key":new vo(vt.layout_fill["fill-sort-key"],"fill-sort-key")})}},Dh=class extends Po{constructor(e,t){super(e,Th,t)}recalculate(e,t){super.recalculate(e,t);let i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new vh(e)}queryRadius(){return Vl(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:r}){return Cl(Nl(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),t)}isTileClipped(){return!0}};const Eh=ko([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Sh=ko([{name:"a_centroid",components:2,type:"Int16"}],4),Ph=Eh.members;Eh.size,Eh.alignment;var Ih=class e{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(t){let i=new e;return i.extend(t(new c(this.minX,this.minY))),i.extend(t(new c(this.maxX,this.minY))),i.extend(t(new c(this.minX,this.maxY))),i.extend(t(new c(this.maxX,this.maxY))),i}static fromPoints(t){let i=new e;for(let e of t)i.extend(e);return i}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}};const Ah=Ih.fromPoints([new c(0,0),new c(re,re)]);function Ch(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function Mh(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)}var zh=class{constructor(e,t,i,r,a){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=a;e.pos<t;){let t=e.readVarint();if(8===t)this.id=e.readVarint();else if(18===t){let t=e.readVarint()+e.pos;for(;e.pos<t;){let t=r[e.readVarint()],i=a[e.readVarint()];this.properties[t]=i}}else 24===t?this.type=e.readVarint():(34===t&&(this._geometry=e.pos),e.skip(t))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t,i=e.readVarint()+e.pos,r=[],a=1,n=0,o=0,s=0;for(;e.pos<i;){if(n<=0){let t=e.readVarint();if(a=7&t,n=t>>3,0===n)continue}if(n--,1===a)o+=e.readSVarint(),s+=e.readSVarint(),t&&r.push(t),t=[new c(o,s)];else if(2===a)o+=e.readSVarint(),s+=e.readSVarint(),t&&t.push(new c(o,s));else{if(7!==a)throw Error(`unknown command ${a}`);t&&t.push(t[0].clone())}}return t&&r.push(t),r}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,i=1,r=0,a=0,n=0,o=1/0,s=-1/0,l=1/0,u=-1/0;for(;e.pos<t;){if(r<=0){let t=e.readVarint();if(i=7&t,r=t>>3,0===r)continue}if(r--,1===i||2===i)a+=e.readSVarint(),n+=e.readSVarint(),a<o&&(o=a),a>s&&(s=a),n<l&&(l=n),n>u&&(u=n);else if(7!==i)throw Error(`unknown command ${i}`)}return[o,l,s,u]}toGeoJSON(e,t,i){let r,a=this.extent*2**i,n=this.extent*e,o=this.extent*t,s=this.loadGeometry();function l(e){return[360*(e.x+n)/a-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/a)*Math.PI))-90]}function u(e){return e.map(l)}if(1===this.type){let e=[];for(let t of s)e.push(t[0]);let t=u(e);r=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){let e=s.map(u);r=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw Error("unknown feature type");{let e=Fh(s),t=[];for(let i of e)t.push(i.map(u));r=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}}let h={type:"Feature",geometry:r,properties:this.properties};return null!=this.id&&(h.id=this.id),h}};function Fh(e){let t=e.length;if(t<=1)return[e];let i,r,a=[];for(let n=0;n<t;n++){let t=Rh(e[n]);0!==t&&(void 0===r&&(r=t<0),r===t<0?(i&&a.push(i),i=[e[n]]):i&&i.push(e[n]))}return i&&a.push(i),a}function Rh(e){let t=0;for(let i,r,a=0,n=e.length,o=n-1;a<n;o=a++)i=e[a],r=e[o],t+=(r.x-i.x)*(i.y+r.y);return t}zh.types=["Unknown","Point","LineString","Polygon"];var kh=class{constructor(e,t){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],void 0===t&&(t=e.length);e.pos<t;){let t=e.readVarint();10===t?this.name=e.readString():18===t?(this._features.push(e.pos),e.skip(t)):26===t?this._keys.push(e.readString()):34===t?this._values.push(Lh(e)):40===t?this.extent=e.readVarint():120===t?this.version=e.readVarint():e.skip(t)}this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new zh(this._pbf,t,this.extent,this._keys,this._values)}};function Lh(e){let t=null,i=e.readVarint()+e.pos;for(;e.pos<i;){let i=e.readVarint();t=10===i?e.readString():21===i?e.readFloat():25===i?e.readDouble():32===i?e.readVarint(!0):40===i?e.readVarint():48===i?e.readSVarint():56===i?e.readBoolean():(e.skip(i),null)}if(null==t)throw Error("unknown feature value");return t}var Bh=class{constructor(e,t=e.length){let i=Object.create(null);for(;e.pos<t;){let t=e.readVarint();if(26===t){let t=new kh(e,e.readVarint()+e.pos);t.length&&(i[t.name]=t)}else e.skip(t)}this.layers=i}};const Oh=6371008.8;var jh=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(Ee(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,i=this.lat*t,r=e.lat*t,a=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return Oh*Math.acos(Math.min(a,1))}static convert(t){if(t instanceof e)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new e(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&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: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};const Vh=2*Math.PI*Oh;function Nh(e){return Vh*Math.cos(e*Math.PI/180)}function Uh(e){return(180+e)/360}function $h(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Gh(e,t){return e/Nh(t)}function Zh(e){return 360*e-180}function qh(e){let t=180-360*e;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function Wh(e,t){return e*Nh(qh(t))}var Xh=class e{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(t,i=0){let r=jh.convert(t);return new e(Uh(r.lng),$h(r.lat),Gh(i,r.lat))}toLngLat(){return new jh(Zh(this.x),qh(this.y))}toAltitude(){return Wh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Vh*function(e){return 1/Math.cos(e*Math.PI/180)}(qh(this.y))}};const Hh=89.25;function Yh(e,t,i){let r=1/(1<<i.z);return new Xh(e/re*r+i.x*r,t/re*r+i.y*r)}function Kh(e,t){let i=De(t.lat,-85.051129,He);return new c(Uh(t.lng)*e,$h(i)*e)}function Jh(e,t){return new Xh(t.x/e,t.y/e).toLngLat()}function Qh(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(Ge(90-e.pitch)),Math.tan(Ge(Hh-e.pitch)))}function ec(e,t){let i=e.canonical,r=t/Ce(i.z),a=i.x+2**i.z*e.wrap,n=new Float64Array(16);return v(n),T(n,n,[a*r,i.y*r,0]),D(n,n,[r/re,r/re,1]),n}function tc(e,t,i,r,a){let n=Xh.fromLngLat(e,t),o=a*Gh(1,e.lat),{x:s,y:l,z:u}=ic(i,r),h=o*-s,c=o*-l,d=o*u;return new Xh(n.x+h,n.y+c,n.z+d)}function ic(e,t){let i=Ge(e),r=Ge(t),a=Math.cos(-i),n=Math.sin(i);return{x:n*Math.sin(r),y:-n*Math.cos(r),z:a}}function rc(e,t,i){if(t<=0||!e||0===e.length)return e;let r=function(e,t){let i=function(e,t,i){return Yh(4096,4096,i).toLngLat()}(0,0,t);return e*Xh.fromLngLat(i).meterInMercatorCoordinateUnits()*((1<<t.z)*re)}(t,i);return e.map(e=>function(e,t){if(!e||e.length<3)return e;let i=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=i?e.length-1:e.length;if(r<3)return e;let a=[];for(let i=0;i<r;i++){let n=e[(i-1+r)%r],o=e[i],s=e[(i+1)%r];Ch(n,o)||Ch(o,s)?a.push(o.clone()):ac(a,n,o,s,t)}let n=function(e){let t=[];for(let i of e){let e=i.round(),r=t[t.length-1];(r?.x!==e.x||r?.y!==e.y)&&t.push(e)}for(;t.length>1&&t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y;)t.pop();return t}(a);return n.length<3?e:(i&&n.push(n[0].clone()),n)}(e,r))}function ac(e,t,i,r,a){let n=t.sub(i),o=r.sub(i),s=n.mag(),l=o.mag();if(s<1e-6||l<1e-6)return void e.push(i.clone());n._div(s),o._div(l);let u=n.x*o.x+n.y*o.y;if(Math.abs(u)>Math.cos(5*Math.PI/180))return void e.push(i.clone());let h=Math.min(a,.2*s,.2*l),c=i.add(n.mult(h)),d=i.add(o.mult(h)),p=Math.sqrt((1+u)/2),f=i.add(n.add(o)._unit()._mult(h/p)),m=c.sub(f).angleWith(d.sub(f)),g=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/6)-1e-6));for(let t=0;t<=g;t++)e.push(c.rotateAround(t/g*m,f))}const nc=8192;function oc(e,t,i,r,a,n,o,s){e.emplaceBack(t,i,2*Math.floor(r*nc)+o,a*nc*2,n*nc*2,Math.round(s))}var sc=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 Ds,this.centroidVertexArray=new xs,this.indexArray=new Ls,this.programConfigurations=new yl(e.layers,e.zoom),this.segments=new Ns,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=Tu("fill-extrusion",this.layers,t);let r=new so(this.zoom),a=this.layers[0],n=a.layout.get("fill-extrusion-rounded-corner-distance"),o=a._featureFilter.needGeometry;for(let{feature:s,id:l,index:u,sourceLayerIndex:h}of e){let e=Dl(s,o);if(!a._featureFilter.filter(r,e,i))continue;let c=o?e.geometry:Tl(s),d={id:l,sourceLayerIndex:h,index:u,geometry:n>0?rc(c,n,i):c,properties:s.properties,type:s.type,patterns:{}};this.hasDependencies?this.features.push(Du("fill-extrusion",this.layers,d,{zoom:this.zoom},t)):this.addFeature(d,d.geometry,u,i,{},t.subdivisionGranularity),t.featureIndex.insert(s,d.geometry,u,h,this.index,!0)}}addFeatures({options:e,canonical:t,patternPositions:i}){for(let r of this.features){let{geometry:a}=r;this.addFeature(r,a,r.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ph),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Sh.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,r,a,n){let o=this.layers[0],s=o.layout?o.layout.get("fill-extrusion-rounded-corner-distance"):0,l=s>0?rc(t,s,r):t;for(let t of $i(l,500)){let i={x:0,y:0,sampleCount:0},a=this.layoutVertexArray.length;this.processPolygon(i,r,e,t,n);let o=this.layoutVertexArray.length-a,s=Math.floor(i.x/i.sampleCount),l=Math.floor(i.y/i.sampleCount);for(let e=0;e<o;e++)this.centroidVertexArray.emplaceBack(s,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,canonical:r})}processPolygon(e,t,i,r,a){if(r.length<1||Mh(r[0]))return;for(let t of r)0!==t.length&&lc(e,t);let n={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=a.fill.getGranularityForZoomLevel(t.z),s="Polygon"===zh.types[i.type];for(let e of r){if(0===e.length||Mh(e))continue;let t=gh(e,o,s);this._generateSideFaces(t,n)}if(!s)return;let l=mh(r,t,o,!1),u=this.layoutVertexArray;yh((e,t)=>{oc(u,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let r=1;r<e.length;r++){let a=e[r],n=e[r-1];if(Ch(a,n))continue;t.segment.vertexLength+4>Ns.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=a.sub(n)._perp()._unit(),s=n.dist(a);i+s>32768&&(i=0),oc(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,0,i),oc(this.layoutVertexArray,a.x,a.y,o.x,o.y,0,1,i),i+=s,oc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,i),oc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,1,i);let l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}};function lc(e,t){for(let i=0;i<t.length;i++){let r=t[i];(i!==t.length-1||t[0].x!==r.x||t[0].y!==r.y)&&(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}let uc,hc;eo("FillExtrusionBucket",sc,{omit:["layers","features"]});var cc={get paint(){return hc||=new Do({"fill-extrusion-opacity":new xo(vt["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new vo(vt["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new xo(vt["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new xo(vt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new bo(vt["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new vo(vt["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new vo(vt["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new xo(vt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})},get layout(){return uc||=new Do({"fill-extrusion-rounded-corner-distance":new xo(vt["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})}},dc=class extends Po{constructor(e,t){super(e,cc,t)}createBucket(e){return new sc(e)}queryRadius(){return Vl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n,pixelPosMatrix:o}){let s=Nl(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-a.bearingInRadians,n),l=this.paint.get("fill-extrusion-height").evaluate(t,i),u=this.paint.get("fill-extrusion-base").evaluate(t,i),h=function(e,t){let i=[];for(let r of e){let e=[r.x,r.y,0,1];W(e,e,t),i.push(new c(e[0]/e[3],e[1]/e[3]))}return i}(s,o),d=function(e,t,i,r){let a=[],n=[],o=r[8]*t,s=r[9]*t,l=r[10]*t,u=r[11]*t,h=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(let t of e){let e=[],i=[];for(let a of t){let t=a.x,n=a.y,m=r[0]*t+r[4]*n+r[12],g=r[1]*t+r[5]*n+r[13],_=r[2]*t+r[6]*n+r[14],y=r[3]*t+r[7]*n+r[15],x=_+l,v=y+u,b=m+h,w=g+d,T=_+p,D=y+f,E=new c((m+o)/v,(g+s)/v);E.z=x/v,e.push(E);let S=new c(b/D,w/D);S.z=T/D,i.push(S)}a.push(e),n.push(i)}return[a,n]}(r,u,l,o);return function(e,t,i){let r=1/0;Cl(i,t)&&(r=fc(i,t[0]));for(let a=0;a<t.length;a++){let n=t[a],o=e[a];for(let e=0;e<n.length-1;e++){let t=n[e],a=n[e+1],s=o[e],l=[t,a,o[e+1],s,t];Il(i,l)&&(r=Math.min(r,fc(i,l)))}}return r!==1/0&&r}(d[0],d[1],h)}};function pc(e,t){return e.x*t.x+e.y*t.y}function fc(e,t){if(1===e.length){let i,r=0,a=t[r++];for(;!i||a.equals(i);)if(i=t[r++],!i)return 1/0;for(;r<t.length;r++){let n=t[r],o=e[0],s=i.sub(a),l=n.sub(a),u=o.sub(a),h=pc(s,s),c=pc(s,l),d=pc(l,l),p=pc(u,s),f=pc(u,l),m=h*d-c*c,g=(d*p-c*f)/m,_=(h*f-c*p)/m,y=1-g-_,x=a.z*y+i.z*g+n.z*_;if(isFinite(x))return x}return 1/0}{let e=1/0;for(let i of t)e=Math.min(e,i.z);return e}}new Uint32Array(96);const mc=ko([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),gc=mc.members;mc.size,mc.alignment;const _c=ko([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),yc=_c.members;_c.size,_c.alignment;const xc=Math.cos(Math.PI/180*37.5);var vc=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 Es,this.layoutVertexArray2=new Ss,this.indexArray=new Ls,this.programConfigurations=new yl(e.layers,e.zoom),this.segments=new Ns,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Tu("line",this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),a=!r.isConstant(),n=[],o=new so(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:t,id:l,index:u,sourceLayerIndex:h}of e){let e=Dl(t,s);if(!this.layers[0]._featureFilter.filter(o,e,i))continue;let c=a?r.evaluate(e,{},i):void 0,d={id:l,properties:t.properties,type:t.type,sourceLayerIndex:h,index:u,geometry:s?e.geometry:Tl(t),patterns:{},dashes:{},sortKey:c};n.push(d)}a&&n.sort((e,t)=>e.sortKey-t.sortKey);for(let r of n){let{geometry:a,index:n,sourceLayerIndex:o}=r;this.hasDependencies?(Tu("line",this.layers,t)?Du("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,a,n,i,{},{},t.subdivisionGranularity);let s=e[n].feature;t.featureIndex.insert(s,a,n,o,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures({options:e,canonical:t,patternPositions:i,dashPositions:r}){for(let a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,i,r,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,yc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.hasOwn(e.properties,"geojsonvt_clip_start")&&Object.hasOwn(e.properties,"geojsonvt_clip_end"))return{start:+e.properties.geojsonvt_clip_start,end:+e.properties.geojsonvt_clip_end}}addFeature(e,t,i,r,a,n,o){let s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),u=s.get("line-cap").evaluate(e,{}),h=s.get("line-miter-limit").evaluate(e,{}),c=s.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let i of t)this.addLine(i,e,l,u,h,c,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:a,dashPositions:n,canonical:r})}addLine(e,t,i,r,a,n,o,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=gh(e,o?s.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let l="Polygon"===zh.types[t.type],u=e.length;for(;u>=2&&e[u-1].equals(e[u-2]);)u--;let h=0;for(;h<u-1&&e[h].equals(e[h+1]);)h++;if(u-h<(l?3:2))return;"bevel"===i&&(a=1.05);let c,d,p,f,m,g=this.overscaling<=16?15*re/(512*this.overscaling):0,_=this.segments.prepareSegment(10*u,this.layoutVertexArray,this.indexArray);this.e1=this.e2=-1,l&&(c=e[u-2],m=e[h].sub(c)._unit()._perp());for(let t=h;t<u;t++){if(p=t===u-1?l?e[h+1]:void 0:e[t+1],p&&e[t].equals(p))continue;m&&(f=m),c&&(d=c),c=e[t],m=p?p.sub(c)._unit()._perp():f,f||=m;let o=f.add(m);(0!==o.x||0!==o.y)&&o._unit();let s=f.x*m.x+f.y*m.y,y=o.x*m.x+o.y*m.y,x=0===y?1/0:1/y,v=2*Math.sqrt(2-2*y),b=y<xc&&d&&p,w=f.x*m.y-f.y*m.x>0;if(b&&t>h){let e=c.dist(d);if(e>2*g){let t=c.sub(c.sub(d)._mult(g/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,f,0,0,_),d=t}}let T=d&&p,D=T?i:l?"butt":r;if(T&&"round"===D&&(x<n?D="miter":x<=2&&(D="fakeround")),"miter"===D&&x>a&&(D="bevel"),"bevel"===D&&(x>2&&(D="flipbevel"),x<a&&(D="miter")),d&&this.updateDistance(d,c),"miter"===D)o._mult(x),this.addCurrentVertex(c,o,0,0,_);else if("flipbevel"===D){if(x>100)o=m.mult(-1);else{let e=x*f.add(m).mag()/f.sub(m).mag();o._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(c,o,0,0,_),this.addCurrentVertex(c,o.mult(-1),0,0,_)}else if("bevel"===D||"fakeround"===D){let e=-Math.sqrt(x*x-1),t=w?e:0,i=w?0:e;if(d&&this.addCurrentVertex(c,f,t,i,_),"fakeround"===D){let e=Math.round(180*v/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){let e=i-.5;i+=i*e*(i-1)*((1.0904+s*(s*(3.55645-1.43519*s)-3.2452))*e*e+(.848013+s*(.215638*s-1.06021)))}let r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(c,r.x,r.y,!1,w,0,_)}}p&&this.addCurrentVertex(c,m,-t,-i,_)}else if("butt"===D)this.addCurrentVertex(c,o,0,0,_);else if("square"===D){let e=d?1:-1;this.addCurrentVertex(c,o,e,e,_)}else"round"===D&&(d&&(this.addCurrentVertex(c,f,0,0,_),this.addCurrentVertex(c,f,1,1,_,!0)),p&&(this.addCurrentVertex(c,m,-1,-1,_,!0),this.addCurrentVertex(c,m,0,0,_)));if(b&&t<u-1){let e=c.dist(p);if(e>2*g){let t=c.add(p.sub(c)._mult(g/e)._round());this.updateDistance(c,t),this.addCurrentVertex(t,m,0,0,_),c=t}}}}addCurrentVertex(e,t,i,r,a,n=!1){let o=t.x+t.y*i,s=t.y-t.x*i,l=-t.x+t.y*r,u=-t.y-t.x*r;this.addHalfVertex(e,o,s,n,!1,i,a),this.addHalfVertex(e,l,u,n,!0,-r,a),this.distance>16384&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,a,n))}addHalfVertex({x:e,y:t},i,r,a,n,o,s){let l=.5*(this.lineClips?32767*this.scaledDistance:this.scaledDistance);if(this.layoutVertexArray.emplaceBack(+!!a+(e<<1),+!!n+(t<<1),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips){let e=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(e,this.lineClipsArray.length)}let u=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),s.primitiveLength++),n?this.e2=u:this.e1=u}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(let t of e){let e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,r){for(let a of e){let e=a.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;let n="round"===a.layout.get("line-cap").evaluate(t,{}),o={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:n},s={dasharray:e.value.evaluate({zoom:i},t,{}),round:n},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:n},u=`${o.dasharray.join(",")},${o.round}`,h=`${s.dasharray.join(",")},${s.round}`,c=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[u]=o,r.dashDependencies[h]=s,r.dashDependencies[c]=l,t.dashes[a.id]={min:u,mid:h,max:c}}}};let bc,wc;eo("LineBucket",vc,{omit:["layers","patternFeatures"]});var Tc={get paint(){return wc||=new Do({"line-opacity":new vo(vt.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new xo(vt.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new vo(vt.paint_line["line-color"],"line-color"),"line-translate":new xo(vt.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new xo(vt.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new vo(vt.paint_line["line-width"],"line-width"),"line-gap-width":new vo(vt.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new vo(vt.paint_line["line-offset"],"line-offset"),"line-blur":new vo(vt.paint_line["line-blur"],"line-blur"),"line-dasharray":new bo(vt.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new bo(vt.paint_line["line-pattern"],"line-pattern"),"line-gradient":new To(vt.paint_line["line-gradient"],"line-gradient")})},get layout(){return bc||=new Do({"line-cap":new vo(vt.layout_line["line-cap"],"line-cap"),"line-join":new vo(vt.layout_line["line-join"],"line-join"),"line-miter-limit":new vo(vt.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new vo(vt.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new vo(vt.layout_line["line-sort-key"],"line-sort-key")})}},Dc=class extends vo{possiblyEvaluate(e,t){return t=new so(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=Se({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}};let Ec;var Sc=class extends Po{constructor(e,t){super(e,Tc,t),this.gradientVersion=0,Ec||(Ec=new Dc(Tc.paint.properties["line-width"].specification,"line-floorwidth"),Ec.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){let e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof ki,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"]=Ec.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new vc(e)}queryRadius(e){let t=e,i=Pc(jl("line-width",this,t),jl("line-gap-width",this,t)),r=jl("line-offset",this,t);return i/2+Math.abs(r)+Vl(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:a,pixelsToTileUnits:n}){let o=Nl(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-a.bearingInRadians,n),s=n/2*Pc(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=function(e,t){let i=[];for(let r of e){let e=Ul(r),a=[];for(let i=0;i<e.length;i++){let r=e[i],n=e[i-1],o=e[i+1],s=0===i?new c(0,0):r.sub(n)._unit()._perp(),l=i===e.length-1?new c(0,0):o.sub(r)._unit()._perp(),u=s._add(l)._unit(),h=u.x*l.x+u.y*l.y;0!==h&&u._mult(1/h),a.push(u._mult(t)._add(r))}i.push(a)}return i}(r,l*n)),function(e,t,i){for(let r of t){if(e.length>=3)for(let t of r)if(Bl(e,t))return!0;if(Ml(e,r,i))return!0}return!1}(o,r,s)}isTileClipped(){return!0}};function Pc(e,t){return t>0?t+2*e:e}const Ic=ko([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_height_offset",components:1,type:"Float32"}],4),Ac=ko([{name:"a_projected_pos",components:3,type:"Float32"}],4);ko([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Cc=ko([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);ko([{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 Mc=ko([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),zc=ko([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ko([{name:"triangle",components:3,type:"Uint16"}]),ko([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Float32",name:"heightOffset"}]),ko([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"},{type:"Float32",name:"heightOffset"}]),ko([{type:"Float32",name:"offsetX"}]),ko([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),ko([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Fc=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(Fc.isParsed())throw Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(e,t){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;let i=e.pluginURL,r=new Promise(e=>{this.loadScriptResolve=e}),a=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(await t(i),await Promise.race([r,a]),this.isParsed()){let e={pluginStatus:"loaded",pluginURL:i};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${i}`)}};function Rc(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function kc(e){return/[\u02EA\u02EB\u1100-\u11FF\u1401-\u167F\u18B0-\u18FF\u2065\u20DD-\u20E0\u20E2-\u20E4\u2B97\u2BF0-\u2BFF\u2E50\u2E51\u2E80-\u3007\u3012\u3013\u3020-\u302F\u3031-\u30FB\u30FD-\uA4CF\uA960-\uA97F\uAC00-\uD7FF\uF900-\uFAFF\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7\uFFF0-\uFFF8]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|[\uD80C-\uD810\uD81C-\uD822\uD83C\uD83D\uD840-\uD87E\uD880-\uD8BE][\uDC00-\uDFFF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFFF]|\uD823[\uDC00-\uDDFF]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFF]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83E[\uDD00-\uDEFF]|[\uD87F\uD8BF][\uDC00-\uDFFD]/gim.test(String.fromCodePoint(e))}function Lc(e){return/[\u0E01-\u0E3A\u0E40-\u0E4E\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0EDC-\u0EDF\u0F00-\u0F47\u0F49-\u0F6C\u0F71-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FD4\u0FD9\u0FDA\u1000-\u103F\u1050-\u108F\u109A-\u109F\u1780-\u17D3\u17D7\u17DC\u17DD\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19DE\u19DF\u1A20-\u1A5E\u1A60-\u1A7C\u1AA0-\u1AAD\u1B00-\u1B4C\u1B4E-\u1B7F\uA980-\uA9CD\uA9D0-\uA9D9\uA9DE-\uA9EF\uA9FA-\uA9FE\uAA60-\uAAC2\uAADB-\uAADF]|\uD805[\uDF00-\uDF1A\uDF1D-\uDF2B\uDF3A\uDF3B\uDF3F-\uDF46]/gim.test(String.fromCodePoint(e))}function Bc(e,t){return/(?:[\u1039\u17D2\u1A60\u1BAB\u200D\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807[\uDD45\uDD97\uDF42])$/.test(e)||/^\p{gc=Mc}/u.test(t)}const Oc={C:"18g,1;g2,3;4nb,1",D:"17k,1;5,1;1,1;1,5;4,d;1,7;1,2;z,2;8,g;i,12;1,2;9,1;1,1;1,2;14,3;2,1;28,9;3,f;2,4;1,1;2,3;2,6;7a,1;2,5;1,1;g,a;5,2;2,6;1,f",R:"17m,4;1,1;1,1;5,4;l,1;14,3;1,3;g,i;12,1;2,9;1,1;1,1;2,2;1,1;o,2;2x,3;f,2;4,1;1,2;3,2;6u,j;b,1;r,3;1,1;2,2;6,1",T:"174,b;1,1;1a,l;g,1;2t,7;2,6;2,2;1,4;bt,9;16,o;1,t;1clb,1"},jc={1569:[65152,0,0,0],1570:[65153,65154,0,0],1571:[65155,65156,0,0],1572:[65157,65158,0,0],1573:[65159,65160,0,0],1574:[65161,65162,65163,65164],1575:[65165,65166,0,0],1576:[65167,65168,65169,65170],1577:[65171,65172,0,0],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194,0,0],1584:[65195,65196,0,0],1585:[65197,65198,0,0],1586:[65199,65200,0,0],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262,0,0],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1611:[65136,0,0,65137],1612:[65138,0,0,0],1613:[65140,0,0,0],1614:[65142,0,0,65143],1615:[65144,0,0,65145],1616:[65146,0,0,65147],1617:[65148,0,0,65149],1618:[65150,0,0,65151],1649:[64336,64337,0,0],1655:[64477,0,0,0],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393,0,0],1676:[64388,64389,0,0],1677:[64386,64387,0,0],1678:[64390,64391,0,0],1681:[64396,64397,0,0],1688:[64394,64395,0,0],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415,0,0],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421,0,0],1729:[64422,64423,64424,64425],1733:[64480,64481,0,0],1734:[64473,64474,0,0],1735:[64471,64472,0,0],1736:[64475,64476,0,0],1737:[64482,64483,0,0],1739:[64478,64479,0,0],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431,0,0],1747:[64432,64433,0,0]},Vc={لآ:[65269,65270],لأ:[65271,65272],لإ:[65273,65274],لا:[65275,65276]},Nc=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function Uc(e,t,i){let r=0;for(let a of e.split(";")){let[e,n]=a.split(",").map(e=>parseInt(e,36)),o=r+e;for(let e=o;e<o+n;e++)i.set(e,t);r=o+n}}const $c=new Map;for(let[e,t]of Object.entries(Oc))Uc(t,e,$c);function Gc(e){return $c.get(e)??"U"}function Zc(e){return"D"===e||"L"===e||"C"===e}function qc(e){return"D"===e||"R"===e||"C"===e}function Wc(e,t,i){return"D"===e?t&&i?3:t?1:i?2:0:"R"===e?+!!t:"L"===e?i?2:0:null}function Xc(e){if(!Nc.test(e))return e;let t=function(e){return[...e].map(e=>{let t=e.codePointAt(0);return{codePoint:t,type:Gc(t),form:null}})}(e);return function(e){let t=e.filter(e=>"T"!==e.type);for(let e=0;e<t.length;e++){let i=t[e],r=e>0&&Zc(t[e-1].type),a=e+1<t.length&&qc(t[e+1].type);i.form=Wc(i.type,r,a)}}(t),function(e){let t=!1;for(let i of e)"T"===i.type?i.form=t?3:0:t=2===i.form||3===i.form}(t),function(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(1604!==r.codePoint){t.push(r);continue}let a=i+1;for(;a<e.length&&"T"===e[a].type;)a++;let n=e[a],o=n&&Vc[String.fromCodePoint(1604,n.codePoint)];if(!o){t.push(r);continue}let s=3===r.form||1===r.form;t.push({codePoint:o[+!!s],type:"R",form:0}),t.push(...e.slice(i+1,a)),i=a}return t}(t).map(e=>String.fromCodePoint(function(e){if(null===e.form)return e.codePoint;let t=jc[e.codePoint];return t&&(t[e.form]||t[0])||e.codePoint}(e))).join("")}function Hc(e,t,i){let r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),(Fc.applyArabicShaping??Xc)(e)}function Yc(e,t,i){for(let r of e.sections)r.text=Hc(r.text,t,i);return e}const Kc=typeof Intl<"u"&&"Segmenter"in Intl;let Jc,Qc;function ed(e){if(!Kc||!function(e){return/[\r\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0600-\u0605\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DD\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0890\u0891\u0897-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E33-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB3-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1037\u1039-\u103E\u1056-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1084-\u1086\u108D\u109D\u1100-\u11FF\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60\u1A62\u1A65-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA960-\uA97C\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCBD\uDCC2\uDCCD\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC2\uDDC3\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDE41\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDFB8-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD2\uDFE1\uDFE2]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF1F\uDF22-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE84-\uDE99\uDF60-\uDF67]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6\uDF00-\uDF03\uDF34-\uDF3A\uDF3E-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDD63\uDD67-\uDD6A\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDDE6-\uDDFF\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF]/.test(e)}(e))return[...e];Jc??=new Intl.Segmenter(void 0,{granularity:"grapheme"});let t=[];for(let{segment:i}of Jc.segment(e)){let e=t.length-1;e>=0&&Bc(t[e],i)?t[e]+=i:t.push(i)}return t}function td(e){let t=new Set;if(Kc){Qc??=new Intl.Segmenter(void 0,{granularity:"word"});for(let{index:i}of Qc.segment(e))t.add(i);return t}let i=0;for(let r of e.split(/\b|(?=\p{Ideo})/u))t.add(i),i+=r.length;return t}function id(e){let t=e.codePointAt(0);return e.length>(t>65535?2:1)}function rd(e){return/\s/u.test(String.fromCodePoint(e))}function ad(e){for(let t of e)if(kc(t.codePointAt(0)))return!0;return!1}function nd(e){for(let t of e)if(!od(t.codePointAt(0)))return!1;return!0}function od(e){return!function(e){return/[\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u077F\u07C0-\u07FA\u07FD-\u07FF\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\u1800\u1801\u1804\u1806-\u1819\u1820-\u1878\u1880-\u18AA\uA840-\uA877\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF80-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDD00-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDEFF\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB]|\uD805[\uDE60-\uDE6C]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9C-\uDC9F]|\uD83A[\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}(e)}function sd(e){return!(kc(e)||function(e){return/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))}(e))}function ld(e){return/\p{sc=Arab}/u.test(String.fromCodePoint(e))}function ud(e){return function(e){return/[\u0591-\u05C7\u05D0-\u05EA\u05EF-\u05F4\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u07B1\u07C0-\u07FA\u07FD-\u082D\u0830-\u083E\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\uFB1D-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC57-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD1F-\uDD39\uDD3F-\uDD59\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE50-\uDE58\uDE60-\uDE9F\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF00-\uDF35\uDF39-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD85\uDD8E\uDD8F\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB-\uDEAD\uDEB0\uDEB1\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDF27\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}(e)}function hd(e){for(let t of e)if(ud(t.codePointAt(0)))return!0;return!1}const cd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},dd={10:!0,13:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},pd={40:!0};function fd(e,t,i,r,a,n){if("fontStack"in t){let r=i[t.fontStack],n=r?.[e];if(n)return n.metrics.advance*t.scale+a;let o=0;for(let i of e){let e=r?.[i];e&&(o+=e.metrics.advance*t.scale+a)}return o}{let e=r[t.imageName];return e?e.displaySize[0]*t.scale*24/n+a:0}}function md(e,t,i,r){let a=(e-t)**2;return r?e<t?a/2:2*a:a+Math.abs(i)*i}function gd(e){return/^\s+$/u.test(e)}function _d(e,t,i){let r=0;return(10===e||13===e)&&(r-=1e4),i&&(r+=150),(40===e||65288===e)&&(r+=50),(41===t||65289===t)&&(r+=50),r}function yd(e,t,i,r,a,n){let o=null,s=md(t,i,a,n);for(let e of r){let r=md(t-e.x,i,a,n)+e.badness;r<=s&&(o=e,s=r)}return{index:e,x:t,priorBreak:o,badness:s}}function xd(e){return e?xd(e.priorBreak).concat(e.index):[]}var vd=class e{constructor(e="",t=[],i=[]){this.text=e,this.sections=t,this.sectionIndex=i,this.imageSectionID=null,this._graphemes=null}graphemes(){return this._graphemes??=ed(this.text),this._graphemes}static fromFeature(t,i){let r=new e;for(let e of t.sections)e.image?r.addImageSection(e):r.addTextSection(e,i);return r}length(){return this.graphemes().length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=function(e){let t="",i={premature:!0,value:void 0},r=e[Symbol.iterator](),a=r.next(),n=e[Symbol.iterator]();n.next();let o=n.next();for(;!a.done;)!o.done&&sd(o.value.codePointAt(0))&&!cd[o.value]||!i.premature&&sd(i.value.codePointAt(0))&&!cd[i.value]||!cd[a.value]?t+=a.value:t+=cd[a.value],i={value:a.value,premature:!1},a=r.next(),o=n.next();return t}(this.text),this._graphemes=null}hasZeroWidthSpaces(){return this.text.includes("")}trim(){let e=this.graphemes(),t=0;for(;t<e.length&&gd(e[t]);)t++;let i=e.length;for(;i>t&&gd(e[i-1]);)i--;this.text=e.slice(t,i).join(""),this.sectionIndex=this.sectionIndex.slice(t,i),this._graphemes=null}substring(t,i){let r=this.graphemes().slice(t,i).join(""),a=this.sectionIndex.slice(t,i);return new e(r,this.sections,a)}toCodeUnitIndex(e){return this.graphemes().slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,i=0;for(let r=0;r<this.length();r++){let a=this.getSection(r);if("imageName"in a){let r=e[a.imageName];if(!r)continue;let n=r.displaySize;t=Math.max(t,n[0]),i=Math.max(i,n[1])}}return{maxImageWidth:t,maxImageHeight:i}}_appendSection(e,t){let i=this.graphemes(),r=i.length>0?i[i.length-1]:"",a=ed(r+e);this.text+=e,this._graphemes=i.slice(0,r?-1:void 0).concat(a);let n=a.length-+!!r;for(let e=0;e<n;e++)this.sectionIndex.push(t)}addTextSection(e,t){this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||t}),this._appendSection(e.text,this.sections.length-1)}addImageSection(e){let t=e.image?e.image.name:"";if(0===t.length)return void Oe("Can't add FormattedSection with an empty image.");let i=this.getNextImageSectionCharCode();i?(this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:t}),this._appendSection(String.fromCharCode(i),this.sections.length-1)):Oe("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,i,r,a){let n=[],o=this.determineAverageLineWidth(e,t,i,r,a),s=this.hasZeroWidthSpaces(),l=this.graphemes(),u=null,h=0,c=0;for(let t=0;t<l.length;t++){let d=l[t];if(t>0){let e=l[t-1].codePointAt(0),i=d.codePointAt(0),r=Rc(e),a=Lc(e)&&Lc(i);(dd[e]||r||"imageName"in this.getSection(t-1)||void 0!==l[t+1]&&pd[i]||a&&(u??=td(this.text)).has(c))&&n.push(yd(t,h,o,n,_d(e,i,r&&s),!1))}rd(d.codePointAt(0))||(h+=fd(d,this.getSection(t),i,r,e,a)),c+=d.length}return xd(yd(this.length(),h,o,n,0,!0))}determineAverageLineWidth(e,t,i,r,a){let n=0,o=0;for(let t of this.graphemes())n+=fd(t,this.getSection(o),i,r,e,a),o++;return n/Math.max(1,Math.ceil(n/t))}};const bd=function(e){var t={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},i={},r={};i.L=1,r[1]="L",Object.keys(t).forEach(function(e,t){i[e]=1<<t+1,r[i[e]]=e}),Object.freeze(i);var a=i.LRI|i.RLI|i.FSI,n=i.L|i.R|i.AL,o=i.B|i.S|i.WS|i.ON|i.FSI|i.LRI|i.RLI|i.PDI,s=i.BN|i.RLE|i.LRE|i.RLO|i.LRO|i.PDF,l=i.S|i.WS|i.B|a|i.PDI|s,u=null;function h(e){return function(){if(!u){u=new Map;var e=0;for(var r in t)if(t.hasOwnProperty(r))for(var a=t[r],n="",o=void 0,s=!1,l=0,h=0;h<=a.length+1;h+=1){var c=a[h];if(","!==c&&h!==a.length)"+"===c?(s=!0,l=e=l+parseInt(n,36),n=""):n+=c;else{s?o=e+parseInt(n,36):(l=e=l+parseInt(n,36),o=e),s=!1,n="",l=o;for(var d=e;d<o+1;d+=1)u.set(d,i[r])}}}}(),u.get(e.codePointAt(0))||i.L}var c,d,p,f="14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",m="6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye";function g(e,t){var i,r=0,a=new Map,n=t&&new Map;return e.split(",").forEach(function e(o){if(-1!==o.indexOf("+"))for(var s=+o;s--;)e(i);else{i=o;var l=o.split(">"),u=l[0],h=l[1];u=String.fromCodePoint(r+=parseInt(u,36)),h=String.fromCodePoint(r+=parseInt(h,36)),a.set(u,h),t&&n.set(h,u)}}),{map:a,reverseMap:n}}function _(){if(!c){var e=g(f,!0),t=e.map,i=e.reverseMap;c=t,d=i,p=g(m,!1).map}}function y(e){return _(),c.get(e)||null}function x(e){return _(),d.get(e)||null}function v(e){return _(),p.get(e)||null}var b,w=i.L,T=i.R,D=i.EN,E=i.ES,S=i.ET,P=i.AN,I=i.CS,A=i.B,C=i.S,M=i.ON,z=i.BN,F=i.NSM,R=i.AL,k=i.LRO,L=i.RLO,B=i.LRE,O=i.RLE,j=i.PDF,V=i.LRI,N=i.RLI,U=i.FSI,$=i.PDI;function G(e){return function(){if(!b){var e=g("14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",!0),t=e.map;e.reverseMap.forEach(function(e,i){t.set(i,e)}),b=t}}(),b.get(e)||null}function Z(e,t,i,r){var a=e.length;i=Math.max(0,null==i?0:+i),r=Math.min(a-1,null==r?a-1:+r);var n=[];return t.paragraphs.forEach(function(a){var o=Math.max(i,a.start),s=Math.min(r,a.end);if(o<s){for(var u=t.levels.slice(o,s+1),c=s;c>=o&&h(e[c])&l;c--)u[c]=a.level;for(var d=a.level,p=1/0,f=0;f<u.length;f++){var m=u[f];m>d&&(d=m),m<p&&(p=1|m)}for(var g=d;g>=p;g--)for(var _=0;_<u.length;_++)if(u[_]>=g){for(var y=_;_+1<u.length&&u[_+1]>=g;)_++;_>y&&n.push([y+o,_+o])}}}),n}function q(e,t,i,r){for(var a=Z(e,t,i,r),n=[],o=0;o<e.length;o++)n[o]=o;return a.forEach(function(e){for(var t=e[0],i=e[1],r=n.slice(t,i+1),a=r.length;a--;)n[i-a]=r[a]}),n}return e.closingToOpeningBracket=x,e.getBidiCharType=h,e.getBidiCharTypeName=function(e){return r[h(e)]},e.getCanonicalBracket=v,e.getEmbeddingLevels=function(e,t){for(var i=new Uint32Array(e.length),r=0;r<e.length;r++)i[r]=h(e[r]);var u=new Map;function c(e,t){var r=i[e];i[e]=t,u.set(r,u.get(r)-1),r&o&&u.set(o,u.get(o)-1),u.set(t,(u.get(t)||0)+1),t&o&&u.set(o,(u.get(o)||0)+1)}for(var d=new Uint8Array(e.length),p=new Map,f=[],m=null,g=0;g<e.length;g++)m||f.push(m={start:g,end:e.length-1,level:"rtl"===t?1:"ltr"===t?0:Vt(g,!1)}),i[g]&A&&(m.end=g,m=null);for(var _=O|B|L|k|a|$|j|A,b=function(e){return e+(1&e?1:2)},G=function(e){return e+(1&e?2:1)},Z=0;Z<f.length;Z++){var q=[{_level:(m=f[Z]).level,_override:0,_isolate:0}],W=void 0,X=0,H=0,Y=0;u.clear();for(var K=m.start;K<=m.end;K++){var J=i[K];if(W=q[q.length-1],u.set(J,(u.get(J)||0)+1),J&o&&u.set(o,(u.get(o)||0)+1),J&_)if(J&(O|B)){d[K]=W._level;var Q=(J===O?G:b)(W._level);Q<=125&&!X&&!H?q.push({_level:Q,_override:0,_isolate:0}):X||H++}else if(J&(L|k)){d[K]=W._level;var ee=(J===L?G:b)(W._level);ee<=125&&!X&&!H?q.push({_level:ee,_override:J&L?T:w,_isolate:0}):X||H++}else if(J&a){J&U&&(J=1===Vt(K+1,!0)?N:V),d[K]=W._level,W._override&&c(K,W._override);var te=(J===N?G:b)(W._level);te<=125&&0===X&&0===H?(Y++,q.push({_level:te,_override:0,_isolate:1,_isolInitIndex:K})):X++}else if(J&$){if(X>0)X--;else if(Y>0){for(H=0;!q[q.length-1]._isolate;)q.pop();var ie=q[q.length-1]._isolInitIndex;null!=ie&&(p.set(ie,K),p.set(K,ie)),q.pop(),Y--}W=q[q.length-1],d[K]=W._level,W._override&&c(K,W._override)}else J&j?(0===X&&(H>0?H--:!W._isolate&&q.length>1&&(q.pop(),W=q[q.length-1])),d[K]=W._level):J&A&&(d[K]=m.level);else d[K]=W._level,W._override&&J!==z&&c(K,W._override)}for(var re=[],ae=null,ne=m.start;ne<=m.end;ne++){var oe=i[ne];if(!(oe&s)){var se=d[ne],le=oe&a,ue=oe===$;ae&&se===ae._level?(ae._end=ne,ae._endsWithIsolInit=le):re.push(ae={_start:ne,_end:ne,_level:se,_startsWithPDI:ue,_endsWithIsolInit:le})}}for(var he=[],ce=0;ce<re.length;ce++){var de=re[ce];if(!de._startsWithPDI||de._startsWithPDI&&!p.has(de._start)){for(var pe=[ae=de],fe=void 0;ae&&ae._endsWithIsolInit&&null!=(fe=p.get(ae._end));)for(var me=ce+1;me<re.length;me++)if(re[me]._start===fe){pe.push(ae=re[me]);break}for(var ge=[],_e=0;_e<pe.length;_e++)for(var ye=pe[_e],xe=ye._start;xe<=ye._end;xe++)ge.push(xe);for(var ve=d[ge[0]],be=m.level,we=ge[0]-1;we>=0;we--)if(!(i[we]&s)){be=d[we];break}var Te=ge[ge.length-1],De=d[Te],Ee=m.level;if(!(i[Te]&a))for(var Se=Te+1;Se<=m.end;Se++)if(!(i[Se]&s)){Ee=d[Se];break}he.push({_seqIndices:ge,_sosType:Math.max(be,ve)%2?T:w,_eosType:Math.max(Ee,De)%2?T:w})}}for(var Pe=0;Pe<he.length;Pe++){var Ie=he[Pe],Ae=Ie._seqIndices,Ce=Ie._sosType,Me=Ie._eosType,ze=1&d[Ae[0]]?T:w;if(u.get(F))for(var Fe=0;Fe<Ae.length;Fe++){var Re=Ae[Fe];if(i[Re]&F){for(var ke=Ce,Le=Fe-1;Le>=0;Le--)if(!(i[Ae[Le]]&s)){ke=i[Ae[Le]];break}c(Re,ke&(a|$)?M:ke)}}if(u.get(D))for(var Be=0;Be<Ae.length;Be++){var Oe=Ae[Be];if(i[Oe]&D)for(var je=Be-1;je>=-1;je--){var Ve=-1===je?Ce:i[Ae[je]];if(Ve&n){Ve===R&&c(Oe,P);break}}}if(u.get(R))for(var Ne=0;Ne<Ae.length;Ne++){var Ue=Ae[Ne];i[Ue]&R&&c(Ue,T)}if(u.get(E)||u.get(I))for(var $e=1;$e<Ae.length-1;$e++){var Ge=Ae[$e];if(i[Ge]&(E|I)){for(var Ze=0,qe=0,We=$e-1;We>=0&&(Ze=i[Ae[We]])&s;We--);for(var Xe=$e+1;Xe<Ae.length&&(qe=i[Ae[Xe]])&s;Xe++);Ze===qe&&(i[Ge]===E?Ze===D:Ze&(D|P))&&c(Ge,Ze)}}if(u.get(D))for(var He=0;He<Ae.length;He++)if(i[Ae[He]]&D){for(var Ye=He-1;Ye>=0&&i[Ae[Ye]]&(S|s);Ye--)c(Ae[Ye],D);for(He++;He<Ae.length&&i[Ae[He]]&(S|s|D);He++)i[Ae[He]]!==D&&c(Ae[He],D)}if(u.get(S)||u.get(E)||u.get(I))for(var Ke=0;Ke<Ae.length;Ke++){var Je=Ae[Ke];if(i[Je]&(S|E|I)){c(Je,M);for(var Qe=Ke-1;Qe>=0&&i[Ae[Qe]]&s;Qe--)c(Ae[Qe],M);for(var et=Ke+1;et<Ae.length&&i[Ae[et]]&s;et++)c(Ae[et],M)}}if(u.get(D))for(var tt=0,it=Ce;tt<Ae.length;tt++){var rt=Ae[tt],at=i[rt];at&D?it===w&&c(rt,w):at&n&&(it=at)}if(u.get(o)){for(var nt=T|D|P,ot=nt|w,st=[],lt=[],ut=0;ut<Ae.length;ut++)if(i[Ae[ut]]&o){var ht=e[Ae[ut]],ct=void 0;if(null!==y(ht)){if(!(lt.length<63))break;lt.push({char:ht,seqIndex:ut})}else if(null!==(ct=x(ht)))for(var dt=lt.length-1;dt>=0;dt--){var pt=lt[dt].char;if(pt===ct||pt===x(v(ht))||y(v(pt))===ht){st.push([lt[dt].seqIndex,ut]),lt.length=dt;break}}}st.sort(function(e,t){return e[0]-t[0]});for(var ft=0;ft<st.length;ft++){for(var mt=st[ft],gt=mt[0],_t=mt[1],yt=!1,xt=0,vt=gt+1;vt<_t;vt++){var bt=Ae[vt];if(i[bt]&ot){yt=!0;var wt=i[bt]&nt?T:w;if(wt===ze){xt=wt;break}}}if(yt&&!xt){xt=Ce;for(var Tt=gt-1;Tt>=0;Tt--){var Dt=Ae[Tt];if(i[Dt]&ot){var Et=i[Dt]&nt?T:w;xt=Et===ze?ze:Et;break}}}if(xt){if(i[Ae[gt]]=i[Ae[_t]]=xt,xt!==ze)for(var St=gt+1;St<Ae.length;St++)if(!(i[Ae[St]]&s)){h(e[Ae[St]])&F&&(i[Ae[St]]=xt);break}if(xt!==ze)for(var Pt=_t+1;Pt<Ae.length;Pt++)if(!(i[Ae[Pt]]&s)){h(e[Ae[Pt]])&F&&(i[Ae[Pt]]=xt);break}}}for(var It=0;It<Ae.length;It++)if(i[Ae[It]]&o){for(var At=It,Ct=It,Mt=Ce,zt=It-1;zt>=0;zt--){if(!(i[Ae[zt]]&s)){Mt=i[Ae[zt]]&nt?T:w;break}At=zt}for(var Ft=Me,Rt=It+1;Rt<Ae.length;Rt++){if(!(i[Ae[Rt]]&(o|s))){Ft=i[Ae[Rt]]&nt?T:w;break}Ct=Rt}for(var kt=At;kt<=Ct;kt++)i[Ae[kt]]=Mt===Ft?Mt:ze;It=Ct}}}for(var Lt=m.start;Lt<=m.end;Lt++){var Bt=d[Lt],Ot=i[Lt];if(1&Bt?Ot&(w|D|P)&&d[Lt]++:Ot&T?d[Lt]++:Ot&(P|D)&&(d[Lt]+=2),Ot&s&&(d[Lt]=0===Lt?m.level:d[Lt-1]),Lt===m.end||h(e[Lt])&(C|A))for(var jt=Lt;jt>=0&&h(e[jt])&l;jt--)d[jt]=m.level}}return{levels:d,paragraphs:f};function Vt(t,r){for(var n=t;n<e.length;n++){var o=i[n];if(o&(T|R))return 1;if(o&(A|w)||r&&o===$)return 0;if(o&a){var s=Nt(n);n=-1===s?e.length:s}}return 0}function Nt(t){for(var r=1,n=t+1;n<e.length;n++){var o=i[n];if(o&A)break;if(o&$){if(0===--r)return n}else o&a&&r++}return-1}},e.getMirroredCharacter=G,e.getMirroredCharactersMap=function(e,t,i,r){var a=e.length;i=Math.max(0,null==i?0:+i),r=Math.min(a-1,null==r?a-1:+r);for(var n=new Map,o=i;o<=r;o++)if(1&t[o]){var s=G(e[o]);null!==s&&n.set(o,s)}return n},e.getReorderSegments=Z,e.getReorderedIndices=q,e.getReorderedString=function(e,t,i,r){var a=q(e,t,i,r),n=[].concat(e);return a.forEach(function(i,r){n[r]=(1&t.levels[i]?G(e[i]):null)||e[i]}),n.join("")},e.openingToClosingBracket=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({}),wd=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/,Td=new Set(["WS","FSI","LRI","RLI","PDI"]),Dd=new Set(["S","B"]);function Ed(e){return e.level%2==0?e.text:bd.getMirroredCharacter(e.text)??e.text}function Sd(e,t){let{levels:i,paragraphs:r}=bd.getEmbeddingLevels(e);return function(e,t){let i=t.filter(t=>t>0&&t<e.length),r=[...new Set([0,...i,e.length])].sort((e,t)=>e-t),a=[];for(let e=0;e+1<r.length;e++)a.push([r[e],r[e+1]]);return a}(e,t.concat(r.map(e=>e.start))).map(([t,a])=>function(e,t,i,r,a){let n=function(e,t,i,r){let a=[],n=i;for(let o of ed(e.slice(i,r)))a.push({index:n,text:o,level:t[n]}),n+=o.length;return a}(e,t,r,a);!function(e,t){let i=!0;for(let r=e.length-1;r>=0;r--){let a=bd.getBidiCharTypeName(e[r].text[0]);Dd.has(a)?(e[r].level=t,i=!0):i&&Td.has(a)?e[r].level=t:i=!1}}(n,i);let o="",s=[];for(let e of function(e,t){let i=t,r=1/0;for(let{level:t}of e)t>i&&(i=t),(1|t)<r&&(r=1|t);let a=e.slice();for(let e=i;e>=r;e--)for(let t=0;t<a.length;t++){if(a[t].level<e)continue;let i=t;for(;i+1<a.length&&a[i+1].level>=e;)i++;for(let e=t,r=i;e<r;e++,r--)[a[e],a[r]]=[a[r],a[e]];t=i}return a}(n,i)){if(wd.test(e.text))continue;let t=Ed(e);o+=t,s.push(...Array(t.length).fill(e.index))}return{text:o,sourceIndices:s}}(e,i,function(e,t){return e.find(e=>t>=e.start&&t<=e.end)?.level??0}(r,t),t,a))}const Pd=4294967296,Id=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var Ad=class{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(e,t,i=this.length){let r;for(;r=this.nextField(i);)e(r,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Pd;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Pd;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,i=t[this.pos++];if(i<128)return i;let r,a=127&i;return r=t[this.pos++],a|=(127&r)<<7,r<128||(r=t[this.pos++],a|=(127&r)<<14,r<128)||(r=t[this.pos++],a|=(127&r)<<21,r<128)?a:(r=t[this.pos],a|=(15&r)<<28,function(e,t,i){let r,a,n=i.buf;if(a=n[i.pos++],r=(112&a)>>4,a<128||(a=n[i.pos++],r|=(127&a)<<3,a<128)||(a=n[i.pos++],r|=(127&a)<<10,a<128)||(a=n[i.pos++],r|=(127&a)<<17,a<128)||(a=n[i.pos++],r|=(127&a)<<24,a<128)||(a=n[i.pos++],r|=(1&a)<<31,a<128))return function(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}(e,r,t);throw Error("Expected varint not more than 10 bytes")}(a,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&&Id?Id.decode(this.buf.subarray(t,e)):function(e,t,i){let r="",a=t;for(;a<i;){let t,n,o,s=e[a],l=null,u=s>239?4:s>223?3:s>191?2:1;if(a+u>i)break;1===u?s<128&&(l=s):2===u?(t=e[a+1],128==(192&t)&&(l=(31&s)<<6|63&t,l<=127&&(l=null))):3===u?(t=e[a+1],n=e[a+2],128==(192&t)&&128==(192&n)&&(l=(15&s)<<12|(63&t)<<6|63&n,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(t=e[a+1],n=e[a+2],o=e[a+3],128==(192&t)&&128==(192&n)&&128==(192&o)&&(l=(15&s)<<18|(63&t)<<12|(63&n)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),a+=u}return r}(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}nextField(e=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=e)return 0;let t=this.readVarint();return this.type=7&t,this._valueStart=this.pos,t>>>3}skip(e){let t=7&e;if(0===t)for(;this.buf[this.pos++]>127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw Error(`Unimplemented type: ${t}`);this.pos+=8}}};function Cd(e,t,i){1===e&&i.readMessage(Md,t)}function Md(e,t,i){if(3===e){let{id:e,bitmap:r,width:a,height:n,left:o,top:s,advance:l}=i.readMessage(zd,{});t.push({id:e,bitmap:new nu({width:a+6,height:n+6},r),metrics:{width:a,height:n,left:o,top:s,advance:l}})}}function zd(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}function Fd(e){return"function"==typeof e?.renderWithWebGL}function Rd(e){let{userImage:t}=e;return!(!t?.render||!t.render()||(Fd(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),0))}function kd(e){let t=0,i=0;for(let r of e)t+=r.w*r.h,i=Math.max(i,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)),i),h:1/0}],a=0,n=0;for(let t of e)for(let e=r.length-1;e>=0;e--){let i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,n=Math.max(n,t.y+t.h),a=Math.max(a,t.x+t.w),t.w===i.w&&t.h===i.h){let t=r.pop();t&&e<r.length&&(r[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(r.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:a,h:n,fill:t/(a*n)||0}}var Ld=class{constructor(e,{pixelRatio:t,version:i,isWebGLImage:r=!1,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=a,this.stretchY=n,this.content=o,this.version=i,this.needsFirstWebGLRender=r,this.textFitWidth=s,this.textFitHeight=l}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}};eo("ImagePosition",Ld),eo("ImageAtlas",class{constructor(e,t){let i={},r={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let a=[];this.addImages(e,i,a),this.addImages(t,r,a);let{w:n,h:o}=kd(a),s=new ou({width:n||1,height:o||1});for(let t in e){let r=e[t];if(r.isWebGLImage)continue;let a=i[t].paddedRect;ou.copy(r.data,s,{x:0,y:0},{x:a.x+1,y:a.y+1},r.data)}for(let e in t){let i=t[e],a=r[e].paddedRect,n=a.x+1,o=a.y+1,l=i.data.width,u=i.data.height;ou.copy(i.data,s,{x:0,y:0},{x:n,y:o},i.data),ou.copy(i.data,s,{x:0,y:u-1},{x:n,y:o-1},{width:l,height:1}),ou.copy(i.data,s,{x:0,y:0},{x:n,y:o+u},{width:l,height:1}),ou.copy(i.data,s,{x:l-1,y:0},{x:n-1,y:o},{width:1,height:u}),ou.copy(i.data,s,{x:0,y:0},{x:n+l,y:o},{width:1,height:u})}this.image=s,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(let r in e){let a=e[r],n={x:0,y:0,w:a.data.width+2,h:a.data.height+2};i.push(n),t[r]=new Ld(n,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){if(e.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==e.updateVersion){this.patchedUpdateVersion=e.updateVersion;for(let i in this.iconPositions)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t);for(let i in this.patternPositions)this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}}patchUpdatedImage(e,t,i){if(!e||!t||!e.needsFirstWebGLRender&&e.version===t.version)return;e.needsFirstWebGLRender=!1,e.version=t.version;let[r,a]=e.tl,n=t.userImage?.data;if(!Fd(n))return void i.update(t.data,void 0,{x:r,y:a});let{width:o,height:s}=t.data;i.context.setCustomLayerDefaults(),n.renderWithWebGL({gl:i.context.gl,texture:i.texture,x:r,y:a,width:o,height:s}),i.context.setDirty()}});var Bd=function(e){return e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly",e}(Bd||{});const Od=/^\p{gc=M}$/u;function jd(e,t,i){let r=new vd(e.join(""),t,[]),a=0;for(let e of r.graphemes())r.sectionIndex.push(i[a]??0),a+=[...e].length;return r}function Vd(e){let t=[],i=0;for(let r of e)t.push(i),i+=r.length;return t}function Nd(e,t,i){let r=[...e],a=Vd(r),n=function(e){let t=[],i=0;for(;i<e.length;){if(!Od.test(e[i])){t.push(i),i++;continue}let r=i;for(;r<e.length&&Od.test(e[r]);)r++;let a=e[r];if(void 0!==a&&ud(a.codePointAt(0))){t.push(r);for(let e=r-1;e>=i;e--)t.push(e);i=r+1}else{for(let e=i;e<r;e++)t.push(e);i=r}}return t}(r);return jd(n.map(e=>r[e]),t,n.map(e=>i[a[e]]??0))}function Ud(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f){let m=vd.fromFeature(e,a);2===c&&m.verticalizePunctuation();let g=m.determineLineBreaks(u,n,t,r,p),_=hd(m.text)?function(e,t){let i=t.map(t=>e.toCodeUnitIndex(t)),r=Fc.isParsed()?Fc:null;if(1===e.sections.length)return r?r.processBidirectionalText(e.toString(),i).map(t=>Nd(t,e.sections,[...t].map(()=>0))):function(e,t){return Sd(e,t).map(e=>e.text)}(e.toString(),i).map(t=>jd([...t],e.sections,[...t].map(()=>0)));let a=function(e){let t=[],i=0;for(let r of e.graphemes())t.push(...Array(r.length).fill(e.sectionIndex[i])),i++;return t}(e);return r?r.processStyledBidirectionalText(e.text,a,i).map(([t,i])=>Nd(t,e.sections,i)):function(e,t,i){return Sd(e,i).map(e=>[e.text,e.sourceIndices.map(e=>t[e]??0)])}(e.text,a,i).map(([t,i])=>{let r=[...t];return jd(r,e.sections,Vd(r).map(e=>i[e]??0))})}(m,g):function(e,t){let i=[],r=0;for(let a of t)i.push(e.substring(r,a)),r=a;return r<e.length()&&i.push(e.substring(r,e.length())),i}(m,g),y=[],x={positionedLines:y,text:m.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:c,iconsInText:!1,verticalizable:!1};return function(e,t,i,r,a,n,o,s,l,u,h,c){let d=0,p=0,f=0,m=0,g="right"===s?1:"left"===s?0:.5,_=24/c,y=0;for(let o of a){o.trim();let a=o.getMaxScale(),s={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=s;let c=s.positionedGlyphs,x=0;if(!o.length()){p+=n,++y;continue}let v=Gd(r,o,_),b=2!==l||h?null:Kd(o),w=o.graphemes();for(let n=0;n<w.length;n++){let s=o.getSection(n),f=w[n],m=f.codePointAt(0),g=b?b[n]:qd(l,h,m),y="fontStack"in s&&id(f)&&!t[s.fontStack]?.[f]?[...f]:[f];for(let l of y){let h,f={glyph:l.codePointAt(0),grapheme:l,imageName:null,x:d,y:p+-17,vertical:g,scale:1,fontStack:"",sectionIndex:o.getSectionIndex(n),metrics:null,rect:null};if("fontStack"in s){if(h=Jd(s,l,g,v,t,i),!h)continue;f.fontStack=s.fontStack}else{if(e.iconsInText=!0,s.scale*=_,h=Qd(s,g,a,v,r),!h)continue;x=Math.max(x,h.imageOffset),f.imageName=s.imageName}let{rect:m,metrics:y,baselineOffset:b}=h;f.y+=b,f.scale=s.scale,f.metrics=y,f.rect=m,c.push(f),g?(e.verticalizable=!0,d+=("imageName"in s?y.advance:24)*s.scale+u):d+=y.advance*s.scale+u}}if(0!==c.length){let e=d-u;f=Math.max(e,f),ep(c,0,c.length-1,g)}d=0;let T=24*(a-1);s.lineOffset=Math.max(x,T);let D=n*a+x;p+=D,m=Math.max(D,m),++y}let{horizontalAlign:x,verticalAlign:v}=$d(o);(function(e,t,i,r,a,n,o,s,l){let u=(t-i)*a,h=0;h=n===o?-r*l*o+.5*o:-s*r- -17;for(let t of e)for(let e of t.positionedGlyphs)e.x+=u,e.y+=h})(e.positionedLines,g,x,v,f,m,n,p,a.length),e.top+=-v*p,e.bottom=e.top+p,e.left+=-x*f,e.right=e.left+f}(x,t,i,r,_,o,s,l,c,u,d,f),!function(e){for(let t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(y)&&x}function $d(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function Gd(e,t,i){let r=24*t.getMaxScale(),{maxImageWidth:a,maxImageHeight:n}=t.getMaxImageSize(e),o=Math.max(r,n*i);return{verticalLineContentWidth:Math.max(r,a*i),horizontalLineContentHeight:o}}function Zd(e){switch(e){case"top":return 0;case"center":return.5;default:return 1}}function qd(e,t,i){return!(1===e||!t&&!kc(i)||t&&(rd(i)||ld(i)))}function Wd(e){return/\p{Nd}/u.test(String.fromCodePoint(e))}function Xd(e){return/\p{Lu}/u.test(String.fromCodePoint(e))}function Hd(e){let t=e.some(Wd)&&e.every(e=>Wd(e)||function(e){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(e))}(e)),i=e.length<=3&&e.every(e=>Xd(e)||Wd(e));return t||i}function Yd(e){return(Wd(e)||Xd(e))&&!ld(e)}function Kd(e){let t=e.graphemes().slice(),i=t.map(e=>e.codePointAt(0)),r=i.map(kc),a=t=>!r[t]&&!rd(i[t])&&!("imageName"in e.getSection(t));for(let e=0;e<i.length;e++){if(!a(e))continue;let t=e;for(;t+1<i.length&&a(t+1);)t++;if(Hd(i.slice(e,t+1)))for(let a=e;a<=t;a++)r[a]=Yd(i[a]);e=t}return function(e,t){let i=!1;for(let r=0;r<e.length;r++){if(t[r])continue;let a=cd[e[r]];a&&(0===r||t[r-1])&&(r===e.length-1||t[r+1])&&(e[r]=a,t[r]=!0,i=!0)}return i}(t,r)&&(e.text=t.join(""),e._graphemes=null),r}function Jd(e,t,i,r,a,n){let o,s=n[e.fontStack]?.[t],l=function(e,t,i,r){if(e?.rect)return e;let a=t[i.fontStack]?.[r];return a?{rect:null,metrics:a.metrics}:null}(s,a,e,t);if(null===l)return null;if(i)o=r.verticalLineContentWidth-24*e.scale;else{let t=Zd(e.verticalAlign);o=(r.horizontalLineContentHeight-24*e.scale)*t}return{rect:l.rect,metrics:l.metrics,baselineOffset:o}}function Qd(e,t,i,r,a){let n=a[e.imageName];if(!n)return null;let o,s=n.paddedRect,l=n.displaySize,u={width:l[0],height:l[1],left:1,top:-3,advance:t?l[1]:l[0]};if(t)o=r.verticalLineContentWidth-l[1]*e.scale;else{let t=Zd(e.verticalAlign);o=(r.horizontalLineContentHeight-l[1]*e.scale)*t}return{rect:s,metrics:u,baselineOffset:o,imageOffset:(t?l[0]:l[1])*e.scale-24*i}}function ep(e,t,i,r){if(0===r)return;let a=e[i],n=a.metrics.advance*a.scale,o=(e[i].x+n)*r;for(let r=t;r<=i;r++)e[r].x-=o}function tp(e,t,i){let{horizontalAlign:r,verticalAlign:a}=$d(i),n=t[0],o=t[1],s=n-e.displaySize[0]*r,l=s+e.displaySize[0],u=o-e.displaySize[1]*a;return{image:e,top:u,bottom:u+e.displaySize[1],left:s,right:l}}function ip(e){let t=e.left,i=e.top,r=e.right-t,a=e.bottom-i,n=e.image.content[2]-e.image.content[0],o=e.image.content[3]-e.image.content[1],s=e.image.textFitWidth??"stretchOrShrink",l=e.image.textFitHeight??"stretchOrShrink",u=n/o;if("proportional"===l){if("stretchOnly"===s&&r/a<u||"proportional"===s){let e=Math.ceil(a*u);t*=e/r,r=e}}else if("proportional"===s&&"stretchOnly"===l&&0!==u&&r/a>u){let e=Math.ceil(r/u);i*=e/a,a=e}return{x1:t,y1:i,x2:t+r,y2:i+a}}function rp(e,t,i,r,a,n){let o,s=e.image;if(s.content){let e=s.content,t=s.pixelRatio||1;o=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}let l,u,h,c,d=t.left*n,p=t.right*n;"width"===i||"both"===i?(c=a[0]+d-r[3],u=a[0]+p+r[1]):(c=a[0]+(d+p-s.displaySize[0])/2,u=c+s.displaySize[0]);let f=t.top*n,m=t.bottom*n;return"height"===i||"both"===i?(l=a[1]+f-r[0],h=a[1]+m+r[2]):(l=a[1]+(f+m-s.displaySize[1])/2,h=l+s.displaySize[1]),{image:s,top:l,right:u,bottom:h,left:c,collisionPadding:o}}function ap(e,t){let{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new so(e+1))};if("source"===i.kind)return{kind:"source"};if("composite"===i.kind){let{minZoom:t,maxZoom:r}=function(e,t){let i=0;for(;i<e.length&&e[i]<=t;)i++;i=Math.max(0,i-1);let r=i;for(;r<e.length&&e[r]<t+1;)r++;return r=Math.min(e.length-1,r),{minZoom:e[i],maxZoom:e[r]}}(i.zoomStops,e);return{kind:"composite",minZoom:t,maxZoom:r,interpolationType:i.interpolationType}}{let t=function(e){return e.zoomStops.map(t=>e.evaluate(new so(t===-1/0?e.zoomStops[1]-1:t)))}(i),r=i.evaluate(new so(e+1));return{kind:"camera",zoomStops:i.zoomStops,sizes:t,layoutSize:r,interpolationType:i.interpolationType}}}function np(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:a}){return"source"===e.kind?r/128:"composite"===e.kind?Oi.number(r/128,a/128,i):t}function op(e,t){let i=0,r=0;return"constant"===e.kind?r=e.layoutSize:"camera"===e.kind?r=function({zoomStops:e,sizes:t,layoutSize:i,interpolationType:r},a){let n=e.length-1;for(;n>0&&e[n]>a;)n--;let o=Math.min(n+1,e.length-1),s=r?De(Li.interpolationFactor(r,a,e[n],e[o]),0,1):0;return Math.min(Oi.number(t[n],t[o],s),i)}(e,t):"composite"===e.kind&&(i=function({interpolationType:e,minZoom:t,maxZoom:i},r){return e?De(Li.interpolationFactor(e,r,t,i),0,1):0}(e,t)),{uSizeT:i,uSize:r}}var sp=class e extends c{constructor(e,t,i,r){super(e,t),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new e(this.x,this.y,this.angle,this.segment)}};function lp(e,t,i,r,a){if(void 0===t.segment||0===i)return!0;let n=t,o=t.segment+1,s=0;for(;s>-i/2;){if(o--,o<0)return!1;s-=e[o].dist(n),n=e[o]}s+=e[o].dist(e[o+1]),o++;let l=[],u=0;for(;s<i/2;){let t=e[o-1],i=e[o],n=e[o+1];if(!n)return!1;let h=t.angleTo(i)-i.angleTo(n);for(h=Math.abs((h+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:s,angleDelta:h}),u+=h;s-l[0].distance>r;)u-=l.shift().angleDelta;if(u>a)return!1;o++,s+=i.dist(n)}return!0}function up(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function hp(e,t,i){return e?.6*t*i:0}function cp(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function dp(e,t,i,r,a,n){let o=hp(i,a,n),s=cp(i,r)*n,l=0,u=up(e)/2;for(let i=0;i<e.length-1;i++){let r=e[i],a=e[i+1],n=r.dist(a);if(l+n>u){let h=(u-l)/n,c=new sp(Oi.number(r.x,a.x,h),Oi.number(r.y,a.y,h),a.angleTo(r),i);return c._round(),!o||lp(e,c,s,o,t)?c:void 0}l+=n}}function pp(e,t,i,r,a,n,o,s,l){let u=hp(r,n,o),h=cp(r,a),c=h*o,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-c<t/4&&(t=c+t/4),fp(e,d?t/2*s%t:(h/2+2*n)*o*s%t,t,u,i,c,d,!1,l)}function fp(e,t,i,r,a,n,o,s,l){let u=n/2,h=up(e),c=0,d=t-i,p=[];for(let t=0;t<e.length-1;t++){let o=e[t],s=e[t+1],f=o.dist(s),m=s.angleTo(o);for(;d+i<c+f;){d+=i;let g=(d-c)/f,_=Oi.number(o.x,s.x,g),y=Oi.number(o.y,s.y,g);if(_>=0&&_<l&&y>=0&&y<l&&d-u>=0&&d+u<=h){let i=new sp(_,y,m,t);i._round(),(!r||lp(e,i,n,r,a))&&p.push(i)}}c+=f}return!s&&!p.length&&!o&&(p=fp(e,c/2,i,r,a,n,o,!0,l)),p}function mp(e,t,i,r,a){let n=[];for(let o of e){let e;for(let s=0;s<o.length-1;s++){let l=o[s],u=o[s+1];l.x<t&&u.x<t||(l.x<t?l=new c(t,l.y+(u.y-l.y)*((t-l.x)/(u.x-l.x)))._round():u.x<t&&(u=new c(t,l.y+(u.y-l.y)*((t-l.x)/(u.x-l.x)))._round()),!(l.y<i&&u.y<i)&&(l.y<i?l=new c(l.x+(u.x-l.x)*((i-l.y)/(u.y-l.y)),i)._round():u.y<i&&(u=new c(l.x+(u.x-l.x)*((i-l.y)/(u.y-l.y)),i)._round()),!(l.x>=r&&u.x>=r)&&(l.x>=r?l=new c(r,l.y+(u.y-l.y)*((r-l.x)/(u.x-l.x)))._round():u.x>=r&&(u=new c(r,l.y+(u.y-l.y)*((r-l.x)/(u.x-l.x)))._round()),!(l.y>=a&&u.y>=a)&&(l.y>=a?l=new c(l.x+(u.x-l.x)*((a-l.y)/(u.y-l.y)),a)._round():u.y>=a&&(u=new c(l.x+(u.x-l.x)*((a-l.y)/(u.y-l.y)),a)._round()),(!e||!l.equals(e[e.length-1]))&&(e=[l],n.push(e)),e.push(u)))))}}return n}function gp(e,t,i,r){let a=[],n=e.image,o=n.pixelRatio,s=n.paddedRect.w-2,l=n.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},h=n.stretchX||[[0,s]],d=n.stretchY||[[0,l]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),g=s-f,_=l-m,y=0,x=f,v=0,b=m,w=0,T=g,D=0,E=_;if(n.content&&r){let t=n.content,i=t[2]-t[0],r=t[3]-t[1];(n.textFitWidth||n.textFitHeight)&&(u=ip(e)),y=_p(h,0,t[0]),v=_p(d,0,t[1]),x=_p(h,t[0],t[2]),b=_p(d,t[1],t[3]),w=t[0]-y,D=t[1]-v,T=i-x,E=r-b}let S=u.x1,P=u.y1,I=u.x2-S,A=u.y2-P,C=(e,r,a,s)=>{let l=xp(e.stretch-y,x,I,S),u=vp(e.fixed-w,T,e.stretch,f),h=xp(r.stretch-v,b,A,P),d=vp(r.fixed-D,E,r.stretch,m),p=xp(a.stretch-y,x,I,S),g=vp(a.fixed-w,T,a.stretch,f),_=xp(s.stretch-v,b,A,P),C=vp(s.fixed-D,E,s.stretch,m),M=new c(l,h),z=new c(p,h),F=new c(p,_),R=new c(l,_),k=new c(u/o,d/o),L=new c(g/o,C/o),B=t*Math.PI/180;if(B){let e=Math.sin(B),t=Math.cos(B),i=[t,-e,e,t];M._matMult(i),z._matMult(i),R._matMult(i),F._matMult(i)}let O=e.stretch+e.fixed,j=a.stretch+a.fixed,V=r.stretch+r.fixed,N=s.stretch+s.fixed;return{tl:M,tr:z,bl:R,br:F,tex:{x:n.paddedRect.x+1+O,y:n.paddedRect.y+1+V,w:j-O,h:N-V},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:L,minFontScaleX:T/o/I,minFontScaleY:E/o/A,isSDF:i}};if(r&&(n.stretchX||n.stretchY)){let e=yp(h,g,f),t=yp(d,_,m);for(let i=0;i<e.length-1;i++){let r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++){let i=t[e],o=t[e+1];a.push(C(r,i,n,o))}}}else a.push(C({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:s+1},{fixed:0,stretch:l+1}));return a}function _p(e,t,i){let r=0;for(let a of e)r+=Math.max(t,Math.min(i,a[1]))-Math.max(t,Math.min(i,a[0]));return r}function yp(e,t,i){let r=[{fixed:-1,stretch:0}];for(let[t,i]of e){let e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)})}return r.push({fixed:t+1,stretch:i}),r}function xp(e,t,i,r){return e/t*i+r}function vp(e,t,i,r){return e-t*i/r}eo("Anchor",sp);var bp=class{constructor(e,t,i,r,a,n,o,s,l,u){if(this.boxStartIndex=e.length,l){let e=n.top,t=n.bottom,i=n.collisionPadding;i&&(e-=i[1],t+=i[3]);let r=t-e;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let l=n.image?.content&&(n.image.textFitWidth||n.image.textFitHeight)?ip(n):{x1:n.left,y1:n.top,x2:n.right,y2:n.bottom};l.y1=l.y1*o-s[0],l.y2=l.y2*o+s[2],l.x1=l.x1*o-s[3],l.x2=l.x2*o+s[1];let h=n.collisionPadding;if(h&&(l.x1-=h[0]*o,l.y1-=h[1]*o,l.x2+=h[2]*o,l.y2+=h[3]*o),u){let e=new c(l.x1,l.y1),t=new c(l.x2,l.y1),i=new c(l.x1,l.y2),r=new c(l.x2,l.y2),a=u*Math.PI/180;e._rotate(a),t._rotate(a),i._rotate(a),r._rotate(a),l.x1=Math.min(e.x,t.x,i.x,r.x),l.x2=Math.max(e.x,t.x,i.x,r.x),l.y1=Math.min(e.y,t.y,i.y,r.y),l.y2=Math.max(e.y,t.y,i.y,r.y)}e.emplaceBack(t.x,t.y,l.x1,l.y1,l.x2,l.y2,i,r,a)}this.boxEndIndex=e.length}},wp=class{constructor(e=[],t=(e,t)=>e<t?-1:+(e>t)){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(0===this.length)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let a=e-1>>1,n=t[a];if(i(r,n)>=0)break;t[e]=n,e=a}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,a=t[e];for(;e<r;){let r=1+(e<<1),n=r+1;if(n<this.length&&i(t[n],t[r])<0&&(r=n),i(t[r],a)>=0)break;t[e]=t[r],e=r}t[e]=a}};function Tp(e,t=1){let i=Ih.fromPoints(e[0]),r=Math.min(i.width(),i.height()),a=r/2,n=new wp([],Dp),{minX:o,minY:s,maxX:l,maxY:u}=i;if(0===r)return new c(o,s);for(let t=o;t<l;t+=r)for(let i=s;i<u;i+=r)n.push(new Ep(t+a,i+a,a,e));let h=function(e){let t=0,i=0,r=0,a=e[0];for(let e=0,n=a.length,o=n-1;e<n;o=e++){let n=a[e],s=a[o],l=n.x*s.y-s.x*n.y;i+=(n.x+s.x)*l,r+=(n.y+s.y)*l,t+=3*l}return new Ep(i/t,r/t,0,e)}(e),d=h;for(;n.length;){let i=n.pop();(i.d>d.d||!d.d)&&(d=i),!(i.max-d.d<=t)&&(a=i.h/2,n.push(new Ep(i.p.x-a,i.p.y-a,a,e)),n.push(new Ep(i.p.x+a,i.p.y-a,a,e)),n.push(new Ep(i.p.x-a,i.p.y+a,a,e)),n.push(new Ep(i.p.x+a,i.p.y+a,a,e)))}return h.d>0&&d.d-h.d<=t?h.p:d.p}function Dp(e,t){return t.max-e.max}var Ep=class{constructor(e,t,i,r){this.p=new c(e,t),this.h=i,this.d=function(e,t){let i=!1,r=1/0;for(let a of t)for(let t=0,n=a.length,o=n-1;t<n;o=t++){let n=a[t],s=a[o];n.y>e.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(i=!i),r=Math.min(r,kl(e,n,s))}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}};let Sp=function(e){return e[e.center=1]="center",e[e.left=2]="left",e[e.right=3]="right",e[e.top=4]="top",e[e.bottom=5]="bottom",e[e["top-left"]=6]="top-left",e[e["top-right"]=7]="top-right",e[e["bottom-left"]=8]="bottom-left",e[e["bottom-right"]=9]="bottom-right",e}({});const Pp=1/0;function Ip(e,t){return t[1]===Pp?function(e,t){let i=0,r=0;t<0&&(t=0);let a=t/Math.SQRT2;switch(e){case"top-right":case"top-left":r=a-7;break;case"bottom-right":case"bottom-left":r=7-a;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":i=-a;break;case"top-left":case"bottom-left":i=a;break;case"left":i=t;break;case"right":i=-t}return[i,r]}(e,t[0]):function(e,t,i){let r=0,a=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":a=i-7;break;case"bottom-right":case"bottom-left":case"bottom":a=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,a]}(e,t[0],t[1])}function Ap(e,t,i){let r=e.layout,a=r.get("text-variable-anchor-offset")?.evaluate(t,{},i);if(a){let e=a.values,t=[];for(let i=0;i<e.length;i+=2){let r=t[i]=e[i],a=e[i+1].map(e=>24*e);r.startsWith("top")?a[1]-=7:r.startsWith("bottom")&&(a[1]+=7),t[i+1]=a}return new Ti(t)}let n=r.get("text-variable-anchor");if(n){let a;a=void 0===e._unevaluatedLayout.getValue("text-radial-offset")?r.get("text-offset").evaluate(t,{},i).map(e=>24*e):[24*r.get("text-radial-offset").evaluate(t,{},i),Pp];let o=[];for(let e of n)o.push(e,Ip(e,a));return new Ti(o)}return null}function Cp(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 Mp(e,t,i,r,a,n,o,s,l,u,h,c){let d=n.textMaxSize.evaluate(t,{});void 0===d&&(d=o);let p,f=e.layers[0].layout,m=f.get("icon-offset").evaluate(t,{},h),g=Fp(i.horizontal),_=o/24,y=e.tilePixelRatio*_,x=e.tilePixelRatio*d/24,v=e.tilePixelRatio*s,b=e.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*e.tilePixelRatio,T=function(e,t,i,r=1){let a=e.get("icon-padding").evaluate(t,{},i)?.values;return[a[0]*r,a[1]*r,a[2]*r,a[3]*r]}(f,t,h,e.tilePixelRatio),D=f.get("text-max-angle")/180*Math.PI,E="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),S="map"===f.get("icon-rotation-alignment").constantOr("viewport")&&"point"!==f.get("symbol-placement"),P=f.get("symbol-placement"),I=b/2,A=f.get("icon-text-fit");r&&"none"!==A&&(e.allowVerticalPlacement&&i.vertical&&(p=rp(r,i.vertical,A,f.get("icon-text-fit-padding"),m,_)),g&&(r=rp(r,g,A,f.get("icon-text-fit-padding"),m,_)));let C=h?c.line.getGranularityForZoomLevel(h.z):1,M=(s,c)=>{c.x<0||c.x>=8192||c.y<0||c.y>=8192||function(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,x,v,b,w,T,D){let E=e.addToLineVertexArray(t,i),S=s.layout.get("symbol-height-offset").evaluate(v,{},T);S>e.maxHeightOffset&&(e.maxHeightOffset=S);let P,I,A,C,M=0,z=0,F=0,R=0,k=-1,L=-1,B={},O=(0,Ws.default)("");if(e.allowVerticalPlacement&&r.vertical){let e=s.layout.get("text-rotate").evaluate(v,{},T)+90,i=r.vertical;A=new bp(l,t,u,h,c,i,d,p,f,e),o&&(C=new bp(l,t,u,h,c,o,g,_,f,e))}if(a){let i=s.layout.get("icon-rotate").evaluate(v,{}),r="none"!==s.layout.get("icon-text-fit"),n=gp(a,i,w,r),d=o?gp(o,i,w,r):void 0;I=new bp(l,t,u,h,c,a,g,_,!1,i),M=4*n.length;let p=e.iconSizeData,f=null;"source"===p.kind?(f=[128*s.layout.get("icon-size").evaluate(v,{})],f[0]>32640&&Oe(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[128*b.compositeIconSizes[0].evaluate(v,{},T),128*b.compositeIconSizes[1].evaluate(v,{},T)],(f[0]>32640||f[1]>32640)&&Oe(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,n,f,x,y,v,0,t,E.lineStartIndex,E.lineLength,-1,T,S),k=e.icon.placedSymbolArray.length-1,d&&(z=4*d.length,e.addSymbols(e.icon,d,f,x,y,v,2,t,E.lineStartIndex,E.lineLength,-1,T,S),L=e.icon.placedSymbolArray.length-1)}let j=Object.keys(r.horizontal);for(let i of j){let a=r.horizontal[i];P||=(O=(0,Ws.default)(a.text),new bp(l,t,u,h,c,a,d,p,f,s.layout.get("text-rotate").evaluate(v,{},T)));let o=1===a.positionedLines.length;if(F+=zp(e,t,a,n,s,f,v,m,S,E,r.vertical?1:3,o?j:[i],B,k,b,T),o)break}r.vertical&&(R+=zp(e,t,r.vertical,n,s,f,v,m,S,E,2,["vertical"],B,L,b,T));let V=P?P.boxStartIndex:e.collisionBoxArray.length,N=P?P.boxEndIndex:e.collisionBoxArray.length,U=A?A.boxStartIndex:e.collisionBoxArray.length,$=A?A.boxEndIndex:e.collisionBoxArray.length,G=I?I.boxStartIndex:e.collisionBoxArray.length,Z=I?I.boxEndIndex:e.collisionBoxArray.length,q=C?C.boxStartIndex:e.collisionBoxArray.length,W=C?C.boxEndIndex:e.collisionBoxArray.length,X=-1,H=(e,t)=>e?.circleDiameter?Math.max(e.circleDiameter,t):t;X=H(P,X),X=H(A,X),X=H(I,X),X=H(C,X);let Y=+(X>-1);Y&&(X*=D/24),e.glyphOffsetArray.length>=e.maxGlyphs&&Oe("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey);let K=Ap(s,v,T),[J,Q]=function(e,t){let i=e.length,r=t?.values;if(r?.length>0)for(let t=0;t<r.length;t+=2){let i=Sp[r[t]],a=r[t+1];e.emplaceBack(i,a[0],a[1])}return[i,e.length]}(e.textAnchorOffsets,K);e.symbolInstances.emplaceBack(t.x,t.y,B.right>=0?B.right:-1,B.center>=0?B.center:-1,B.left>=0?B.left:-1,B.vertical||-1,k,L,O,V,N,U,$,G,Z,q,W,u,F,R,M,z,Y,0,d,X,J,Q,S)}(e,c,s,i,r,a,p,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,y,[w,w,w,w],E,l,v,T,S,m,t,n,u,h,o)};if("line"===P)for(let a of mp(t.geometry,0,0,re,re)){let t=gh(a,C),n=pp(t,b,D,i.vertical||g,r,24,x,e.overscaling,re);for(let i of n)(!g||!Rp(e,g.text,I,i))&&M(t,i)}else if("line-center"===P){for(let e of t.geometry)if(e.length>1){let t=gh(e,C),a=dp(t,D,i.vertical||g,r,24,x);a&&M(t,a)}}else if("Polygon"===t.type)for(let e of $i(t.geometry,0)){let t=Tp(e,16);M(gh(e[0],C,!0),new sp(t.x,t.y,0))}else if("LineString"===t.type)for(let e of t.geometry){let t=gh(e,C);M(t,new sp(t[0].x,t[0].y,0))}else if("Point"===t.type)for(let e of t.geometry)for(let t of e)M([t],new sp(t.x,t.y,0))}function zp(e,t,i,r,a,n,o,s,l,u,h,d,p,f,m,g){let _=function(e,t,i,r,a,n,o,s){let l=r.layout.get("text-rotate").evaluate(n,{})*Math.PI/180,u=[];for(let e of t.positionedLines)for(let r of e.positionedGlyphs){if(!r.rect)continue;let n=r.rect||{},h=4,d=!0,p=1,f=0,m=(a||s)&&r.vertical,g=r.metrics.advance*r.scale/2;if(s&&t.verticalizable){let t=24*(r.scale-1),i=(24-r.metrics.width*r.scale)/2;f=e.lineOffset/2-(r.imageName?-i:t)}if(r.imageName){let e=o[r.imageName];d=e.sdf,p=e.pixelRatio,h=1/p}let _=a?[r.x+g,r.y]:[0,0],y=a?[0,0]:[r.x+g+i[0],r.y+i[1]-f],x=[0,0];m&&(x=y,y=[0,0]);let v=r.metrics.isDoubleResolution?2:1,b=(r.metrics.left-h)*r.scale-g+y[0],w=(-r.metrics.top-h)*r.scale+y[1],T=b+n.w/v*r.scale/p,D=w+n.h/v*r.scale/p,E=new c(b,w),S=new c(T,w),P=new c(b,D),I=new c(T,D);if(m){let e=new c(-g,g- -17),t=-Math.PI/2,i=12-g,a=new c(22-i,-(r.imageName?i:0)),n=new c(...x);E._rotateAround(t,e)._add(a)._add(n),S._rotateAround(t,e)._add(a)._add(n),P._rotateAround(t,e)._add(a)._add(n),I._rotateAround(t,e)._add(a)._add(n)}if(l){let e=Math.sin(l),t=Math.cos(l),i=[t,-e,e,t];E._matMult(i),S._matMult(i),P._matMult(i),I._matMult(i)}let A=new c(0,0),C=new c(0,0);u.push({tl:E,tr:S,bl:P,br:I,tex:n,writingMode:t.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:A,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0})}return u}(0,i,s,a,n,o,r,e.allowVerticalPlacement),y=e.textSizeData,x=null;"source"===y.kind?(x=[128*a.layout.get("text-size").evaluate(o,{})],x[0]>32640&&Oe(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===y.kind&&(x=[128*m.compositeTextSizes[0].evaluate(o,{},g),128*m.compositeTextSizes[1].evaluate(o,{},g)],(x[0]>32640||x[1]>32640)&&Oe(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,_,x,s,n,o,h,t,u.lineStartIndex,u.lineLength,f,g,l);for(let t of d)p[t]=e.text.placedSymbolArray.length-1;return 4*_.length}function Fp(e){for(let t in e)return e[t];return null}function Rp(e,t,i,r){let a=e.compareText;if(t in a){let e=a[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<i)return!0}else a[t]=[];return a[t].push(r),!1}function kp(e,t,i){let r="never",a=e.get(t);return a?r=a:e.get(i)&&(r="always"),r}const Lp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Bp(e,t,i,r,a,n,o,s,l,u,h,c,d,p){let f=s?Math.min(32640,Math.round(s[0])):0,m=s?Math.min(32640,Math.round(s[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*a),n,o,+!!l+(f<<1),m,16*u,16*h,256*c,256*d,p)}function Op(e,t,i){e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i)}function jp(e){for(let t of e.sections)if(hd(t.text))return!0;return!1}var Vp=class{constructor(e){this.layoutVertexArray=new As,this.indexArray=new Ls,this.programConfigurations=e,this.segments=new Ns,this.dynamicLayoutVertexArray=new Cs,this.opacityVertexArray=new Ms,this.hasVisibleVertices=!1,this.placedSymbolArray=new hs}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ic.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Ac.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Lp,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}};eo("SymbolBuffers",Vp);var Np=class{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new Ns,this.collisionVertexArray=new Rs}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Cc.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};eo("CollisionBuffers",Np);var Up=class{constructor(e){this.collisionBoxArray=e.collisionBoxArray,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.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!0,this.hasRTLText=!1,this.maxHeightOffset=0,this.sortKeyRanges=[],this.collisionCircleArray=[],this.maxGlyphs=65535;let t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ap(this.zoom,t["text-size"]),this.iconSizeData=ap(this.zoom,t["icon-size"]);let i=this.layers[0].layout,r=i.get("symbol-sort-key"),a=i.get("symbol-z-order");this.canOverlap="never"!==kp(i,"text-overlap","text-allow-overlap")||"never"!==kp(i,"icon-overlap","icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&!r.isConstant();let n="viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey;this.sortFeaturesByY=n&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map(e=>Bd[e])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID}createArrays(){this.text=new Vp(new yl(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new Vp(new yl(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new ps,this.lineVertexArray=new fs,this.symbolInstances=new ds,this.textAnchorOffsets=new gs}calculateGlyphDependencies(e,t,i,r,a){let n=(r||this.allowVerticalPlacement)&&a,o=vd.fromFeature(e,i),s=o.graphemes();for(let e=0;e<s.length;e++){let i=o.getSection(e);if("imageName"in i)continue;let r=t[i.fontStack]||={},a=s[e];id(a)&&(r[a]=!0);for(let e of a){if(r[e]=!0,!n)continue;let t=cd[e];t&&(r[t]=!0)}}}populate(e,t,i){let r=this.layers[0],a=r.layout,n=a.get("text-font"),o=a.get("text-field"),s=a.get("icon-image"),l=("constant"!==o.value.kind||o.value.value instanceof _i&&!o.value.value.isEmpty()||o.value.value.toString().length>0)&&("constant"!==n.value.kind||n.value.value.length>0),u="constant"!==s.value.kind||!!s.value.value||Object.keys(s.parameters).length>0,h=a.get("symbol-sort-key");if(this.features=[],!l&&!u)return;let c=t.iconDependencies,d=t.glyphDependencies,p=t.availableImages,f=new so(this.zoom);for(let{feature:t,id:o,index:s,sourceLayerIndex:m}of e){let e,g,_=r._featureFilter.needGeometry,y=Dl(t,_);if(!r._featureFilter.filter(f,y,i))continue;if(_||(y.geometry=Tl(t)),l){let t=r.getValueAndResolveTokens("text-field",y,i,p),a=_i.factory(t);this.hasRTLText||=jp(a),e=Yc(a,r,y)}if(u){let e=r.getValueAndResolveTokens("icon-image",y,i,p);g=e instanceof Di?e:Di.fromString(e)}if(!e&&!g)continue;let x=this.sortFeaturesByKey?h.evaluate(y,{},i):void 0,v={id:o,text:e,icon:g,index:s,sourceLayerIndex:m,geometry:y.geometry,properties:t.properties,type:zh.types[t.type],sortKey:x};if(this.features.push(v),g&&(c[g.name]=!0),e){let t=n.evaluate(y,{},i).join(","),r="viewport"!==a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes?.includes(2);let o=ad(e.toString());this.calculateGlyphDependencies(e,d,t,r,o);for(let t of e.sections)t.image&&(c[t.image.name]=!0)}}"line"===a.get("symbol-placement")&&(this.features=function(e){let t={},i={},r=[],a=0;function n(t){r.push(e[t]),a++}function o(e,t,a){let n=i[e];return delete i[e],i[t]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(a[0]),n}function s(e,i,a){let n=t[i];return delete t[i],t[e]=n,r[n].geometry[0].shift(),r[n].geometry[0]=a[0].concat(r[n].geometry[0]),n}function l(e,t,i){let r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let u=0;u<e.length;u++){let h=e[u],c=h.geometry,d=h.text?h.text.toString():null;if(!d){n(u);continue}let p=l(d,c),f=l(d,c,!0);if(p in i&&f in t&&i[p]!==t[f]){let e=s(p,f,c),a=o(p,f,r[e].geometry);delete t[p],delete i[f],i[l(d,r[a].geometry,!0)]=a,r[e].geometry=null}else p in i?o(p,f,c):f in t?s(p,f,c):(n(u),t[p]=a-1,i[f]=a-1)}return r.filter(e=>e.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}addFeatures({options:e,canonical:t,glyphMap:i,glyphPositions:r,iconMap:a,iconPositions:n,showCollisionBoxes:o}){!function(e){e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=re/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let i=e.bucket.layers[0],r=i.layout,a=i._unevaluatedLayout._values,n={layoutIconSize:a["icon-size"].possiblyEvaluate(new so(e.bucket.zoom+1),e.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new so(e.bucket.zoom+1),e.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new so(18))};if("composite"===e.bucket.textSizeData.kind){let{minZoom:t,maxZoom:i}=e.bucket.textSizeData;n.compositeTextSizes=[a["text-size"].possiblyEvaluate(new so(t),e.canonical),a["text-size"].possiblyEvaluate(new so(i),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){let{minZoom:t,maxZoom:i}=e.bucket.iconSizeData;n.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new so(t),e.canonical),a["icon-size"].possiblyEvaluate(new so(i),e.canonical)]}let o=24*r.get("text-line-height"),s="viewport"!==r.get("text-rotation-alignment")&&"point"!==r.get("symbol-placement"),l=r.get("text-keep-upright"),u=r.get("text-size");for(let t of e.bucket.features){let a=r.get("text-font").evaluate(t,{},e.canonical).join(","),h=u.evaluate(t,{},e.canonical),c=n.layoutTextSize.evaluate(t,{},e.canonical),d=n.layoutIconSize.evaluate(t,{},e.canonical),p={horizontal:{},vertical:void 0},f=t.text,m=[0,0];if(f){let n=f.toString(),u=24*r.get("text-letter-spacing").evaluate(t,{},e.canonical),d=nd(n)?u:0,g=r.get("text-anchor").evaluate(t,{},e.canonical),_=Ap(i,t,e.canonical);if(!_){let i=r.get("text-radial-offset").evaluate(t,{},e.canonical);m=i?Ip(g,[24*i,Pp]):r.get("text-offset").evaluate(t,{},e.canonical).map(e=>24*e)}let y=s?"center":r.get("text-justify").evaluate(t,{},e.canonical),x="point"===r.get("symbol-placement")?24*r.get("text-max-width").evaluate(t,{},e.canonical):1/0,v=()=>{e.bucket.allowVerticalPlacement&&ad(n)&&(p.vertical=Ud(f,e.glyphMap,e.glyphPositions,e.imagePositions,a,x,o,g,"left",d,m,2,!0,c,h))};if(!s&&_){let t=new Set;if("auto"===y)for(let e=0;e<_.values.length;e+=2)t.add(Cp(_.values[e]));else t.add(y);let i=!1;for(let r of t)if(!p.horizontal[r])if(i)p.horizontal[r]=p.horizontal[0];else{let t=Ud(f,e.glyphMap,e.glyphPositions,e.imagePositions,a,x,o,"center",r,d,m,1,!1,c,h);t&&(p.horizontal[r]=t,i=1===t.positionedLines.length)}v()}else{"auto"===y&&(y=Cp(g));let t=Ud(f,e.glyphMap,e.glyphPositions,e.imagePositions,a,x,o,g,y,d,m,1,!1,c,h);t&&(p.horizontal[y]=t),v(),ad(n)&&s&&l&&(p.vertical=Ud(f,e.glyphMap,e.glyphPositions,e.imagePositions,a,x,o,g,y,d,m,2,!1,c,h))}}let g,_=!1;if(t.icon?.name){let i=e.imageMap[t.icon.name];i&&(g=tp(e.imagePositions[t.icon.name],r.get("icon-offset").evaluate(t,{},e.canonical),r.get("icon-anchor").evaluate(t,{},e.canonical)),_=!!i.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=_:e.bucket.sdfIcons!==_&&Oe("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),i.pixelRatio===e.bucket.pixelRatio?0!==r.get("icon-rotate").constantOr(1)&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let y=Fp(p.horizontal)||p.vertical;e.bucket.iconsInText||=!!y&&y.iconsInText,(y||g)&&Mp(e.bucket,t,p,g,e.imageMap,n,c,d,m,_,e.canonical,e.subdivisionGranularity)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}({bucket:this,glyphMap:i,glyphPositions:r,imageMap:a,imagePositions:n,showCollisionBoxes:o,canonical:t,subdivisionGranularity:e.subdivisionGranularity})}isEmpty(){return 0===this.symbolInstances.length}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]),a={};for(let r=e.segment+1;r<t.length;r++)a[r]={x:t[r].x,y:t[r].y,tileUnitDistanceFromAnchor:i},r<t.length-1&&(i+=t[r+1].dist(t[r]));for(let i=e.segment||0;i>=0;i--)a[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=t[i-1].dist(t[i]));for(let e=0;e<t.length;e++){let t=a[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=e.indexArray,f=e.layoutVertexArray,m=e.segments.prepareSegment(4*t.length,f,p,this.canOverlap?n.sortKey:void 0),g=this.glyphOffsetArray.length,_=m.vertexLength,y=this.allowVerticalPlacement&&2===o?Math.PI/2:0,x=n.text&&n.text.sections;for(let r=0;r<t.length;r++){let{tl:a,tr:o,bl:l,br:u,tex:h,pixelOffsetTL:g,pixelOffsetBR:_,minFontScaleX:v,minFontScaleY:b,glyphOffset:w,isSDF:T,sectionIndex:D}=t[r],E=m.vertexLength,S=w[1];Bp(f,s.x,s.y,a.x,S+a.y,h.x,h.y,i,T,g.x,g.y,v,b,d),Bp(f,s.x,s.y,o.x,S+o.y,h.x+h.w,h.y,i,T,_.x,g.y,v,b,d),Bp(f,s.x,s.y,l.x,S+l.y,h.x,h.y+h.h,i,T,g.x,_.y,v,b,d),Bp(f,s.x,s.y,u.x,S+u.y,h.x+h.w,h.y+h.h,i,T,_.x,_.y,v,b,d),Op(e.dynamicLayoutVertexArray,s,y),p.emplaceBack(E,E+2,E+1),p.emplaceBack(E+1,E+2,E+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(w[0]),(r===t.length-1||D!==t[r+1].sectionIndex)&&e.programConfigurations.populatePaintArrays(f.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:x?.[D]})}e.placedSymbolArray.emplaceBack(s.x,s.y,g,this.glyphOffsetArray.length-g,_,l,u,s.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],o,0,!1,0,h,d)}_addCollisionDebugVertex(e,t,i,r,a,n){return t.emplaceBack(0,0),e.emplaceBack(i.x,i.y,r,a,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(e,t,i,r,a,n,o){let s=a.segments.prepareSegment(4,a.layoutVertexArray,a.indexArray),l=s.vertexLength,u=a.layoutVertexArray,h=a.collisionVertexArray,d=o.anchorX,p=o.anchorY;this._addCollisionDebugVertex(u,h,n,d,p,new c(e,t)),this._addCollisionDebugVertex(u,h,n,d,p,new c(i,t)),this._addCollisionDebugVertex(u,h,n,d,p,new c(i,r)),this._addCollisionDebugVertex(u,h,n,d,p,new c(e,r)),s.vertexLength+=4;let f=a.indexArray;f.emplaceBack(l,l+1),f.emplaceBack(l+1,l+2),f.emplaceBack(l+2,l+3),f.emplaceBack(l+3,l),s.primitiveLength+=4}addDebugCollisionBoxes(e,t,i,r){for(let a=e;a<t;a++){let e=this.collisionBoxArray.get(a),t=e.x1,n=e.y1,o=e.x2,s=e.y2;this.addCollisionDebugVertices(t,n,o,s,r?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Np(zs,Mc.members,Bs),this.iconCollisionBox=new Np(zs,Mc.members,Bs);for(let e=0;e<this.symbolInstances.length;e++){let t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,i,r,a,n,o,s,l){let u={};for(let r=t;r<i;r++){let t=e.get(r);u.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},u.textFeatureIndex=t.featureIndex;break}for(let t=r;t<a;t++){let i=e.get(t);u.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},u.verticalTextFeatureIndex=i.featureIndex;break}for(let t=n;t<o;t++){let i=e.get(t);u.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},u.iconFeatureIndex=i.featureIndex;break}for(let t=s;t<l;t++){let i=e.get(t);u.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},u.verticalIconFeatureIndex=i.featureIndex;break}return u}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){let i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+2,t+1),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;let t=Math.sin(e),i=Math.cos(e),r=[],a=[],n=[];for(let e=0;e<this.symbolInstances.length;++e){n.push(e);let o=this.symbolInstances.get(e);r.push(0|Math.round(t*o.anchorX+i*o.anchorY)),a.push(o.featureIndex)}return n.sort((e,t)=>r[e]-r[t]||a[t]-a[e]),n}addToSortKeyRanges(e,t){let i=this.sortKeyRanges[this.sortKeyRanges.length-1];i?.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let e of this.symbolInstanceIndexes){let t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);let i=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let e=0;e<i.length;e++){let t=i[e];t>=0&&i.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)}}};let $p,Gp;eo("SymbolBucket",Up,{omit:["layers","collisionBoxArray","features","compareText"]});var Zp={get paint(){return Gp||=new Do({"icon-opacity":new vo(vt.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new vo(vt.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new vo(vt.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new vo(vt.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new vo(vt.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new xo(vt.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new xo(vt.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new vo(vt.paint_symbol["text-opacity"],"text-opacity"),"text-color":new vo(vt.paint_symbol["text-color"],"text-color",{runtimeType:Pt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new vo(vt.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new vo(vt.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new vo(vt.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new xo(vt.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new xo(vt.paint_symbol["text-translate-anchor"],"text-translate-anchor")})},get layout(){return $p||=new Do({"symbol-placement":new xo(vt.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new xo(vt.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new xo(vt.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new vo(vt.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new xo(vt.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new xo(vt.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new xo(vt.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new xo(vt.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new xo(vt.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new vo(vt.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new vo(vt.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new xo(vt.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new xo(vt.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new vo(vt.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new vo(vt.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new vo(vt.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new xo(vt.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new vo(vt.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new vo(vt.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new xo(vt.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new xo(vt.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new xo(vt.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new vo(vt.layout_symbol["text-field"],"text-field"),"text-font":new vo(vt.layout_symbol["text-font"],"text-font"),"text-size":new vo(vt.layout_symbol["text-size"],"text-size"),"text-max-width":new vo(vt.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new xo(vt.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new vo(vt.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new vo(vt.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new vo(vt.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new xo(vt.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new vo(vt.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new vo(vt.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new xo(vt.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new xo(vt.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new vo(vt.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new xo(vt.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new xo(vt.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new vo(vt.layout_symbol["text-transform"],"text-transform"),"text-offset":new vo(vt.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new xo(vt.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new xo(vt.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new xo(vt.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new xo(vt.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new vo(vt.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new xo(vt.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")})}},qp=class{constructor(e){if(void 0===e.property.overrides)throw Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Tt,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){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}};eo("FormatSectionOverride",qp,{omit:["defaultValue"]});const Wp=e=>"symbol"===e.type;var Xp=class e extends Po{constructor(e,t){super(e,Zp,t)}recalculate(e,t){super.recalculate(e,t);let i=this.layout.get("icon-rotation-alignment");if(("constant"!==i.value.kind||"auto"===i.value.value)&&(this.layout._values["icon-rotation-alignment"]=new mo(i.property,{kind:"constant",value:"point"===this.layout.get("symbol-placement")?"viewport":"map"},i.parameters)),"auto"===this.layout.get("text-rotation-alignment")&&("point"===this.layout.get("symbol-placement")?this.layout._values["text-rotation-alignment"]="viewport":this.layout._values["text-rotation-alignment"]="map"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment").constantOr("viewport")),"point"===this.layout.get("symbol-placement")){let e=this.layout.get("text-writing-mode");if(e){let t=[];for(let i of e)t.includes(i)||t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,r){let a=this.layout.get(e).evaluate(t,{},i,r),n=this._unevaluatedLayout._values[e];return n.isDataDriven()||ka(n.value)||!a?a:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,a)}createBucket(e){return new Up(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of Zp.paint.overridableProperties){if(!e.hasPaintOverride(this.layout,t))continue;let i=this.paint.get(t),r=new za(new qp(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),a=null;a="constant"===i.value.kind||"source"===i.value.kind?new Ba("source",r):new Oa("composite",r,i.value.zoomStops),this.paint._values[t]=new mo(i.property,a,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&e.hasPaintOverride(this.layout,t)}static hasPaintOverride(e,t){let i=e.get("text-field"),r=Zp.paint.properties[t],a=!1,n=e=>{for(let t of e)if(r.overrides?.hasOverride(t))return void(a=!0)};if("constant"===i.value.kind&&i.value.value instanceof _i)n(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){let e=t=>{if(!a)if(t instanceof Mi&&Ai(t.value)===zt){let e=t.value;n(e.sections)}else t instanceof ji?n(t.sections):t.eachChild(e)},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return a}};let Hp;var Yp={get paint(){return Hp||=new Do({"background-color":new xo(vt.paint_background["background-color"],"background-color"),"background-pattern":new wo(vt.paint_background["background-pattern"],"background-pattern"),"background-opacity":new xo(vt.paint_background["background-opacity"],"background-opacity")})}},Kp=class extends Po{constructor(e,t){super(e,Yp,t)}},Jp=class extends Po{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"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error("Custom layers cannot be serialized")}};function Qp(e,t){if("custom"===e.type)return new Jp(e,t);switch(e.type){case"background":return new Kp(e,t);case"circle":return new Jl(e,t);case"color-relief":return new vu(e,t);case"fill":return new Dh(e,t);case"fill-extrusion":return new dc(e,t);case"heatmap":return new hu(e,t);case"hillshade":return new pu(e,t);case"line":return new Sc(e,t);case"raster":return new Mo(e,t);case"symbol":return new Xp(e,t)}}var ef=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 tf={once:!0};var rf=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ef(()=>this.process()),this.subscription=$e(this.target,"message",e=>this.receive(e),!1),this.globalScope=Ve(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,r)=>{let a=Math.round(1e18*Math.random()).toString(36).substring(0,10),n=t?$e(t.signal,"abort",()=>{n?.unsubscribe(),delete this.resolveRejects[a];let i={id:a,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(i),r(new it(t.signal.reason))},tf):null;this.resolveRejects[a]={resolve:e=>{n?.unsubscribe(),i(e)},reject:e=>{n?.unsubscribe(),r(e)}};let o=[],s={...e,id:a,sourceMapId:this.mapId,origin:location.origin,data:ao(e.data,o)};this.target.postMessage(s,{transfer:o})})}receive(e){let t=e.data,i=t.id,r=["file://","resource://android","null"],a=[t.origin,location.origin],n=t.origin===location.origin,o=a.some(e=>r.includes(e));if((n||o)&&(!t.targetMapId||this.mapId===t.targetMapId)){if("<cancel>"===t.type){delete this.tasks[i];let e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if(Ve(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)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("<response>"===t.type){let i=this.resolveRejects[e];if(delete this.resolveRejects[e],!i)return;return void(t.error?i.reject(ne(no(t.error))):i.resolve(no(t.data)))}if(!this.messageHandlers[t.type])return void this.completeTask(e,null,null);let i=no(t.data),r=new AbortController;this.abortControllers[e]=r;try{let a=await this.messageHandlers[t.type](t.sourceMapId,i,r);this.completeTask(e,null,a)}catch(t){this.completeTask(e,ne(t))}}completeTask(e,t,i){let r=[];delete this.abortControllers[e];let a={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?ao(t):null,data:ao(i,r)};this.target.postMessage(a,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function af(e,t){let{x:i,y:r}=Xh.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||i<0||i>=1)}var nf=class{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=2**e||t<0||t>=2**e)}(e,t,i))throw Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=lf(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){let r=function(e,t,i){let r=hf(256*e,256*(t=2**i-t-1),i),a=hf(256*(e+1),256*(t+1),i);return`${r[0]},${r[1]},${a[0]},${a[1]}`}(this.x,this.y,this.z),a=function(e,t,i){let r="";for(let a=e;a>0;a--){let e=1<<a-1;r+=(t&e?1:0)+(i&e?2:0)}return r}(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("tms"===i?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,a).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 c((e.x*t-this.x)*re,(e.y*t-this.y)*re)}toString(){return`${this.z}/${this.x}/${this.y}`}},of=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=lf(e,t.z,t.z,t.x,t.y)}},sf=class e{constructor(e,t,i,r,a){if(this.terrainRttPosMatrix32f=null,e<i)throw Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new nf(i,+r,+a),this.key=lf(t,e,i,r,a)}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 i=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>>i,this.canonical.y>>i)}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 i=this.canonical.z-e;return e>this.canonical.z?lf(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):lf(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;let t=this.canonical.z-e.canonical.z;return!(t<0)&&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 i=this.canonical.z+1,r=2*this.canonical.x,a=2*this.canonical.y;return[new e(i,this.wrap,i,r,a),new e(i,this.wrap,i,r+1,a),new e(i,this.wrap,i,r,a+1),new e(i,this.wrap,i,r+1,a+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new e(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new e(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new of(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Xh(e.x-this.wrap,e.y))}normalizeCoordinates(t,i,r=re){if(t>=0&&t<r&&i>=0&&i<r)return{tileID:this,x:t,y:i};let a=Math.floor(t/r),n=Math.floor(i/r),o=t-a*r,s=i-n*r,l=this.canonical.z,u=1<<l,h=this.canonical.y+n;if(h<0||h>=u)return null;let c=this.canonical.x+a,d=this.wrap;return c<0?(d-=Math.ceil(-c/u),c=(c%u+u)%u):c>=u&&(d+=Math.floor(c/u),c%=u),{tileID:new e(this.overscaledZ,d,l,c,h),x:o,y:s}}};function lf(e,t,i,r,a){(e*=2)<0&&(e=-1*e-1);let n=1<<i;return(n*n*e+n*a+r).toString(36)+i.toString(36)+t.toString(36)}const uf=6378137*Math.PI;function hf(e,t,i){let r=2*uf/256/2**i;return[e*r-uf,t*r-uf]}function cf(e,t){let i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}eo("CanonicalTileID",nf),eo("OverscaledTileID",sf,{omit:["terrainRttPosMatrix32f"]});const df="_geojsonTileLayer";var pf=class{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){let i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}},ff=class{constructor(e,t,i,r,a){this.type="Feature",this._vectorTileFeature=e,this._x=i,this._y=r,this._z=t;for(let t in e.properties)"string"==typeof e.properties[t]&&e.properties[t].startsWith("__$json__:")&&(e.properties[t]=JSON.parse(e.properties[t].slice(10)));this.properties=e.properties,this.id=a}projectPoint(e,t,i,r){return[360*(e.x+t)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+i)/r)*Math.PI))-90]}projectLine(e,t,i,r){return e.map(e=>this.projectPoint(e,t,i,r))}get geometry(){if(this._geometry)return this._geometry;let e=this._vectorTileFeature,t=e.extent*2**this._z,i=e.extent*this._x,r=e.extent*this._y,a=e.loadGeometry();switch(e.type){case 1:{let e=[];for(let t of a)e.push(t[0]);let n=this.projectLine(e,i,r,t);this._geometry=1===e.length?{type:"Point",coordinates:n[0]}:{type:"MultiPoint",coordinates:n};break}case 2:{let e=a.map(e=>this.projectLine(e,i,r,t));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{let e=Fh(a),n=[];for(let a of e)n.push(a.map(e=>this.projectLine(e,i,r,t)));this._geometry=1===n.length?{type:"Polygon",coordinates:n[0]}:{type:"MultiPolygon",coordinates:n};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)"_geometry"!==t&&"_vectorTileFeature"!==t&&"_x"!==t&&"_y"!==t&&"_z"!==t&&(e[t]=this[t]);return e}},mf=class{constructor(e,t,i){this._name=e,this.dataBuffer=t,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},gf=class extends mf{},_f=class extends gf{getValueFromBuffer(e){return this.dataBuffer[e]}},yf=class extends gf{getValueFromBuffer(e){return this.dataBuffer[e]}},xf=class extends mf{constructor(e,t,i,r){super(e,t,r),this.delta=i}},vf=class extends xf{constructor(e,t,i,r,a){super(e,a?Int32Array.of(t):Uint32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},bf=class extends mf{constructor(e,t,i,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},wf=class{constructor(e,t,i,r,a=4096){if(this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=r,this._extent=a,0===e.length)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 i=0;i<this.numFeatures;i++){let r;if(this.idVector){let e=this.idVector.getValue(i);null!==e&&(r=this.containsMaxSafeIntegerValues(this.idVector)?Number(e):e)}let a={coordinates:t[i],type:this.geometryVector.geometryType(i)},n={};for(let e of this.propertyVectors){if(!e)continue;let t=e.name,r=e.getValue(i);null!==r&&(n[t]=r)}e.push({id:r,geometry:a,properties:n})}return e}containsMaxSafeIntegerValues(e){return e instanceof _f||e instanceof bf||e instanceof vf||e instanceof yf}};var Tf,Df,Ef=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}};!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON"}(Tf||={}),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT"}(Df||={});const Sf=new Uint32Array(33);Sf[0]=0;for(let e=1;e<=32;e++)Sf[e]=32===e?4294967295:4294967295>>>32-e;const Pf=Sf;function If(e,t){return e-e%t}function Af(e){return If(e+31,32)}function Cf(e){let t=e>>>0;return((255&t)<<24|(65280&t)<<8|t>>>8&65280|t>>>24&255)>>>0}const Mf=function(e){if(!Number.isFinite(e))return 65536;let t=If(Math.floor(e),256);return 0===t?256:t}(65536),zf=3*Mf/256+Mf|0;function Ff(){let e=new Uint8Array(zf);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 Rf(e,t,i,r,a){switch(a){case 1:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<8;t++){let t=e[n++]>>>0;i[a++]=t>>>0&1,i[a++]=t>>>1&1,i[a++]=t>>>2&1,i[a++]=t>>>3&1,i[a++]=t>>>4&1,i[a++]=t>>>5&1,i[a++]=t>>>6&1,i[a++]=t>>>7&1,i[a++]=t>>>8&1,i[a++]=t>>>9&1,i[a++]=t>>>10&1,i[a++]=t>>>11&1,i[a++]=t>>>12&1,i[a++]=t>>>13&1,i[a++]=t>>>14&1,i[a++]=t>>>15&1,i[a++]=t>>>16&1,i[a++]=t>>>17&1,i[a++]=t>>>18&1,i[a++]=t>>>19&1,i[a++]=t>>>20&1,i[a++]=t>>>21&1,i[a++]=t>>>22&1,i[a++]=t>>>23&1,i[a++]=t>>>24&1,i[a++]=t>>>25&1,i[a++]=t>>>26&1,i[a++]=t>>>27&1,i[a++]=t>>>28&1,i[a++]=t>>>29&1,i[a++]=t>>>30&1,i[a++]=t>>>31&1}}(e,t,i,r);break;case 2:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<8;t++){let t=e[n++]>>>0,r=e[n++]>>>0;i[a++]=t>>>0&3,i[a++]=t>>>2&3,i[a++]=t>>>4&3,i[a++]=t>>>6&3,i[a++]=t>>>8&3,i[a++]=t>>>10&3,i[a++]=t>>>12&3,i[a++]=t>>>14&3,i[a++]=t>>>16&3,i[a++]=t>>>18&3,i[a++]=t>>>20&3,i[a++]=t>>>22&3,i[a++]=t>>>24&3,i[a++]=t>>>26&3,i[a++]=t>>>28&3,i[a++]=t>>>30&3,i[a++]=r>>>0&3,i[a++]=r>>>2&3,i[a++]=r>>>4&3,i[a++]=r>>>6&3,i[a++]=r>>>8&3,i[a++]=r>>>10&3,i[a++]=r>>>12&3,i[a++]=r>>>14&3,i[a++]=r>>>16&3,i[a++]=r>>>18&3,i[a++]=r>>>20&3,i[a++]=r>>>22&3,i[a++]=r>>>24&3,i[a++]=r>>>26&3,i[a++]=r>>>28&3,i[a++]=r>>>30&3}}(e,t,i,r);break;case 3:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<8;t++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0;i[a++]=t>>>0&7,i[a++]=t>>>3&7,i[a++]=t>>>6&7,i[a++]=t>>>9&7,i[a++]=t>>>12&7,i[a++]=t>>>15&7,i[a++]=t>>>18&7,i[a++]=t>>>21&7,i[a++]=t>>>24&7,i[a++]=t>>>27&7,i[a++]=7&(t>>>30|(1&r)<<2),i[a++]=r>>>1&7,i[a++]=r>>>4&7,i[a++]=r>>>7&7,i[a++]=r>>>10&7,i[a++]=r>>>13&7,i[a++]=r>>>16&7,i[a++]=r>>>19&7,i[a++]=r>>>22&7,i[a++]=r>>>25&7,i[a++]=r>>>28&7,i[a++]=7&(r>>>31|(3&o)<<1),i[a++]=o>>>2&7,i[a++]=o>>>5&7,i[a++]=o>>>8&7,i[a++]=o>>>11&7,i[a++]=o>>>14&7,i[a++]=o>>>17&7,i[a++]=o>>>20&7,i[a++]=o>>>23&7,i[a++]=o>>>26&7,i[a++]=o>>>29&7}}(e,t,i,r);break;case 4:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<8;t++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=e[n++]>>>0;i[a++]=t>>>0&15,i[a++]=t>>>4&15,i[a++]=t>>>8&15,i[a++]=t>>>12&15,i[a++]=t>>>16&15,i[a++]=t>>>20&15,i[a++]=t>>>24&15,i[a++]=t>>>28&15,i[a++]=r>>>0&15,i[a++]=r>>>4&15,i[a++]=r>>>8&15,i[a++]=r>>>12&15,i[a++]=r>>>16&15,i[a++]=r>>>20&15,i[a++]=r>>>24&15,i[a++]=r>>>28&15,i[a++]=o>>>0&15,i[a++]=o>>>4&15,i[a++]=o>>>8&15,i[a++]=o>>>12&15,i[a++]=o>>>16&15,i[a++]=o>>>20&15,i[a++]=o>>>24&15,i[a++]=o>>>28&15,i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15}}(e,t,i,r);break;case 5:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<8;t++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=e[n++]>>>0,l=e[n++]>>>0;i[a++]=t>>>0&31,i[a++]=t>>>5&31,i[a++]=t>>>10&31,i[a++]=t>>>15&31,i[a++]=t>>>20&31,i[a++]=t>>>25&31,i[a++]=31&(t>>>30|(7&r)<<2),i[a++]=r>>>3&31,i[a++]=r>>>8&31,i[a++]=r>>>13&31,i[a++]=r>>>18&31,i[a++]=r>>>23&31,i[a++]=31&(r>>>28|(1&o)<<4),i[a++]=o>>>1&31,i[a++]=o>>>6&31,i[a++]=o>>>11&31,i[a++]=o>>>16&31,i[a++]=o>>>21&31,i[a++]=o>>>26&31,i[a++]=31&(o>>>31|(15&s)<<1),i[a++]=s>>>4&31,i[a++]=s>>>9&31,i[a++]=s>>>14&31,i[a++]=s>>>19&31,i[a++]=s>>>24&31,i[a++]=31&(s>>>29|(3&l)<<3),i[a++]=l>>>2&31,i[a++]=l>>>7&31,i[a++]=l>>>12&31,i[a++]=l>>>17&31,i[a++]=l>>>22&31,i[a++]=l>>>27&31}}(e,t,i,r);break;case 6:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<8;t++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0;i[a++]=t>>>0&63,i[a++]=t>>>6&63,i[a++]=t>>>12&63,i[a++]=t>>>18&63,i[a++]=t>>>24&63,i[a++]=63&(t>>>30|(15&r)<<2),i[a++]=r>>>4&63,i[a++]=r>>>10&63,i[a++]=r>>>16&63,i[a++]=r>>>22&63,i[a++]=63&(r>>>28|(3&o)<<4),i[a++]=o>>>2&63,i[a++]=o>>>8&63,i[a++]=o>>>14&63,i[a++]=o>>>20&63,i[a++]=o>>>26&63,i[a++]=s>>>0&63,i[a++]=s>>>6&63,i[a++]=s>>>12&63,i[a++]=s>>>18&63,i[a++]=s>>>24&63,i[a++]=63&(s>>>30|(15&l)<<2),i[a++]=l>>>4&63,i[a++]=l>>>10&63,i[a++]=l>>>16&63,i[a++]=l>>>22&63,i[a++]=63&(l>>>28|(3&u)<<4),i[a++]=u>>>2&63,i[a++]=u>>>8&63,i[a++]=u>>>14&63,i[a++]=u>>>20&63,i[a++]=u>>>26&63}}(e,t,i,r);break;case 7:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<8;t++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0;i[a++]=t>>>0&127,i[a++]=t>>>7&127,i[a++]=t>>>14&127,i[a++]=t>>>21&127,i[a++]=127&(t>>>28|(7&r)<<4),i[a++]=r>>>3&127,i[a++]=r>>>10&127,i[a++]=r>>>17&127,i[a++]=r>>>24&127,i[a++]=127&(r>>>31|(63&o)<<1),i[a++]=o>>>6&127,i[a++]=o>>>13&127,i[a++]=o>>>20&127,i[a++]=127&(o>>>27|(3&s)<<5),i[a++]=s>>>2&127,i[a++]=s>>>9&127,i[a++]=s>>>16&127,i[a++]=s>>>23&127,i[a++]=127&(s>>>30|(31&l)<<2),i[a++]=l>>>5&127,i[a++]=l>>>12&127,i[a++]=l>>>19&127,i[a++]=127&(l>>>26|(1&u)<<6),i[a++]=u>>>1&127,i[a++]=u>>>8&127,i[a++]=u>>>15&127,i[a++]=u>>>22&127,i[a++]=127&(u>>>29|(15&h)<<3),i[a++]=h>>>4&127,i[a++]=h>>>11&127,i[a++]=h>>>18&127,i[a++]=h>>>25&127}}(e,t,i,r);break;case 8:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<8;t++){let t=e[n++]>>>0,r=e[n++]>>>0,o=e[n++]>>>0,s=e[n++]>>>0,l=e[n++]>>>0,u=e[n++]>>>0,h=e[n++]>>>0,c=e[n++]>>>0;i[a++]=t>>>0&255,i[a++]=t>>>8&255,i[a++]=t>>>16&255,i[a++]=t>>>24&255,i[a++]=r>>>0&255,i[a++]=r>>>8&255,i[a++]=r>>>16&255,i[a++]=r>>>24&255,i[a++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255}}(e,t,i,r);break;case 16:!function(e,t,i,r){let a=r,n=t;for(let t=0;t<128;t++){let t=e[n++]>>>0;i[a++]=65535&t,i[a++]=t>>>16&65535}}(e,t,i,r);break;default:!function(e,t,i,r,a){let n=Pf[a]>>>0,o=t,s=0,l=e[o]>>>0,u=r;for(let t=0;t<8;t++){for(let t=0;t<32;t++)if(s+a<=32){let r=l>>>s&n;i[u+t]=0|r,s+=a,32===s&&(s=0,o++,31!==t&&(l=e[o]>>>0))}else{let r=32-s,h=l>>>s;o++,l=e[o]>>>0;let c=a-r,d=(h|(l&-1>>>32-c>>>0)<<r)&n;i[u+t]=0|d,s=c}u+=32,s=0,t<7&&(l=e[o]>>>0)}}(e,t,i,r,a)}return t+(a<<3)|0}function kf(e,t,i,r){if(i+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${t})`);let a=e[i++],n=e[i++];if(a>32)throw Error(`FastPFOR decode: invalid bitWidth=${a} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:a,exceptionCount:n,bytePosIn:i}}function Lf(e,t,i,r,a,n,o,s,l){let{maxBits:u,exceptionBitWidth:h,bytePosIn:c}=function(e,t,i,r,a,n){if(i+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${n} (need 1 byte for maxBits, bytePos=${i}, byteSize=${t})`);let o=e[i++];if(o<r||o>32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${n} (bitWidth=${r}, expected ${r}..32)`);let s=o-r|0;if(s<1||s>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${s} at block=${n} (bitWidth=${r}, maxBits=${o})`);if(i+a>t)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${a}, have=${t-i})`);return{maxBits:o,exceptionBitWidth:s,bytePosIn:i}}(a,n,o,i,r,l);if(o=c,1===h){let n=1<<i;for(let i=0;i<r;i=i+1|0)e[a[o++]+t|0]|=n;return o}let d=s.dataToBePacked[h];if(!d)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${i}, maxBits=${u}) at block ${l}`);let p=s.dataPointers,f=0|p[h],m=0|s.exceptionSizes[h];if(f+r>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${r}, size=${m}) at block ${l}`);for(let n=0;n<r;n=n+1|0){let r=a[o++],n=0|d[f++];e[r+t|0]|=n<<i}return p[h]=f,o}function Bf(e,t,i,r,a,n){let o=0|i,s=0|e[o];if(s<=0||o+s>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${s} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let l=o+1|0,u=o+s|0,h=e[u]>>>0,c=h+3>>>2,d=u+1,p=d+c;if(p>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${h} (metaInts=${c}, pageStart=${o}, packedEnd=${u}, byteContainerStart=${d}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let f=function(e,t,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(2*i),r.byteContainerI32=void 0);let a=r.byteContainer,n=i>>>2;if(3&a.byteOffset)for(let i=0;i<n;i=i+1|0){let r=0|e[t+i|0],n=i<<2;a[n]=255&r,a[n+1|0]=r>>>8&255,a[n+2|0]=r>>>16&255,a[n+3|0]=r>>>24&255}else{let i=r.byteContainerI32;(!i||i.buffer!==a.buffer||i.byteOffset!==a.byteOffset||i.length<n)&&(i=r.byteContainerI32=new Int32Array(a.buffer,a.byteOffset,a.byteLength>>>2)),i.set(e.subarray(t,t+n))}let o=3&i;if(o>0){let i=0|e[t+n|0],r=n<<2;for(let e=0;e<o;e=e+1|0)a[r+e|0]=i>>>(e<<3)&255}return a}(e,d,h,n),m=h,g=function(e,t,i){let r=0|e[t++],a=i.dataToBePacked;for(let n=2;n<=32;n=n+1|0){if(!(r>>>n-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${n}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let o=e[t++]>>>0,s=Af(o),l=o*n+31>>>5;if(t+l>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${n}, size=${o}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let u=a[n];(!u||u.length<s)&&(u=a[n]=new Uint32Array(s));let h=0;for(;h<o;h=h+32|0)Of(e,t,u,h,n),t=t+n|0;t=t-((h-o|0)*n>>>5)|0,i.exceptionSizes[n]=o}return t}(e,p,n);return n.dataPointers.fill(0),function(e,t,i,r,a,n,o,s,l,u){let h=0|i,c=0;for(let t=0;t<o;t=t+1|0){let i=kf(s,l,c,t);c=i.bytePosIn;let r=i.bitWidth,o=i.exceptionCount,d=n+256*t|0;switch(r){case 0:a.fill(0,d,d+256);break;case 32:for(let t=0;t<256;t=t+1|0)a[d+t|0]=0|e[h+t|0];h=h+256|0;break;default:h=Rf(e,h,a,d,r)}o>0&&(c=Lf(a,d,r,o,s,l,c,u,t))}if(h!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${h}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${e.length})`)}(e,o,l,u,t,0|r,a/256|0,f,m,n),g}function Of(e,t,i,r,a){switch(a){case 2:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0;i[a++]=n>>>0&3,i[a++]=n>>>2&3,i[a++]=n>>>4&3,i[a++]=n>>>6&3,i[a++]=n>>>8&3,i[a++]=n>>>10&3,i[a++]=n>>>12&3,i[a++]=n>>>14&3,i[a++]=n>>>16&3,i[a++]=n>>>18&3,i[a++]=n>>>20&3,i[a++]=n>>>22&3,i[a++]=n>>>24&3,i[a++]=n>>>26&3,i[a++]=n>>>28&3,i[a++]=n>>>30&3,i[a++]=o>>>0&3,i[a++]=o>>>2&3,i[a++]=o>>>4&3,i[a++]=o>>>6&3,i[a++]=o>>>8&3,i[a++]=o>>>10&3,i[a++]=o>>>12&3,i[a++]=o>>>14&3,i[a++]=o>>>16&3,i[a++]=o>>>18&3,i[a++]=o>>>20&3,i[a++]=o>>>22&3,i[a++]=o>>>24&3,i[a++]=o>>>26&3,i[a++]=o>>>28&3,i[a]=o>>>30&3}(e,t,i,r);case 3:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0;i[a++]=n>>>0&7,i[a++]=n>>>3&7,i[a++]=n>>>6&7,i[a++]=n>>>9&7,i[a++]=n>>>12&7,i[a++]=n>>>15&7,i[a++]=n>>>18&7,i[a++]=n>>>21&7,i[a++]=n>>>24&7,i[a++]=n>>>27&7,i[a++]=7&(n>>>30|(1&o)<<2),i[a++]=o>>>1&7,i[a++]=o>>>4&7,i[a++]=o>>>7&7,i[a++]=o>>>10&7,i[a++]=o>>>13&7,i[a++]=o>>>16&7,i[a++]=o>>>19&7,i[a++]=o>>>22&7,i[a++]=o>>>25&7,i[a++]=o>>>28&7,i[a++]=7&(o>>>31|(3&s)<<1),i[a++]=s>>>2&7,i[a++]=s>>>5&7,i[a++]=s>>>8&7,i[a++]=s>>>11&7,i[a++]=s>>>14&7,i[a++]=s>>>17&7,i[a++]=s>>>20&7,i[a++]=s>>>23&7,i[a++]=s>>>26&7,i[a]=s>>>29&7}(e,t,i,r);case 4:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0;i[a++]=n>>>0&15,i[a++]=n>>>4&15,i[a++]=n>>>8&15,i[a++]=n>>>12&15,i[a++]=n>>>16&15,i[a++]=n>>>20&15,i[a++]=n>>>24&15,i[a++]=n>>>28&15,i[a++]=o>>>0&15,i[a++]=o>>>4&15,i[a++]=o>>>8&15,i[a++]=o>>>12&15,i[a++]=o>>>16&15,i[a++]=o>>>20&15,i[a++]=o>>>24&15,i[a++]=o>>>28&15,i[a++]=s>>>0&15,i[a++]=s>>>4&15,i[a++]=s>>>8&15,i[a++]=s>>>12&15,i[a++]=s>>>16&15,i[a++]=s>>>20&15,i[a++]=s>>>24&15,i[a++]=s>>>28&15,i[a++]=l>>>0&15,i[a++]=l>>>4&15,i[a++]=l>>>8&15,i[a++]=l>>>12&15,i[a++]=l>>>16&15,i[a++]=l>>>20&15,i[a++]=l>>>24&15,i[a]=l>>>28&15}(e,t,i,r);case 5:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0;i[a++]=n>>>0&31,i[a++]=n>>>5&31,i[a++]=n>>>10&31,i[a++]=n>>>15&31,i[a++]=n>>>20&31,i[a++]=n>>>25&31,i[a++]=31&(n>>>30|(7&o)<<2),i[a++]=o>>>3&31,i[a++]=o>>>8&31,i[a++]=o>>>13&31,i[a++]=o>>>18&31,i[a++]=o>>>23&31,i[a++]=31&(o>>>28|(1&s)<<4),i[a++]=s>>>1&31,i[a++]=s>>>6&31,i[a++]=s>>>11&31,i[a++]=s>>>16&31,i[a++]=s>>>21&31,i[a++]=s>>>26&31,i[a++]=31&(s>>>31|(15&l)<<1),i[a++]=l>>>4&31,i[a++]=l>>>9&31,i[a++]=l>>>14&31,i[a++]=l>>>19&31,i[a++]=l>>>24&31,i[a++]=31&(l>>>29|(3&u)<<3),i[a++]=u>>>2&31,i[a++]=u>>>7&31,i[a++]=u>>>12&31,i[a++]=u>>>17&31,i[a++]=u>>>22&31,i[a]=u>>>27&31}(e,t,i,r);case 6:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0;i[a++]=n>>>0&63,i[a++]=n>>>6&63,i[a++]=n>>>12&63,i[a++]=n>>>18&63,i[a++]=n>>>24&63,i[a++]=63&(n>>>30|(15&o)<<2),i[a++]=o>>>4&63,i[a++]=o>>>10&63,i[a++]=o>>>16&63,i[a++]=o>>>22&63,i[a++]=63&(o>>>28|(3&s)<<4),i[a++]=s>>>2&63,i[a++]=s>>>8&63,i[a++]=s>>>14&63,i[a++]=s>>>20&63,i[a++]=s>>>26&63,i[a++]=l>>>0&63,i[a++]=l>>>6&63,i[a++]=l>>>12&63,i[a++]=l>>>18&63,i[a++]=l>>>24&63,i[a++]=63&(l>>>30|(15&u)<<2),i[a++]=u>>>4&63,i[a++]=u>>>10&63,i[a++]=u>>>16&63,i[a++]=u>>>22&63,i[a++]=63&(u>>>28|(3&h)<<4),i[a++]=h>>>2&63,i[a++]=h>>>8&63,i[a++]=h>>>14&63,i[a++]=h>>>20&63,i[a]=h>>>26&63}(e,t,i,r);case 7:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0;i[a++]=n>>>0&127,i[a++]=n>>>7&127,i[a++]=n>>>14&127,i[a++]=n>>>21&127,i[a++]=127&(n>>>28|(7&o)<<4),i[a++]=o>>>3&127,i[a++]=o>>>10&127,i[a++]=o>>>17&127,i[a++]=o>>>24&127,i[a++]=127&(o>>>31|(63&s)<<1),i[a++]=s>>>6&127,i[a++]=s>>>13&127,i[a++]=s>>>20&127,i[a++]=127&(s>>>27|(3&l)<<5),i[a++]=l>>>2&127,i[a++]=l>>>9&127,i[a++]=l>>>16&127,i[a++]=l>>>23&127,i[a++]=127&(l>>>30|(31&u)<<2),i[a++]=u>>>5&127,i[a++]=u>>>12&127,i[a++]=u>>>19&127,i[a++]=127&(u>>>26|(1&h)<<6),i[a++]=h>>>1&127,i[a++]=h>>>8&127,i[a++]=h>>>15&127,i[a++]=h>>>22&127,i[a++]=127&(h>>>29|(15&c)<<3),i[a++]=c>>>4&127,i[a++]=c>>>11&127,i[a++]=c>>>18&127,i[a]=c>>>25&127}(e,t,i,r);case 8:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0;i[a++]=n>>>0&255,i[a++]=n>>>8&255,i[a++]=n>>>16&255,i[a++]=n>>>24&255,i[a++]=o>>>0&255,i[a++]=o>>>8&255,i[a++]=o>>>16&255,i[a++]=o>>>24&255,i[a++]=s>>>0&255,i[a++]=s>>>8&255,i[a++]=s>>>16&255,i[a++]=s>>>24&255,i[a++]=l>>>0&255,i[a++]=l>>>8&255,i[a++]=l>>>16&255,i[a++]=l>>>24&255,i[a++]=u>>>0&255,i[a++]=u>>>8&255,i[a++]=u>>>16&255,i[a++]=u>>>24&255,i[a++]=h>>>0&255,i[a++]=h>>>8&255,i[a++]=h>>>16&255,i[a++]=h>>>24&255,i[a++]=c>>>0&255,i[a++]=c>>>8&255,i[a++]=c>>>16&255,i[a++]=c>>>24&255,i[a++]=d>>>0&255,i[a++]=d>>>8&255,i[a++]=d>>>16&255,i[a]=d>>>24&255}(e,t,i,r);case 9:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0;i[a++]=n>>>0&511,i[a++]=n>>>9&511,i[a++]=n>>>18&511,i[a++]=511&(n>>>27|(15&o)<<5),i[a++]=o>>>4&511,i[a++]=o>>>13&511,i[a++]=o>>>22&511,i[a++]=511&(o>>>31|(255&s)<<1),i[a++]=s>>>8&511,i[a++]=s>>>17&511,i[a++]=511&(s>>>26|(7&l)<<6),i[a++]=l>>>3&511,i[a++]=l>>>12&511,i[a++]=l>>>21&511,i[a++]=511&(l>>>30|(127&u)<<2),i[a++]=u>>>7&511,i[a++]=u>>>16&511,i[a++]=511&(u>>>25|(3&h)<<7),i[a++]=h>>>2&511,i[a++]=h>>>11&511,i[a++]=h>>>20&511,i[a++]=511&(h>>>29|(63&c)<<3),i[a++]=c>>>6&511,i[a++]=c>>>15&511,i[a++]=511&(c>>>24|(1&d)<<8),i[a++]=d>>>1&511,i[a++]=d>>>10&511,i[a++]=d>>>19&511,i[a++]=511&(d>>>28|(31&p)<<4),i[a++]=p>>>5&511,i[a++]=p>>>14&511,i[a]=p>>>23&511}(e,t,i,r);case 10:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0;i[a++]=n>>>0&1023,i[a++]=n>>>10&1023,i[a++]=n>>>20&1023,i[a++]=1023&(n>>>30|(255&o)<<2),i[a++]=o>>>8&1023,i[a++]=o>>>18&1023,i[a++]=1023&(o>>>28|(63&s)<<4),i[a++]=s>>>6&1023,i[a++]=s>>>16&1023,i[a++]=1023&(s>>>26|(15&l)<<6),i[a++]=l>>>4&1023,i[a++]=l>>>14&1023,i[a++]=1023&(l>>>24|(3&u)<<8),i[a++]=u>>>2&1023,i[a++]=u>>>12&1023,i[a++]=u>>>22&1023,i[a++]=h>>>0&1023,i[a++]=h>>>10&1023,i[a++]=h>>>20&1023,i[a++]=1023&(h>>>30|(255&c)<<2),i[a++]=c>>>8&1023,i[a++]=c>>>18&1023,i[a++]=1023&(c>>>28|(63&d)<<4),i[a++]=d>>>6&1023,i[a++]=d>>>16&1023,i[a++]=1023&(d>>>26|(15&p)<<6),i[a++]=p>>>4&1023,i[a++]=p>>>14&1023,i[a++]=1023&(p>>>24|(3&f)<<8),i[a++]=f>>>2&1023,i[a++]=f>>>12&1023,i[a]=f>>>22&1023}(e,t,i,r);case 11:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0;i[a++]=n>>>0&2047,i[a++]=n>>>11&2047,i[a++]=2047&(n>>>22|(1&o)<<10),i[a++]=o>>>1&2047,i[a++]=o>>>12&2047,i[a++]=2047&(o>>>23|(3&s)<<9),i[a++]=s>>>2&2047,i[a++]=s>>>13&2047,i[a++]=2047&(s>>>24|(7&l)<<8),i[a++]=l>>>3&2047,i[a++]=l>>>14&2047,i[a++]=2047&(l>>>25|(15&u)<<7),i[a++]=u>>>4&2047,i[a++]=u>>>15&2047,i[a++]=2047&(u>>>26|(31&h)<<6),i[a++]=h>>>5&2047,i[a++]=h>>>16&2047,i[a++]=2047&(h>>>27|(63&c)<<5),i[a++]=c>>>6&2047,i[a++]=c>>>17&2047,i[a++]=2047&(c>>>28|(127&d)<<4),i[a++]=d>>>7&2047,i[a++]=d>>>18&2047,i[a++]=2047&(d>>>29|(255&p)<<3),i[a++]=p>>>8&2047,i[a++]=p>>>19&2047,i[a++]=2047&(p>>>30|(511&f)<<2),i[a++]=f>>>9&2047,i[a++]=f>>>20&2047,i[a++]=2047&(f>>>31|(1023&m)<<1),i[a++]=m>>>10&2047,i[a]=m>>>21&2047}(e,t,i,r);case 12:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0;i[a++]=n>>>0&4095,i[a++]=n>>>12&4095,i[a++]=4095&(n>>>24|(15&o)<<8),i[a++]=o>>>4&4095,i[a++]=o>>>16&4095,i[a++]=4095&(o>>>28|(255&s)<<4),i[a++]=s>>>8&4095,i[a++]=s>>>20&4095,i[a++]=l>>>0&4095,i[a++]=l>>>12&4095,i[a++]=4095&(l>>>24|(15&u)<<8),i[a++]=u>>>4&4095,i[a++]=u>>>16&4095,i[a++]=4095&(u>>>28|(255&h)<<4),i[a++]=h>>>8&4095,i[a++]=h>>>20&4095,i[a++]=c>>>0&4095,i[a++]=c>>>12&4095,i[a++]=4095&(c>>>24|(15&d)<<8),i[a++]=d>>>4&4095,i[a++]=d>>>16&4095,i[a++]=4095&(d>>>28|(255&p)<<4),i[a++]=p>>>8&4095,i[a++]=p>>>20&4095,i[a++]=f>>>0&4095,i[a++]=f>>>12&4095,i[a++]=4095&(f>>>24|(15&m)<<8),i[a++]=m>>>4&4095,i[a++]=m>>>16&4095,i[a++]=4095&(m>>>28|(255&g)<<4),i[a++]=g>>>8&4095,i[a]=g>>>20&4095}(e,t,i,r);case 16:return void function(e,t,i,r){let a=r,n=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,l=e[t+3]>>>0,u=e[t+4]>>>0,h=e[t+5]>>>0,c=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0,_=e[t+12]>>>0,y=e[t+13]>>>0,x=e[t+14]>>>0,v=e[t+15]>>>0;i[a++]=n>>>0&65535,i[a++]=n>>>16&65535,i[a++]=o>>>0&65535,i[a++]=o>>>16&65535,i[a++]=s>>>0&65535,i[a++]=s>>>16&65535,i[a++]=l>>>0&65535,i[a++]=l>>>16&65535,i[a++]=u>>>0&65535,i[a++]=u>>>16&65535,i[a++]=h>>>0&65535,i[a++]=h>>>16&65535,i[a++]=c>>>0&65535,i[a++]=c>>>16&65535,i[a++]=d>>>0&65535,i[a++]=d>>>16&65535,i[a++]=p>>>0&65535,i[a++]=p>>>16&65535,i[a++]=f>>>0&65535,i[a++]=f>>>16&65535,i[a++]=m>>>0&65535,i[a++]=m>>>16&65535,i[a++]=g>>>0&65535,i[a++]=g>>>16&65535,i[a++]=_>>>0&65535,i[a++]=_>>>16&65535,i[a++]=y>>>0&65535,i[a++]=y>>>16&65535,i[a++]=x>>>0&65535,i[a++]=x>>>16&65535,i[a++]=v>>>0&65535,i[a]=v>>>16&65535}(e,t,i,r);case 32:for(let a=0;a<32;a=a+1|0)i[r+a|0]=0|e[t+a|0];return}let n=Pf[a]>>>0,o=t,s=0,l=e[o]>>>0;for(let t=0;t<32;t++)if(s+a<=32){let u=l>>>s&n;i[r+t]=0|u,s+=a,32===s&&(s=0,o++,31!==t&&(l=e[o]>>>0))}else{let u=32-s,h=l>>>s;o++,l=e[o]>>>0;let c=(h|(l&Pf[a-u]>>>0)<<u)&n;i[r+t]=0|c,s=a-u}}function jf(e,t,i){let r=new Uint32Array(i),a=0,n=t.get();for(let t=0;t<r.length;t++){let t=e[n++],i=127&t;t<128||(t=e[n++],i|=(127&t)<<7,t<128||(t=e[n++],i|=(127&t)<<14,t<128||(t=e[n++],i|=(127&t)<<21,t<128||(t=e[n++],i|=(15&t)<<28)))),r[a++]=i}return t.set(n),r}function Vf(e,t,i){let r=new BigUint64Array(i);for(let i=0;i<r.length;i++)r[i]=Nf(e,t);return r}function Nf(e,t){let i=0n,r=0,a=t.get();for(;a<e.length;){let t=e[a++];if(i|=BigInt(127&t)<<BigInt(r),!(128&t))break;if(r+=7,r>=64)throw Error("Varint too long")}return t.set(a),i}function Uf(e,t){let i,r;return r=e[t.get()],t.increment(),i=127&r,r<128||(r=e[t.get()],t.increment(),i|=(127&r)<<7,r<128)||(r=e[t.get()],t.increment(),i|=(127&r)<<14,r<128)||(r=e[t.get()],t.increment(),i|=(127&r)<<21,r<128)?i:(r=e[t.get()],i|=(15&r)<<28,function(e,t,i){let r,a;if(a=t[i.get()],i.increment(),r=(112&a)>>4,a<128||(a=t[i.get()],i.increment(),r|=(127&a)<<3,a<128)||(a=t[i.get()],i.increment(),r|=(127&a)<<10,a<128)||(a=t[i.get()],i.increment(),r|=(127&a)<<17,a<128)||(a=t[i.get()],i.increment(),r|=(127&a)<<24,a<128)||(a=t[i.get()],i.increment(),r|=(1&a)<<31,a<128))return 4294967296*r+(e>>>0);throw Error("Expected varint not more than 10 bytes")}(i,e,t))}function $f(e,t,i,r){return function(e,t,i,r,a){let n=r.get();if(3&i)throw Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${n} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=i>>>2,s=function(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let i=new Uint32Array(Math.max(16,2*t));return e.encodedWords=i,i}(a,o);!function(e,t,i,r){if(t<0||i<0||t+i>e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${i}, bytes.length=${e.length})`);let a=Math.floor(i/4),n=i%4!=0,o=n?a+1:a;if(r.length<o)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(a>0){let i=e.byteOffset+t;if(3&i)for(let i=0;i<a;i++){let a=t+4*i;r[i]=e[a]<<24|e[a+1]<<16|e[a+2]<<8|e[a+3]}else{let t=new Uint32Array(e.buffer,i,a);for(let e=0;e<a;e++)r[e]=0|Cf(t[e])}}if(n){let n=t+4*a,o=i-4*a,s=0;for(let t=0;t<o;t++)s|=e[n+t]<<24-8*t;r[a]=0|s}}(e,n,i,s);let l=function(e,t,i){let r=0,a=0,n=new Uint32Array(t),o=i??Ff();if(e.length>0){let t=0|e[r];if(r=r+1|0,255&t)throw Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(a+t>n.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${a}, alignedLength=${t}, out.length=${n.length})`);r=function(e,t,i,r,a,n){let o=r+If(a,256),s=r,l=i;for(;s!==o;){let i=Math.min(Mf,o-s);l=Bf(e,t,l,s,i,n),s=s+i|0}return l}(e,n,r,a,t,o),a=a+t|0}return function(e,t,i,r,a,n){if(0===n)return t;let o=0,s=t,l=t+i,u=a,h=a,c=a+n,d=0,p=0;for(;s<l&&h<c;){let t=e[s]>>>o&255;if(o+=8,s+=o>>>5,o&=31,d|=(127&t)<<p,128&t)r[h++]=0|d,d=0,p=0;else if(p+=7,p>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${d}, decoded=${h-u}/${n}, inPos=${s}, inEnd=${l})`)}if(h!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${h-u}, expected=${n}, consumedWords=${s-t}/${i}, vbyteStart=${t}, vbyteEnd=${l})`)}(e,r,e.length-r|0,n,a,t-a|0),n}(s.subarray(0,o),t,a.decoderWorkspace);return r.add(i),l}(e,t,i,r,function(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let t=Math.max(16,0|e);return{encodedWords:new Uint32Array(t),decoderWorkspace:Ff()}}(i>>>2))}function Gf(e){return e>>>1^-(1&e)}function Zf(e){return e>>1n^-(1n&e)}function qf(e){return e%2==1?(e+1)/-2:e/2}function Wf(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=e[r]}let r=new Uint32Array(i),a=0;for(let i=0;i<t;i++){let n=e[i],o=e[i+t];r.fill(o,a,a+n),a+=n}return r}function Xf(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=Number(e[r])}let r=new BigUint64Array(i),a=0;for(let i=0;i<t;i++){let n=Number(e[i]),o=e[i+t];r.fill(o,a,a+n),a+=n}return r}function Hf(e,t,i){let r=new Float64Array(i),a=0;for(let i=0;i<t;i++){let n=e[i],o=e[i+t];r.fill(o,a,a+n),a+=n}return r}function Yf(e){let t=new Int32Array(e.length);t[0]=Gf(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let i=e[r],a=e[r+1],n=e[r+2],o=e[r+3];t[r]=Gf(i)+t[r-1],t[r+1]=Gf(a)+t[r],t[r+2]=Gf(n)+t[r+1],t[r+3]=Gf(o)+t[r+2]}for(;r!==e.length;++r)t[r]=Gf(e[r])+t[r-1];return t}function Kf(e){let t=new BigInt64Array(e.length);t[0]=Zf(e[0]);let i=e.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let i=e[r],a=e[r+1],n=e[r+2],o=e[r+3];t[r]=Zf(i)+t[r-1],t[r+1]=Zf(a)+t[r],t[r+2]=Zf(n)+t[r+1],t[r+3]=Zf(o)+t[r+2]}for(;r!==t.length;++r)t[r]=Zf(e[r])+t[r-1];return t}function Jf(e){let t=e.length/4*4,i=1;if(t>=4)for(let r=e[0];i<t-4;i+=4)r=e[i]+=r,r=e[i+1]+=r,r=e[i+2]+=r,r=e[i+3]+=r;for(;i!==e.length;)e[i]+=e[i-1],++i}function Qf(e,t,i,r){if(e.length<2)return new Int32Array(e);let a=new Int32Array(e.length),n=Gf(e[0]),o=Gf(e[1]);a[0]=em(Math.round(n*t),i,r),a[1]=em(Math.round(o*t),i,r);let s=e.length/16,l=2;if(s>=4)for(;l<s-4;l+=4){let s=e[l],u=e[l+1],h=Gf(s)+n,c=Gf(u)+o;a[l]=em(Math.round(h*t),i,r),a[l+1]=em(Math.round(c*t),i,r);let d=e[l+2],p=e[l+3];n=Gf(d)+h,o=Gf(p)+c,a[l+2]=em(Math.round(n*t),i,r),a[l+3]=em(Math.round(o*t),i,r)}for(;l!==e.length;l+=2)n+=Gf(e[l]),o+=Gf(e[l+1]),a[l]=em(Math.round(n*t),i,r),a[l+1]=em(Math.round(o*t),i,r);return a}function em(e,t,i){return Math.min(i,Math.max(t,e))}function tm(e){let t=new Uint32Array(e.length);t[0]=Gf(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+Gf(e[i])>>>0;return t}function im(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,Zf(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+Zf(e[i]));return t}var rm,am,nm,om;!function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(rm||={}),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(am||={}),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(nm||={}),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"}(om||={});const sm=[rm.PRESENT,rm.DATA,rm.OFFSET,rm.LENGTH],lm=[Tf.NONE,Tf.DELTA,Tf.COMPONENTWISE_DELTA,Tf.RLE,Tf.MORTON],um=[Df.NONE,Df.FAST_PFOR,Df.VARINT],hm=[am.NONE,am.SINGLE,am.SHARED,am.VERTEX,am.MORTON,am.FSST],cm=[nm.VERTEX,nm.INDEX,nm.STRING,nm.KEY],dm=[om.VAR_BINARY,om.GEOMETRIES,om.PARTS,om.RINGS,om.TRIANGLES,om.SYMBOL,om.DICTIONARY];function pm(e,t){let i=function(e,t){let i=e[t.get()],r=sm[i>>4],a={};switch(r){case rm.DATA:a={dictionaryType:hm[15&i]};break;case rm.OFFSET:a={offsetType:cm[15&i]};break;case rm.LENGTH:a={lengthType:dm[15&i]}}t.increment();let n=e[t.get()],o=lm[n>>5],s=lm[n>>2&7],l=um[3&n];t.increment();let u=jf(e,t,2),h=u[0];return{physicalStreamType:r,logicalStreamType:a,logicalLevelTechnique1:o,logicalLevelTechnique2:s,physicalLevelTechnique:l,numValues:h,byteLength:u[1],decompressedCount:h}}(e,t);return i.logicalLevelTechnique1===Tf.MORTON?function(e,t,i){let r=jf(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:r[0],coordinateShift:r[1]}}(i,e,t):Tf.RLE!==i.logicalLevelTechnique1&&Tf.RLE!==i.logicalLevelTechnique2||Df.NONE===i.physicalLevelTechnique?i:function(e,t,i){let r=jf(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}(i,e,t)}var fm;!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"}(fm||={});var mm=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),i=e%8;return 1==(this.values[t]>>i&1)}set(e,t){let i=Math.floor(e/8),r=e%8;this.values[i]=this.values[i]|+!!t<<r}getInt(e){let t=Math.floor(e/8),i=e%8;return this.values[t]>>i&1}size(){return this._size}getBuffer(){return this.values}};function gm(e,t,i){if(!t)return e;let r=t.size(),a=new(0,e.constructor)(r),n=0;for(let o=0;o<r;o++)a[o]=t.get(o)?e[n++]:i;return a}function _m(e,t,i){for(let r=0;r<e;r++){let e=pm(t,i);i.add(e.byteLength)}}function ym(e,t,i,r,a){let n=function(e,t,i,r){let a=new Uint8Array(t),n=0,o=r.get()+i;for(;n<t&&!(r.get()>=o);){let i=e[r.increment()];if(i<=127){let o=i+3,s=e[r.increment()],l=Math.min(n+o,t);a.fill(s,n,l),n=l}else{let o=256-i;for(let i=0;i<o&&n<t;i++)a[n++]=e[r.increment()]}}return r.set(o),a}(e,Math.ceil(t/8),i,r);return a?function(e,t,i){if(!i)return e;let r=i.size(),a=new mm(e,t),n=new mm(new Uint8Array(Math.ceil(r/8)),r),o=0;for(let e=0;e<r;e++){let t=!!i.get(e)&&a.get(o++);n.set(e,t)}return n.getBuffer()}(n,t,a):n}function xm(e,t,i,r){let a=t.get(),n=a+i*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(a,n)).buffer,s=new Float32Array(o);return t.set(n),r?gm(s,r,0):s}function vm(e,t,i,r){let a=t.get(),n=a+i*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(a,n)).buffer,s=new Float64Array(o);return t.set(n),r?gm(s,r,0):s}const bm=new TextDecoder;function wm(e,t,i){return i-t>=12?bm.decode(e.subarray(t,i)):function(e,t,i){let r="",a=t;for(;a<i;){let t,n,o,s=e[a],l=null,u=s>239?4:s>223?3:s>191?2:1;if(a+u>i)break;1===u?s<128&&(l=s):2===u?(t=e[a+1],128==(192&t)&&(l=(31&s)<<6|63&t,l<=127&&(l=null))):3===u?(t=e[a+1],n=e[a+2],128==(192&t)&&128==(192&n)&&(l=(15&s)<<12|(63&t)<<6|63&n,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(t=e[a+1],n=e[a+2],o=e[a+3],128==(192&t)&&128==(192&n)&&128==(192&o)&&(l=(15&s)<<18|(63&t)<<12|(63&n)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),a+=u}return r}(e,t,i)}function Tm(e,t,i,r,a){return function(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case Tf.DELTA:if(t.logicalLevelTechnique2===Tf.RLE){let i=t;if(!r)return function(e,t,i){let r=new Int32Array(i),a=0,n=0;for(let i=0;i<t;i++){let o=e[i],s=Gf(e[i+t]);for(let e=0;e<o;e++)n+=s,r[a++]=n}return r}(e,i.runs,i.numRleValues);a=Yf(e=Wf(e,i.runs,i.numRleValues))}else a=Yf(e);break;case Tf.RLE:a=function(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=e[r]}let r=new Int32Array(i),a=0;for(let i=0;i<t;i++){let n=e[i],o=e[i+t];o=Gf(o),r.fill(o,a,a+n),a+=n}return r}(e,t.runs,t.numRleValues);break;case Tf.MORTON:Jf(e),a=new Int32Array(e);break;case Tf.COMPONENTWISE_DELTA:if(i&&!r)return Qf(e,i.scale,i.min,i.max);a=function(e){if(e.length<2)return new Int32Array(e);let t=new Int32Array(e.length);t[0]=Gf(e[0]),t[1]=Gf(e[1]);let i=e.length/4*4,r=2;if(i>=4)for(;r<i-4;r+=4){let i=e[r],a=e[r+1],n=e[r+2],o=e[r+3];t[r]=Gf(i)+t[r-2],t[r+1]=Gf(a)+t[r-1],t[r+2]=Gf(n)+t[r],t[r+3]=Gf(o)+t[r+1]}for(;r!==e.length;r+=2)t[r]=Gf(e[r])+t[r-2],t[r+1]=Gf(e[r+1])+t[r-1];return t}(e);break;case Tf.NONE:a=function(e){let t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=Gf(e[i]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?gm(a,r,0):a}(Sm(e,t,i),i,r,a)}function Dm(e,t,i,r,a){return function(e,t,i,r){let a;switch(t.logicalLevelTechnique1){case Tf.DELTA:if(t.logicalLevelTechnique2===Tf.RLE){let i=t;a=tm(Wf(e,i.runs,i.numRleValues))}else a=tm(e);break;case Tf.RLE:a=Wf(e,t.runs,t.numRleValues);break;case Tf.MORTON:Jf(e),a=e;break;case Tf.COMPONENTWISE_DELTA:a=i&&!r?function(e,t,i,r){let a=Qf(e,t,i,r);return new Uint32Array(a)}(e,i.scale,i.min,i.max):function(e){if(e.length<2)return new Uint32Array(e);let t=new Uint32Array(e.length);t[0]=Gf(e[0])>>>0,t[1]=Gf(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+Gf(e[i])>>>0,t[i+1]=t[i-1]+Gf(e[i+1])>>>0;return t}(e);break;case Tf.NONE:a=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?gm(a,r,0):a}(Sm(e,t,i),i,r,a)}function Em(e,t,i){return function(e,t){if(t.logicalLevelTechnique1===Tf.DELTA&&t.logicalLevelTechnique2===Tf.NONE)return function(e){let t=new Int32Array(e.length+1);t[0]=0,t[1]=Gf(e[0]);let i=t[1];for(let r=2;r!==t.length;++r)i+=Gf(e[r-1]),t[r]=t[r-1]+i;return new Uint32Array(t)}(e);if(t.logicalLevelTechnique1===Tf.RLE&&t.logicalLevelTechnique2===Tf.NONE){let i=t;return function(e,t,i){let r=new Uint32Array(i+1);r[0]=0;let a=1,n=r[0];for(let i=0;i<t;i++){let o=e[i],s=e[i+t];for(let e=a;e<a+o;e++)r[e]=s+n,n=r[e];a+=o}return r}(e,i.runs,i.numRleValues)}if(t.logicalLevelTechnique1===Tf.NONE&&t.logicalLevelTechnique2===Tf.NONE){!function(e){let t=0;for(let i=0;i<e.length;i++)e[i]+=t,t=e[i]}(e);let i=new Uint32Array(t.numValues+1);return i[0]=0,i.set(e,1),i}if(t.logicalLevelTechnique1===Tf.DELTA&&t.logicalLevelTechnique2===Tf.RLE){let i=t,r=function(e,t,i){let r=new Int32Array(i+1);r[0]=0;let a=1,n=r[0];for(let i=0;i<t;i++){let o=e[i],s=e[i+t];s=Gf(s);for(let e=a;e<a+o;e++)r[e]=s+n,n=r[e];a+=o}return r}(e,i.runs,i.numRleValues);return Jf(r),new Uint32Array(r)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}(Sm(e,t,i),i)}function Sm(e,t,i){let r=i.physicalLevelTechnique;switch(r){case Df.FAST_PFOR:return $f(e,i.numValues,i.byteLength,t);case Df.VARINT:return jf(e,t,i.numValues);case Df.NONE:return function(e,t,i){let r=t.get(),a=i*Uint32Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=new Uint32Array(i);for(let e=0;e<i;e++)o[e]=n.getUint32(r+e*Uint32Array.BYTES_PER_ELEMENT,!0);return t.add(a),o}(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function Pm(e,t,i){let r=i.physicalLevelTechnique;switch(r){case Df.VARINT:return Vf(e,t,i.numValues);case Df.NONE:return function(e,t,i){let r=t.get(),a=i*BigUint64Array.BYTES_PER_ELEMENT,n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=new BigUint64Array(i);for(let e=0;e<i;e++)o[e]=n.getBigUint64(r+e*BigUint64Array.BYTES_PER_ELEMENT,!0);return t.add(a),o}(e,t,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function Im(e,t,i){let r=Sm(e,t,i);return 1===r.length?i.logicalLevelTechnique1===Tf.DELTA?Gf(r[0]):r[0]:function(e){return e[1]}(r)}function Am(e,t,i){return function(e){if(2===e.length){let t=Gf(e[1]);return[t,t]}return[Gf(e[2]),Gf(e[3])]}(Sm(e,t,i))}function Cm(e,t,i){return function(e){if(2===e.length){let t=Zf(e[1]);return[t,t]}return[Zf(e[2]),Zf(e[3])]}(Vf(e,t,i.numValues))}function Mm(e,t,i,r){return Rm(Pm(e,t,i),i,r)}function zm(e,t,i,r){return km(Pm(e,t,i),i,r)}function Fm(e,t,i){let r=Pm(e,t,i);return 1===r.length?i.logicalLevelTechnique1===Tf.DELTA?Zf(r[0]):r[0]:function(e){return e[1]}(r)}function Rm(e,t,i){let r;switch(t.logicalLevelTechnique1){case Tf.DELTA:if(t.logicalLevelTechnique2===Tf.RLE){let a=t;if(!i)return function(e,t,i){let r=new BigInt64Array(i),a=0,n=0n;for(let i=0;i<t;i++){let o=Number(e[i]),s=Zf(e[i+t]);for(let e=0;e<o;e++)n+=s,r[a++]=n}return r}(e,a.runs,a.numRleValues);r=Kf(e=Xf(e,a.runs,a.numRleValues))}else r=Kf(e);break;case Tf.RLE:r=function(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=Number(e[r])}let r=new BigInt64Array(i),a=0;for(let i=0;i<t;i++){let n=Number(e[i]),o=e[i+t];o=Zf(o),r.fill(o,a,a+n),a+=n}return r}(e,t.runs,t.numRleValues);break;case Tf.NONE:r=function(e){let t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=Zf(e[i]);return t}(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?gm(r,i,0n):r}function km(e,t,i){let r;switch(t.logicalLevelTechnique1){case Tf.DELTA:if(t.logicalLevelTechnique2===Tf.RLE){let i=t;r=im(Xf(e,i.runs,i.numRleValues))}else r=im(e);break;case Tf.RLE:r=Xf(e,t.runs,t.numRleValues);break;case Tf.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?gm(r,i,0n):r}function Lm(e,t,i,r,a="int32"){let n=e.logicalLevelTechnique1;if(n===Tf.RLE)return 1===e.runs?fm.CONST:fm.FLAT;if(n!==Tf.DELTA||e.logicalLevelTechnique2!==Tf.RLE)return 1===e.numValues?fm.CONST:fm.FLAT;let o=t instanceof mm?t.size():t,s=e;if(s.numRleValues!==o)return fm.FLAT;if(1===s.runs)return fm.SEQUENCE;if(2!==s.runs)return 1===e.numValues?fm.CONST:fm.FLAT;let l=r.get();if(e.physicalLevelTechnique===Df.VARINT)return function(e,t,i){let r=new Ef(t.get());if("int64"===i){let t=Vf(e,r,4);return 2n===t[2]&&2n===t[3]}let a=jf(e,r,4);return 2===a[2]&&2===a[3]}(i,r,a)?fm.SEQUENCE:1===e.numValues?fm.CONST:fm.FLAT;let u=r.get(),h=new Int32Array(i.buffer,i.byteOffset+u,4);return r.set(l),2===h[2]&&2===h[3]?fm.SEQUENCE:1===e.numValues?fm.CONST:fm.FLAT}var Bm,Om,jm,Vm=class extends gf{getValueFromBuffer(e){return this.dataBuffer[e]}},Nm=class extends xf{constructor(e,t,i,r,a){super(e,a?BigInt64Array.of(t):BigUint64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function Um(e,t,i){return{x:$m(e,t)-i,y:$m(e>>1,t)-i}}function $m(e,t){let i=0;for(let r=0;r<t;r++)i|=(e&1<<2*r)>>r;return i}function Gm(e,t,i,r,a,n,o){return e===jm.MORTON?function(e,t,i,r,a,n){let o=Array(a?r+1:r);for(let a=0;a<r;a++){let r=Um(e[t[i+a]],n.numBits,n.coordinateShift);o[a]=new c(r.x,r.y)}return a&&(o[o.length-1]=o[0]),o}(t,i,r,a,n,o):function(e,t,i,r,a){let n=Array(a?r+1:r);for(let a=0;a<2*r;a+=2){let r=2*t[i+a/2],o=e[r],s=e[r+1];n[a/2]=new c(o,s)}return a&&(n[n.length-1]=n[0]),n}(t,i,r,a,n)}function Zm(e,t,i,r){let a=Array(r?i+1:i);for(let r=0;r<2*i;r+=2){let i=e[t+r],n=e[t+r+1];a[r/2]=new c(i,n)}return r&&(a[a.length-1]=a[0]),a}!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"}(Bm||={}),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Om||={}),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(jm||={});var qm=class{constructor(e,t,i,r,a){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=a}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){let t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){let t=this.vertexOffsets[e],i=Um(this.vertexBuffer[t],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[i.x,i.y]}let t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return function(e){let t=Array(e.numGeometries),i=1,r=1,a=1,n=0,o=0,s=0,l=e.mortonSettings,u=e.topologyVector,h=u.geometryOffsets,d=u.partOffsets,p=u.ringOffsets,f=e.vertexOffsets,m=!f||0===f.length,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let u=0;u<e.numGeometries;u++){let y=e.geometryType(u);switch(y){case Bm.POINT:{let u,g;if(m)u=_[o++],g=_[o++];else if(e.vertexBufferType===jm.MORTON){let e=Um(_[f[s++]],l.numBits,l.coordinateShift);u=e.x,g=e.y}else{let e=2*f[s++];u=_[e],g=_[e+1]}t[n++]=[[new c(u,g)]],h&&a++,d&&i++,p&&r++}break;case Bm.MULTIPOINT:{let u,d=h[a]-h[a-1];if(a++,m){u=Array(d);for(let e=0;e<d;e++){let t=_[o++],i=_[o++];u[e]=new c(t,i)}}else u=Gm(e.vertexBufferType,_,f,s,d,!1,l),s+=d;t[n++]=u.map(e=>[e]),i+=d,r+=d}break;case Bm.LINESTRING:{let u,c;g?(u=p[r]-p[r-1],r++):u=d[i]-d[i-1],i++,m?(c=Zm(_,o,u,!1),o+=2*u):(c=Gm(e.vertexBufferType,_,f,s,u,!1,l),s+=u),t[n++]=[c],h&&a++}break;case Bm.POLYGON:{let u=d[i]-d[i-1];i++;let c,g=Array(u-1),y=p[r]-p[r-1];if(r++,m){c=Zm(_,o,y,!0),o+=2*y;for(let e=0;e<g.length;e++)y=p[r]-p[r-1],r++,g[e]=Zm(_,o,y,!0),o+=2*y}else{c=Gm(e.vertexBufferType,_,f,s,y,!0,l),s+=y;for(let t=0;t<g.length;t++)y=p[r]-p[r-1],r++,g[t]=Gm(e.vertexBufferType,_,f,s,y,!0,l),s+=y}t[n++]=[c].concat(g),h&&a++}break;case Bm.MULTILINESTRING:{let u=h[a]-h[a-1];a++;let c=Array(u);for(let t=0;t<u;t++){let a;if(g?(a=p[r]-p[r-1],r++):a=d[i]-d[i-1],i++,m)c[t]=Zm(_,o,a,!1),o+=2*a;else{let i=Gm(e.vertexBufferType,_,f,s,a,!1,l);c[t]=i,s+=a}}t[n++]=c}break;case Bm.MULTIPOLYGON:{let u=h[a]-h[a-1];a++;let c=Array(u);for(let t=0;t<u;t++){let a=d[i]-d[i-1];i++;let n,u=Array(a-1),h=p[r]-p[r-1];r++,m?(n=Zm(_,o,h,!0),o+=2*h):(n=Gm(e.vertexBufferType,_,f,s,h,!0,l),s+=h);for(let t=0;t<u.length;t++){let i=p[r]-p[r-1];r++,m?(u[t]=Zm(_,o,i,!0),o+=2*i):(u[t]=Gm(e.vertexBufferType,_,f,s,i,!0,l),s+=i)}c[t]=[n].concat(u)}t[n++]=c.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return t}(this)}get mortonSettings(){return this._mortonSettings}},Wm=class extends qm{constructor(e,t,i,r,a,n,o){super(i,r,a,n,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Bm.POLYGON||this._geometryType===Bm.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function Xm(e,t,i,r){return new Hm(jm.VEC_2,e,t,i,r)}var Hm=class extends qm{constructor(e,t,i,r,a,n){super(e,i,r,a,n),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===Bm.POLYGON||this.geometryType(e)===Bm.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},Ym=class{constructor(e,t,i,r){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=i,this._topologyVector=r}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw Error("Cannot convert GpuVector to coordinates without topology information");let e=new Uint32Array(this.numGeometries);for(let t=0;t<this.numGeometries;t++)e[t]=this.geometryType(t);return Xm(e,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function Km(e,t,i,r,a,n){return new Jm(e,t,i,r,a,n)}var Jm=class extends Ym{constructor(e,t,i,r,a,n){super(i,r,a,n),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function Qm(e,t,i,r,a){return new eg(e,t,i,r,a)}var eg=class extends Ym{constructor(e,t,i,r,a){super(t,i,r,a),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function tg(e,t,i,r,a){let n,o,s,l,u=pm(e,i);if(Lm(u,r,e,i)===fm.CONST){let h,c,d,p,f=Im(e,i,u);for(let r=0;r<t-1;r++){let t=pm(e,i);switch(t.physicalStreamType){case rm.LENGTH:switch(t.logicalStreamType.lengthType){case om.GEOMETRIES:h=Em(e,i,t);break;case om.PARTS:c=Em(e,i,t);break;case om.RINGS:d=Em(e,i,t);break;case om.TRIANGLES:p=Em(e,i,t)}break;case rm.OFFSET:switch(t.logicalStreamType.offsetType){case nm.VERTEX:n=Dm(e,i,t);break;case nm.INDEX:l=Dm(e,i,t)}break;case rm.DATA:if(am.VERTEX===t.logicalStreamType.dictionaryType)o=Tm(e,i,t,a);else{let r=t;s={numBits:r.numBits,coordinateShift:r.coordinateShift},o=Dm(e,i,t,a)}}}return l?void 0!==h||void 0!==c?Km(r,f,p,l,o,{geometryOffsets:h,partOffsets:c,ringOffsets:d}):Km(r,f,p,l,o):void 0===s?function(e,t,i,r,a){return new Wm(e,t,jm.VEC_2,i,r,a)}(r,f,{geometryOffsets:h,partOffsets:c,ringOffsets:d},n,o):function(e,t,i,r,a,n){return new Wm(e,t,jm.MORTON,i,r,a,n)}(r,f,{geometryOffsets:h,partOffsets:c,ringOffsets:d},n,o,s)}let h,c,d,p,f,m,g,_=Dm(e,i,u);for(let r=0;r<t-1;r++){let t=pm(e,i);switch(t.physicalStreamType){case rm.LENGTH:switch(t.logicalStreamType.lengthType){case om.GEOMETRIES:h=Dm(e,i,t);break;case om.PARTS:c=Dm(e,i,t);break;case om.RINGS:d=Dm(e,i,t);break;case om.TRIANGLES:p=Em(e,i,t)}break;case rm.OFFSET:switch(t.logicalStreamType.offsetType){case nm.VERTEX:n=Dm(e,i,t);break;case nm.INDEX:l=Dm(e,i,t)}break;case rm.DATA:if(am.VERTEX===t.logicalStreamType.dictionaryType)o=Tm(e,i,t,a);else{let r=t;s={numBits:r.numBits,coordinateShift:r.coordinateShift},o=Dm(e,i,t,a)}}}return h?(f=ig(_,h,2),c&&d?(m=rg(_,f,c,!1),g=function(e,t,i,r){let a=new Uint32Array(i[i.length-1]+1),n=0;a[0]=n;let o=1,s=1,l=0;for(let u=0;u<e.length;u++){let h=e[u],c=t[u+1]-t[u];if(0!==h&&3!==h)for(let e=0;e<c;e++){let e=i[o]-i[o-1];o++;for(let t=0;t<e;t++)n=a[s++]=n+r[l++]}else for(let e=0;e<c;e++)a[s++]=++n,o++}return a}(_,f,m,d)):c&&(m=function(e,t,i){let r=new Uint32Array(t[t.length-1]+1),a=0;r[0]=a;let n=1,o=0;for(let s=0;s<e.length;s++){let l=e[s],u=t[s+1]-t[s];if(4===l||1===l)for(let e=0;e<u;e++)a=r[n++]=a+i[o++];else for(let e=0;e<u;e++)r[n++]=++a}return r}(_,f,c))):c&&d?(m=ig(_,c,1),g=rg(_,m,d,!0)):c&&(m=ig(_,c,0)),l&&!m?Qm(_,p,l,o):l?Qm(_,p,l,o,{geometryOffsets:f,partOffsets:m,ringOffsets:g}):void 0===s?Xm(_,{geometryOffsets:f,partOffsets:m,ringOffsets:g},n,o):function(e,t,i,r,a){return new Hm(jm.MORTON,e,t,i,r,a)}(_,{geometryOffsets:f,partOffsets:m,ringOffsets:g},n,o,s)}function ig(e,t,i){let r=new Uint32Array(e.length+1),a=0;r[0]=a;let n=0;for(let o=0;o<e.length;o++)a=r[o+1]=a+(e[o]>i?t[n++]:1);return r}function rg(e,t,i,r){let a=new Uint32Array(t[t.length-1]+1),n=0;a[0]=n;let o=1,s=0;for(let l=0;l<e.length;l++){let u=e[l],h=t[l+1]-t[l];if(5===u||2===u||r&&(4===u||1===u))for(let e=0;e<h;e++)n=a[o++]=n+i[s++];else for(let e=0;e<h;e++)a[o++]=++n}return a}var ag=class extends mf{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}},ng=class extends gf{getValueFromBuffer(e){return this.dataBuffer[e]}},og=class extends mf{constructor(e,t,i,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}},sg=class extends mf{constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}},lg=class extends sg{constructor(e,t,i,r){super(e,t,i,r??t.length-1)}getValueFromBuffer(e){let t=this.offsetBuffer[e],i=this.offsetBuffer[e+1];return wm(this.dataBuffer,t,i)}},ug=class extends sg{constructor(e,t,i,r,a){super(e,i,r,a??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return wm(this.dataBuffer,i,r)}},hg=class extends sg{constructor(e,t,i,r,a,n,o,s){super(e,i,r,o??t.length),this.indexBuffer=t,this.symbolOffsetBuffer=a,this.symbolTableBuffer=n,this.sharedDictionaryCache=s}getValueFromBuffer(e){this.decodedDictionary??(this.decodedDictionary=this.sharedDictionaryCache?.decodedDictionary,this.decodedDictionary??(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let t=this.indexBuffer[e],i=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return wm(this.decodedDictionary,i,r)}decodeDictionary(){return this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),function(e,t,i){let r=new Uint32Array(t.length);for(let e=1;e<t.length;e++)r[e]=r[e-1]+t[e-1];let a=new Uint8Array(function(e,t){let i=0;for(let r=0;r<t.length;r++){let a=t[r];255===a?(i++,r++):i+=e[a]}return i}(t,i)),n=0;for(let o=0;o<i.length;o++){let s=i[o];if(255===s)o++,a[n++]=i[o];else{let i=t[s],o=r[s];for(;i-- >0;)a[n++]=e[o++]}}return a}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),i=e[0];for(let r=1;r<e.length;r++){let a=e[r];t[r-1]=a-i,i=a}return t}};function cg(e,t,i,r,a){let n,o,s,l,u,h,c,d=a;for(let e=0;e<r;e++){let e=pm(t,i);switch(e.physicalStreamType){case rm.PRESENT:{let r=new mm(ym(t,e.numValues,e.byteLength,i),e.numValues);d=a??r;break}case rm.OFFSET:o=Dm(t,i,e,void 0,d);break;case rm.LENGTH:{let r=Em(t,i,e);om.DICTIONARY===e.logicalStreamType.lengthType?n=r:om.SYMBOL===e.logicalStreamType.lengthType?l=r:h=r;break}case rm.DATA:{let r=t.subarray(i.get(),i.get()+e.byteLength);i.add(e.byteLength);let a=e.logicalStreamType.dictionaryType;am.FSST===a?u=r:am.SINGLE===a||am.SHARED===a?s=r:am.NONE===a&&(c=r);break}}}return function(e,t,i,r,a,n,o){if(t){if(!(i&&r&&a&&n))throw Error(`Incomplete FSST dictionary string column "${e}"`);return new hg(e,i,r,a,n,t,o)}}(e,u,o,n,s,l,d)??function(e,t,i,r,a){if(t){if(!i||!r)throw Error(`Incomplete dictionary string column "${e}"`);return a?new ug(e,i,r,t,a):new ug(e,i,r,t)}}(e,s,o,n,d)??function(e,t,i,r,a){if(t&&i){if(r)return a?new ug(e,r,t,i,a):new ug(e,r,t,i);if(a&&a.size()!==t.length-1){let r=new Uint32Array(a.size()),n=0;for(let e=0;e<a.size();e++)a.get(e)?r[e]=n++:r[e]=0;return new ug(e,r,t,i,a)}return a?new lg(e,t,i,a):new lg(e,t,i)}}(e,h,c,o,d)}var dg,pg,fg=class extends mf{constructor(e,t,i){super(e,new Uint8Array,i??t.length),this.values=t}getValueFromBuffer(e){return this.values[e]}};function mg(e,t,i,r,a){let n,{lengthStream:o,flattenedValues:s,presentStream:l,dictionary:u}=e,h=t*i,c=i;if(l){n=new mm(new Uint8Array(Math.ceil(i/8)),i),c=0;for(let e=0;e<i;e++)l.get(h+e)&&(n.set(e,!0),c++)}let d=r+c;if(d>o.length)throw Error("Merged map counts underflow while decoding child streams");let p=Array(i),f=r,m=a;for(let e=0;e<i;e++){if(l&&!l.get(h+e)){p[e]=null;continue}let t=m+o[f++];if(t>s.length)throw Error("Map value stream underflow while decoding feature payload");let i=gg(s,m,t,u);p[e]=i.value,m=i.nextIndex}let g=0;for(let e=r;e<d;e++)g+=o[e];let _=a+g;if(m!==_)throw Error("Unused flattened map values remain after decode");return{value:p,nullabilityBuffer:n,countsEnd:d,valuesEnd:_}}function gg(e,t,i,r){return i-t===1||e[t]===pg.START_LIST?yg(e,t,i,r):_g(e,t,i,r)}function _g(e,t,i,r){let a=Object.create(null),n=t;for(;n<i;){let t=vg(e[n++],r);if("string"!=typeof t)throw Error(`Map key dictionary index does not resolve to a string: ${t}`);let o=yg(e,n,i,r);a[t]=o.value,n=o.nextIndex}return{value:a,nextIndex:n}}function yg(e,t,i,r){if(t>=i)throw Error("Unexpected end of map value stream");let a=e[t];if(a===pg.FALSE)return{value:!1,nextIndex:t+1};if(a===pg.TRUE)return{value:!0,nextIndex:t+1};if(a===pg.START_MAP){let a=xg(e,t,i);return{value:_g(e,t+2,a,r).value,nextIndex:a}}if(a===pg.START_LIST){let a=xg(e,t,i),n=[],o=t+2;for(;o<a;){let t=yg(e,o,a,r);n.push(t.value),o=t.nextIndex}return{value:n,nextIndex:a}}return{value:vg(a,r),nextIndex:t+1}}function xg(e,t,i){if(t+1>=i)throw Error("Missing length for nested map/list payload");let r=e[t+1];if(r<2)throw Error(`Invalid nested payload length: ${r}`);let a=t+r;if(a>i)throw Error("Nested payload exceeds containing payload bounds");return a}function vg(e,t){let i=e-pg.COUNT;if(i<0||i>=t.length)throw Error(`Scalar dictionary index out of range: ${e}`);return t[i]}function bg(e,t){for(let i of t)e.push(i)}function wg(e,t,i,r,a,n){return"scalarType"===i.type?n&&!n.has(i.name)?(_m(r,e,t),null):function(e,t,i,r,a,n){let o;if(0===e)return null;if(n.nullable){let e=pm(t,i),r=e.numValues,a=i.get(),n=ym(t,r,e.byteLength,i);i.set(a+e.byteLength),o=new mm(n,e.numValues)}let s=o??r;switch(a.physicalType){case 4:case 3:return function(e,t,i,r,a){let n=pm(e,t),o=Lm(n,a,e,t),s=3===r.physicalType;if(o===fm.FLAT){let r=Tg(a)?a:void 0,o=s?Tm(e,t,n,void 0,r):Dm(e,t,n,void 0,r);return new _f(i.name,o,a)}if(o===fm.SEQUENCE){let r=Am(e,t,n);return new vf(i.name,r[0],r[1],n.numRleValues,s)}let l=s?function(e,t,i){let r=Sm(e,t,i);return 1===r.length?Gf(r[0]):function(e){return Gf(e[1])}(r)}(e,t,n):Im(e,t,n);return new bf(i.name,l,a,s)}(t,i,n,a,s);case 9:{let r=n.nullable?e-1:e;return cg(n.name,t,i,r,o)??null}case 0:return function(e,t,i,r,a){let n=pm(e,t),o=n.numValues,s=t.get(),l=Tg(a)?a:void 0,u=ym(e,o,n.byteLength,t,l);t.set(s+n.byteLength);let h=new mm(u,o);return new ag(i.name,h,a)}(t,i,n,0,s);case 6:case 5:return function(e,t,i,r,a){let n=pm(e,t),o=Lm(n,r,e,t,"int64"),s=5===a.physicalType;if(o===fm.FLAT){let a=Tg(r)?r:void 0,o=s?Mm(e,t,n,a):zm(e,t,n,a);return new Vm(i.name,o,r)}if(o===fm.SEQUENCE){let r=Cm(e,t,n);return new Nm(i.name,r[0],r[1],n.numRleValues,s)}let l=s?function(e,t,i){let r=Pm(e,t,i);return 1===r.length?Zf(r[0]):function(e){return Zf(e[1])}(r)}(e,t,n):Fm(e,t,n);return new og(i.name,l,r,s)}(t,i,n,s,a);case 7:return function(e,t,i,r){let a=pm(e,t),n=Tg(r)?r:void 0,o=xm(e,t,a.numValues,n);return new ng(i.name,o,r)}(t,i,n,s);case 8:return function(e,t,i,r){let a=pm(e,t),n=Tg(r)?r:void 0,o=vm(e,t,a.numValues,n);return new yf(i.name,o,r)}(t,i,n,s);default:throw Error(`The specified data type for the field is currently not supported: ${a}`)}}(r,e,t,a,i.scalarType,i):2===i.complexType?.physicalType?function(e,t,i,r){let a=function(e){let t="complexType"===e.type?e.complexType.children:void 0;return t&&0!==t.length?t.map(t=>e.name+(t.name??"")):[e.name]}(i);if(0===r)return a.map(e=>new fg(e,[]));let n=function(e,t,i){let r=e[t.get()];t.add(1);let a=Dm(e,t,pm(e,t)),n=i-1,o=[];r&dg.STRING&&(n-=function(e,t,i){let r=e[t.get()];t.add(1);let a=cg("",e,t,r);if(a)for(let e=0;e<a.size;e++)i.push(a.getValue(e));return r}(e,t,o)),n-=function(e,t,i,r){let a=0;return i&dg.INT32?(bg(r,Tm(e,t,pm(e,t))),a++):i&dg.INT64&&(bg(r,Mm(e,t,pm(e,t))),a++),i&dg.UINT32?(bg(r,Dm(e,t,pm(e,t))),a++):i&dg.UINT64&&(bg(r,zm(e,t,pm(e,t))),a++),a}(e,t,r,o),n-=function(e,t,i,r){let a=0;return i&dg.FLOAT&&(bg(r,xm(e,t,pm(e,t).numValues)),a++),i&dg.DOUBLE&&(bg(r,vm(e,t,pm(e,t).numValues)),a++),a}(e,t,r,o);let s,l=0;if(r&dg.PRESENCE){let i=function(e,t){let i=pm(e,t);if(i.physicalStreamType!==rm.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${i.physicalStreamType}`);let r=i.numValues,a=t.get(),n=new mm(ym(e,r,i.byteLength,t),r);return t.set(a+i.byteLength),{value:n,count:r}}(e,t);s=i.value,l=i.count,n--}let u=new Uint32Array;if(n>0&&(u=Dm(e,t,pm(e,t)),n--),0!==n)throw Error(`Unexpected number of remaining streams while decoding map column: ${n}`);return{lengthStream:a,dictionary:o,presentStream:s,presentCount:l,flattenedValues:u}}(e,t,r),o=(n.presentStream?n.presentCount:n.lengthStream.length)/a.length,s=[],l=0,u=0;for(let e=0;e<a.length;e++){let t=mg(n,e,o,l,u);s.push(new fg(a[e],t.value,t.nullabilityBuffer)),l=t.countsEnd,u=t.valuesEnd}return s}(e,t,i,r):0===r?null:function(e,t,i,r){let a,n,o,s,l=!1;for(;!l;){let i=pm(e,t);switch(i.physicalStreamType){case rm.LENGTH:om.DICTIONARY===i.logicalStreamType.lengthType?a=Em(e,t,i):o=Em(e,t,i);break;case rm.DATA:am.SINGLE===i.logicalStreamType.dictionaryType||am.SHARED===i.logicalStreamType.dictionaryType?(n=e.subarray(t.get(),t.get()+i.byteLength),l=!0):s=e.subarray(t.get(),t.get()+i.byteLength),t.add(i.byteLength)}}if("complexType"!==i.type)throw Error(`Shared dictionary column ${i.name} must be a complex (struct) column.`);if(!a||!n)throw Error(`Incomplete shared dictionary for column "${i.name}"`);let u=i.complexType.children,h=[],c=s?{}:void 0,d=0;for(let l of u){let u=jf(e,t,1)[0];if(0===u)continue;let p,f=l.name?`${i.name}${l.name}`:i.name;if(r&&!r.has(f)){_m(u,e,t);continue}if("scalarField"!==l.type||9!==l.scalarField.physicalType)throw Error("Currently only scalar string fields are implemented for a struct.");if(u>1&&!l.nullable||1===u&&l.nullable)throw Error(`The number of streams for the child field ${l.name} does not match its nullability. nullibilty: ${l.nullable}, numStreams: ${u}`);if(l.nullable){let i=pm(e,t);p=new mm(ym(e,i.numValues,i.byteLength,t),i.numValues)}let m=Dm(e,t,pm(e,t),void 0,p);if(s){if(!o)throw Error(`Incomplete shared FSST dictionary for column "${f}"`);h[d++]=new hg(f,m,a,n,o,s,p,c)}else h[d++]=new ug(f,m,a,n,p)}return h}(e,t,i,n)}function Tg(e){return e instanceof mm}!function(e){e[e.STRING=1]="STRING",e[e.INT32=2]="INT32",e[e.UINT32=4]="UINT32",e[e.INT64=8]="INT64",e[e.UINT64=16]="UINT64",e[e.FLOAT=32]="FLOAT",e[e.DOUBLE=64]="DOUBLE",e[e.PRESENCE=128]="PRESENCE"}(dg||={}),function(e){e[e.FALSE=0]="FALSE",e[e.TRUE=1]="TRUE",e[e.START_MAP=2]="START_MAP",e[e.START_LIST=3]="START_LIST",e[e.COUNT=4]="COUNT"}(pg||={});function Dg(e){switch(e){case 0:case 1:case 2:case 3:return{nullable:!!(1&e),columnScope:0,type:"scalarType",scalarType:{longID:!!(2&e),type:"logicalType",logicalType:0}};case 4:return{nullable:!1,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:0,children:[]}};case 30:return{nullable:!1,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:1,children:[]}};case 31:return{nullable:!0,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:2,children:[]}};default:return function(e){let t;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}return{nullable:!!(1&e),columnScope:0,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:t}}}(e)}}function Eg(e){return 30===e||31===e}function Sg(e){if("scalarType"===e.type){let t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if("logicalType"===t.type)return!1}else if("complexType"===e.type){let t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function Pg(e){return"scalarType"===e.type&&"logicalType"===e.scalarType?.type&&0===e.scalarType.logicalType}function Ig(e){return"complexType"===e.type&&"physicalType"===e.complexType?.type&&0===e.complexType.physicalType}const Ag=new TextDecoder,Cg="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function Mg(e,t){let i=jf(e,t,1)[0];if(0===i)return"";let r=t.get(),a=r+i,n=e.subarray(r,a);return t.add(i),Ag.decode(n)}function zg(e,t){let i=jf(e,t,1)[0]>>>0,r=i>=10?Dg(i):null;if(!r)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let a={...r,name:Mg(e,t)};if("complexType"===a.type&&Eg(i)){let i=a.complexType,r=jf(e,t,1)[0]>>>0;i.children=Array(r);for(let a=0;a<r;a++)i.children[a]=zg(e,t)}return function(e){let t=e.name,i=e.nullable;return"scalarType"===e.type?{type:"scalarField",scalarField:e.scalarType,name:t,nullable:i}:{type:"complexField",complexField:e.complexType,name:t,nullable:i}}(a)}function Fg(e,t){let i,r=jf(e,t,1)[0]>>>0,a=Dg(r);if(!a)throw Error(`Unsupported column type code ${r}. Supported: ${Cg}`);if(function(e){return e>=10}(r))i=Mg(e,t);else if(r<4)i="id";else{if(4!==r)throw Error(`Unsupported column type code ${r}. Supported: ${Cg}`);i="geometry"}let n={...a,name:i};if("complexType"===n.type&&Eg(r)){let i=jf(e,t,1)[0]>>>0,r=n.complexType;r.children=Array(i);for(let a=0;a<i;a++)r.children[a]=zg(e,t)}return n}function Rg(e,t){let i={featureTables:[]},r={};if(r.name=Mg(e,t),0===r.name.length)throw Error("Missing layer name");let a=jf(e,t,1)[0]>>>0,n=jf(e,t,1)[0]>>>0;r.columns=Array(n);for(let i=0;i<n;i++)r.columns[i]=Fg(e,t);return i.featureTables.push(r),[i,a]}function kg(e,t,i,r,a,n,o=!1){let s=t.scalarType?.longID?6:4,l="number"==typeof n?void 0:n,u=Lm(a,n,e,i,6===s?"int64":"int32");if(4===s)switch(u){case fm.FLAT:return new _f(r,Dm(e,i,a,void 0,l),n);case fm.SEQUENCE:{let t=Am(e,i,a);return new vf(r,t[0],t[1],a.numRleValues,!1)}case fm.CONST:return new bf(r,Im(e,i,a),n,!1)}switch(u){case fm.FLAT:return o?new yf(r,function(e,t,i,r){let a=function(e,t,i){if(i.physicalLevelTechnique===Df.VARINT)return function(e,t){switch(t.logicalLevelTechnique1){case Tf.DELTA:if(t.logicalLevelTechnique2===Tf.RLE){let i=t;e=Hf(e,i.runs,i.numRleValues)}return function(e){e[0]=qf(e[0]);let t=e.length/4*4,i=1;if(t>=4)for(;i<t-4;i+=4){let t=e[i],r=e[i+1],a=e[i+2],n=e[i+3];e[i]=qf(t)+e[i-1],e[i+1]=qf(r)+e[i],e[i+2]=qf(a)+e[i+1],e[i+3]=qf(n)+e[i+2]}for(;i!==e.length;++i)e[i]=qf(e[i])+e[i-1]}(e),e;case Tf.RLE:return function(e,t){return Hf(e,t.runs,t.numRleValues)}(e,t);case Tf.NONE:return e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}(function(e,t,i){let r=new Float64Array(i);for(let a=0;a<i;a++)r[a]=Uf(e,t);return r}(e,t,i.numValues),i);let r=km(Pm(e,t,i),i);return Float64Array.from(r,Number)}(e,t,i);return r?gm(a,r,0):a}(e,i,a,l),n):new Vm(r,zm(e,i,a,l),n);case fm.SEQUENCE:{let t=Cm(e,i,a);return new Nm(r,t[0],t[1],a.numRleValues,!1)}case fm.CONST:return new og(r,Fm(e,i,a),n,!1)}throw Error("Vector type not supported for id column.")}var Lg=class{constructor(e,t){switch(this._featureData=e,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Bm.POINT:case Bm.MULTIPOINT:this.type=1;break;case Bm.LINESTRING:case Bm.MULTILINESTRING:this.type=2;break;case Bm.POLYGON:case Bm.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){let e=[];for(let t of this._featureData.geometry.coordinates){let i=[];for(let e of t)i.push(new c(e.x,e.y));e.push(i)}return e}},Bg=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 Lg(this.features[e],this.extent)}},Og=class{constructor(e){this.layers={};let t=function(e,t,i=!0){let r=new Ef(0),a=[];for(;r.get()<e.length;){let n=jf(e,r,1)[0]>>>0,o=r.get()+n;if(o>e.length)throw Error(`Block overruns tile: ${o} > ${e.length}`);let s=jf(e,r,1)[0]>>>0;if(1!==s&&2!==s){r.set(o);continue}let[l,u]=Rg(e,r),h=l.featureTables[0],c=null,d=null,p=[],f=0;for(let a of h.columns){let n=a.name;if(Pg(a)){let t=null;if(a.nullable){let i=pm(e,r),a=r.get(),n=ym(e,i.numValues,i.byteLength,r);r.set(a+i.byteLength),t=new mm(n,i.numValues)}let o=pm(e,r);f=t?t.size():o.decompressedCount,c=kg(e,a,r,n,o,t??f,i)}else if(Ig(a)){let i=jf(e,r,1)[0];if(0===f){let t=r.get();f=pm(e,r).decompressedCount,r.set(t)}t&&(t.scale=t.extent/u),d=tg(e,i,r,f,t)}else{let t=Sg(a)?jf(e,r,1)[0]:1;if(0===t)continue;let i=wg(e,r,a,t,f,void 0);if(i)if(Array.isArray(i))for(let e of i)p.push(e);else p.push(i)}}let m=new wf(h.name,d,c,p,u);a.push(m),r.set(o)}return a}(new Uint8Array(e));this.layers=t.reduce((e,t)=>({...e,[t.name]:new Bg(t)}),{})}};function jg(e,t,i,r,a){return Fe(e,(e,n)=>{let o=t instanceof go?t.get(n):null;return function(e){return"object"==typeof e&&!!e&&"evaluate"in e}(o)?o.evaluate(i,r,void 0,a):o})}function Vg(e,t){return t-e}eo("FeatureIndex",class{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Jn(re,16,0),this.grid3D=new Jn(re,16,0),this.featureIndexArray=new ys,this.promoteId=t}insert(e,t,i,r,a,n){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,a);let s=n?this.grid3D:this.grid;for(let e of t){let t=[1/0,1/0,-1/0,-1/0];for(let i of e)t[0]=Math.min(t[0],i.x),t[1]=Math.min(t[1],i.y),t[2]=Math.max(t[2],i.x),t[3]=Math.max(t[3],i.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(){return this.vtLayers||("mlt"===this.encoding?this.vtLayers=new Og(this.rawTileData).layers:this.vtLayers=new Bh(new Ad(this.rawTileData)).layers,this.sourceLayerCoder=new pf(this.vtLayers?Object.keys(this.vtLayers).sort():[df])),this.vtLayers}query(e,t,i,r){this.loadVTLayers();let a=e.params,n=re/e.tileSize/e.scale,o=Ja(a.filter,"queryRenderedFeatures filter",a.globalState),s=e.queryGeometry,l=e.queryPadding*n,u=Ih.fromPoints(s),h=this.grid.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l),d=Ih.fromPoints(e.cameraQueryGeometry).expandBy(l),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,i,r,a)=>function(e,t,i,r,a){for(let n of e)if(t<=n.x&&i<=n.y&&r>=n.x&&a>=n.y)return!0;let n=[new c(t,i),new c(t,a),new c(r,a),new c(r,i)];if(e.length>2)for(let t of n)if(Bl(e,t))return!0;for(let t=0;t<e.length-1;t++)if(Ol(e[t],e[t+1],n))return!0;return!1}(e.cameraQueryGeometry,t-l,i-l,r+l,a+l));for(let e of p)h.push(e);h.sort(Vg);let f,m={};for(let l of h){if(l===f)continue;f=l;let u=this.featureIndexArray.get(l),h=null;this.loadMatchingFeature(m,u.bucketIndex,u.sourceLayerIndex,u.featureIndex,o,a.layers,a.availableImages,t,i,r,(t,i,r)=>(h||=Tl(t),i.queryIntersectsFeature({queryGeometry:s,feature:t,featureState:r,geometry:h,zoom:this.z,transform:e.transform,pixelsToTileUnits:n,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return m}loadMatchingFeature(e,t,i,r,a,n,o,s,l,u,h){let c=this.bucketLayerIDs[t];if(n&&!c.some(e=>n.has(e)))return;let d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(r);if(a.needGeometry){let e=Dl(p,!0);if(!a.filter(new so(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!a.filter(new so(this.tileID.overscaledZ),p))return;let f=this.getId(p,d);for(let t of c){if(n&&!n.has(t))continue;let i=s[t];if(!i)continue;let a={};f&&u&&(a=u.getState(i.sourceLayer||"_geojsonTileLayer",f));let c=Se({},l[t]);c.paint=jg(c.paint,i.paint,p,a,o),c.layout=jg(c.layout,i.layout,p,a,o);let d=!h||h(p,i,a);if(!d)continue;let m=new ff(p,this.z,this.x,this.y,f);m.layer=c;let g=e[t];void 0===g&&(g=e[t]=[]),g.push({featureIndex:r,feature:m,intersectionZ:d})}}lookupSymbolFeatures(e,t,i,r,a,n,o,s){let l={};this.loadVTLayers();let u=Ja(a.filterSpec,"queryRenderedFeatures symbol filter",a.globalState);for(let a of e)this.loadMatchingFeature(l,i,r,a,u,n,o,s,t);return l}hasLayer(e){for(let t of this.bucketLayerIDs)for(let i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;if(this.promoteId){let r="string"==typeof this.promoteId?this.promoteId:this.promoteId[t];i=e.properties[r],"boolean"==typeof i&&(i=Number(i)),void 0===i&&e.properties?.cluster&&this.promoteId&&(i=Number(e.properties.cluster_id))}return i}},{omit:["rawTileData","sourceLayerCoder"]});var Ng=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(let e in this.data)for(let t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){let r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);let a={value:t,timeout:void 0};if(void 0!==i&&(a.timeout=setTimeout(()=>{this.remove(e,a)},i)),this.data[r].push(a),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),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){let t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;let i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),a=this.data[i][r];return this.data[i].splice(r,1),a.timeout&&clearTimeout(a.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(a.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let t=[];for(let i in this.data)for(let r of this.data[i])e(r.value)||t.push(r);for(let e of t)this.remove(e.value.tileID,e)}};function Ug(){var e=new g(4);return g!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let $g,Gg,Zg;const qg={frame(e,t,i,r){let a=r||window,n=a.requestAnimationFrame(e=>{o(),t(e)}),{unsubscribe:o}=$e(e.signal,"abort",()=>{o(),a.cancelAnimationFrame(n),i(new it(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((i,r)=>{this.frame(e,i,r,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t;if(f()&&!m())t=new OffscreenCanvas(e.width,e.height).getContext("2d",{willReadFrequently:!0});else{let i=window.document.createElement("canvas");i.width=e.width,i.height=e.height,t=i.getContext("2d",{willReadFrequently:!0})}if(!t)throw Error("failed to create canvas 2d context");return t.drawImage(e,0,0,e.width,e.height),t},resolveURL:e=>($g||=document.createElement("a"),$g.href=e,$g.href),get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===Zg?!!matchMedia&&(Gg??=matchMedia("(prefers-reduced-motion: reduce)"),Gg.matches):Zg},set prefersReducedMotion(e){Zg=e}},Wg=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null===this._frozenAt?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function Xg(){return Wg.getCurrentTime()}var Hg=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(e,t,i){let r=window.document.createElement(e);return void 0!==t&&(r.className=t),i&&i.appendChild(r),r}static createNS(e,t){return window.document.createElementNS(e,t)}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(e){let t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,t,i){let r=t.boundingClientRect;return new c((i.clientX-r.left)/t.x-e.clientLeft,(i.clientY-r.top)/t.y-e.clientTop)}static mousePos(t,i){let r=e.getScale(t);return e.getPoint(t,r,i)}static touchPos(t,i){let r=[],a=e.getScale(t);for(let n of i)r.push(e.getPoint(t,a,n));return r}static sanitize(t){let i=(new DOMParser).parseFromString(t,"text/html").body||document.createElement("body"),r=i.querySelectorAll("script, iframe");for(let e of r)e.remove();return e.clean(i),i.innerHTML}static isPossiblyDangerous(e,t){let i=t.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(e)&&(i.includes("javascript:")||i.includes("data:"))||"srcdoc"===e||e.startsWith("on"))return!0}static clean(t){let i=t.children;for(let t of i)e.removeAttributes(t),e.clean(t)}static removeAttributes(t){for(let{name:i,value:r}of Array.from(t.attributes))e.isPossiblyDangerous(i,r)&&t.removeAttribute(i)}};let Yg;(function(e){let t,i,r,a;e.resetRequestQueue=()=>{t=[],i=0,r=0,a={}},e.addThrottleControl=e=>{let t=r++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],s()},e.transformAndGetImage=async function(e,t,i,r,a=!0,n){let o=await e.transformRequest(t,i);return at(r.signal),Yg.getImage(o,r,a,n)},e.getImage=(e,i,r=!0,a)=>new Promise((n,o)=>{e.headers||={},e.headers.accept="image/webp,*/*",Se(e,{type:"image"});let l={abortController:i,requestParameters:e,supportImageRefresh:r,imageBitmapOptions:a,state:"queued",onError:e=>{o(e)},onSuccess:e=>{n(e)}};t.push(l),s()});let n=(e,t)=>"function"==typeof createImageBitmap?(async(e,t)=>{let i=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(i,t)}catch(e){throw Error(`Could not load image because of ${ne(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})(e,t):(e=>new Promise((t,i)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>r.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=")},r.onerror=()=>i(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));let a=new Blob([new Uint8Array(e)],{type:"image/png"});r.src=URL.createObjectURL(a)}))(e),o=async e=>{e.state="running";let{requestParameters:t,supportImageRefresh:r,imageBitmapOptions:a,onError:o,onSuccess:u,abortController:h}=e,c=!1===r&&!a&&!Ve(self)&&!ot(t.url)&&(!t.headers||Object.keys(t.headers).reduce((e,t)=>e&&"accept"===t,!0));i++;let d=c?l(t,h):ht(t,h);try{let t=await d;delete e.abortController,e.state="completed",t.data instanceof HTMLImageElement||Ue(t.data)?u(t):t.data&&0!==t.data.byteLength?u({data:await n(t.data,a),cacheControl:t.cacheControl,expires:t.expires}):u({data:null,cacheControl:t.cacheControl,expires:t.expires})}catch(t){delete e.abortController,o(ne(t))}finally{i--,s()}},s=()=>{let e=(()=>{for(let e of Object.keys(a))if(a[e]())return!0;return!1})()?nt.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:nt.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r<e&&t.length>0;r++){let e=t.shift();e.abortController.signal.aborted?r--:o(e)}},l=(e,t)=>new Promise((i,r)=>{let a=new Image,n=e.url,o=e.credentials;o&&"include"===o?a.crossOrigin="use-credentials":(o&&"same-origin"===o||!pt(n))&&(a.crossOrigin="anonymous"),t.signal.addEventListener("abort",()=>{a.src="",r(new it(t.signal.reason))}),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,i({data:a})},a.onerror=()=>{a.onerror=a.onload=null,!t.signal.aborted&&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."))},a.src=n})})(Yg||={}),Yg.resetRequestQueue();var Kg=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}},Jg=class extends gt{},Qg=class extends Jg{},e_=class extends Jg{constructor(e={}){super("style.load",e)}},t_=class extends Jg{constructor(e,t={}){super(e,t),this.dataType="style"}},i_=class extends Jg{constructor(e,t={}){super(e,t),this.dataType="source"}},r_=class extends Jg{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){i=i instanceof MouseEvent?i:new MouseEvent(e,i);let a=Hg.mousePos(t.getCanvas(),i);super(e,Se({point:a,lngLat:t.unproject(a),originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}},a_=class extends Jg{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){let r="touchend"===e?i.changedTouches:i.touches,a=Hg.touchPos(t.getCanvasContainer(),r),n=a.map(e=>t.unproject(e)),o=a.reduce((e,t,i,r)=>e.add(t.div(r.length)),new c(0,0));super(e,{points:a,point:o,lngLats:n,lngLat:t.unproject(o),originalEvent:i}),this._defaultPrevented=!1}},n_=class extends Jg{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}},o_=class extends Jg{},s_=class extends Jg{constructor(e={}){super("terrain",e)}},l_=class extends Jg{constructor(e={}){super("projectiontransition",e)}},u_=class extends Jg{},h_=class extends Jg{constructor(e={}){super("styleimagemissing",e)}};function c_(e,t){let i={};for(let t in e)"ref"!==t&&(i[t]=e[t]);return bt.forEach(e=>{e in t&&(i[e]=t[e])}),i}function d_(e){e=e.slice();let t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=c_(e[i],t[e[i].ref]));return e}function p_(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!p_(e[i],t[i]))return!1;return!0}if("object"==typeof e&&e&&null!==t){if("object"!=typeof t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(!p_(e[i],t[i]))return!1;return!0}return e===t}function f_(e,t){e.push(t)}function m_(e,t,i){f_(i,{command:"addSource",args:[e,t[e]]})}function g_(e,t,i){f_(t,{command:"removeSource",args:[e]}),i[e]=!0}function __(e,t,i,r){g_(e,i,r),m_(e,t,i)}function y_(e,t,i){let r;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!p_(e[i][r],t[i][r]))return!1;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!p_(e[i][r],t[i][r]))return!1;return!0}function x_(e,t,i,r,a,n){e||={},t||={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(p_(e[o],t[o])||i.push({command:n,args:[r,o,t[o],a]}));for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&!Object.prototype.hasOwnProperty.call(e,o)&&(p_(e[o],t[o])||i.push({command:n,args:[r,o,t[o],a]}))}function v_(e){return e.id}function b_(e,t){return e[t.id]=t,e}function w_(e){let t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){let i=[];for(let{id:r,url:a}of e){let e=`${r}${a}`;i.includes(e)||(i.push(e),t.push({id:r,url:a}))}}return t}function T_(e,t,i){try{let r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}var D_=class extends yt{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let e of Object.keys(this.images))this.removeImage(e);this._spriteImagesIds={}}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){let t=this.images[e];if(t&&!t.data&&t.spriteData){let e=t.spriteData;t.data=new ou({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),t.spriteData=null}return t}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t,this._imagesIds=null,t.isWebGLImage&&this.updateImage(e,t,!1))}_validate(e,t){let i=!0,r=t.data||t.spriteData;return this._validateStretch(t.stretchX,r?.width)||(this.fire(new _t(Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,r?.height)||(this.fire(new _t(Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new _t(Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(let r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(4!==e.length)return!1;let i=t.spriteData,r=i?.width||t.data.width,a=i?.height||t.data.height;return!(e[0]<0||r<e[0]||e[1]<0||a<e[1]||e[2]<0||r<e[2]||e[3]<0||a<e[3]||e[2]<e[0])&&e[3]>=e[1]}updateImage(e,t,i=!0){let r=this.images[e];if(i){let e=r.data||r.spriteData;if(e.width!==t.data.width||e.height!==t.data.height)throw Error(`size mismatch between old image (${e.width}x${e.height}) and new image (${t.data.width}x${t.data.height}).`)}t.version=(r.version??0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,t.userImage?.onRemove&&t.userImage.onRemove())}listImages(){return this._imagesIds??=Object.keys(this.images),this._imagesIds}_getSpriteImageId(e,t){return"default"===e?t:`${e}:${t}`}setSpriteImages(e,t){let i=this._spriteImagesIds[e]??[],r=[];for(let i in t){let a=this._getSpriteImageId(e,i);r.push(a),a in this.images?this.updateImage(a,t[i],!1):this.addImage(a,t[i])}let a=new Set(r),n=i.filter(e=>!a.has(e));for(let e of n)this.removeImage(e);return this._spriteImagesIds[e]=r,{loaded:r,removed:n}}removeSpriteImages(e){let t=this._spriteImagesIds[e]??[];for(let e of t)this.removeImage(e);return delete this._spriteImagesIds[e],t}removeAllSpriteImages(){let e=Object.values(this._spriteImagesIds).flat();for(let t of e)this.removeImage(t);return this._spriteImagesIds={},e}setMissingImageResolver(e){this.missingImageResolver=e}getImages(e){return new Promise((t,i)=>{let r=!0;if(!this.isLoaded())for(let t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}async _getImagesForIds(e){let t=new Set(e.filter(e=>!this.getImage(e))),i=this.missingImageResolver;i&&await Promise.allSettled(Array.from(t,e=>i(e)));let r={};for(let i of e){let e=this.getImage(i);e&&(t.delete(i),r[i]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:!!e.userImage?.render,isWebGLImage:e.isWebGLImage})}for(let e of t)this.fire(new h_({id:e})),Oe(`Image "${e}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return r}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let e=this.getImage(t);e||Oe(`Image with ID: "${t}" was not found`),Rd(e)&&this.updateImage(t,e)}}cloneImages(){let e={};for(let t in this.images){let i=this.images[t];e[t]={...i,data:i.data?i.data.clone():null}}return e}},E_=class{constructor(e){this._imageManager=e,this._entries={},this._image=new ou({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&=(this._texture.destroy(),null),this._entries={},this._image=new ou({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:e,height:t}=this._image;return{width:e,height:t}}getPattern(e){let t=this._imageManager.getImage(e);if(!t)return null;let i=this._entries[e];if(i?.image!==t){let i={w:t.data.width+2,h:t.data.height+2,x:0,y:0};this._entries[e]={bin:i,position:new Ld(i,t),image:t}}else{if(i.position.version===t.version)return i.position;i.position.version=t.version}return this._update(),this._entries[e].position}bind(e){let t=e.gl;this._texture?this._dirty&&=(this._texture.update(this._image),!1):(this._texture=new _u(e,this._image,t.RGBA),this._dirty=!1),this._texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_update(){for(let e in this._entries)this._imageManager.getImage(e)||delete this._entries[e];let e=[];for(let t in this._entries)e.push(this._entries[t].bin);let{w:t,h:i}=kd(e),r=this._image;r.resize({width:t||1,height:i||1});for(let e in this._entries){let{bin:t}=this._entries[e],i=t.x+1,a=t.y+1,n=this._entries[e].image.data,o=n.width,s=n.height;ou.copy(n,r,{x:0,y:0},{x:i,y:a},{width:o,height:s}),ou.copy(n,r,{x:0,y:s-1},{x:i,y:a-1},{width:o,height:1}),ou.copy(n,r,{x:0,y:0},{x:i,y:a+s},{width:o,height:1}),ou.copy(n,r,{x:o-1,y:0},{x:i-1,y:a},{width:1,height:s}),ou.copy(n,r,{x:0,y:0},{x:i+o,y:a},{width:1,height:s})}this._dirty=!0}};const S_=1114111,P_={start:0,end:S_};let I_=0;function A_(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,e,i]=t;return e.length+i.length>6?null:C_(parseInt(`${e}${"0".repeat(i.length)}`,16),parseInt(`${e}${"f".repeat(i.length)}`,16))}let i=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!i)return null;let r=parseInt(i[1],16);return C_(r,void 0===i[2]?r:parseInt(i[2],16))}function C_(e,t){return e>t||e>S_?null:{start:e,end:Math.min(t,S_)}}function M_(e,t){return e.ranges.some(({start:e,end:i})=>t>=e&&t<=i)}var z_=class{constructor(e){this.requestManager=e,this._faces={},this._registered=new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,i]of Object.entries(e??{})){let e=Array.isArray(i)?i:[i];this._faces[t]=e.map(e=>this._declareFontFace(t,e)).filter(e=>null!==e)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t){for(let i of e.split(","))for(let e of this._faces[i.trim()]??[])if(M_(e,t)&&(e.loaded??=this._loadFontFace(e),await e.loaded))return e.family;return null}_declareFontFace(e,t){let i="string"==typeof t?{url:t}:t;if("string"!=typeof i?.url)return Oe(`Ignoring the font face declared for "${e}": it has no URL.`),null;let r="maplibre-gl-font-face-"+I_++,a=i["unicode-range"];if(!a?.length)return{url:i.url,ranges:[P_],family:r};let n=[];for(let e of a){let t=A_(e);t?n.push(t):Oe(`Ignoring the unicode range "${e}" of the font face at ${i.url}: it is not a valid range.`)}return n.length?{url:i.url,ranges:n,family:r}:null}async _loadFontFace(e){if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return Oe(`Ignoring the font face at ${e.url}: this environment has no CSS Font Loading API.`),!1;let t;try{return t=new FontFace(e.family,await this._downloadFontFile(e.url)),!!Object.values(this._faces).some(t=>t.includes(e))&&(document.fonts.add(t),this._registered.add(t),await t.load(),!0)}catch(i){return t&&this._unregister(t),Oe(`Ignoring the font face at ${e.url}: ${ne(i).message}`),!1}}async _downloadFontFile(e){let t=await this.requestManager.transformRequest(e,"Glyphs"),i=await dt(t,new AbortController);if(!i?.data)throw Error(`the response was empty for the font file at ${e}`);return i.data}_unregister(e){document.fonts?.delete(e),this._registered.delete(e)}_unregisterAll(){for(let e of this._registered)document.fonts?.delete(e);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}};const F_=1e20,R_=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**(1/2.2);R_[e]=t*Math.abs(t)}R_[255]=-1e20;var k_=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:a="sans-serif",fontWeight:n="normal",fontStyle:o="normal",lang:s=null}={}){this.buffer=t,this.radius=i,this.cutoff=r,this.lang=s;let l=this.size=e+4*t,u=this._createCanvas(l),h=this.ctx=u.getContext("2d",{willReadFrequently:!0});h.font=`${o} ${n} ${e}px ${a}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,e);let t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:a,actualBoundingBoxRight:n}=this.ctx.measureText(e),o=Math.ceil(i),s=Math.floor(-a),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n)-s)),u=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(r))),h=l+2*this.buffer,c=u+2*this.buffer,d=Math.max(h*c,0),p=new Uint8ClampedArray(d),f={data:p,width:h,height:c,glyphWidth:l,glyphHeight:u,glyphTop:o,glyphLeft:s,glyphAdvance:t};if(0===l||0===u)return f;let{ctx:m,buffer:g,gridInner:_,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,l,u),m.fillText(e,g-s,g+o);let x=m.getImageData(g,g,l,u);y.fill(F_,0,d),_.fill(0,0,d);let v=3;for(let e=0;e<u;e++){let t=(e+g)*h+g;for(let e=0;e<l;e++,v+=4,t++){let e=x.data[v];if(0===e)continue;let i=R_[e];y[t]=Math.max(0,i),_[t]=Math.max(0,-i)}}L_(y,0,0,h,c,h,this.f,this.v,this.z);let b=Math.min(g,1);L_(_,g-b,g-b,l+2*b,u+2*b,h,this.f,this.v,this.z);let w=255/this.radius,T=255*(1-this.cutoff);for(let e=0;e<d;e++){let t=Math.sqrt(y[e])-Math.sqrt(_[e]);p[e]=Math.round(T-w*t)}return f}};function L_(e,t,i,r,a,n,o,s,l){for(let u=t;u<t+r;u++)B_(e,i*n+u,n,a,o,s,l);for(let u=i;u<i+a;u++)B_(e,u*n+t,1,r,o,s,l)}function B_(e,t,i,r,a,n,o){n[0]=0,o[0]=-1e20,o[1]=F_,a[0]=e[t];for(let s=1,l=0,u=0;s<r;s++){a[s]=e[t+s*i];let r=s*s;do{let e=n[l];u=(a[s]-a[e]+r-e*e)/(s-e)/2}while(u<=o[l]&&--l>-1);l++,n[l]=s,o[l]=u,o[l+1]=F_}for(let s=0,l=0;s<r;s++){for(;o[l+1]<s;)l++;let r=n[l],u=s-r;e[t+s*i]=a[r]+u*u}}const O_=vt.layout_symbol["text-font"].default.join(","),j_=(e,t)=>{let i=new k_(e);return i.buffer=t,i};var V_=class{constructor(e,t,i,r=j_){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i,this.fontFaceManager=new z_(e),this.createRasterizer=r}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){let t=[];for(let i in e)for(let r of e[i])t.push(this._getAndCacheGlyphsPromise(i,r));let i=await Promise.all(t),r={};for(let{stack:e,id:t,glyph:a}of i)r[e]||={},r[e][t]=a&&{id:a.id,bitmap:a.bitmap.clone(),metrics:a.metrics};return r}async _getAndCacheGlyphsPromise(e,t){this.entries[e]??={glyphs:{},requests:{},ranges:{}};let i=this.entries[e],r=i.glyphs[t];if(void 0!==r)return{stack:e,id:t,glyph:r};let a=t.codePointAt(0),n=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,a):null;return n?(r=i.glyphs[t]=await this._drawGlyph(i,e,t,n),{stack:e,id:t,glyph:r}):!this.url||id(t)||this._charUsesLocalIdeographFontFamily(a)?(r=i.glyphs[t]=await this._drawGlyph(i,e,t),{stack:e,id:t,glyph:r}):await this._downloadAndCacheRangePromise(e,t)}async _downloadAndCacheRangePromise(e,t){let i=t.codePointAt(0),r=this.entries[e],a=Math.floor(i/256);if(r.ranges[a])return{stack:e,id:t,glyph:null};r.requests[a]||=this._loadGlyphRange(e,a);try{let n=await r.requests[a];for(let e in n)r.glyphs[String.fromCodePoint(+e)]=n[+e];return r.ranges[a]=!0,{stack:e,id:t,glyph:n[i]||null}}catch(n){let o=r.glyphs[t]=await this._drawGlyph(r,e,t);return this._warnOnMissingGlyphRange(o,a,i,ne(n)),{stack:e,id:t,glyph:o}}}async _loadGlyphRange(e,t){let i=256*t,r=i+255,a=await this.requestManager.transformRequest(this.url.replace("{fontstack}",e).replace("{range}",`${i}-${r}`),"Glyphs"),n=await dt(a,new AbortController);if(!n?.data)throw Error(`Could not load glyph range. range: ${t}, ${i}-${r}`);let o={};for(let e of function(e){return new Ad(e).readFields(Cd,[])}(n.data))o[e.id]=e;return o}_warnOnMissingGlyphRange(e,t,i,r){let a=256*t;Oe(`Unable to load glyph range ${t}, ${a}-${a+255}. Rendering codepoint U+${i.toString(16).padStart(4,"0").toUpperCase()} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}(e)}async _drawGlyph(e,t,i,r){let a=(await this._getTinySDF(e,t,i,r)).draw(i),n=/^\p{gc=Cf}+$/u.test(i);return{id:i.codePointAt(0),bitmap:new nu({width:a.width||60,height:a.height||60},a.data),metrics:{width:n?0:a.glyphWidth/2||24,height:a.glyphHeight/2||24,left:a.glyphLeft/2+.5||0,top:a.glyphTop/2-27.5||-8,advance:n?0:a.glyphAdvance/2||24,isDoubleResolution:!0}}}_getTinySDF(e,t,i,r){let a=id(i);if(r){let t=a?"clusterTinySDFs":"fontFaceTinySDFs";return e[t]??={},e[t][r]||=this._createTinySDF(r,!1,a?3:1),e[t][r]}let n=t===O_&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(i.codePointAt(0)),o=n?this.localIdeographFontFamily:t;if(a)return e.clusterTinySDFs??={},e.clusterTinySDFs[o]||=this._createTinySDF(o,!0,3),e.clusterTinySDFs[o];let s=n?"ideographTinySDF":"tinySDF";return e[s]||=this._createTinySDF(o),e[s]}async _createTinySDF(e,t=!0,i=1){let r=e?e.split(","):[];r.push("sans-serif");let a=r.map(e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(","),n=t?this._fontWeight(r[0]):void 0,o=t?this._fontStyle(r[0]):"normal";if(typeof document<"u"&&document.fonts?.load)try{await document.fonts.load(`${o} ${n||"normal"} 48px ${a}`)}catch(e){Oe(`Failed to load font "${a}": ${ne(e).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(i-1)/4)),radius:16,cutoff:.25,fontFamily:a,fontWeight:n,fontStyle:o,lang:this.lang},6)}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){let t,i={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};for(let[r,a]of Object.entries(i))RegExp(`\\b${r}\\b`,"i").test(e)&&(t=`${a}`);return t}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.fontFaceTinySDFs={},t.glyphs={},t.requests={},t.ranges={}}this.entries={},this.fontFaceManager.destroy()}};let N_;var U_=class extends yt{constructor(e,t){super(),this._transitionable=new ho(N_||=new Do({anchor:new xo(vt.light.anchor,"anchor"),position:new xo(vt.light.position,"position"),color:new xo(vt.light.color,"color"),intensity:new xo(vt.light.intensity,"intensity")}),"light",t),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,[e*Math.cos(t)*Math.sin(i),e*Math.sin(t)*Math.sin(i),e*Math.cos(i)]}(this.properties.get("position"))}setLight(e,t={}){if(!this._validate(Wn.light,e,t))for(let t in e){let i=e[t];t.endsWith("-transition")?this._transitionable.setTransition(t.slice(0,-11),i):this._transitionable.setValue(t,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return Kn(this,e,{value:t},i)}};let $_;var G_=class extends yt{constructor(e,t){super(),this._transitionable=new ho($_||=new Do({"sky-color":new xo(vt.sky["sky-color"],"sky-color"),"horizon-color":new xo(vt.sky["horizon-color"],"horizon-color"),"fog-color":new xo(vt.sky["fog-color"],"fog-color"),"fog-ground-blend":new xo(vt.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new xo(vt.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new xo(vt.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new xo(vt.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new so(0))}setSky(e,t={}){if(!this._validate(Wn.sky,e,t)){e||={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0};for(let t in e){let i=e[t];t.endsWith("-transition")?this._transitionable.setTransition(t.slice(0,-11),i):this._transitionable.setValue(t,i)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i={}){return Kn(this,e,{value:t},i)}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}},Z_=class{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){let i=e.join(",")+String(t);return this.dashEntry[i]||=this.addDash(e,t),this.dashEntry[i]}getDashRanges(e,t,i){let r=[],a=e.length%2==1?-e[e.length-1]*i:0,n=e[0]*i,o=!0;r.push({left:a,right:n,isDash:o,zeroLength:0===e[0]});let s=e[0];for(let t=1;t<e.length;t++){o=!o;let l=e[t];a=s*i,s+=l,n=s*i,r.push({left:a,right:n,isDash:o,zeroLength:0===l})}return r}addRoundDash(e,t,i){let r=t/2;for(let t=-i;t<=i;t++){let a=this.nextRow+i+t,n=this.width*a,o=0,s=e[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=e[++o]);let l,u=Math.abs(a-s.left),h=Math.abs(a-s.right),c=Math.min(u,h),d=t/i*(r+1);if(s.isDash){let e=r-Math.abs(d);l=Math.sqrt(c*c+e*e)}else l=r-Math.sqrt(c*c+d*d);this.data[n+a]=Math.max(0,Math.min(255,l+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){let i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r?.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}let t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);let r=this.width*this.nextRow,a=0,n=e[a];for(let t=0;t<this.width;t++){t/n.right>1&&(n=e[++a]);let i=Math.abs(t-n.left),o=Math.abs(t-n.right),s=Math.min(i,o),l=n.isDash?s:-s;this.data[r+t]=Math.max(0,Math.min(255,l+128))}}addDash(e,t){let i=t?7:0,r=2*i+1;if(this.nextRow+r>this.height)return Oe("LineAtlas out of space"),null;let a=0;for(let t of e)a+=t;if(0!==a){let r=this.width/a,n=this.getDashRanges(e,this.width,r);t?this.addRoundDash(n,r,i):this.addRegularDash(n)}let n={y:this.nextRow+i,height:2*i,width:a};return this.nextRow+=r,this.dirty=!0,n}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}};function q_(e,t){if(t)try{return new Worker(e,{type:"module"})}catch(e){console.warn("Module worker not supported, falling back to classic worker",e)}return new Worker(e)}async function W_(){let e=nt.WORKER_URL||function(){let e="file:///home/runner/work/graphhopper-maps/graphhopper-maps/node_modules/maplibre-gl/dist/maplibre-gl.mjs";if(!/^https?:/.test(e))return"";let t=e.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs";return new URL(`./${t}`,e).href}(),t=!e?.endsWith(".cjs");if(!function(e){if(!e)return!1;let t=globalThis.location;if(!t)return!1;try{return new URL(e,t.href).origin!==t.origin}catch{return!1}}(e))return q_(e,t);if(t){let r=function(e){let t=new Blob([`import ${JSON.stringify(i(6417)(e).href)}`],{type:"text/javascript"});return URL.createObjectURL(t)}(e);try{return q_(r,t)}finally{URL.revokeObjectURL(r)}}let r=await async function(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);let i=await t.text(),r=new Blob([i],{type:"text/javascript"});return URL.createObjectURL(r)}(e);try{return q_(r,t)}finally{URL.revokeObjectURL(r)}}var X_=class e{constructor(){this.active={},this.workersPromise=null}async acquire(t){if(this.active[t]=!0,!this.workersPromise){let t=[];for(;t.length<e.workerCount;)t.push(W_());this.workersPromise=Promise.all(t)}return(await this.workersPromise).slice()}release(e){if(delete this.active[e],0===this.numActive()&&this.workersPromise){let e=this.workersPromise;this.workersPromise=null,e.then(e=>{for(let t of e)t.terminate()})}}isPreloaded(){return!!this.active.maplibre_preloaded_worker_pool}numActive(){return Object.keys(this.active).length}};const H_=Math.floor(qg.hardwareConcurrency/2);let Y_;function K_(){return Y_||=new X_,Y_}X_.workerCount=function(e){if(null==Ne){let t=e.navigator?e.navigator.userAgent:null;Ne=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Ne}(globalThis)?Math.max(Math.min(H_,3),1):1;var J_=class{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t,this.removed=!1,this.actorsPromise=this.initActors(t)}async initActors(e){let t=await this.workerPool.acquire(e);if(this.removed)return[];if(this.actors=t.map((t,i)=>{let r=new rf(t,e);return r.name=`Worker ${i}`,r}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(e,t){let i=await this.actorsPromise;return Promise.all(i.map(i=>i.sendAsync({type:e,data:t})))}async getActor(){let e=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%e.length,e[this.currentActor]}async waitForInitComplete(){0===this.actors.length&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.removed=!0;for(let e of this.actors)e.remove();this.actors=[],e&&this.workerPool.release(this.id)}async registerMessageHandler(e,t){let i=await this.actorsPromise;for(let r of i)r.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let i of t)i.unregisterMessageHandler(e)}};let Q_;function ey(e,t){let i=y();return T(i,i,[1,1,0]),D(i,i,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?w(i,i,e.calculatePosMatrix(t.toUnwrapped())):i}function ty(e,t,i,r,a,n,o){let s=function(e,t,i){if(e)for(let r of e){let e=t[r];if(e?.source===i&&"fill-extrusion"===e.type)return!0}else for(let e in t){let r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(a?.layers??null,t,e.id),l=n.maxPitchScaleFactor(),u=e.tilesIn(r,l,s);u.sort(iy);let h=[];for(let r of u)h.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,a,n,l,ey(n,r.tileID),o?(e,t)=>o(r.tileID,e,t):void 0)});return function(e,t){for(let i in e)for(let r of e[i])ry(r,t);return e}(function(e){let t={},i={};for(let{queryResults:r,wrappedTileID:a}of e){i[a]||={};let e=i[a];for(let i in r){let a=r[i];e[i]||={};let n=e[i];t[i]||=[];for(let e of a)n[e.featureIndex]||(n[e.featureIndex]=!0,t[i].push(e))}}return t}(h),e)}function iy(e,t){let i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function ry(e,t){let i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}async function ay(e,t,i,r){let a=e;if(e.url?a=(await ct(await t.transformRequest(e.url,"Source"),i)).data:await qg.frameAsync(i,r),!a)return null;let n=Pe(Se(a,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(n.vectorLayerIds=a.vector_layers.map(e=>e.id)),n}var ny=class e{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof jh?new jh(e.lng,e.lat):jh.convert(e),this}setSouthWest(e){return this._sw=e instanceof jh?new jh(e.lng,e.lat):jh.convert(e),this}extend(t){let i,r,a=this._sw,n=this._ne;if(t instanceof jh)i=t,r=t;else{if(!(t instanceof e)){if(Array.isArray(t)){if(4===t.length||t.every(Array.isArray)){let i=t;return this.extend(e.convert(i))}{let e=t;return this.extend(jh.convert(e))}}return t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(jh.convert(t)):this}if(i=t._sw,r=t._ne,!i||!r)return this}return a||n?(a.lng=Math.min(i.lng,a.lng),a.lat=Math.min(i.lat,a.lat),n.lng=Math.max(r.lng,n.lng),n.lat=Math.max(r.lat,n.lat)):(this._sw=new jh(i.lng,i.lat),this._ne=new jh(r.lng,r.lat)),this}getCenter(){return new jh((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 jh(this.getWest(),this.getNorth())}getSouthEast(){return new jh(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:t,lat:i}=jh.convert(e),r=this._sw.lat<=i&&i<=this._ne.lat,a=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=t&&t>=this._ne.lng),r&&a}intersects(t){if(!((t=e.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(i>=360||r>=360)return!0;let a=Ee(this.getWest(),-180,180),n=Ee(this.getEast(),-180,180),o=Ee(t.getWest(),-180,180),s=Ee(t.getEast(),-180,180),l=a>n,u=o>s;return!(!l||!u)||(l?s>=a||o<=n:u?n>=o||a<=s:o<=n&&s>=a)}static convert(t){return t instanceof e||!t?t:new e(t)}static fromLngLat(t,i=0){let r=360*i/40075017,a=r/Math.cos(Math.PI/180*t.lat);return new e(new jh(t.lng-a,t.lat-r),new jh(t.lng+a,t.lat+r))}adjustAntiMeridian(){let t=new jh(this._sw.lng,this._sw.lat),i=new jh(this._ne.lng,this._ne.lat);return t.lng>i.lng?new e(t,new jh(i.lng+360,i.lat)):new e(t,i)}},oy=class{constructor(e,t,i){this.bounds=ny.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let t=2**e.z,i=Math.floor(Uh(this.bounds.getWest())*t),r=Math.floor($h(this.bounds.getNorth())*t),a=Math.ceil(Uh(this.bounds.getEast())*t),n=Math.ceil($h(this.bounds.getSouth())*t);return e.x>=i&&e.x<a&&e.y>=r&&e.y<n}},sy=class extends yt{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Se(this,Pe(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=Se({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}async load(e=!1){this._loaded=!1,this.fire(new i_("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await ay(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(Se(this,t),t.bounds&&(this.tileBounds=new oy(t.bounds,this.minzoom,this.maxzoom)),this.fire(new i_("data",{sourceDataType:"metadata"})),this.fire(new i_("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,rt(e)||this.fire(new _t(ne(e)))}}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return Se({},this._options)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:await this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(e),etag:e.etag};i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getReadyActor(),r="LT";e.abortController=new AbortController;try{let t=await e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);let a={};return t?.etagUnmodified&&(a.unmodified=!0),a}catch(t){if(delete e.abortController,e.aborted||rt(t))return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}}async _getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom||void 0===this.map._zoomLevelsToOverscale)return;let t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:await this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t?.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=t?.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){let t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&await e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}})}async unloadTile(e){e.unloadVectorData(),e.actor&&await e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},ly=class extends yt{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=Se({type:"raster"},t),Se(this,Pe(t,["url","scheme","tileSize"]))}async load(e=!1){this._loaded=!1,this.fire(new i_("dataloading")),this._tileJSONRequest=new AbortController;try{let t=await ay(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(Se(this,t),t.bounds&&(this.tileBounds=new oy(t.bounds,this.minzoom,this.maxzoom)),this.fire(new i_("data",{sourceDataType:"metadata"})),this.fire(new i_("data",{sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,rt(e)||this.fire(new _t(ne(e)))}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(e){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return Se({},this._options)}setPremultiplyAlpha(e){return this._premultiplyAlpha===e||this.setSourceProperty(()=>{this._premultiplyAlpha=e}),this}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i=this._premultiplyAlpha,r=i?void 0:{premultiplyAlpha:"none"};e.abortController=new AbortController;try{let a=await Yg.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,r);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let t=this.map.painter.context,r=t.gl,n=a.data??new ou({width:1,height:1},new Uint8Array(4));e.texture=this.map.painter.getTileTexture(n.width),e.texture?e.texture.update(n,{useMipmap:!0,premultiply:i}):(e.texture=new _u(t,n,r.RGBA,{useMipmap:!0,premultiply:i}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController)}async unloadTile(e){e.texture&&this.map.painter.saveTileTexture(e.texture)}hasTransition(){return!1}},uy=class extends ly{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=Se({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox",this.redFactor=t.redFactor,this.greenFactor=t.greenFactor,this.blueFactor=t.blueFactor,this.baseShift=t.baseShift}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let i=await Yg.transformAndGetImage(this.map._requestManager,t,"Tile",e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i){if(this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires}),!i.data)return void(e.state="loaded");let t=i.data,r=Ue(t)&&f()?t:await this.readImageNow(t),a={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&"expired"!==e.state&&"reloading"!==e.state)return;await this.dispatcher.waitForInitComplete(),(!e.actor||"expired"===e.state)&&(e.actor=this.dispatcher.getReadyActor()),e.dem=await e.actor.sendAsync({type:"LDT",data:a}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0,e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}async readImageNow(e){if(typeof VideoFrame<"u"&&m()){let t=e.width+4,i=e.height+4;try{return new ou({width:t,height:i},await async function(e,t,i,r,a){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let n=new VideoFrame(e,{timestamp:0});try{let o=n?.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw Error(`Unrecognized format ${o}`);let s=o.startsWith("BGR"),l=new Uint8ClampedArray(r*a*4);if(await n.copyTo(l,function(e,t,i,r,a){let n=4*Math.max(-t,0),o=(Math.max(0,i)-i)*r*4+n,s=4*r,l=Math.max(0,t),u=Math.max(0,i);return{rect:{x:l,y:u,width:Math.min(e.width,t+r)-l,height:Math.min(e.height,i+a)-u},layout:[{offset:o,stride:s}]}}(e,t,i,r,a)),s)for(let e=0;e<l.length;e+=4){let t=l[e];l[e]=l[e+2],l[e+2]=t}return l}finally{n.close()}}(e,-2,-2,t,i))}catch{}}return qg.getImageData(e,2)}_getNeighboringTiles(e){let t=e.canonical,i=2**t.z,r=(t.x-1+i)%i,a=0===t.x?e.wrap-1:e.wrap,n=(t.x+1+i)%i,o=t.x+1===i?e.wrap+1:e.wrap,s={};return s[new sf(e.overscaledZ,a,t.z,r,t.y).key]={backfilled:!1},s[new sf(e.overscaledZ,o,t.z,n,t.y).key]={backfilled:!1},t.y>0&&(s[new sf(e.overscaledZ,a,t.z,r,t.y-1).key]={backfilled:!1},s[new sf(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new sf(e.overscaledZ,o,t.z,n,t.y-1).key]={backfilled:!1}),t.y+1<i&&(s[new sf(e.overscaledZ,a,t.z,r,t.y+1).key]={backfilled:!1},s[new sf(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},s[new sf(e.overscaledZ,o,t.z,n,t.y+1).key]={backfilled:!1}),s}async unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&await e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}})}};function hy(e,t){return t?e.properties[t]:e.id}function cy(e,t){let i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties&&e.addOrUpdateProperties){let i=new Set(t.removeProperties);e.addOrUpdateProperties=e.addOrUpdateProperties.filter(e=>!i.has(e.key))}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function dy(e,t){if(e)for(let i of e){let e=hy(i,t);null!=e&&(i.id=e)}}function py(e){if(!e)return{};let t={};return t.removeAll=e.removeAll,t.remove=new Set(e.remove||[]),t.add=new Map(e.add?.map(e=>[e.id,e])),t.update=new Map(e.update?.map(e=>[e.id,e])),t}function fy(e){return e&&0!==e.length?"number"==typeof e[0]?[e]:e.flatMap(e=>fy(e)):[]}function my(e){return"GeometryCollection"===e.type?e.geometries.flatMap(e=>my(e)):fy(e.coordinates)}function gy(e){let t,i=new ny;switch(e.type){case"FeatureCollection":t=e.features.flatMap(e=>my(e.geometry));break;case"Feature":t=my(e.geometry);break;default:t=my(e)}if(0===t.length)return i;for(let e of t){let[t,r]=e;i.extend([t,r])}return i}var _y=class extends yt{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:t.data},this.actorPromise=i.getActor(),this.setEventedParent(r),this._data="string"==typeof t.data?{url:t.data}:{geojson:t.data},this._options=Se({},t),this._collectResourceTiming=t.collectResourceTiming,void 0!==t.maxzoom&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId,void 0!==t.clusterMaxZoom&&this.maxzoom<=t.clusterMaxZoom&&Oe(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=Se({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0===t.buffer?128:t.buffer),tolerance:this._pixelsToTileUnits(void 0===t.tolerance?.375:t.tolerance),extent:re,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1,promoteId:"string"==typeof t.promoteId?t.promoteId:void 0,cluster:t.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(t.clusterMaxZoom),minPoints:Math.max(2,t.clusterMinPoints||2),extent:re,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(re/this.tileSize)}_tileUnitsToPixels(e){return e/(re/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||Oe(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}async load(){await this._updateWorkerData()}onAdd(e){this.map=e,this.load()}setData(e){return this._data="string"==typeof e?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e},this._updateWorkerData()}updateData(e){return this._pendingWorkerUpdate.diff=function(e,t,i){if(!e)return t||{};if(!t)return e||{};i&&(dy(e.add,i),dy(t.add,i));let r=py(e),a=py(t);!function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let i of t.remove)e.add.delete(i),e.update.delete(i);for(let[i,r]of t.update){let a=e.update.get(i);a&&(t.update.set(i,cy(a,r)),e.update.delete(i))}}(r,a);let n={};if((r.removeAll||a.removeAll)&&(n.removeAll=!0),n.remove=new Set([...r.remove,...a.remove]),n.add=new Map([...r.add,...a.add]),n.update=new Map([...r.update,...a.update]),n.remove.size&&n.add.size)for(let e of n.add.keys())n.remove.delete(e);let o=function(e){let t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}(n);return i&&function(e,t){if(e)for(let i of e)null!=hy(i,t)&&delete i.id}(o.add,i),o}(this._pendingWorkerUpdate.diff,e),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 gy(await this.getData())}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,void 0!==e.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),void 0!==e.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}getClusterOptions(){let{cluster:e,clusterOptions:t}=this.workerOptions.geojsonVtOptions;return{cluster:e,clusterMaxZoom:t.maxZoom,clusterRadius:this._tileUnitsToPixels(t.radius)}}async getClusterExpansionZoom(e){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterChildren(e){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}async getClusterLeaves(e,t,i){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate())return void Oe(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:e,diff:t,updateCluster:i}=this._pendingWorkerUpdate,r=this._getLoadGeoJSONParameters(e,t,i);void 0===e?t?this._pendingWorkerUpdate.diff=void 0:i&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(r),await this._updatePromise}async _getLoadGeoJSONParameters(e,t,i){let r=Se({type:this.type,source:this.id},this.workerOptions);return"string"==typeof e?(r.request=await this.map._requestManager.transformRequest(qg.resolveURL(e),"Source"),r.request.collectResourceTiming=this._collectResourceTiming,r):void 0!==e?(r.data=e,r):t?(r.dataDiff=t,r):i?(r.updateCluster=!0,r):void 0}async _dispatchWorkerUpdate(e){this._isUpdatingWorker=!0,this.fire(new i_("dataloading"));try{let t=await e,i=await(await this.actorPromise).sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||i.abandoned)return void this.fire(new i_("dataabort"));i.data&&(this._data={geojson:i.data});let r=this._applyDiffToSource(t.dataDiff),a=this._getShouldReloadTileOptions(r),n={};this._applyResourceTiming(n,i),this.fire(new i_("data",{...n,sourceDataType:"metadata"})),this.fire(new i_("data",{...n,sourceDataType:"content",shouldReloadTileOptions:a}))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new i_("dataabort"));this.fire(new _t(ne(e)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(e,t){if(!this._collectResourceTiming)return;let i=t.resourceTiming?.[this.id];if(!i)return;let r=i.slice(0);r?.length&&Se(e,{resourceTiming:r})}_applyDiffToSource(e){if(!e)return;let t="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let e=function(e,t){let i=new Map;if(null==e||null==e.type)return i;if("Feature"===e.type){let r=hy(e,t);return null==r?void 0:(i.set(r,e),i)}if("FeatureCollection"===e.type){let r=new Set;for(let a of e.features){let e=hy(a,t);if(null==e||r.has(e))return;r.add(e),i.set(e,a)}return i}}(this._data.geojson,t);if(!e)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;let i=function(e,t,i){let r=[];if(t.removeAll)e.clear();else if(t.remove)for(let i of t.remove){let t=e.get(i);t&&(r.push(t.geometry),e.delete(i))}if(t.add)for(let a of t.add){let t=hy(a,i);if(null==t)continue;let n=e.get(t);n&&r.push(n.geometry),r.push(a.geometry),e.set(t,a)}if(t.update)for(let i of t.update){let t=e.get(i.id);if(!t)continue;let a=!!i.newGeometry,n=i.removeAllProperties||i.removeProperties?.length>0||i.addOrUpdateProperties?.length>0;if(!a&&!n)continue;r.push(t.geometry);let o={...t};if(e.set(i.id,o),a&&(r.push(i.newGeometry),o.geometry=i.newGeometry),n){if(o.properties=i.removeAllProperties?{}:{...o.properties||{}},i.removeProperties)for(let e of i.removeProperties)delete o.properties[e];if(i.addOrUpdateProperties)for(let{key:e,value:t}of i.addOrUpdateProperties)o.properties[e]=t}}return r}(this._data.updateable,e,t);return e.removeAll||this._options.cluster?void 0:i}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(e=>gy(e))}}shouldReloadTile(e,{affectedBounds:t}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;let{buffer:i,extent:r}=this.workerOptions.geojsonVtOptions,a=function({x:e,y:t,z:i},r=0){let a=Zh((e-r)/2**i),n=qh((t+1+r)/2**i),o=Zh((e+1+r)/2**i),s=qh((t-r)/2**i);return new ny([a,n],[o,s])}(e.tileID.canonical,i/r);for(let e of t)if(a.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(e){let t=e.actor?"RT":"LT";e.actor=await this.actorPromise;let i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;try{let r=await(await this.actorPromise).sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t)}catch(t){if(delete e.abortController,e.aborted||rt(t))return;throw t}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}async unloadTile(e){e.unloadVectorData(),await(await this.actorPromise).sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then(e=>e.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return Se({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}};const yy=[0,0,1],xy=(e,t,i,r,a,n)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp:n,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:wy(r.paint.get("raster-saturation")),u_contrast_factor:by(r.paint.get("raster-contrast")),u_spin_weights:vy(r.paint.get("raster-hue-rotate")),u_coords_top:[a[0].x,a[0].y,a[1].x,a[1].y],u_coords_bottom:[a[3].x,a[3].y,a[2].x,a[2].y]});function vy(e){e*=Math.PI/180;let t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}function by(e){return e>0?1/(1-e):1+e}function wy(e){return e>0?1-1/(1.001-e):-e}var Ty=class{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const Dy=ko([{name:"a_pos",type:"Int16",components:2}]);function Ey(e,t){let i=function(e){let t=void 0===e.granularity?1:Math.max(e.granularity,1),i=t+(e.generateBorders?2:0),r=t+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),a=i+1,n=r+1,o=e.generateBorders?-1:0,s=e.generateBorders||e.extendToNorthPole?-1:0,l=t+ +!!e.generateBorders,u=t+(e.generateBorders||e.extendToSouthPole?1:0),h=a*n,c=i*r*6,d=a*n>65536;if(d)throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let p=d||!1,f=new Int16Array(2*h),m=0;for(let i=s;i<=u;i++)for(let r=o;r<=l;r++){let a=r/t*re;-1===r&&(a=-64),r===t+1&&(a=8256);let n=i/t*re;-1===i&&(n=e.extendToNorthPole?dh:-64),i===t+1&&(n=e.extendToSouthPole?ph:8256),f[m++]=a,f[m++]=n}let g=p?new Uint32Array(c):new Uint16Array(c),_=0;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let i=t+e*a,r=t+1+e*a,n=t+(e+1)*a,o=t+1+(e+1)*a;g[_++]=i,g[_++]=n,g[_++]=r,g[_++]=r,g[_++]=n,g[_++]=o}return{vertices:f.buffer.slice(0),indices:g.buffer.slice(0),uses32bitIndices:p}}(t),r=xs.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),a=Ls.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new Ty(e.createVertexBuffer(r,Dy.members),e.createIndexBuffer(a),Ns.simpleSegment(0,0,r.length,a.length))}var Sy=class extends yt{constructor(e,t,i,r){super(),this.imageWarp=yy,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}async load(e){if(void 0===this.options.url)return this._loaded=!0,void this._finishLoading();this._loaded=!1,this.fire(new i_("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let t=await Yg.transformAndGetImage(this.map._requestManager,this.url,"Image",this._abortController);this._abortController=null,this._loaded=!0,t?.data?(this._setImage(t.data),e&&(this.coordinates=e),this._finishLoading()):this.fire(new _t(Error(`Could not load image ${this.url}: the response is empty`)))}catch(e){if(rt(e))return;this._abortController=null,this._loaded=!0,this.fire(new _t(ne(e)))}}loaded(){return this._loaded}updateImage(e){return this._abortController&&=(this._abortController.abort(),null),"image"in e?(this._loaded=!0,this._setImage(e.image),e.coordinates&&(this.coordinates=e.coordinates),this._finishLoading(),this):e.url?(this.options.url=e.url,this.load(e.coordinates),this):this}_setImage(e){this.image=e,this._imageDirty=!0}getMesh(e,t){return!this._subdividedQuad||t?null:(this._subdividedMesh??=Ey(e,{granularity:16}),this._subdividedMesh)}_disposeTexture(){this.texture?.destroy(),this.texture=null}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i_("data",{sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._abortController&&=(this._abortController.abort(),null),this._disposeTexture(),this._subdividedMesh?.destroy(),this._subdividedMesh=null,this.image=null,this.tiles={}}setWarp(e){return this._warp===e||(this._warp=e,this.tileCoords&&this.setCoordinates(this.coordinates)),this}getWarp(){return this._warp}setCoordinates(e){this.coordinates=e;let t=e.map(Xh.fromLngLat);return this.tileID=function(e){let t=Ih.fromPoints(e),i=t.width(),r=t.height(),a=Math.max(0,Math.floor(-Math.log(Math.max(i,r))/Math.LN2)),n=2**a;return new nf(a,Math.floor((t.minX+t.maxX)/2*n),Math.floor((t.minY+t.maxY)/2*n))}(t),this.terrainTileRanges=this._getOverlappingTileRanges(t),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=t.map(e=>this.tileID.getTilePoint(e)._round()),this.imageWarp=function(e,t){if("flat"===t||Py(e))return yy;let[i,r,a,n]=e,o=i.x-r.x+a.x-n.x,s=i.y-r.y+a.y-n.y,l=[r.x-a.x,r.y-a.y,n.x-a.x,n.y-a.y],[u,h,c,d]=l,p=function(e){return e[0]*e[3]-e[2]*e[1]}(l),f=(o*d-c*s)/p,m=(u*s-o*h)/p,g=[1,1+f,1+f+m,1+m],_=Math.max(...g)/Math.min(...g),y="perspective"===t?0:function(e){let t=(1-4/e)/(1-4/512);return Math.max(0,t)}(_);return!(_>=1&&_<=512)||y>=1?yy:[f,m,y]}(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!Py(this.tileCoords),this.flippedWindingOrder=function(e){let t=e[1].x-e[0].x,i=e[1].y-e[0].y,r=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-i*r<0}(this.tileCoords),this.fire(new i_("data",{sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;let e=this.map.painter.context,t=e.gl;this.texture?this._imageDirty&&(this.texture.update(this.image),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)):(this.texture=new _u(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let i=!1;for(let e in this.tiles){let t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,i=!0)}i&&this.fire(new i_("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(e){this.tileID?.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}serialize(){let e={type:"image",coordinates:this.coordinates};return void 0!==this.options.url&&(e.url=this.options.url),e}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:t,minY:i,maxX:r,maxY:a}=Ih.fromPoints(e),n={};for(let e=0;e<=25;e++){let o=2**e,s=Math.floor(t*o),l=Math.floor(i*o),u=Math.floor(r*o),h=Math.floor(a*o),c=(s%o+o)%o,d=u%o,p=Math.floor(s/o),f=Math.floor(u/o);n[e]={minWrap:p,maxWrap:f,minTileXWrapped:c,maxTileXWrapped:d,minTileY:l,maxTileY:h}}return n}};function Py(e){let[t,i,r,a]=e;return t.x+r.x===i.x+a.x&&t.y+r.y===i.y+a.y}var Iy=class extends Sy{constructor(e,t,i,r){super(e,t,i,r),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=t}async load(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push((await this.map._requestManager.transformRequest(t,"Source")).url);try{let e=await(e=>{let t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(let i of e){let e=window.document.createElement("source");pt(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})})(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new _t(ne(e)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new _t(new wt(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;let e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new _u(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let i=!1;for(let e in this.tiles){let t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,i=!0)}i&&this.fire(new i_("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},Ay=class extends Sy{constructor(e,t,i,r){super(e,t,i,r),t.coordinates?(!Array.isArray(t.coordinates)||4!==t.coordinates.length||t.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e)))&&this.fire(new _t(new wt(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new _t(new wt(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new _t(new wt(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"!=typeof t.canvas&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new _t(new wt(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new _t(new wt(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.animate}async load(){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 _t(Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&=(this.prepare(),!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this._playing=!1,super.onRemove()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;let t=this.map.painter.context,i=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new _u(t,this.canvas,i.RGBA,{premultiply:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(let e in this.tiles){let t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new i_("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}};const Cy={},My="RTLPluginLoaded";var zy=class extends yt{constructor(...e){super(...e),this.status="unavailable",this.url=null,this.dispatcher=(Q_||(Q_=new J_(K_(),st),Q_.registerMessageHandler("GR",(e,t,i)=>ht(t,i))),Q_)}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}async setRTLTextPlugin(e,t=!1){if(this.url)throw Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=qg.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new gt(My))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}};let Fy=null;function Ry(){return Fy||=new zy,Fy}var ky=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=Ae(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=Xg(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(e){return this.rttObjects[e]}acquireRTT(e,t,i){return this.rttObjects[t]=e.acquireRTT(i)}releaseRTT(e){if(0!==this.rttObjects.length){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}loadVectorData(e,t,i){if(!0!==e?.etagUnmodified)if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){let i={};if(!t)return i;for(let r of e){let e=r.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(let t of e)i[t.id]=r}}return i}(e.buckets,t?.style),this.hasSymbolBuckets=!1;for(let e in this.buckets){let t=this.buckets[e];if(t instanceof Up){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let e in this.buckets){let t=this.buckets[e];if(t instanceof Up&&t.hasRTLText){this.hasRTLText=!0,Ry().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(i))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new ls;else this.state="loaded"}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(let t in this.buckets){let i=this.buckets[t];i.uploadPending()&&i.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new _u(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new _u(e,this.glyphAtlasImage,t.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,a,n,o,s,l,u,h){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:a,scale:n,tileSize:this.tileSize,pixelPosMatrix:u,transform:s,params:o,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,t){let i=this.latestFeatureIndex;if(!i?.rawTileData)return;let r=i.loadVTLayers(),a=t?.sourceLayer?t.sourceLayer:"",n=r._geojsonTileLayer||r[a];if(!n)return;let o=Ja(t?.filter,`querySourceFeatures[${a}].filter`,t?.globalState),{z:s,x:l,y:u}=this.tileID.canonical,h={z:s,x:l,y:u};for(let t=0;t<n.length;t++){let r=n.feature(t);if(o.needGeometry){let e=Dl(r,!0);if(!o.filter(new so(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!o.filter(new so(this.tileID.overscaledZ),r))continue;let c=i.getId(r,a),d=new ff(r,s,l,u,c);d.tile=h,e.push(d)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let t=this.expirationTime;if(e.cacheControl){let t=function(e){let t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,r,a)=>{let n=r||a;return t[i]=!n||n.toLowerCase(),""}),t["max-age"]){let e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){let e=Date.now(),i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{let r=this.expirationTime-t;r?this.expirationTime=e+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),2**31-1)}setFeatureState(e,t,i){if(!this.latestFeatureIndex?.rawTileData||0===Object.keys(e).length||this.featureStateRevision===i)return;this.featureStateRevision=i;let r=this.latestFeatureIndex.loadVTLayers();for(let i in this.buckets){if(!t.style.hasLayer(i))continue;let a=this.buckets[i],n=a.layers[0].sourceLayer||"_geojsonTileLayer",o=r[n],s=e[n];if(!o||!s||0===s.length)continue;a.update(s,o,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let l=t?.style?.getLayer(i);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(a)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Xg()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=Xg()+e}setDependencies(e,t){let i={};for(let e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(let i of e){let e=this.dependencies[i];if(e)for(let i of t)if(e[i])return!0}return!1}};function Ly(e){let t=[];for(let i in e)t.push({id:i,state:e[i]});return t}var By=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,i){let r=String(t);if(this.stateChanges[e]||={},this.stateChanges[e][r]||={},Se(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(let t in this.state[e])if(t===r){this.deletedStates[e][r]={};for(let a in this.state[e][t])void 0===i[a]&&(this.deletedStates[e][r][a]=null)}else this.deletedStates[e][t]=null}else if(null===this.deletedStates[e]?.[r]){this.deletedStates[e][r]={};for(let t in this.state[e][r])void 0===i[t]&&(this.deletedStates[e][r][t]=null)}else for(let t in i)null===this.deletedStates[e]?.[r]?.[t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;let r=String(t);if(this.deletedStates[e]||={},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]||={},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]?.[r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){let i=String(t),r=this.state[e]||{},a=this.stateChanges[e]||{},n=Se({},r[i],a[i]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){let i=this.deletedStates[e][t];if(null===i)return{};for(let e in i)delete n[e]}return n}initializeTileState(e,t){let i={};for(let e in this.state)i[e]=Ly(this.state[e]);e.setFeatureState(i,t,this.revision)}coalesceChanges(e,t){let i={};for(let e in this.stateChanges){this.state[e]||={},i[e]||={};for(let t in this.stateChanges[e])this.state[e][t]||={},Se(this.state[e][t],this.stateChanges[e][t]),i[e][t]=this.state[e][t]}for(let e in this.deletedStates)if(this.state[e]||={},i[e]||={},null===this.deletedStates[e])for(let t in this.state[e])this.state[e][t]={},i[e][t]={};else for(let t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(let i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[e][t]=this.state[e][t]}if(this.stateChanges={},this.deletedStates={},0===Object.keys(i).length)return;this.revision++;let r={};for(let e in i)r[e]=Ly(i[e]);e.setFeatureState(r,t,this.revision)}},Oy=class e{constructor(e,t){this.min=e,this.max=t,this.center=L([],R([],this.min,this.max),.5)}quadrant(t){let i=[t%2==0,t<2],r=M(this.min),a=M(this.max);for(let e=0;e<i.length;e++)r[e]=i[e]?this.min[e]:this.center[e],a[e]=i[e]?this.center[e]:this.max[e];return a[2]=this.max[2],new e(r,a)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(let i of e.planes){let e=this.intersectsPlane(i);if(0===e)return 0;1===e&&(t=!1)}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],i=e[3];for(let r=0;r<3;r++)e[r]>0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}},jy=class e{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(t,i=1,r=0,a,n){let o=n?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],s=2**r,l=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(e=>function(e,t,i,r){let a=W([],e,t),n=1/a[3]/i*r;return function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}(a,a,[n,n,1/a[3],n])}(e,t,i,s));a&&function(e,t,i,r){let a=r?4:0,n=r?0:4,o=0,s=[],l=[];for(let t=0;t<4;t++){let i=Z([],e[t+n],e[t+a]),r=z(i);L(i,i,1/r),s.push(r),l.push(i)}for(let t=0;t<4;t++){let r=fe(e[t+a],l[t],i);o=null!==r&&r>=0?Math.max(o,r):Math.max(o,s[t])}let u=function(e,t){let i=[0,0,0,0];return O(i,V([],Z([],e[t[0]],e[t[1]]),Z([],e[t[2]],e[t[1]]))),i[3]=-j(i,e[t[0]]),i}(e,t),h=function(e,t){let i=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}([],e,1/q(e)),r=Z([],t,L([],i,j(t,i))),a=q(r);if(a>0){let e=Math.sqrt(1-i[3]*i[3]);return de(t,R([],L([],i,-i[3]),L([],r,e/a)))}return null}(i,u);if(null!==h){let e=h/j(l[0],u);o=Math.min(o,e)}for(let t=0;t<4;t++){let i=Math.min(o,s[t]);e[t+n]=[e[t+a][0]+l[t][0]*i,e[t+a][1]+l[t][1]*i,e[t+a][2]+l[t][2]*i,1]}}(l,o[0],a,n);let u=o.map(e=>{let t=O([],V([],Z([],l[e[0]],l[e[1]]),Z([],l[e[2]],l[e[1]]))),i=-j(t,l[e[1]]);return t.concat(i)}),h=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];for(let e of l)for(let t=0;t<3;t++)h[t]=Math.min(h[t],e[t]),c[t]=Math.max(c[t],e[t]);return new e(l,u,new Oy(h,c))}};function Vy(e,t,i){let r=t.intersectsFrustum(e);if(!i||0===r)return r;let a=t.intersectsPlane(i);return 0===a?0:2===r&&2===a?2:1}function Ny(e,t,i){let r=0,a=(i-t)/10;for(let n=0;n<10;n++){let o=t+(n+.5)/10*(i-t);r+=a*Math.cos(o)**+e}return r}function Uy(e,t){return function(i,r,a,n,o){let s=2*((e-1)/Me(Math.cos(Ge(Hh-o))/Math.cos(Ge(Hh)))-1),l=Math.acos(a/n),u=2*Ny(s-1,0,Ge(o/2)),h=Math.min(Ge(Hh),l+Ge(o/2)),c=Ny(s-1,Math.min(h,l-Ge(o/2)),h),d=Math.atan(r/a),p=i;return p+=Me(n/Math.hypot(r,a)/Math.max(.5,Math.cos(Ge(o/2)))),p+=s*Me(Math.cos(d))/2,p-=Me(Math.max(1,c/u/t))/2,p}}const $y=Uy(9.314,3);function Gy(e,t){let i=(t.roundZoom?Math.round:Math.floor)(e.zoom+Me(e.tileSize/t.tileSize));return Math.max(0,i)}function Zy(e,t){let i=e.getCameraFrustum(),r=e.getClippingPlane();if(r&&t.maxContentElevation>0){let a=Math.hypot(r[0],r[1],r[2]);if(a>0){let n=1+t.maxContentElevation/Oh,o=De(-r[3]/a,-1,1),s=Math.cos(Math.acos(o)+Math.acos(1/n));r=[r[0],r[1],r[2],-s*a],i=function(e,t,i){let r=e.planes[1],a=e.points.map(e=>{let a=r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3];if(Math.abs(a)>1e-6)return e;let n=[e[0]-i[0],e[1]-i[1],e[2]-i[2]],o=r[0]*n[0]+r[1]*n[1]+r[2]*n[2];if(o>=-1e-9)return e;let s=t/-o;return[e[0]+n[0]*s,e[1]+n[1]*s,e[2]+n[2]*s,e[3]]}),n=e.planes.map((e,i)=>1===i?[e[0],e[1],e[2],e[3]+t]:e),o=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let e of a)for(let t=0;t<3;t++)o[t]=Math.min(o[t],e[t]),s[t]=Math.max(s[t],e[t]);return new jy(a,n,new Oy(o,s))}(i,Math.sqrt(n*n-1),e.cameraPosition)}}let a=function(e){let t=Gh(1,e.center.lat)*e.worldSize;return tc(e.center,e.elevation,e.pitch,e.bearing,e.cameraToCenterDistance/t)}(e),n=Xh.fromLngLat(e.center,e.elevation),o=function(e,t){let i=De((15-(Hh-e.pitch-e.fov/2))/15,0,1),r=Math.max(500,t??0);return e.elevation+i*r}(e,t.maxContentElevation),s=e.getCoveringTilesDetailsProvider(),l=s.allowVariableZoom(e,t),u=Gy(e,t),h=t.minzoom||0,c=void 0===t.maxzoom?e.maxZoom:t.maxzoom,d=Math.min(Math.max(0,u),c),p=2**d,f=[p*a.x,p*a.y,0],m=[p*n.x,p*n.y,0],g=Math.hypot(n.x-a.x,n.y-a.y),_=Math.abs(n.z-a.z),y=Math.hypot(g,_),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],b=[];if(e.renderWorldCopies&&s.allowWorldCopies())for(let e=1;e<=3;e++)v.push(x(-e)),v.push(x(e));for(v.push(x(0));v.length>0;){let p=v.pop(),g=p.x,x=p.y,w=p.fullyVisible,T={x:g,y:x,z:p.zoom},D=s.getTileBoundingVolume(T,p.wrap,o,t);if(!w){let e=Vy(i,D,r);if(0===e)continue;w=2===e}let E=s.distanceToTile2d(a.x,a.y,T,D),S=u;l&&(S=(t.calculateTileZoom||$y)(e.zoom+Me(e.tileSize/t.tileSize),E,_,y,e.fov)),S=(t.roundZoom?Math.round:Math.floor)(S),S=Math.max(0,S);let P=Math.min(S,c);if(p.wrap=s.getWrap(n,T,p.wrap),p.zoom>=P){if(p.zoom<h)continue;let e=d-p.zoom,i=f[0]-.5-(g<<e),r=f[1]-.5-(x<<e),a=t.reparseOverscaled?Math.max(p.zoom,S):p.zoom;b.push({tileID:new sf(p.zoom===c?a:p.zoom,p.wrap,p.zoom,g,x),distanceSq:ie([m[0]-.5-g,m[1]-.5-x]),tileDistanceToCamera:Math.sqrt(i*i+r*r)});continue}for(let e=0;e<4;e++){let t=(g<<1)+e%2,i=(x<<1)+(e>>1),r=p.zoom+1;v.push({zoom:r,x:t,y:i,wrap:p.wrap,fullyVisible:w})}}return b.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}function qy(e){return"raster"===e||"image"===e||"video"===e}function Wy(e,t,i,r,a,n,o){if(!t.hasData())return!1;let{tileID:s,fadingRole:l,fadingDirection:u,fadingParentID:h}=t;if(0===l&&1===u&&h)return i[h.key]=h,!0;let c=Math.max(s.overscaledZ-a,n);for(let a=s.overscaledZ-1;a>=c;a--){let n=s.scaledTo(a),l=e.getLoadedTile(n);if(l)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:l.tileID,fadeEndTime:r+o}),l.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+o}),i[n.key]=n,!0}return!1}function Xy(e,t,i,r,a,n){if(!t.hasData())return!1;let o=t.tileID.children(a),s=Hy(e,t,o,i,r,a,n);if(s)return!0;for(let l of o)Hy(e,t,l.children(a),i,r,a,n)&&(s=!0);return s}function Hy(e,t,i,r,a,n,o){if(i[0].overscaledZ>=n)return!1;let s=!1;for(let n of i){let i=e.getLoadedTile(n);if(!i)continue;let{fadingRole:l,fadingDirection:u,fadingParentID:h}=i;(0!==l||0!==u||!h)&&(i.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:t.tileID,fadeEndTime:a+o}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:a+o})),r[n.key]=n,s=!0}return s}function Yy(e,t,i,r){let a=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(a)){let t=i+r;return e.setSelfFadeLogic(t),!0}return!1}function Ky(e,t){e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x,r=t.tileID.canonical.y-e.tileID.canonical.y,a=2**e.tileID.canonical.z,n=t.tileID.key;(0!==i||0!==r)&&(Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+a)?i+=a:1===Math.abs(i-a)&&(i-=a)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles?.[n]&&(e.neighboringTiles[n].backfilled=!0))))}var Jy=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let i in this._tiles){let r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t,i){for(let r in this._tiles)this._tiles[r].setFeatureState(e,t,i)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(e=>e.tileID).sort(cf).map(e=>e.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){let t=this.getTileById(e.key);return t?.hasData()?t:null}isIdRenderable(e,t=!1){return this.getTileById(e)?.isRenderable(t)}getRenderableIds(e=0,t){let i=[];for(let e of this.getAllIds())this.isIdRenderable(e,t)&&i.push(this.getTileById(e));return t?i.sort((t,i)=>{let r=t.tileID,a=i.tileID,n=new c(r.canonical.x,r.canonical.y)._rotate(-e),o=new c(a.canonical.x,a.canonical.y)._rotate(-e);return r.overscaledZ-a.overscaledZ||o.y-n.y||o.x-n.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(cf).map(e=>e.key)}},Qy=class e extends yt{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(e,t,i){super(),this._maxContentElevationSeen=0,this.id=e,this.dispatcher=i,this.on("data",e=>{this._dataHandler(e)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,r)=>{let a=new((e=>{switch(e){case"geojson":return _y;case"image":return Sy;case"raster":return ly;case"raster-dem":return uy;case"vector":return sy;case"video":return Iy;case"canvas":return Ay}return Cy[e]})(t.type))(e,t,i,r);if(a.id!==e)throw Error(`Expected Source id to be ${e} instead of ${a.id}`);return a})(e,t,i,this),this._inViewTiles=new Jy,this._outOfViewCache=new Ng(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new By,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(e)}onRemove(e){for(let e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(e),this._inViewTiles=new Jy}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}async _loadTile(e,t,i,r){try{let a=await this._source.loadTile(e);this._tileLoaded(e,t,i,r,a)}catch(t){e.state="errored",404===t.status?this.update(this.transform,this.terrain):this._source.fire(new _t(ne(t),{tile:e}))}}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new i_("dataabort",{tile:e,coord:e.tileID}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,e)}hasRenderableParent(e){let t=e.overscaledZ-1;if(t>=this._source.minzoom){let i=this.getLoadedTile(e.scaledTo(t));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);(!t||this._source.shouldReloadTile(r,t))&&(e?this._reloadTile(i,"errored"===r.state?"loading":"expired"):"errored"!==r.state&&this._reloadTile(i,"reloading"))}}}async _reloadTile(e,t){let i=this._inViewTiles.getTileById(e);if(!i)return;let r=i.hasData();"loading"!==i.state&&(i.state=t),await this._loadTile(i,e,t,r)}_tileLoaded(e,t,i,r,a){r||(e.timeAdded=Xg(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration)),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),!a?.unmodified&&("raster-dem"===this.getSource().type&&e.dem&&function(e,t){let i=t.getRenderableIds();for(let r of i){if(!e.neighboringTiles?.[r])continue;let i=t.getTileById(r);e.neighboringTiles[r].backfilled||Ky(e,i),!i.neighboringTiles?.[e.tileID.key]?.backfilled&&Ky(i,e)}}(e,this._inViewTiles),e.featureStateRevision=-1,this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new i_("data",{tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(t,i){let r=this._getLoadedDescendents(i),a=new Set;for(let n of i){let i=r[n.key];if(!i?.length){a.add(n);continue}let o=n.overscaledZ+e.maxOverzooming,s=i.filter(e=>e.tileID.overscaledZ<=o);if(!s.length){a.add(n);continue}let l=Math.min(...s.map(e=>e.tileID.overscaledZ)),u=s.filter(e=>e.tileID.overscaledZ===l).map(e=>e.tileID);for(let e of u)t[e.key]=e;this._areDescendentsComplete(u,l,n.overscaledZ)||a.add(n)}return a}_getLoadedDescendents(e){let t={};for(let i of this._inViewTiles.getAllTiles().filter(e=>e.hasData()))for(let r of e)i.tileID.isChildOf(r)&&(t[r.key]||=[],t[r.key].push(i));return t}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:4**(t-i)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){let t=(Math.ceil(e.width/this._source.tileSize)+1)*(Math.ceil(e.height/this._source.tileSize)+1),i=null===this._maxTileCacheZoomLevels?nt.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,r=Math.floor(t*i),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._outOfViewCache.setMaxSize(a)}handleWrapJump(e){let t=(e-(void 0===this._prevLng?e:this._prevLng))/360,i=Math.round(t);this._prevLng=e,i&&(this._inViewTiles.handleWrapJump(i),this._resetTileReloadTimers())}_updateMaxContentElevation(){let e=this._maxContentElevationSeen,t=this.map?.style?._layers;if(!t)return e;let i=this._inViewTiles.getAllTiles();for(let r in t){let a=t[r];if("symbol"!==a.type||a.source!==this.id||a.isHidden(this.transform.zoom))continue;let n=a;if(n.layout){e=Math.max(e,n.layout.get("symbol-height-offset").constantOr(0));for(let t of i){let i=t.getBucket(a);i&&i.maxHeightOffset>e&&(e=i.maxHeightOffset)}}}return this._maxContentElevationSeen=e,e}update(e,t){if(!this._sourceLoaded||this._paused)return;let i;this.transform=e,this.terrain=t,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new sf(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(i=Zy(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?Math.max(this._source.maxzoom,e.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:t,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(i=i.filter(e=>this._source.hasTile(e)))):i=[],this.usedForTerrain&&(i=this._addTerrainIdealTiles(i));let r=0===i.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new i_("data",{sourceDataType:"idle",sourceId:this.id}));let a=Gy(e,this._source),n=this._updateRetainedTiles(i,a),o=qy(this._source.type);o&&this._rasterFadeDuration>0&&!t&&function(e,t,i,r,a,n,o){let s=Xg(),l=function(e){if(!e.length)return new Set;let t=Math.max(...e.map(e=>e.canonical.z)),i=1/0,r=-1/0,a=1/0,n=-1/0,o=[];for(let s of e){let{x:e,y:l,z:u}=s.canonical,h=2**(t-u),c=e*h,d=l*h;o.push({id:s,x:c,y:d}),c<i&&(i=c),c>r&&(r=c),d<a&&(a=d),d>n&&(n=d)}let s=new Set;for(let e of o)(e.x===i||e.x===r||e.y===a||e.y===n)&&s.add(e.id);return s}(t);for(let u of t){let t=e.getTileById(u.key);(0===t.fadingDirection||0===t.fadeOpacity)&&t.resetFadeLogic(),!Wy(e,t,i,s,r,a,o)&&(Xy(e,t,i,s,n,o)||Yy(t,l,s,o)||t.resetFadeLogic())}}(this._inViewTiles,i,n,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),o?this._cleanUpRasterTiles(n):this._cleanUpVectorTiles(n)}_cleanUpRasterTiles(e){for(let t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(let t of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(t);e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){let t=[];for(let i of e)if(i.canonical.z>this._source.minzoom){let e=i.scaledTo(i.canonical.z-1);t.push(e);let r=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(r)}return e.concat(t)}releaseSymbolFadeTiles(){for(let e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(t,i){let r=new Set;for(let e of t)this._addTile(e).hasData()||r.add(e);let a=t.reduce((e,t)=>(e[t.key]=t,e),{}),n=this._retainLoadedChildren(a,r),o={},s=Math.max(i-e.maxUnderzooming,this._source.minzoom);for(let e of n){let t=this._inViewTiles.getTileById(e.key),i=t?.wasRequested();for(let r=e.overscaledZ-1;r>=s;--r){let n=e.scaledTo(r);if(o[n.key])break;if(o[n.key]=!0,t=this.getTile(n),!t&&i&&(t=this._addTile(n)),t){let e=t.hasData();if((e||!this.map?.cancelPendingTileRequestsWhileZooming||i)&&(a[n.key]=n),i=t.wasRequested(),e)break}}}return a}_addTile(e){let t=this._inViewTiles.getTileById(e.key);if(t)return t;t=this._outOfViewCache.getAndRemove(e),t&&(t.resetFadeLogic(),this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null));let i=t;return t||(t=new ky(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(t,e.key,t.state,!1)),t.uses++,this._inViewTiles.setTile(e.key,t),i||this._source.fire(new i_("dataloading",{tile:t,coord:t.tileID})),t}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);let i=t.getExpiryTimeout();if(i){let t=()=>{this._reloadTile(e,"expired"),delete this._timers[e]};this._timers[e]=setTimeout(t,i)}}_clearTileReloadTimer(e){let t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(let e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(let e of this._inViewTiles.getAllIds()){let t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t)}}refreshTiles(e){for(let t of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(t);(this._inViewTiles.isIdRenderable(t)||"errored"==i.state)&&e.some(e=>e.equals(i.tileID.canonical))&&this._reloadTile(t,"expired")}}_removeTile(e){let t=this._inViewTiles.getTileById(e);t&&(t.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),!(t.uses>0)&&(t.hasData()&&"reloading"!==t.state?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){if("source"===e.dataType){if("metadata"===e.sourceDataType)return void(this._sourceLoaded=!0);"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}resetMaxContentElevation(){this._maxContentElevationSeen=0}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1,this.resetMaxContentElevation();for(let e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,t,i){let r=[],a=this.transform;if(!a)return r;let n=a.getCoveringTilesDetailsProvider().allowWorldCopies(),o=i?a.getCameraQueryGeometry(e):e,s=e=>a.screenPointToMercatorCoordinate(e,this.terrain),l=this.transformBbox(e,s,!n),u=this.transformBbox(o,s,!n),h=this.getIds(),c=Ih.fromPoints(u);for(let e of h){let i=this._inViewTiles.getTileById(e);if(i.holdingForSymbolFade())continue;let o=n?[i.tileID]:[i.tileID.unwrapTo(-1),i.tileID.unwrapTo(0)],s=2**(a.zoom-i.tileID.overscaledZ),h=t*i.queryPadding*re/i.tileSize/s;for(let e of o){let t=c.map(t=>e.getTilePoint(new Xh(t.x,t.y)));if(t.expandBy(h),t.intersects(Ah)){let t=l.map(t=>e.getTilePoint(t)),a=u.map(t=>e.getTilePoint(t));r.push({tile:i,tileID:n?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:a,scale:s})}}}return r}transformBbox(e,t,i){let r=e.map(t);if(i){let i=Ih.fromPoints(e);i.shrinkBy(.001*Math.min(i.width(),i.height()));let a=i.map(t);Ih.fromPoints(r).covers(a)||(r=r.map(e=>e.x>.5?new Xh(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){let t=this.getRenderableIds(e).map(e=>this._inViewTiles.getTileById(e).tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){return!!this._source.hasTransition()||qy(this._source.type)&&function(e,t){if(t<=0)return!1;let i=Xg();for(let t of e.getAllTiles())if(t.fadeEndTime>=i)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,t,i){e||=df,this._state.updateState(e,t,i)}removeFeatureState(e,t,i){e||=df,this._state.removeFeatureState(e,t,i)}getFeatureState(e,t){return e||=df,this._state.getState(e,t)}setDependencies(e,t,i){let r=this._inViewTiles.getTileById(e);r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(let i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(e,t)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter(i=>!i.hasDependency(e,t))}areTilesLoaded(){for(let e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}},ex=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=De(e,0,1);let t=1,i=this._distances[t],r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];let a=t-1,n=this._distances[a],o=i-n,s=o>0?(r-n)/o:0;return this.points[a].mult(1-s).add(this.points[t].mult(s))}};function tx(e,t,i,r,a){return a?e?e(t,i)+r:0===r?void 0:r:r}function ix(e,t){let i=!0;return"always"===e||("never"===e||"never"===t)&&(i=!1),i}var rx=class{constructor(e,t,i){let r=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),a.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,a){this._forEachCell(t,i,r,a,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,a,n){this.boxCells[a].push(n)}_insertCircleCell(e,t,i,r,a,n){this.circleCells[a].push(n)}_query(e,t,i,r,a,n,o){if(i<0||e>this.width||r<0||t>this.height)return[];let s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(a)return[{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){let t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}}else{let l={hitTest:a,overlapMode:n,seenUids:{box:{},circle:{}}};this._forEachCell(e,t,i,r,this._queryCell,s,l,o)}return s}query(e,t,i,r){return this._query(e,t,i,r,!1,null)}hitTest(e,t,i,r,a,n){return this._query(e,t,i,r,!0,a,n).length>0}hitTestCircle(e,t,i,r,a){let n=e-i,o=e+i,s=t-i,l=t+i;if(o<0||n>this.width||l<0||s>this.height)return!1;let u=[],h={hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}};return this._forEachCell(n,s,o,l,this._queryCellCircle,u,h,a),u.length>0}_queryCell(e,t,i,r,a,n,o,s){let{seenUids:l,hitTest:u,overlapMode:h}=o,c=this.boxCells[a],d=1e-6;if(null!==c){let a=this.bboxes;for(let o of c)if(!l.box[o]){l.box[o]=!0;let c=4*o,p=this.boxKeys[o];if(e<=a[c+2]+d&&t<=a[c+3]+d&&i>=a[c+0]-d&&r>=a[c+1]-d&&(!s||s(p))&&(!u||!ix(h,p.overlapMode))&&(n.push({key:p,x1:a[c],y1:a[c+1],x2:a[c+2],y2:a[c+3]}),u))return!0}}let p=this.circleCells[a];if(null!==p){let a=this.circles;for(let o of p)if(!l.circle[o]){l.circle[o]=!0;let c=3*o,d=this.circleKeys[o];if(this._circleAndRectCollide(a[c],a[c+1],a[c+2],e,t,i,r)&&(!s||s(d))&&(!u||!ix(h,d.overlapMode))){let e=a[c],t=a[c+1],i=a[c+2];if(n.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),u)return!0}}}return!1}_queryCellCircle(e,t,i,r,a,n,o,s){let{circle:l,seenUids:u,overlapMode:h}=o,c=this.boxCells[a];if(null!==c){let e=this.bboxes;for(let t of c)if(!u.box[t]){u.box[t]=!0;let i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!s||s(r))&&!ix(h,r.overlapMode))return n.push(!0),!0}}let d=this.circleCells[a];if(null!==d){let e=this.circles;for(let t of d)if(!u.circle[t]){u.circle[t]=!0;let i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!s||s(r))&&!ix(h,r.overlapMode))return n.push(!0),!0}}}_forEachCell(e,t,i,r,a,n,o,s){let l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),c=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=u;l<=c;l++){let u=this.xCellCount*l+d;if(a.call(this,e,t,i,r,u,n,o,s))return}}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,a,n){let o=r-e,s=a-t,l=i+n;return l*l>o*o+s*s}_circleAndRectCollide(e,t,i,r,a,n,o){let s=(n-r)/2,l=Math.abs(e-(r+s));if(l>s+i)return!1;let u=(o-a)/2,h=Math.abs(t-(a+u));if(h>u+i)return!1;if(l<=s||h<=u)return!0;let c=l-s,d=h-u;return c*c+d*d<=i*i}};function ax(e,t){let i=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),a=t[0]*i,n=t[4]*i,o=t[8]*r,s=t[1]*i,l=t[5]*i,u=t[9]*r,h=t[2]*i,c=t[6]*i,d=t[10]*r;e[0]=a,e[1]=n,e[2]=o,e[4]=s,e[5]=l,e[6]=u,e[8]=h,e[9]=c,e[10]=d;let p=t[12],f=t[13],m=t[14];return e[12]=-a*p-s*f-h*m,e[13]=-n*p-l*f-c*m,e[14]=-o*p-u*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}const nx=y();function ox(e,t,i){let r=y();if(!e){let{vecSouth:e,vecEast:i}=lx(t),a=Ug();a[0]=i[0],a[1]=i[1],a[2]=e[0],a[3]=e[1],function(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=i*n-a*r;o&&(o=1/o,e[0]=n*o,e[1]=-r*o,e[2]=-a*o,e[3]=i*o)}(a,a),r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3]}return D(r,r,[1/i,1/i,1]),r}function sx(e,t,i,r){if(e){let e=y();if(!t){let{vecSouth:t,vecEast:r}=lx(i);e[0]=r[0],e[1]=r[1],e[4]=t[0],e[5]=t[1]}return D(e,e,[r,r,1]),e}return i.pixelsToClipSpaceMatrix}function lx(e){let t=Math.cos(e.rollInRadians),i=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),n=Math.sin(e.bearingInRadians),o=K();o[0]=-a*r*i-n*t,o[1]=-n*r*i+a*t;let s=ee(o);s<1e-9?te(o):Q(o,o,1/s);let l=K();l[0]=a*r*t-n*i,l[1]=n*r*t+a*i;let u=ee(l);return u<1e-9?te(l):Q(l,l,1/u),{vecEast:l,vecSouth:o}}function ux(e,t,i){return tx(e.getElevation,t,i,e.heightOffset??0,e.heightAnchorGround??!0)}function hx(e,t,i,r){let a;null==r?(a=[e,t,0,1],Px(a,a,i)):(a=[e,t,r,1],W(a,a,i));let n=a[3];return{point:new c(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function cx(e,t){return.5+e/t*.5}function dx(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function px(e,t,i,r,a,n,o,s,l,u,h,d,p){let f=i?e.textSizeData:e.iconSizeData,m=op(f,t.transform.zoom),g=[256/t.width*2+1,256/t.height*2+1],_=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let y=e.lineVertexArray,x=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=t.transform.width/t.transform.height,b=!1;for(let i=0;i<x.length;i++){let w=x.get(i);if(w.hidden||2===w.writingMode&&!b){Sx(w.numGlyphs,_);continue}b=!1;let T=new c(w.anchorX,w.anchorY),D={getElevation:p,pitchedLabelPlaneMatrix:r,lineVertexArray:y,pitchWithMap:n,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:T,unwrappedTileID:l,width:u,height:h,translation:d},E=bx(w.anchorX,w.anchorY,D);if(!dx(E.point,g)){Sx(w.numGlyphs,_);continue}let S=E.signedDistanceFromCamera,P=cx(t.transform.cameraToCenterDistance,S),I=np(f,m,w),A=n?I*t.transform.getPitchedTextCorrection(w.anchorX,w.anchorY,l)/P:I*P,C=gx({projectionContext:D,pitchedLabelPlaneMatrixInverse:a,symbol:w,fontSize:A,flip:!1,keepUpright:o,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:s});b=C.useVertical,(C.notEnoughRoom||b||C.needsFlipping&&gx({projectionContext:D,pitchedLabelPlaneMatrixInverse:a,symbol:w,fontSize:A,flip:!0,keepUpright:o,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:s}).notEnoughRoom)&&Sx(w.numGlyphs,_)}i?e.text.dynamicLayoutVertexBuffer.updateData(_):e.icon.dynamicLayoutVertexBuffer.updateData(_)}function fx(e,t,i,r,a,n,o,s){let l=n.glyphStartIndex+n.numGlyphs,u=n.lineStartIndex,h=n.lineStartIndex+n.lineLength,c=t.getoffsetX(n.glyphStartIndex),d=t.getoffsetX(l-1),p=Dx(e*c,i,r,a,n.segment,u,h,s,o);if(!p)return null;let f=Dx(e*d,i,r,a,n.segment,u,h,s,o);return!f||s.projectionCache.anyProjectionOccluded?null:{first:p,last:f}}function mx(e,t,i,r){return 1===e&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:(2===e?t.y<i.y:t.x>i.x)?{needsFlipping:!0}:null}function gx(e){let t,{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:a,fontSize:n,flip:o,keepUpright:s,glyphOffsetArray:l,dynamicLayoutVertexArray:u,aspectRatio:h,rotateToLine:d}=e,p=n/24,f=a.lineOffsetX*p,m=a.lineOffsetY*p;if(a.numGlyphs>1){let e=a.glyphStartIndex+a.numGlyphs,n=a.lineStartIndex,u=a.lineStartIndex+a.lineLength,c=fx(p,l,f,m,o,a,d,i);if(!c)return{notEnoughRoom:!0};let g=vx(c.first.point.x,c.first.point.y,i,r),_=vx(c.last.point.x,c.last.point.y,i,r);if(s&&!o){let e=mx(a.writingMode,g,_,h);if(e)return e}t=[c.first];for(let r=a.glyphStartIndex+1;r<e-1;r++){let e=Dx(p*l.getoffsetX(r),f,m,o,a.segment,n,u,i,d);if(!e)return{notEnoughRoom:!0};t.push(e)}t.push(c.last)}else{if(s&&!o){let e=xx(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,t=a.lineStartIndex+a.segment+1,n=new c(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),o=xx(n.x,n.y,i),s=o.signedDistanceFromCamera>0?o.point:_x(i.tileAnchorPoint,n,e,1,i),l=vx(e.x,e.y,i,r),u=vx(s.x,s.y,i,r),d=mx(a.writingMode,l,u,h);if(d)return d}let e=Dx(p*l.getoffsetX(a.glyphStartIndex),f,m,o,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,i,d);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};t=[e]}for(let e of t)Op(u,e.point,e.angle);return{}}function _x(e,t,i,r,a){let n=e.add(e.sub(t)._unit()),o=xx(n.x,n.y,a).point,s=i.sub(o);return i.add(s._mult(r/s.mag()))}function yx(e,t,i){let r=t.projectionCache;if(r.projections[e])return r.projections[e];let a=new c(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),n=xx(a.x,a.y,t);if(n.signedDistanceFromCamera>0)return r.projections[e]=n.point,r.anyProjectionOccluded||=n.isOccluded,n.point;let o=e-i.direction,s=0===i.distanceFromAnchor?t.tileAnchorPoint:new c(t.lineVertexArray.getx(o),t.lineVertexArray.gety(o)),l=i.absOffsetX-i.distanceFromAnchor+1;return _x(s,a,i.previousVertex,l,t)}function xx(e,t,i){let r,a=e+i.translation[0],n=t+i.translation[1];return i.pitchWithMap?(r=hx(a,n,i.pitchedLabelPlaneMatrix,ux(i,a,n)),r.isOccluded=!1):(r=i.transform.projectTileCoordinates(a,n,i.unwrappedTileID,ux(i,a,n)),r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height),r}function vx(e,t,i,r){if(i.pitchWithMap){let a=[e,t,0,1];W(a,a,r);let n=a[0]/a[3],o=a[1]/a[3];return i.transform.projectTileCoordinates(n,o,i.unwrappedTileID,ux(i,n,o)).point}return{x:e/i.width*2-1,y:1-t/i.height*2}}function bx(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,ux(i,e,t))}function wx(e,t,i){return e._unit()._perp()._mult(t*i)}function Tx(e,t,i,r,a,n,o,s,l){if(s.projectionCache.offsets[e])return s.projectionCache.offsets[e];let u=i.add(t);if(e+l.direction<r||e+l.direction>=a)return s.projectionCache.offsets[e]=u,u;let h=yx(e+l.direction,s,l),d=wx(h.sub(i),o,l.direction),p=i.add(d),f=h.add(d);return s.projectionCache.offsets[e]=function(e,t,i,r){let a=t.y-e.y,n=t.x-e.x,o=r.y-i.y,s=r.x-i.x,l=o*n-s*a;if(0===l)return null;let u=(s*(e.y-i.y)-o*(e.x-i.x))/l;return new c(e.x+u*n,e.y+u*a)}(n,u,p,f)||u,s.projectionCache.offsets[e]}function Dx(e,t,i,r,a,n,o,s,l){let u=r?e-t:e+t,h=u>0?1:-1,c=0;r&&(h*=-1,c=Math.PI),h<0&&(c+=Math.PI);let d,p=h>0?n+a:n+a+1;s.projectionCache.cachedAnchorPoint?d=s.projectionCache.cachedAnchorPoint:(d=xx(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=d);let f,m,g,_=d,y=d,x=0,v=0,b=Math.abs(u),w=[];for(;x+v<=b;){if(p+=h,p<n||p>=o)return null;x+=v,y=_,m=f;let e={absOffsetX:b,direction:h,distanceFromAnchor:x,previousVertex:y};if(_=yx(p,s,e),0===i)w.push(y),g=_.sub(y);else{let t,r=_.sub(y);t=0===r.mag()?wx(yx(p+h,s,e).sub(_),i,h):wx(r,i,h),m||=y.add(t),f=Tx(p,t,_,n,o,m,i,s,e),w.push(m),g=f.sub(m)}v=g.mag()}let T=(b-x)/v,D=g._mult(T)._add(m||y),E=c+Math.atan2(_.y-y.y,_.x-y.x);return w.push(D),{point:D,angle:l?E:0,path:w}}const Ex=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Sx(e,t){for(let i=0;i<e;i++){let e=t.length;t.resize(e+4),t.float32.set(Ex,3*e)}}function Px(e,t,i){let r=t[0],a=t[1];return e[0]=i[0]*r+i[4]*a+i[12],e[1]=i[1]*r+i[5]*a+i[13],e[3]=i[3]*r+i[7]*a+i[15],e}var Ix=class{constructor(e,t=new rx(e.width+200,e.height+200,25),i=new rx(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=i,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,i,r,a,n,o,s,l,u,h,c,d=0,p=!0){let f,m=e.anchorPointX+s[0],g=e.anchorPointY+s[1],_=this.projectAndGetPerspectiveRatio(m,g,a,tx(u,m,g,d,p),c),y=i*_.perspectiveRatio;if(n||o)f=this._projectCollisionBox(e,y,r,a,n,o,s,_,u,h,c,d,p);else{let t=_.x+(h?h.x*y:0),i=_.y+(h?h.y*y:0);f={allPointsOccluded:!1,box:[t+e.x1*y,i+e.y1*y,t+e.x2*y,i+e.y2*y]}}let[x,v,b,w]=f.box,T=n?f.allPointsOccluded:_.isOccluded,D=T;return D||=_.perspectiveRatio<this.perspectiveRatioCutoff,D||=!this.isInsideGrid(x,v,b,w),D||"always"!==t&&this.grid.hitTest(x,v,b,w,t,l)?{box:[x,v,b,w],placeable:!1,offscreen:!1,occluded:T}:{box:[x,v,b,w],placeable:!0,offscreen:this.isOffscreen(x,v,b,w),occluded:T}}placeCollisionCircles(e,t,i,r,a,n,o,s,l,u,h,d,p,f){let m=[],g=new c(t.anchorX,t.anchorY),_=this.getPerspectiveRatio(g.x,g.y,n,f?.(g.x,g.y)),y=(l?a*this.transform.getPitchedTextCorrection(t.anchorX,t.anchorY,n)/_:a*_)/24,x=t.lineOffsetX*y,v=t.lineOffsetY*y,b={getElevation:f,pitchedLabelPlaneMatrix:o,lineVertexArray:i,pitchWithMap:l,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:n,width:this.transform.width,height:this.transform.height,translation:p},w=fx(y,r,x,v,!1,t,!1,b),T=!1,D=!1,E=!0;if(w){let t=.5*h*_+d,i=new c(-100,-100),r=new c(this.screenRightBoundary,this.screenBottomBoundary),a=new ex,n=w.first,o=w.last,p=[];for(let e=n.path.length-1;e>=1;e--)p.push(n.path[e]);for(let e=1;e<o.path.length;e++)p.push(o.path[e]);let f=2.5*t;if(l){let e=this.projectPathToScreenSpace(p,b);p=e.some(e=>e.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){let e=p[0].clone(),t=p[0].clone();for(let i=1;i<p.length;i++)e.x=Math.min(e.x,p[i].x),e.y=Math.min(e.y,p[i].y),t.x=Math.max(t.x,p[i].x),t.y=Math.max(t.y,p[i].y);g=e.x>=i.x&&t.x<=r.x&&e.y>=i.y&&t.y<=r.y?[p]:t.x<i.x||e.x>r.x||t.y<i.y||e.y>r.y?[]:mp([p],i.x,i.y,r.x,r.y)}for(let i of g){a.reset(i,.25*t);let r=0;r=a.length<=.5*t?1:Math.ceil(a.paddedLength/f)+1;for(let i=0;i<r;i++){let n=i/Math.max(r-1,1),o=a.lerp(n),l=o.x+100,h=o.y+100;m.push(l,h,t,0);let c=l-t,d=h-t,p=l+t,f=h+t;if(E&&=this.isOffscreen(c,d,p,f),D||=this.isInsideGrid(c,d,p,f),"always"!==e&&this.grid.hitTestCircle(l,h,t,e,u)&&(T=!0,!s))return{circles:[],offscreen:!1,collisionDetected:T}}}}return{circles:!s&&T||!D||_<this.perspectiveRatioCutoff?[]:m,offscreen:E,collisionDetected:T}}projectPathToScreenSpace(e,t){return function(e){let t=0,i=0,r=0,a=0;for(let n=0;n<e.length;n++)e[n].isOccluded?(r=n+1,a=0):(a++,a>i&&(i=a,t=r));return e.slice(t,t+i)}(function(e,t){let i=nx;return function(e,t){let i=1/(t[0]*t[5]-t[1]*t[4]);e[0]=t[5]*i,e[1]=-t[1]*i,e[2]=0,e[3]=0,e[4]=-t[4]*i,e[5]=t[0]*i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15]}(i,t.pitchedLabelPlaneMatrix),e.map(e=>{let r=hx(e.x,e.y,i,ux(t,e.x,e.y)),a=t.transform.projectTileCoordinates(r.point.x,r.point.y,t.unwrappedTileID,ux(t,r.point.x,r.point.y));return a.point.x=(.5*a.point.x+.5)*t.width,a.point.y=(.5*-a.point.y+.5)*t.height,a})}(e,t))}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};let t=[],i=new Ih;for(let r of e){let e=new c(r.x+100,r.y+100);i.extend(e),t.push(e)}let{minX:r,minY:a,maxX:n,maxY:o}=i,s=this.grid.query(r,a,n,o).concat(this.ignoredGrid.query(r,a,n,o)),l={},u={};for(let e of s){let i=e.key;void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex]||Il(t,[new c(e.x1,e.y1),new c(e.x2,e.y1),new c(e.x2,e.y2),new c(e.x1,e.y2)])&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===u[i.bucketInstanceId]&&(u[i.bucketInstanceId]=[]),u[i.bucketInstanceId].push(i.featureIndex))}return u}insertCollisionBox(e,t,i,r,a,n){let o={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};(i?this.ignoredGrid:this.grid).insert(o,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,a,n){let o=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n,overlapMode:t};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,t,i,r,a){if(a){let i;null==r?(i=[e,t,0,1],Px(i,i,a)):(i=[e,t,r,1],W(i,i,a));let n=i[3];return{x:(i[0]/n+1)/2*this.transform.width+100,y:(-i[1]/n+1)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/n*.5,isOccluded:!1,signedDistanceFromCamera:n}}{let a=this.transform.projectTileCoordinates(e,t,i,r);return{x:(a.point.x+1)/2*this.transform.width+100,y:(1-a.point.y)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/a.signedDistanceFromCamera*.5,isOccluded:a.isOccluded,signedDistanceFromCamera:a.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,i,r){let a=this.transform.projectTileCoordinates(e,t,i,r);return.5+this.transform.cameraToCenterDistance/a.signedDistanceFromCamera*.5}isOffscreen(e,t,i,r){return i<100||e>=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){let e=v([]);return T(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,i,r,a,n,o,s,l,u,h,d=0,p=!0){let f=1,m=0,g=0,_=1,y=e.anchorPointX+o[0],x=e.anchorPointY+o[1];if(n&&!a){let e=this.projectAndGetPerspectiveRatio(y+1,x,r,tx(l,y+1,x,d,p),h),t=e.x-s.x,i=e.y-s.y,a=Math.atan(i/t)+(t<0?Math.PI:0),n=Math.sin(a),o=Math.cos(a);f=o,m=n,g=-n,_=o}else if(!n&&a){let e=lx(this.transform);f=e.vecEast[0],m=e.vecEast[1],g=e.vecSouth[0],_=e.vecSouth[1]}let v=s.x,b=s.y,w=t;a&&(v=y,b=x,w=2**-(this.transform.zoom-i.overscaledZ),w*=this.transform.getPitchedTextCorrection(y,x,r),!u)&&(w*=De(.5+s.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4)),u&&(v+=f*u.x*w+g*u.y*w,b+=m*u.x*w+_*u.y*w);let T=e.x1*w,D=e.x2*w,E=(T+D)/2,S=e.y1*w,P=e.y2*w,I=(S+P)/2,A=[{offsetX:T,offsetY:S},{offsetX:E,offsetY:S},{offsetX:D,offsetY:S},{offsetX:D,offsetY:I},{offsetX:D,offsetY:P},{offsetX:E,offsetY:P},{offsetX:T,offsetY:P},{offsetX:T,offsetY:I}],C=[];for(let{offsetX:e,offsetY:t}of A)C.push(new c(v+f*e+g*t,b+m*e+_*t));let M=!1;if(a){let e=C.map(e=>this.projectAndGetPerspectiveRatio(e.x,e.y,r,tx(l,e.x,e.y,d,p),h));M=e.some(e=>!e.isOccluded),C=e.map(e=>new c(e.x,e.y))}else M=!0;return{box:be(C),allPointsOccluded:!M}}},Ax=class{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}},Cx=class{constructor(e,t,i,r,a){this.text=new Ax(e?e.text:null,t,i,a),this.icon=new Ax(e?e.icon:null,t,r,a)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Mx=class{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}},zx=class{constructor(e,t,i,r,a){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=a}},Fx=class{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}};function Rx(e,t,i,r,a){let{horizontalAlign:n,verticalAlign:o}=$d(e),s=-(o-.5)*i;return new c(-(n-.5)*t+r[0]*a,s+r[1]*a)}var kx=class{constructor(e,t,i,r,a){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Ix(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Fx(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=a,a&&(a.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;if(t)return(i,r)=>t.getElevation(e,i,r)}getBucketParts(e,t,i,r){let a=i.getBucket(t),n=i.latestFeatureIndex;if(!a||!n||t.id!==a.layerIds[0])return;let o=i.collisionBoxArray,s=a.layers[0].layout,l=a.layers[0].paint,u=2**(this.transform.zoom-i.tileID.overscaledZ),h=i.tileSize/re,c=i.tileID.toUnwrapped(),d="map"===s.get("text-rotation-alignment"),p=ae(i,1,this.transform.zoom),f=ce(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=ce(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),g=ox(d,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new zx(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,i.tileID);let _={bucket:a,layout:s,translationText:f,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:g,scale:u,textPixelRatio:h,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:op(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(r)for(let t of a.sortKeyRanges){let{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:a}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:a,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:_})}attemptAnchorPlacement(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y,x,v,b){let w=Sp[e.textAnchor],T=[e.textOffset0,e.textOffset1],D=Rx(w,i,r,T,a),E=this.collisionIndex.placeCollisionBox(t,c,s,l,u,o,n,m,h.predicate,y,D,x,v,b);if((!_||this.collisionIndex.placeCollisionBox(_,c,s,l,u,o,n,g,h.predicate,y,D,x,v,b).placeable)&&E.placeable){let e;if(this.prevPlacement?.variableOffsets[d.crossTileID]&&this.prevPlacement?.placements[d.crossTileID]?.text&&(e=this.prevPlacement.variableOffsets[d.crossTileID].anchor),0===d.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:T,width:i,height:r,anchor:w,textBoxScale:a,prevAnchor:e},this.markUsedJustification(p,w,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:D,placedGlyphBoxes:E}}}placeLayerBucketPart(e,t,i){let{bucket:r,layout:a,translationText:n,translationIcon:o,unwrappedTileID:s,pitchedLabelPlaneMatrix:l,textPixelRatio:u,holdingForFade:h,collisionBoxArray:c,partiallyEvaluatedTextSize:d,collisionGroup:p}=e.parameters,f=a.get("text-optional"),m=a.get("icon-optional"),g=kp(a,"text-overlap","text-allow-overlap"),_="always"===g,y=kp(a,"icon-overlap","icon-allow-overlap"),x="always"===y,v="map"===a.get("text-rotation-alignment"),b="map"===a.get("text-pitch-alignment"),w="none"!==a.get("icon-text-fit"),T="viewport-y"===a.get("symbol-z-order"),D="ground"===a.get("symbol-height-anchor"),E=_&&(x||!r.hasIconData()||m),S=x&&(_||!r.hasTextData()||f);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let P=this.retainedQueryData[r.bucketInstanceId].tileID,I=this._getTerrainElevationFunc(P),A=this.transform.getFastPathSimpleProjectionMatrix(P),C=(e,c,x)=>{if(t[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new Mx(!1,!1,!1));let T=e.heightOffset,C=!1,M=!1,z=!0,F=null,R={box:null,placeable:!1,offscreen:null,occluded:!1},k={box:null,placeable:!1,offscreen:null},L=null,B=null,O=null,j=0,V=0,N=0;c.textFeatureIndex?j=c.textFeatureIndex:e.useRuntimeCollisionCircles&&(j=e.featureIndex),c.verticalTextFeatureIndex&&(V=c.verticalTextFeatureIndex);let U=c.textBox;if(U){let t=t=>{let i=1;if(r.allowVerticalPlacement&&!t&&this.prevPlacement){let t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,i=t,this.markUsedOrientation(r,i,e))}return i},a=(t,i)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&c.verticalTextBox){for(let e of r.writingModes)if(2===e?(R=i(),k=R):R=t(),R?.placeable)break}else R=t()},l=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===l){let i=(t,i)=>{let a=this.collisionIndex.placeCollisionBox(t,g,u,P,s,b,v,n,p.predicate,I,void 0,A,T,D);return a?.placeable&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),a};a(()=>i(U,1),()=>{let t=c.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&t?i(t,2):{box:null,offscreen:null}}),t(R?.placeable)}else{let d=Sp[this.prevPlacement?.variableOffsets[e.crossTileID]?.anchor],f=(t,a,c)=>{let f=t.x2-t.x1,m=t.y2-t.y1,_=e.textBoxScale,x=w&&"never"===y?a:null,E=null,S="never"===g?1:2,M="never";d&&S++;for(let i=0;i<S;i++){for(let i=l;i<h;i++){let a=r.textAnchorOffsets.get(i);if(d&&a.textAnchor!==d)continue;let l=this.attemptAnchorPlacement(a,t,f,m,_,v,b,u,P,s,p,M,e,r,c,n,o,x,I,A,T,D);if(l&&(E=l.placedGlyphBoxes,E?.placeable))return C=!0,F=l.shift,E}d?d=null:M=g}return i&&!E&&(E={box:this.collisionIndex.placeCollisionBox(U,"always",u,P,s,b,v,n,p.predicate,I,void 0,A,T,D).box,offscreen:!1,placeable:!1,occluded:!1}),E};a(()=>f(U,c.iconBox,1),()=>{let t=c.verticalTextBox,i=R?.placeable;return r.allowVerticalPlacement&&!i&&e.numVerticalGlyphVertices>0&&t?f(t,c.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),R&&(C=R.placeable,z=R.offscreen);let m=t(R?.placeable);if(!C&&this.prevPlacement){let t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,m))}}}if(L=R,C=L?.placeable,z=L?.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){let t=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),o=np(r.textSizeData,d,t),u=a.get("text-padding"),h=e.collisionCircleDiameter;B=this.collisionIndex.placeCollisionCircles(g,t,r.lineVertexArray,r.glyphOffsetArray,o,s,l,i,b,p.predicate,h,u,n,I),B.circles.length&&B.collisionDetected&&!i&&Oe("Collisions detected, but collision boxes are not shown"),C=_||B.circles.length>0&&!B.collisionDetected,z&&=B.offscreen}if(c.iconFeatureIndex&&(N=c.iconFeatureIndex),c.iconBox){let e=e=>this.collisionIndex.placeCollisionBox(e,y,u,P,s,b,v,o,p.predicate,I,w&&F?F:void 0,A,T,D);k&&k.placeable&&c.verticalIconBox?(O=e(c.verticalIconBox),M=O.placeable):(O=e(c.iconBox),M=O.placeable),z&&=O.offscreen}let $=f||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,G=m||0===e.numIconVertices;$||G?G?$||(M&&=C):C=M&&C:M=C=M&&C;let Z=C&&L.placeable,q=M&&O.placeable;if(Z&&(k&&k.placeable&&V?this.collisionIndex.insertCollisionBox(L.box,g,a.get("text-ignore-placement"),r.bucketInstanceId,V,p.ID):this.collisionIndex.insertCollisionBox(L.box,g,a.get("text-ignore-placement"),r.bucketInstanceId,j,p.ID)),q&&this.collisionIndex.insertCollisionBox(O.box,y,a.get("icon-ignore-placement"),r.bucketInstanceId,N,p.ID),B&&C&&this.collisionIndex.insertCollisionCircles(B.circles,g,a.get("text-ignore-placement"),r.bucketInstanceId,j,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,x,c,L,O,B),0===e.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw Error("bucket.bucketInstanceId can't be 0");let W=(C||E)&&!L?.occluded,X=(M||S)&&!O?.occluded;this.placements[e.crossTileID]=new Mx(W,X,z||r.justReloaded),t[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw Error("bucket.bucketInstanceId should be 0");let t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){let i=t[e];C(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)C(r.symbolInstances.get(t),r.collisionArrays[t],t);r.justReloaded=!1}storeCollisionData(e,t,i,r,a,n){if(i.textBox||i.iconBox){let n,o;this.collisionBoxArrays.has(e)?n=this.collisionBoxArrays.get(e):(n=new Map,this.collisionBoxArrays.set(e,n)),n.has(t)?o=n.get(t):(o={text:null,icon:null},n.set(t,o)),i.textBox&&(o.text=r.box),i.iconBox&&(o.icon=a.box)}if(n){let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<n.circles.length;e+=4)t.push(n.circles[e+0]-100),t.push(n.circles[e+1]-100),t.push(n.circles[e+2]),t.push(+!!n.collisionDetected)}}markUsedJustification(e,t,i,r){let a,n={left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex};a=2===r?i.verticalPlacedTextSymbolIndex:n[Cp(t)];let o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(let t of o)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:i.crossTileID)}markUsedOrientation(e,t,i){let r=1===t||3===t?t:0,a=2===t?t:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(let t of n)e.text.placedSymbolArray.get(t).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let t=this.prevPlacement,i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;let r=t?t.symbolFadeChange(e):1,a=t?t.opacities:{},n=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(let e in this.placements){let t=this.placements[e],n=a[e];n?(this.opacities[e]=new Cx(n,r,t.text,t.icon),i||=t.text!==n.text.placed,i||=t.icon!==n.icon.placed):(this.opacities[e]=new Cx(null,r,t.text,t.icon,t.skipFade),i||=t.text||t.icon)}for(let e in a){let t=a[e];if(!this.opacities[e]){let a=new Cx(t,r,!1,!1);a.isHidden()||(this.opacities[e]=a,i||=t.text.placed,i||=t.icon.placed)}}for(let e in n)!this.variableOffsets[e]&&this.opacities[e]&&!this.opacities[e].isHidden()&&(this.variableOffsets[e]=n[e]);for(let e in o)!this.placedOrientations[e]&&this.opacities[e]&&!this.opacities[e].isHidden()&&(this.placedOrientations[e]=o[e]);if(t&&void 0===t.lastPlacementChangeTime)throw Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let i={};for(let r of t){let t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(e,t,i,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let a=e.layers[0],n=a.layout,o=new Cx(null,0,!1,!1,!0),s=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),u=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===n.get("text-rotation-alignment"),d="map"===n.get("text-pitch-alignment"),p="none"!==n.get("icon-text-fit"),f=new Cx(null,0,s&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(s||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);let m=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i);e.hasVisibleVertices||=i!==Ox},g=this.collisionBoxArrays.get(e.bucketInstanceId);for(let t=0;t<e.symbolInstances.length;t++){let r=e.symbolInstances.get(t),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:n,crossTileID:s}=r,l=i[s],_=this.opacities[s];l?_=o:_||(_=f,this.opacities[s]=_),i[s]=!0;let y=a>0||n>0,x=r.numIconVertices>0,v=this.placedOrientations[r.crossTileID],b=2===v,w=1===v||3===v;if(y){let t=Bx(_.text),i=b?Ox:t;m(e.text,a,i);let o=w?Ox:t;m(e.text,n,o);let s=_.text.isHidden(),l=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(let t of l)t>=0&&(e.text.placedSymbolArray.get(t).hidden=s||b?1:0);r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=s||w?1:0);let u=this.variableOffsets[r.crossTileID];u&&this.markUsedJustification(e,u.anchor,r,v);let h=this.placedOrientations[r.crossTileID];h&&(this.markUsedJustification(e,"left",r,h),this.markUsedOrientation(e,h,r))}if(x){let t=Bx(_.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&b);if(r.placedIconSymbolIndex>=0){let a=i?t:Ox;m(e.icon,r.numIconVertices,a),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=_.icon.isHidden()}if(r.verticalPlacedIconSymbolIndex>=0){let a=i?Ox:t;m(e.icon,r.numVerticalIconVertices,a),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=_.icon.isHidden()}}let T=g?.has(t)?g.get(t):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let i=e.collisionArrays[t];if(i){let t=new c(0,0);if(i.textBox||i.verticalTextBox){let r=!0;if(u){let e=this.variableOffsets[s];e?(t=Rx(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&t._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):r=!1}if(i.textBox||i.verticalTextBox){let a;i.textBox&&(a=b),i.verticalTextBox&&(a=w),Lx(e.textCollisionBox.collisionVertexArray,_.text.placed,!r||a,T.text,t.x,t.y)}}if(i.iconBox||i.verticalIconBox){let r,a=!(w||!i.verticalIconBox);i.iconBox&&(r=a),i.verticalIconBox&&(r=!a),Lx(e.iconCollisionBox.collisionVertexArray,_.icon.placed,r,T.icon,p?t.x:0,p?t.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){let i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}};function Lx(e,t,i,r,a,n){(!r||0===r.length)&&(r=[0,0,0,0]);let o=r[0]-100,s=r[1]-100,l=r[2]-100,u=r[3]-100;e.emplaceBack(+!!t,+!!i,a||0,n||0,o,s),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,s),e.emplaceBack(+!!t,+!!i,a||0,n||0,l,u),e.emplaceBack(+!!t,+!!i,a||0,n||0,o,u)}function Bx(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;let t=+!!e.placed,i=Math.floor(127*e.opacity);return 33554432*i+16777216*t+131072*i+65536*t+512*i+256*t+2*i+t}const Ox=0;var jx=class{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,r,a){let n=this._bucketParts;for(;this._currentTileIndex<e.length;){let i=e[this._currentTileIndex];if(t.getBucketParts(n,r,i,this._sortAcrossTiles),this._currentTileIndex++,a())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<n.length;){let e=n[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i),this._currentPartIndex++,a())return!0}return!1}},Vx=class{constructor(e,t,i,r,a,n,o,s){this.placement=new kx(e,t,n,o,s),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=a,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){let r=Xg(),a=()=>!this._forceFullPlacement&&Xg()-r>2;for(;this._currentPlacementIndex>=0;){let r=t[e[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if(Wp(r)&&r.layout&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||=new jx(r),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}};const Nx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Ux=new Uint32Array(96);var $x=class e{static from(t){if(!t||void 0===t.byteLength||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(t,0,2);if(219!==i)throw Error("Data does not appear to be in a KDBush format.");let a=r>>4;if(1!==a)throw Error(`Got v${a} data when expected v1.`);let n=Nx[15&r];if(!n)throw Error("Unrecognized array type.");let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,n,void 0,t)}constructor(e,t=64,i=Float64Array,r=ArrayBuffer,a){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=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let n=Nx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-s%8)%8;if(n<0)throw Error(`Unexpected typed array class: ${i}.`);if(a)this.data=a,this.ids=new this.IndexArrayType(a,8,e),this.coords=new i(a,8+s+l,2*e),this._pos=2*e,this._finished=!0;else{let a=this.data=new r(8+o+s+l);this.ids=new this.IndexArrayType(a,8,e),this.coords=new i(a,8+s+l,2*e),this._pos=0,this._finished=!1,new Uint8Array(a,0,2).set([219,16+n]),new Uint16Array(a,2,1)[0]=t,new Uint32Array(a,4,1)[0]=e}}add(e,t){let i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return Gx(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:a,coords:n,nodeSize:o}=this;Ux[0]=0,Ux[1]=a.length-1,Ux[2]=0;let s=3,l=[];for(;s>0;){let u=Ux[--s],h=Ux[--s],c=Ux[--s];if(h-c<=o){for(let o=c;o<=h;o++){let s=n[2*o],u=n[2*o+1];s>=e&&s<=i&&u>=t&&u<=r&&l.push(a[o])}continue}let d=c+h>>1,p=n[2*d],f=n[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(a[d]),(0===u?e<=p:t<=f)&&(Ux[s++]=c,Ux[s++]=d-1,Ux[s++]=1-u),(0===u?i>=p:r>=f)&&(Ux[s++]=d+1,Ux[s++]=h,Ux[s++]=1-u)}return l}within(e,t,i){let r=[];return this.withinInto(e,t,i,r),r}withinInto(e,t,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:a,coords:n,nodeSize:o}=this;Ux[0]=0,Ux[1]=a.length-1,Ux[2]=0;let s=3,l=0,u=i*i;for(;s>0;){let h=Ux[--s],c=Ux[--s],d=Ux[--s];if(c-d<=o){for(let i=d;i<=c;i++)Xx(n[2*i],n[2*i+1],e,t)<=u&&(r[l++]=a[i]);continue}let p=d+c>>1,f=n[2*p],m=n[2*p+1];Xx(f,m,e,t)<=u&&(r[l++]=a[p]),(0===h?e-i<=f:t-i<=m)&&(Ux[s++]=d,Ux[s++]=p-1,Ux[s++]=1-h),(0===h?e+i>=f:t+i>=m)&&(Ux[s++]=p+1,Ux[s++]=c,Ux[s++]=1-h)}return l}};function Gx(e,t,i,r,a,n){if(a-r<=i)return;let o=r+a>>1;Zx(e,t,o,r,a,n),Gx(e,t,i,r,o-1,1-n),Gx(e,t,i,o+1,a,1-n)}function Zx(e,t,i,r,a,n){for(;a>r;){if(a-r>600){let o=a-r+1,s=i-r+1,l=Math.log(o),u=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*u*(o-u)/o)*(s-o/2<0?-1:1);Zx(e,t,i,Math.max(r,Math.floor(i-s*u/o+h)),Math.min(a,Math.floor(i+(o-s)*u/o+h)),n)}let o=t[2*i+n],s=r,l=a;for(qx(e,t,r,i),t[2*a+n]>o&&qx(e,t,r,a);s<l;){for(qx(e,t,s,l),s++,l--;t[2*s+n]<o;)s++;for(;t[2*l+n]>o;)l--}t[2*r+n]===o?qx(e,t,r,l):(l++,qx(e,t,l,a)),l<=i&&(r=l+1),i<=l&&(a=l-1)}}function qx(e,t,i,r){Wx(e,i,r),Wx(t,2*i,2*r),Wx(t,2*i+1,2*r+1)}function Wx(e,t,i){let r=e[t];e[t]=e[i],e[i]=r}function Xx(e,t,i,r){let a=e-i,n=t-r;return a*a+n*n}const Hx=.03125;var Yx=class{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this._symbolsByKey={};let r=new Map;for(let e=0;e<t.length;e++){let i=t.get(e),a=i.key,n=r.get(a);n?n.push(i):r.set(a,[i])}for(let[e,t]of r){let i={positions:t.map(e=>({x:Math.floor(e.anchorX*Hx),y:Math.floor(e.anchorY*Hx)})),crossTileIDs:t.map(e=>e.crossTileID)};if(i.positions.length>128){let e=new $x(i.positions.length,16,Uint16Array);for(let{x:t,y:r}of i.positions)e.add(t,r);e.finish(),delete i.positions,i.index=e}this._symbolsByKey[e]=i}}getScaledCoordinates(e,t){let{x:i,y:r,z:a}=this.tileID.canonical,{x:n,y:o,z:s}=t.canonical,l=Hx/2**(s-a),u=(n*re+e.anchorX)*l,h=(o*re+e.anchorY)*l,c=i*re*Hx,d=r*re*Hx;return{x:Math.floor(u-c),y:Math.floor(h-d)}}findMatches(e,t,i){let r=this.tileID.canonical.z<t.canonical.z?1:2**(this.tileID.canonical.z-t.canonical.z);for(let a=0;a<e.length;a++){let n=e.get(a);if(n.crossTileID)continue;let o=this._symbolsByKey[n.key];if(!o)continue;let s=this.getScaledCoordinates(n,t);o.index?this.findMatchesForIndexedEntry(o,n,s,r,i):o.positions&&this.findMatchesForNonIndexedEntry(o,n,s,r,i)}}findMatchesForIndexedEntry(e,t,i,r,a){let n=e.index.range(i.x-r,i.y-r,i.x+r,i.y+r),o=1/0;for(let t of n)t<o&&!a[e.crossTileIDs[t]]&&(o=t);if(o!==1/0){let i=e.crossTileIDs[o];a[i]=!0,t.crossTileID=i}}findMatchesForNonIndexedEntry(e,t,i,r,a){for(let n=0;n<e.positions.length;n++){let o=e.positions[n],s=e.crossTileIDs[n];if(Math.abs(o.x-i.x)<=r&&Math.abs(o.y-i.y)<=r&&!a[s]){a[s]=!0,t.crossTileID=s;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}},Kx=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Jx=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(0!==t)for(let e in this.indexes){let i=this.indexes[e],r={};for(let e in i){let a=i[e];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+t),r[a.tileID.key]=a}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){if(this.indexes[e.overscaledZ]?.[e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||={};let r=this.usedCrossTileIDs[e.overscaledZ];for(let i in this.indexes){let a=this.indexes[i];if(Number(i)>e.overscaledZ)for(let i in a){let n=a[i];n.tileID.isChildOf(e)&&n.findMatches(t.symbolInstances,e,r)}else{let n=a[e.scaledTo(Number(i)).key];n&&n.findMatches(t.symbolInstances,e,r)}}for(let e=0;e<t.symbolInstances.length;e++){let a=t.symbolInstances.get(e);a.crossTileID||(a.crossTileID=i.generate(),r[a.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Yx(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(let i of t.getCrossTileIDsLists())for(let t of i)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(let i in this.indexes){let r=this.indexes[i];for(let a in r)e[r[a].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[a]),delete r[a],t=!0)}return t}},Qx=class{constructor(){this.layerIndexes={},this.crossTileIDs=new Kx,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let r=this.layerIndexes[e.id];void 0===r&&(r=this.layerIndexes[e.id]=new Jx);let a=!1,n={};r.handleWrapJump(i);for(let i of t){let t=i.getBucket(e);e.id===t?.layerIds[0]&&(t.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),r.addBucket(i.tileID,t,this.crossTileIDs)&&(a=!0),n[t.bucketInstanceId]=!0)}return r.removeStaleBuckets(n)&&(a=!0),a}pruneUnusedLayers(e){let t={};for(let i of e)t[i]=!0;for(let e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}},ev="void main() {fragColor=vec4(1.0);}";const tv={prelude:iv("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const uint packedOpacity) {return vec2(float(packedOpacity >> 1u)/127.0,float(packedOpacity & 1u));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform highp sampler2D u_depth;layout(std140) uniform TerrainUBO {highp mat4 u_terrain_matrix;highp vec4 u_terrain_unpack;highp float u_terrain_dim;highp float u_terrain_exaggeration;};\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(ivec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texelFetch(u_terrain,pos,0)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+2.0;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;\n#define PROJECTION_UBO\nlayout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};"),projectionMercator:iv("\nvoid 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:iv("in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}","#define GLOBE_RADIUS 6371008.8\n#ifndef PROJECTION_UBO\nuniform 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;\n#endif\nout 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\n);}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\n);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:iv("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:iv("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:iv("in vec3 v_data;flat in float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;flat out float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main(void) {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} 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);}"),clippingMask:iv(ev,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:iv("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma maplibre: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in ivec2 a_pos;out vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#pragma maplibre: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma maplibre: initialize highp float weight\n#pragma maplibre: initialize mediump float radius\nivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=vec2(pos_raw >> 3);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:iv("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:iv("flat in float v_placed;flat in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;flat out float v_placed;flat out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:iv("flat in float v_radius;in vec2 v_extrude;flat in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;flat out float v_radius;out vec2 v_extrude;flat out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:iv("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {vec4 data=texelFetch(u_elevation_stops,ivec2(stop,0),0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=2.0/u_dimension;float scale=(u_dimension.x-4.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:iv("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","layout(location=0) in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:iv(ev,"layout(location=0) in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:iv("#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:iv("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:iv("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;uniform bool u_sdf_pattern;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*alpha*opacity;} else {fragColor=mix(color1,color2,u_fade)*alpha*opacity;}\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:iv("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform bool u_sdf_pattern;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*opacity;} else {fragColor=mix(color1,color2,u_fade)*opacity;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:iv("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma maplibre: define highp float base\n#pragma maplibre: define highp float height\n#pragma maplibre: define highp vec4 color\nvoid main() {\n#pragma maplibre: initialize highp float base\n#pragma maplibre: initialize highp float height\n#pragma maplibre: initialize highp vec4 color\nvec3 normal=vec3(a_normal_ed.xyz);\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:iv("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=vec3(a_normal_ed.xyz);float edgedistance=float(a_normal_ed.w);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:iv("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-4.0;float a=getElevation(pos+ivec2(-1,-1));float b=getElevation(pos+ivec2(0,-1));float c=getElevation(pos+ivec2(1,-1));float d=getElevation(pos+ivec2(-1,0));float e=getElevation(pos);float f=getElevation(pos+ivec2(1,0));float g=getElevation(pos+ivec2(-1,1));float h=getElevation(pos+ivec2(0,1));float i=getElevation(pos+ivec2(1,1));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:iv("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec2 size=vec2(textureSize(u_image,0));vec2 texturePos=(v_pos*(size-2.0)+1.0)/size;vec4 pixel=texture(u_image,texturePos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:iv("flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:iv("uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:iv("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:iv("uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:iv("uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),layerOpacity:iv("uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:iv("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec3 u_image_warp;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 topLeft=u_coords_top.xy;vec2 topRight=u_coords_top.zw;vec2 bottomLeft=u_coords_bottom.xy;vec2 bottomRight=u_coords_bottom.zw;vec2 bilinearPos=mix(mix(topLeft,topRight,fractionalPos.x),mix(bottomLeft,bottomRight,fractionalPos.x),fractionalPos.y);float denominator=dot(u_image_warp.xy,fractionalPos)+1.0;vec2 acrossTop=topRight-topLeft+u_image_warp.x*topRight;vec2 downLeft=bottomLeft-topLeft+u_image_warp.y*bottomLeft;vec2 projectivePos=(acrossTop*fractionalPos.x+downLeft*fractionalPos.y+topLeft)/denominator;vec2 position=mix(projectivePos,bilinearPos,u_image_warp.z);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}\n#endif\nfloat perspectiveRatio=mix(1.0/denominator,1.0,u_image_warp.z);v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}"),symbolIcon:iv("uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform bool u_rotate_symbol;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_tex;flat out float v_total_opacity;\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}"),symbolSDF:iv("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_data0;out vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}"),symbolTextAndIcon:iv("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;layout(location=4) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(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);}\n#endif\nvec4 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:iv("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:iv("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),atmosphere:iv("#ifdef GL_ES\nprecision highp float;\n#endif\nin 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\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:iv("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;uniform vec3 u_globe_position;uniform float u_globe_radius;in vec3 v_view_direction;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,(angle_to_globe_center-horizon_angle)*u_camera_to_center_distance*u_device_pixel_ratio,u_sky_blend);}if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}")};function iv(e,t){let i=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=n?n.concat(a):a,s=r?r.length:0,l={};return e=e.replace(i,(e,t,i,r,a)=>(l[a]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nin ${i} ${r} ${a};\n#else\nuniform ${i} ${r} u_${a};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${a}\n ${i} ${r} ${a} = u_${a};\n#endif\n`)),t=t.replace(i,(e,t,i,r,a)=>{let n="float"===r?"vec2":"vec4",o=a.match(/color/)?"color":n;return l[a]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nlayout(location = ${s++}) in ${i} ${n} a_${a};\nout ${i} ${r} ${a};\n#else\nuniform ${i} ${r} u_${a};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = a_${a};\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = unpack_mix_${o}(a_${a}, u_${a}_t);\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nlayout(location = ${s++}) in ${i} ${n} a_${a};\n#else\nuniform ${i} ${r} u_${a};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${a}\n ${i} ${r} ${a} = a_${a};\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${i} ${r} ${a} = unpack_mix_${o}(a_${a}, u_${a}_t);\n#else\n ${i} ${r} ${a} = u_${a};\n#endif\n`}),{fragmentSource:e,vertexSource:t,staticAttributes:r,staticUniforms:o}}const rv="#define PROJECTION_MERCATOR",av="mercator";var nv=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return av}get shaderDefine(){return rv}get shaderPreludeCode(){return tv.projectionMercator}get vertexShaderPreludeCode(){return tv.projectionMercator.vertexSource}get subdivisionGranularity(){return ch.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,i,r,a){if(this._cachedMesh)return this._cachedMesh;let n=new xs;n.emplaceBack(0,0),n.emplaceBack(re,0),n.emplaceBack(0,re),n.emplaceBack(re,re);let o=e.createVertexBuffer(n,Dy.members),s=Ns.simpleSegment(0,0,4,2),l=new Ls;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new Ty(o,u,s),this._cachedMesh}recalculate(){}hasTransition(){return!1}},ov=class e{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(e,t,i){return null!=t.top&&null!=e.top&&(this.top=Oi.number(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=Oi.number(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=Oi.number(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=Oi.number(e.right,t.right,i)),this}getCenter(e,t){return new c(De((this.left+e-this.right)/2,0,e),De((this.top+t-this.bottom)/2,0,t))}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new e(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function sv(e,t){if(!e.renderWorldCopies||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function lv(e){return Math.max(0,Math.floor(e))}var uv=class{constructor(e,t){this.applyConstrain=(e,t)=>null===this._constrainOverride?this._callbacks.defaultConstrain(e,t):this._constrainOverride(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===t?.renderWorldCopies||!!t?.renderWorldCopies,this._minZoom=t?.minZoom||0,this._maxZoom=t?.maxZoom||22,this._minPitch=t?.minPitch??0,this._maxPitch=t?.maxPitch??60,this._constrainOverride=t?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new jh(0,0),this._elevation=0,this._zoom=0,this._tileZoom=lv(this._zoom),this._scale=Ce(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new ov,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,t,i){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=lv(this._zoom),this._scale=Ce(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new ov(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!i&&e.autoCalculateNearFarZ,t&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){if(this._minZoom===e)return;this._minZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get maxZoom(){return this._maxZoom}setMaxZoom(e){if(this._maxZoom===e)return;this._maxZoom=e;let t=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=t}get minPitch(){return this._minPitch}setMinPitch(e){if(this._minPitch===e)return;this._minPitch=e;let t=this._unmodified;this.setPitch(Math.max(this.pitch,e)),this._unmodified=t}get maxPitch(){return this._maxPitch}setMaxPitch(e){if(this._maxPitch===e)return;this._maxPitch=e;let t=this._unmodified;this.setPitch(Math.min(this.pitch,e)),this._unmodified=t}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new c(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let t=Ee(e,-180,180)*Math.PI/180;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=Ug(),function(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=Math.sin(i),l=Math.cos(i);e[0]=r*l+n*s,e[1]=a*l+o*s,e[2]=r*-s+n*l,e[3]=a*-s+o*l}(this._rotationMatrix,this._rotationMatrix,-this._bearingInRadians))}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let t=De(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==t&&(this._unmodified=!1,this._pitchInRadians=t,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return Ze(this._fovInRadians)}setFov(e){e=De(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=Ge(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let t=this.applyConstrain(this._center,e).zoom;this._zoom!==t&&(this._unmodified=!1,this._zoom=t,this._tileZoom=Math.max(0,Math.floor(t)),this._scale=Ce(t),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){(e.lat!==this._center.lat||e.lng!==this._center.lng)&&(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return 2!==this._latRange?.length||2!==this._lngRange?.length?null:new ny([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-He,He])}getCameraQueryGeometry(e,t){if(1===t.length)return[t[0],e];{let{minX:i,minY:r,maxX:a,maxY:n}=Ih.fromPoints(t).extend(e);return[new c(i,r),new c(a,r),new c(a,n),new c(i,n),new c(i,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._pixelPerMeter=Gh(1,this.center.lat)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=v(new Float64Array(16));D(e,e,[this._width/2,-this._height/2,1]),T(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=v(new Float64Array(16)),D(e,e,[1,-1,1]),T(e,e,[-1,-1,0]),D(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e;let t=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(t)*this._height,this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,i,r){let a,n,o=void 0===i?this.bearing:i,s=r=void 0===r?this.pitch:r,{distanceToCenter:l,clampedElevation:u}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,s),{x:h,y:c}=ic(s,o),d=Xh.fromLngLat(e,t),p=Wh(1,d.y),f=0;do{if(f+=1,f>10)break;n=l/p;let e=h*n,t=c*n;a=new Xh(d.x+e,d.y+t),p=1/a.meterInMercatorCoordinateUnits()}while(Math.abs(l-n*p)>1e-12);return{center:a.toLngLat(),elevation:u,zoom:Me(this.height/2/Math.tan(this.fovInRadians/2)/n/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e===0)return;let t=1/this.worldSize,i=Gh(1,this.center.lat)*this.worldSize,r=Xh.fromLngLat(this.center,this.elevation),a=r.x/t,n=r.y/t,o=r.z/t,s=this.pitch,l=this.bearing,{x:u,y:h,z:c}=ic(s,l),d=this.cameraToCenterDistance,p=a+d*-u,f=n+d*-h,m=o+d*c,{distanceToCenter:g,clampedElevation:_}=this._distanceToCenterFromAltElevationPitch(m/i,e,s),y=g*i,x=new Xh((p+u*y)*t,(f+h*y)*t,0).toLngLat(),v=Gh(1,x.lat),b=Me(this.height/2/Math.tan(this.fovInRadians/2)/g/v/this.tileSize);this._elevation=_,this._center=x,this.setZoom(b)}_distanceToCenterFromAltElevationPitch(e,t,i){let r,a=-Math.cos(Ge(i)),n=e-t,o=t;return a*n>=0||Math.abs(a)<.1?(r=1e4,o=e+r*a):r=-n/a,{distanceToCenter:r,clampedElevation:o}}getCameraPoint(){let e=this.pitchInRadians,t=Math.tan(e)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new c(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let t=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/t,e.canonical.y/t,1/t/re,1/t/re]}},hv=class{distanceToTile2d(e,t,i,r){let a=r,n=a.distanceX([e,t]),o=a.distanceY([e,t]);return Math.hypot(n,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,t,i,r){let a=Math.min(0,i),n=Math.max(0,i);if(r?.terrain){let i=new sf(e.z,t,e.z,e.x,e.y),o=r.terrain.getMinMaxElevation(i);a=o.minElevation??a,n=o.maxElevation??n}let o=1<<e.z;return new Oy([t+e.x/o,e.y/o,a],[t+(e.x+1)/o,(e.y+1)/o,n])}allowVariableZoom(e,t){let i=De(78.5-e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height/2,0,60);return!!t.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}};const cv=ko([{name:"a_pos3d",type:"Int16",components:3}]);var dv=class extends yt{constructor(e){super(),this._lastTilesetChange=Xg(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(e,t){this.tileManager.update(e,t),this._renderableTilesKeys=[];let i={},r=!1;for(let a of Zy(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t,calculateTileZoom:this.tileManager._source.calculateTileZoom}))i[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=new Float32Array(16),A(a.terrainRttPosMatrix32f,0,re,re,0,0,1),this._tiles[a.key]=new ky(a,this.tileSize),this._lastTilesetChange=Xg(),r=!0);for(let e in this._tiles)i[e]||(this._tiles[e].releaseRTT(this.tileManager.map.painter),delete this._tiles[e],r=!0);return r}releaseRTT(e){for(let t in this._tiles){let i=this._tiles[t];(i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&i.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let e in this._tiles)this._tiles[e].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let t={};for(let i of this._renderableTilesKeys){let r=this._tiles[i].tileID,a=e.clone(),n=le();if(r.canonical.equals(e.canonical))A(n,0,re,re,0,0,1);else if(r.canonical.isChildOf(e.canonical)){let t=r.canonical.z-e.canonical.z,i=r.canonical.x-(r.canonical.x>>t<<t),a=r.canonical.y-(r.canonical.y>>t<<t),o=re>>t;A(n,0,o,o,0,0,1),T(n,n,[-i*o,-a*o,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{let t=e.canonical.z-r.canonical.z,i=e.canonical.x-(e.canonical.x>>t<<t),a=e.canonical.y-(e.canonical.y>>t<<t),o=re>>t;A(n,0,re,re,0,0,1),T(n,n,[i*o,a*o,0]),D(n,n,[1/2**t,1/2**t,0])}}a.terrainRttPosMatrix32f=new Float32Array(n),t[i]=a}return t}_getTerrainCoordsForTileRanges(e,t){let i={};for(let r of this._renderableTilesKeys){let a=this._tiles[r].tileID;if(!this._isWithinTileRanges(a,t))continue;let n=e.clone(),o=le();if(a.canonical.z===e.canonical.z){let t=e.canonical.x-a.canonical.x+e.wrap*(1<<e.canonical.z),i=e.canonical.y-a.canonical.y;A(o,0,re,re,0,0,1),T(o,o,[t*re,i*re,0])}else if(a.canonical.z>e.canonical.z){let t=a.canonical.z-e.canonical.z,i=a.canonical.x-(a.canonical.x>>t<<t)+e.wrap*(1<<a.canonical.z),r=a.canonical.y-(a.canonical.y>>t<<t),n=e.canonical.x-(a.canonical.x>>t),s=e.canonical.y-(a.canonical.y>>t),l=re>>t;A(o,0,l,l,0,0,1),T(o,o,[-i*l+n*re,-r*l+s*re,0])}else{let t=e.canonical.z-a.canonical.z,i=e.canonical.x-(e.canonical.x>>t<<t)+e.wrap*(1<<e.canonical.z),r=e.canonical.y-(e.canonical.y>>t<<t),n=(e.canonical.x>>t)-a.canonical.x,s=(e.canonical.y>>t)-a.canonical.y,l=re<<t;A(o,0,l,l,0,0,1),T(o,o,[i*re+n*l,r*re+s*l,0])}n.terrainRttPosMatrix32f=new Float32Array(o),i[r]=n}return i}getSourceTile(e,t){let i=this.tileManager._source,r=e.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;this._sourceTileCache[e.key]||=e.scaledTo(r).key;let a=this.findTileInCaches(this._sourceTileCache[e.key]);if(!a?.dem&&t)for(;r>=i.minzoom&&!a?.dem;)a=this.findTileInCaches(e.scaledTo(r--).key);return a}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Xg()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){let i=t[e.canonical.z];return!!i&&(e.wrap>i.minWrap||e.wrap<i.maxWrap||e.canonical.x>=i.minTileXWrapped&&e.canonical.x<=i.maxTileXWrapped&&e.canonical.y>=i.minTileY&&e.canonical.y<=i.maxTileY)}};const pv=re*(1-1e-12);var fv=class{constructor(e,t,i,r="auto"){this._meshCache={},this.painter=e,this.tileManager=new dv(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this._terrainSkirtLength=r,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this._elevationSamplerCache=new Map}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null);for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,i,r=re){let a=e.normalizeCoordinates(t,i,r);if(!a)return 0;let n=this.getElevationSampler(a.tileID);return n?n(a.x,a.y,r):0}getElevationForLngLatZoom(e,t){if(!af(t,e.wrap()))return 0;let{tileID:i,mercatorX:r,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(i,r%re,a%re,re)}getElevationForLngLat(e,t){let i=this.getCoverageIndex();if(i){let t=Xh.fromLngLat(e),r=gv(i,this.exaggeration,t.x,t.y);if(r.demLoaded)return r.elevation}let r=Zy(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),a=0;for(let e of r)e.canonical.z>a&&(a=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,a)}getElevation(e,t,i,r=re){return this.getDEMElevation(e,t,i,r)*this.exaggeration}resetElevationCache(){this._elevationSamplerCache.clear(),this._coverageIndex=void 0}getCoverageIndex(){return void 0===this._coverageIndex&&(this._coverageIndex=this._buildCoverageIndex()),this._coverageIndex}_buildCoverageIndex(){let e=[],t=new Map,i=0,r=0;for(let a of this.tileManager.getRenderableTiles()){if(!a)continue;let{canonical:n,wrap:o}=a.tileID;e.includes(n.z)||e.push(n.z);let s=this.getElevationSampler(a.tileID);t.set(`${o}/${n.z}/${n.x}/${n.y}`,s);let{minElevation:l,maxElevation:u}=this.getMinMaxElevation(a.tileID);i=Math.min(i,l??0),r=Math.max(r,u??0)}return 0===t.size?null:(e.sort((e,t)=>t-e),{zooms:e,samplerPerTile:t,minElevation:i-10,maxElevation:r+10})}getElevationSampler(e){let t=e.key,i=this._elevationSamplerCache.get(t);if(i)return i;let r=this.tileManager.getSourceTile(e,!0),a=r?.dem;if(!r||!a)return null;let n=this._getDEMTileMatrix(e,r),o=n[0]*a.dim,s=n[5]*a.dim,l=n[12]*a.dim,u=n[13]*a.dim,h=(e,t,i)=>{let r=8192===i?1:re/i;return a.sampleBilinear(e*r*o+l,t*r*s+u)};return this._elevationSamplerCache.set(t,h),h}_getDEMTileMatrix(e,t){let i=`${t.tileID.key}/${e.key}`,r=this._demMatrixCache.get(i);if(r)return r;let a=this.tileManager.getSource().maxzoom,n=e.canonical.z-t.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=a?n=e.canonical.z-a:Oe("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let o=e.canonical.x-(e.canonical.x>>n<<n),s=e.canonical.y-(e.canonical.y>>n<<n),l=function(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}(new Float64Array(16),[1/(re<<n),1/(re<<n),0]);return T(l,l,[o*re,s*re,0]),this._demMatrixCache.set(i,l),l}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,t=new ou({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new _u(e,t,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new _u(e,new ou({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=v([])}let t=this.tileManager.getSourceTile(e,!0);if(t?.dem&&(!t.demTexture||t.needsTerrainPrepare)){let e=this.painter.context;t.demTexture||=this.painter.getTileTexture(t.dem.stride),t.demTexture?t.demTexture.update(t.dem.getPixels(),{premultiply:!1}):t.demTexture=new _u(e,t.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),t.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),t.needsTerrainPrepare=!1}let i=t?this._getDEMTileMatrix(e,t):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:t?.dem?.dim||1,u_terrain_matrix:i,u_terrain_unpack:t?.dem?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(t?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:t}}getFramebuffer(){let e=this.painter,t=e.width/devicePixelRatio,i=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==t||this._fbo.height!==i)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new _u(e.context,{width:t,height:i,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(t,i,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,t,i))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}depthAtPoint(e){let t=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer().framebuffer),r.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),i.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){let t=this.painter.style.projection?.transitionState>0,i=t&&0===e.canonical.y,r=t&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${i?"n":""}_${r?"s":""}`;if(this._meshCache[a])return this._meshCache[a];let n=this.painter.context,o=new vs,s=new Ls,l=this.meshSize,u=re/l,h=l*l;for(let e=0;e<=l;e++)for(let t=0;t<=l;t++)o.emplaceBack(t*u,e*u,0);for(let e=0;e<h;e+=l+1)for(let t=0;t<l;t++)s.emplaceBack(t+e,l+t+e+1,l+t+e+2),s.emplaceBack(t+e,l+t+e+2,t+e+1);"none"!==this._terrainSkirtLength&&this._buildSkirts(o,s,l,u,i,r);let c=new Ty(n.createVertexBuffer(o,cv.members),n.createIndexBuffer(s),Ns.simpleSegment(0,0,o.length,s.length));return this._meshCache[a]=c,c}getSkirtLength(e){return 2*Math.PI*Oh/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,t){if(!af(t,e.wrap()))return 0;let{tileID:i}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getMinMaxElevation(i).minElevation??0}getMinMaxElevation(e){let t=this.tileManager.getSourceTile(e,!0),i={minElevation:null,maxElevation:null};return t?.dem&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(e,t){let i=Xh.fromLngLat(e.wrap()),r=(1<<t)*re,a=i.x*r,n=i.y*r,o=Math.floor(a/re),s=Math.floor(n/re);return{tileID:new sf(t,0,t,o,s),mercatorX:a,mercatorY:n}}_buildSkirts(e,t,i,r,a,n){let o=e.length,s=o+(i+1),l=(i+1)*i,u=a?dh:0,h=+!a,c=n?ph:re,d=+!n;for(let t=0;t<=i;t++)e.emplaceBack(t*r,u,h);for(let t=0;t<=i;t++)e.emplaceBack(t*r,c,d);for(let e=0;e<i;e++)t.emplaceBack(l+e,s+e,s+e+1),t.emplaceBack(l+e,s+e+1,l+e+1),t.emplaceBack(0+e,o+e+1,o+e),t.emplaceBack(0+e,0+e+1,o+e+1);let p=e.length,f=p+2*(i+1);for(let t of[0,1])for(let a=0;a<=i;a++)for(let i of[0,1])e.emplaceBack(t*re,a*r,i);for(let e=0;e<2*i;e+=2)t.emplaceBack(p+e,p+e+1,p+e+3),t.emplaceBack(p+e,p+e+3,p+e+2),t.emplaceBack(f+e,f+e+3,f+e+1),t.emplaceBack(f+e,f+e+2,f+e+3)}};const mv={covered:!1,demLoaded:!1,elevation:0};function gv(e,t,i,r){if(r<0||r>=1)return mv;let a=Math.floor(i),n=i-a;for(let i of e.zooms){let o=1<<i,s=n*o,l=r*o,u=Math.floor(s),h=Math.floor(l),c=`${a}/${i}/${u}/${h}`;if(!e.samplerPerTile.has(c))continue;let d=e.samplerPerTile.get(c);return d?{covered:!0,demLoaded:!0,elevation:d(Math.min((s-u)*re,pv),Math.min((l-h)*re,pv),re)*t}:{covered:!0,demLoaded:!1,elevation:0}}return mv}function _v(e,t){return e.covered&&t<=e.elevation+1e-6}function yv(e,t,i,r,a){for(let n=0;n<40&&r-i>a;n++){let a=(i+r)/2;t(e,a)?r=a:i=a}return{lo:i,hi:r}}var xv=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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}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(e){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,t)=>{t=De(+t,this.minZoom,this.maxZoom);let i={center:new jh(e.lng,e.lat),zoom:t},r=this._helper._lngRange;!this._helper._renderWorldCopies&&null===r&&(r=[-179.9999999999,180-1e-10]);let a=this.tileSize*Ce(i.zoom),n=0,o=a,s=0,l=a,u=0,h=0,{x:d,y:p}=this.size;if(this._helper._latRange){let e=this._helper._latRange;n=$h(e[1])*a,o=$h(e[0])*a,o-n<p&&(u=p/(o-n))}r&&(s=Ee(Uh(r[0])*a,0,a),l=Ee(Uh(r[1])*a,0,a),l<s&&(l+=a),l-s<d&&(h=d/(l-s)));let f,m,{x:g,y:_}=Kh(a,e),y=Math.max(h||0,u||0);if(y){let e=new c(h?(l+s)/2:g,u?(o+n)/2:_);return i.center=Jh(a,e).wrap(),i.zoom+=Me(y),i}if(this._helper._latRange){let e=p/2;_-e<n&&(m=n+e),_+e>o&&(m=o-e)}if(r){let e=(s+l)/2,t=g;this._helper._renderWorldCopies&&(t=Ee(g,e-a/2,e+a/2));let i=d/2;t-i<s&&(f=s+i),t+i>l&&(f=l-i)}if(void 0!==f||void 0!==m){let e=new c(f??g,m??_);i.center=Jh(a,e).wrap()}return i},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new uv({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new hv}clone(){let t=new e;return t.apply(this,!1),t}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){let t=[new of(0,e)];if(this._helper._renderWorldCopies){let i=this.screenPointToMercatorCoordinate(new c(0,0)),r=this.screenPointToMercatorCoordinate(new c(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new c(this._helper._width,this._helper._height)),n=this.screenPointToMercatorCoordinate(new c(0,this._helper._height)),o=Math.floor(Math.min(i.x,r.x,a.x,n.x)),s=Math.floor(Math.max(i.x,r.x,a.x,n.x));for(let i=o-1;i<=s+1;i++)0!==i&&t.push(new of(i,e))}return t}getCameraFrustum(){return jy.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){let t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLat(t,this):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,t,i=this.elevation){let r=i-this.elevation,a=this.screenPointToMercatorCoordinateAtZ(t,r),n=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),o=Xh.fromLngLat(e),s=new Xh(o.x-(a.x-n.x),o.y-(a.y-n.y));this.setCenter(s?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,t){return t?this.coordinatePoint(Xh.fromLngLat(e),t.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(Xh.fromLngLat(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToLocationAtElevation(e,t){return this.screenPointToMercatorCoordinateAtZ(e,t-this.elevation)?.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){let i=this.screenTerrainPointToMercatorCoordinate(e,t);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenTerrainPointToMercatorCoordinate(e,t){let i=t.getCoverageIndex();if(!i)return null;let{near:r,far:a}=this.getRaySegmentFromPixel(e),n=this.worldSize,o=a[0]-r[0],s=a[1]-r[1],l=a[2]-r[2],u={index:i,exaggeration:t.exaggeration,near:r,dx:o,dy:s,dz:l,worldSize:n},h=0,c=1;if(0===l){if(r[2]>i.maxElevation||r[2]<i.minElevation)return null}else{let e=(i.maxElevation-r[2])/l,t=(i.minElevation-r[2])/l;if(h=Math.max(h,Math.min(e,t)),c=Math.min(c,Math.max(e,t)),h>c)return null}let d=Math.hypot(o,s),p=De(Math.ceil(d*(c-h)/4),1,512),f=0,m=!bv(u,0);for(let e=0;e<=p;e++){let t=h+(c-h)*e/p;if(m){if(bv(u,t)){let{lo:e,hi:i}=yv(u,bv,f,t,.001/d),a=vv(u,e),h=vv(u,i),c=r[2]+e*l-a.elevation,p=r[2]+i*l-h.elevation,m=a.covered&&c>p?De(e+c*(i-e)/(c-p),e,i):i;return new Xh((r[0]+m*o)/n,(r[1]+m*s)/n,vv(u,m).elevation)}}else m=!bv(u,t);f=t}return null}getRaySegmentFromPixel(e){let t=[e.x,e.y,0,1],i=[e.x,e.y,1,1];W(t,t,this._pixelMatrixInverse),W(i,i,this._pixelMatrixInverse);let r=t[3],a=i[3],n=this.elevation;return{near:[t[0]/r,t[1]/r,t[2]/r+n],far:[i[0]/a,i[1]/a,i[2]/a+n]}}screenPointToMercatorCoordinateAtZ(e,t){let i=t||0,{near:r,far:a}=this.getRaySegmentFromPixel(e),n=r[2]===a[2]?0:(i+this.elevation-r[2])/(a[2]-r[2]);return new Xh(Oi.number(r[0],a[0],n)/this.worldSize,Oi.number(r[1],a[1],n)/this.worldSize,i)}coordinatePoint(e,t=0,i=this._pixelMatrix){let r=[e.x*this.worldSize,e.y*this.worldSize,t,1];return W(r,r,i),new c(r[0]/r[3],r[1]/r[3])}getBounds(){let e=Math.max(0,this._helper._height/2-Qh(this));return(new ny).extend(this.screenPointToLocation(new c(0,e))).extend(this.screenPointToLocation(new c(this._helper._width,e))).extend(this.screenPointToLocation(new c(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new c(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=this.screenTerrainPointToMercatorCoordinate(e,t):e.y>this.height/2-Qh(this)}calculatePosMatrix(e,t=!1,i=!1){let r=e.key??lf(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),a=t?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(r)){let e=a.get(r);return i?e.f32:e.f64}let n=ec(e,this.worldSize);w(n,t?this._alignedProjMatrix:this._viewProjMatrix,n);let o={f64:n,f32:new Float32Array(n)};return a.set(r,o),i?o.f32:o.f64}calculateFogMatrix(e){let t=e.key,i=this._fogMatrixCacheF32;if(i.has(t))return i.get(t);let r=ec(e,this.worldSize);return w(r,this._fogMatrix,r),i.set(t,new Float32Array(r)),i.get(t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}calculateCameraOptionsFromTo(e,t,i,r){let a=Xh.fromLngLat(e,t),n=Xh.fromLngLat(i,r),o=n.x-a.x,s=n.y-a.y,l=n.z-a.z,u=Math.hypot(o,s,l);if(0===u)throw Error("Can't calculate camera options with same From and To");let h=Math.hypot(o,s),c=Me(this.cameraToCenterDistance/u/this.tileSize),d=Ze(Math.atan2(o,-s)),p=Ze(Math.acos(h/u));return p=l<0?90-p:90+p,{center:n.toLngLat(),elevation:r,zoom:c,pitch:p,bearing:d}}_calculateNearFarZIfNeeded(e,t,i){if(!this._helper.autoCalculateNearFarZ)return;let r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-r*this._helper._pixelPerMeter/Math.cos(t),n=r<0?a:e,o=Math.PI/2+this.pitchInRadians,s=Ge(this.fov)*(Math.abs(Math.cos(Ge(this.roll)))*this.height+Math.abs(Math.sin(Ge(this.roll)))*this.width)/this.height*(.5+i.y/this.height),l=Math.sin(s)*n/Math.sin(De(Math.PI-o-s,.01,Math.PI-.01)),u=Qh(this),h=Math.atan(u/this._helper.cameraToCenterDistance),c=Ge(.75),d=h>c?2*h*(.5+i.y/(2*u)):c,p=Math.sin(d)*n/Math.sin(De(Math.PI-o-d,.01,Math.PI-.01)),f=Math.min(l,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-t)*f+n),this._helper._nearZ=this._helper._height/50}_calcMatrices(){let e,t=this.centerOffset,i=Kh(this.worldSize,this.center),r=i.x,a=i.y,n=Ge(Math.min(this.pitch,Hh)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(n));this._calculateNearFarZIfNeeded(o,n,t),e=new Float64Array(16),I(e,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),function(e,t){e[0]=1/t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1/t[5],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=0,e[11]=1/t[14],e[12]=0,e[13]=0,e[14]=-1,e[15]=t[10]/t[14]}(this._invProjMatrix,e),e[8]=2*-t.x/this._helper._width,e[9]=2*t.y/this._helper._height,this._projectionMatrix=x(e),D(e,e,[1,-1,1]),T(e,e,[0,0,-this._helper.cameraToCenterDistance]),P(e,e,-this.rollInRadians),E(e,e,this.pitchInRadians),P(e,e,-this.bearingInRadians),T(e,e,[-r,-a,0]),this._mercatorMatrix=D([],e,[this.worldSize,this.worldSize,this.worldSize]),D(e,e,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=w(new Float64Array(16),this.clipSpaceToPixelsMatrix,e),T(e,e,[0,0,-this.elevation]),this._viewProjMatrix=e,this._invViewProjMatrix=b([],e);let s=[0,0,-1,1];W(s,s,this._invViewProjMatrix),this._cameraPosition=[s[0]/s[3],s[1]/s[3],s[2]/s[3]],this._fogMatrix=new Float64Array(16),I(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,D(this._fogMatrix,this._fogMatrix,[1,-1,1]),T(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),P(this._fogMatrix,this._fogMatrix,-this.rollInRadians),E(this._fogMatrix,this._fogMatrix,this.pitchInRadians),P(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),T(this._fogMatrix,this._fogMatrix,[-r,-a,0]),D(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),T(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=w(new Float64Array(16),this.clipSpaceToPixelsMatrix,e);let l=this._helper._width%2/2,u=this._helper._height%2/2,h=Math.cos(this.bearingInRadians),c=Math.sin(-this.bearingInRadians),d=r-Math.round(r)+h*l+c*u,p=a-Math.round(a)+h*u+c*l,f=new Float64Array(e);if(T(f,f,[d>.5?d-1:d,p>.5?p-1:p,0]),this._alignedProjMatrix=f,e=b(new Float64Array(16),this._pixelMatrix),!e)throw Error("failed to invert matrix");this._pixelMatrixInverse=e,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new c(0,0)),t=[e.x*this.worldSize,e.y*this.worldSize,0,1];return W(t,t,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this.cameraToCenterDistance/this.pixelsPerMeter+this.elevation}getCameraLngLat(){let e=Gh(1,this.center.lat)*this.worldSize,t=this._helper.cameraToCenterDistance/e;return tc(this.center,this.elevation,this.pitch,this.bearing,t).toLngLat()}lngLatToCameraDepth(e,t){let i=Xh.fromLngLat(e),r=[i.x*this.worldSize,i.y*this.worldSize,t,1];return W(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){let t,{overscaledTileID:i,aligned:r,applyTerrainMatrix:a}=e,n=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,r,!0):null;return t=i?.terrainRttPosMatrix32f&&a?i.terrainRttPosMatrix32f:o||he(),{mainMatrix:t,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:t,clipAntimeridian:!1}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return M(e)}getRayDirectionFromPixel(e){throw Error("Not implemented.")}projectTileCoordinates(e,t,i,r){let a,n=this.calculatePosMatrix(i);null==r?(a=[e,t,0,1],Px(a,a,n)):(a=[e,t,r,1],W(a,a,n));let o=a[3];return{point:new c(a[0]/o,a[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}populateCache(e){for(let t of e)this.calculatePosMatrix(t)}getProjectionDataForCustomLayer(e=!0){let t=new sf(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:t,applyGlobeMatrix:e}),r=ec(t,this.worldSize);w(r,this._viewProjMatrix,r);let a=[re,re,this.worldSize/this._helper.pixelsPerMeter],n=le();return D(n,r,a),{...i,tileMercatorCoords:[0,0,1,1],fallbackMatrix:n,mainMatrix:n}}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}};function vv(e,t){return gv(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize)}function bv(e,t){return _v(vv(e,t),e.near[2]+t*e.dz)}function wv(){Oe("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Tv(e){if(e.useSlerp)if(e.k<1){let t=Xe(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),i=Xe(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);!function(e,t,i,r){var a,n,o,s,l=t[0],u=t[1],h=t[2],c=t[3],d=i[0],p=i[1],f=i[2],m=i[3],g=l*d+u*p+h*f+c*m;g<0&&(g=-g,d=-d,p=-p,f=-f,m=-m),1-g>1e-6?(a=Math.acos(g),n=Math.sin(a),o=Math.sin((1-r)*a)/n,s=Math.sin(r*a)/n):(o=1-r,s=r),e[0]=o*l+s*d,e[1]=o*u+s*p,e[2]=o*h+s*f,e[3]=o*c+s*m}(r,t,i,e.k);let a=function(e){let t=new Float64Array(9);!function(e,t){var i=t[0],r=t[1],a=t[2],n=t[3],o=i+i,s=r+r,l=a+a,u=i*o,h=r*o,c=r*s,d=a*o,p=a*s,f=a*l,m=n*o,g=n*s,_=n*l;e[0]=1-c-f,e[3]=h-_,e[6]=d+g,e[1]=h+_,e[4]=1-u-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-u-c}(t,e);let i,r,a=Ze(-Math.asin(De(t[2],-1,1)));return Math.hypot(t[5],t[8])<.001?(i=0,r=-Ze(Math.atan2(t[3],t[4]))):(i=Ze(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),r=Ze(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:i,pitch:a+90,bearing:r}}(r);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(Oi.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(Oi.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(Oi.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Dv(e,t,i,r,a){let n=a.padding,o=Kh(a.worldSize,i.getNorthWest()),s=Kh(a.worldSize,i.getNorthEast()),l=Kh(a.worldSize,i.getSouthEast()),u=Kh(a.worldSize,i.getSouthWest()),h=Ge(-r),d=o.rotate(h),p=s.rotate(h),f=l.rotate(h),m=u.rotate(h),g=new c(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new c(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),y=g.sub(_),x=a.width-(n.left+n.right+t.left+t.right),v=a.height-(n.top+n.bottom+t.top+t.bottom),b=x/y.x,w=v/y.y;if(w<0||b<0)return void wv();let T=Math.min(Me(a.scale*Math.min(b,w)),e.maxZoom),D=c.convert(e.offset),E=new c((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(Ge(r)),S=D.add(E).mult(a.scale/Ce(T));return{center:Jh(a.worldSize,o.add(l).div(2).sub(S)),zoom:T,bearing:r}}var Ev=class{get useGlobeControls(){return!1}handlePanInertia(e,t){let i=e.mag(),r=Math.abs(Qh(t));return{easingOffset:e.mult(Math.min(.75*r/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around,e.aroundElevation)}cameraForBoxAndBearing(e,t,i,r,a){return Dv(e,t,i,r,a)}handleJumpToCenterZoom(e,t){let i=void 0===t.zoom?e.zoom:+t.zoom;e.zoom!==i&&e.setZoom(+t.zoom),void 0!==t.center&&e.setCenter(jh.convert(t.center))}handleEaseTo(e,t){let i=e.zoom,r=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===t.roll?e.roll:t.roll,pitch:void 0===t.pitch?e.pitch:t.pitch,bearing:void 0===t.bearing?e.bearing:t.bearing},o=void 0!==t.zoom,s=!e.isPaddingEqual(t.padding),l=!1,u=o?+t.zoom:e.zoom,h=e.centerPoint.add(t.offsetAsPoint),c=e.screenPointToLocation(h),{center:d,zoom:p}=e.applyConstrain(jh.convert(t.center||c),u??i);sv(e,d);let f=Kh(e.worldSize,c),m=Kh(e.worldSize,d).sub(f),g=Ce(p-i);return l=p!==i,{easeFunc:o=>{if(l&&e.setZoom(Oi.number(i,p,o)),qe(a,n)||Tv({startEulerAngles:a,endEulerAngles:n,tr:e,k:o,useSlerp:a.roll!=n.roll}),s&&(e.interpolatePadding(r,t.padding,o),h=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{let t=Ce(e.zoom-i),r=(p>i?Math.min(2,g):Math.max(.5,g))**(1-o),a=Jh(e.worldSize,f.add(m.mult(o*r)).mult(t));e.setLocationAtPoint(e.renderWorldCopies?a.wrap():a,h)}},isZooming:l,elevationCenter:d}}handleFlyTo(e,t){let i=void 0!==t.zoom,r=e.zoom,a=e.applyConstrain(jh.convert(t.center||t.locationAtOffset),i?+t.zoom:r),n=a.center,o=a.zoom;sv(e,n);let s=e.worldSize,l=Kh(s,t.locationAtOffset),u=Kh(s,n).sub(l),h=u.mag(),c=Ce(o-r),d=void 0===t.minZoom?e.minZoom:+t.minZoom,p=Math.max(d,e.minZoom),f=Math.min(p,r,o),m=e.applyConstrain(n,f).zoom;return{easeFunc:(t,i,a,h)=>{e.setZoom(1===t?o:r+Me(i));let c=1===t?n:Jh(s,l.add(u.mult(a)));e.setLocationAtPoint(e.renderWorldCopies?c.wrap():c,h)},scaleOfZoom:c,targetCenter:n,scaleOfMinZoom:Ce(m-r),pixelPathLength:h}}};let Sv;const Pv=new ch({fill:new hh(128,2),line:new hh(512,0),tile:new hh(128,32),stencil:new hh(128,1),circle:3});var Iv=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return tv.projectionGlobe}get vertexShaderPreludeCode(){return tv.projectionMercator.vertexSource}get subdivisionGranularity(){return Pv}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,r,a){let n=("stencil"===a?Pv.stencil:Pv.tile).getGranularityForZoomLevel(t.z),o=0===t.y&&r,s=t.y===(1<<t.z)-1&&r;return this._getMesh(e,{granularity:n,generateBorders:i,extendToNorthPole:o,extendToSouthPole:s})}_getMesh(e,t){let i=this._getMeshKey(t);if(i in this._tileMeshCache)return this._tileMeshCache[i];let r=Ey(e,t);return this._tileMeshCache[i]=r,r}recalculate(e){}hasTransition(){return!1}},Av=class extends yt{constructor(e,t){super(),this._transitionable=new ho(Sv||=new Do({type:new xo(vt.projection.type,"type")}),"projection",t),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new so(0)),this._mercatorProjection=new nv,this._verticalPerspectiveProjection=new Iv}get transitionState(){let e=this.properties.get("type");if("string"==typeof e&&"mercator"===e)return 0;if("string"==typeof e&&"vertical-perspective"===e)return 1;if(e instanceof Ei){if(e.from===e.to)return"mercator"===e.from?0:1;if("vertical-perspective"===e.from&&"mercator"===e.to)return 1-e.transition;if("mercator"===e.from&&"vertical-perspective"===e.to)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}getMeshFromTileID(e,t,i,r,a){return this.currentProjection.getMeshFromTileID(e,t,i,r,a)}setProjection(e){this._transitionable.setValue("type",e?.type||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}};function Cv(e){let t=Fv(e.worldSize,e.center.lat);return 2*Math.PI*t}function Mv(e,t,i,r,a){let n=1/(1<<a),o=t/re*n+r*n,s=ye((e/re*n+i*n)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI,u=Math.cos(l),h=new Float64Array(3);return h[0]=Math.sin(s)*u,h[1]=Math.sin(l),h[2]=Math.cos(s)*u,h}function zv(e){return function(e,t){let i=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*i,r[1]=Math.sin(t),r[2]=Math.cos(e)*i,r}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function Fv(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function Rv(e){let t=W(oe(),[0,0,0,1],e.modelViewProjectionMatrix);return W(t,t,e.inverseProjectionMatrix),[t[0]/t[3],t[1]/t[3],t[2]/t[3]]}function kv(e){let t=Math.asin(e[1])/Math.PI*180,i=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(i>1e-6){let r=e[0]/i,a=e[2]/i,n=Math.acos(a),o=(r>0?n:-n)/Math.PI*180;return new jh(Ee(o,-180,180),t)}return new jh(0,t)}const Lv=.98*Math.PI;function Bv(e,t){let i=e.cameraPosition,r=z(i);if(r<=1)return e.screenPointToLocation(t);let a=se();O(a,i);let n=e.getRayDirectionFromPixel(t),o=-j(n,a),s=se();B(s,n,a,o);let l=z(s);if(l<1e-9)return e.screenPointToLocation(t);let u=Math.atan2(l,o),h=.9*Math.asin(1/r);if(u<h)return e.screenPointToLocation(t);let c=r*Math.sin(h),d=Math.asin(De(c,-1,1))-h,p=r*Math.cos(h)/Math.sqrt(Math.max(1-c*c,1e-12))-1,f=Lv-d,m=u-h,g=d+p*m*f/(f+p*m),_=se();L(_,s,1/l);let y=se();return L(y,a,Math.cos(De(g,0,Lv))),B(y,y,_,Math.sin(De(g,0,Lv))),O(y,y),kv(y)}function Ov(e){return Math.cos(e*Math.PI/180)}function jv(e,t){let i=Ov(e);return Me(Ov(t)/i)}function Vv(e){let t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function Nv(e,t,i,r){let a=e.lat+i*r;if(Math.abs(i)>1){let n=e.lat+i,o=(Math.sign(n)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,s=Math.abs(e.lat+i)*Math.PI/180,l=Vv(o+r*(s-o)),u=Vv(o),h=(l-u)/(Vv(s)-u),c=e.lng+t*h;return new jh(c,a)}{let i=e.lng+t*r;return new jh(i,a)}}function Uv(e,t,i=1){let r=j(e,t),a=i*i,n=se(),o=se();L(o,t,r),Z(n,e,o);let s=a-j(n,n);if(s<0)return null;let l=j(e,e)-a,u=-r+(r<0?1:-1)*Math.sqrt(s),h=l/u,c=u;return{tMin:Math.min(h,c),tMax:Math.max(h,c)}}var $v=class{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,r){let a=`${e.z}_${e.x}_${e.y}_${r?.terrain?"t":""}_${Math.round(i)}`,n=this._cache.get(a);if(n)return n;let o=this._cachePrevious.get(a);if(o)return this._cache.set(a,o),o;let s=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(a,s),this._hadAnyChanges=!0,s}},Gv=class e{constructor(e,t,i,r){this.min=i,this.max=r,this.points=e,this.planes=t}static fromAabb(t,i){let r=[];for(let e=0;e<8;e++)r.push([1&~e?t[0]:i[0],1==(e>>1&1)?i[1]:t[1],1==(e>>2&1)?i[2]:t[2]]);return new e(r,[[-1,0,0,i[0]],[1,0,0,-t[0]],[0,-1,0,i[1]],[0,1,0,-t[1]],[0,0,-1,i[2]],[0,0,1,-t[2]]],t,i)}static fromCenterSizeAngles(t,i,r){let a=H([],r[0],r[1],r[2]),n=N([],[i[0],0,0],a),o=N([],[0,i[1],0],a),s=N([],[0,0,i[2]],a),l=[...t],u=[...t];for(let e=0;e<8;e++)for(let i=0;i<3;i++){let r=t[i]+n[i]*(1&~e?-1:1)+o[i]*(1==(e>>1&1)?1:-1)+s[i]*(1==(e>>2&1)?1:-1);l[i]=Math.min(l[i],r),u[i]=Math.max(u[i],r)}let h=[];for(let e=0;e<8;e++){let i=[...t];R(i,i,L([],n,1&~e?-1:1)),R(i,i,L([],o,1==(e>>1&1)?1:-1)),R(i,i,L([],s,1==(e>>2&1)?1:-1)),h.push(i)}return new e(h,[[...n,-j(n,h[0])],[...o,-j(o,h[0])],[...s,-j(s,h[0])],[-n[0],-n[1],-n[2],-j(n,h[7])],[-o[0],-o[1],-o[2],-j(o,h[7])],[-s[0],-s[1],-s[2],-j(s,h[7])]],l,u)}intersectsFrustum(e){let t=!0,i=this.points.length,r=this.planes.length,a=e.planes.length,n=e.points.length;for(let r=0;r<a;r++){let a=e.planes[r],n=0;for(let e=0;e<i;e++){let t=this.points[e];a[0]*t[0]+a[1]*t[1]+a[2]*t[2]+a[3]>=0&&n++}if(0===n)return 0;n<i&&(t=!1)}if(t)return 2;for(let t=0;t<r;t++){let i=this.planes[t],r=0;for(let t=0;t<n;t++){let a=e.points[t];i[0]*a[0]+i[1]*a[1]+i[2]*a[2]+i[3]>=0&&r++}if(0===r)return 0}return 1}intersectsPlane(e){let t=this.points.length,i=0;for(let r=0;r<t;r++){let t=this.points[r];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&i++}return i===t?2:0===i?0:1}};function Zv(e,t,i){let r=e-t;return r<0?-r:Math.max(0,r-i)}function qv(e,t,i,r,a){let n,o=e-i;return n=o<0?Math.min(-o,1+o-a):o>a?Math.min(Math.max(o-a,0),1-o):0,Math.max(n,Zv(t,r,a))}var Wv=class{constructor(){this._boundingVolumeCache=new $v(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){let a=1<<i.z,n=1/a,o=i.x/a,s=i.y/a,l=2;return l=Math.min(l,qv(e,t,o,s,n)),l=Math.min(l,qv(e,t,o+.5,-s-n,n)),l=Math.min(l,qv(e,t,o+.5,2-s-n,n)),l}getWrap(e,t,i){let r=1<<t.z,a=1/r,n=t.x/r,o=Zv(e.x,n,a),s=Zv(e.x,n-1,a),l=Zv(e.x,n+1,a),u=Math.min(o,s,l);return u===l?1:u===s?-1:0}allowVariableZoom(e,t){return Gy(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,r)}_computeTileBoundingVolume(e,t,i,r){let a=Math.min(0,i),n=Math.max(0,i);if(r?.terrain){let i=new sf(e.z,t,e.z,e.x,e.y),o=r.terrain.getMinMaxElevation(i);a=o.minElevation??a,n=Math.max(o.maxElevation??n,n)}if(a/=Oh,n/=Oh,a+=1,n+=1,e.z<=0)return Gv.fromAabb([-n,-n,-n],[n,n,n]);if(1===e.z)return Gv.fromAabb([0===e.x?-n:0,0===e.y?0:-n,-n],[0===e.x?0:n,0===e.y?n:0,n]);{let t=[Mv(0,0,e.x,e.y,e.z),Mv(re,0,e.x,e.y,e.z),Mv(re,re,e.x,e.y,e.z),Mv(0,re,e.x,e.y,e.z)],i=[];for(let e of t)i.push(L([],e,n));if(n!==a)for(let e of t)i.push(L([],e,a));0===e.y&&i.push([0,1,0]),e.y===(1<<e.z)-1&&i.push([0,-1,0]);let r=[1,1,1],o=[-1,-1,-1];for(let e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);let s=Mv(re/2,re/2,e.x,e.y,e.z),l=V([],[0,1,0],s);O(l,l);let u=V([],s,l);O(u,u);let h=V([],t[2],t[1]);O(h,h);let c=V([],t[0],t[3]);O(c,c),i.push(L([],s,n)),e.y>=(1<<e.z)/2&&i.push(L([],Mv(re/2,0,e.x,e.y,e.z),n)),e.y<(1<<e.z)/2&&i.push(L([],Mv(re/2,re,e.x,e.y,e.z),n));let d=Xv(s,i),p=Xv(u,i),f=[-s[0],-s[1],-s[2],d.max],m=[s[0],s[1],s[2],-d.min],g=[-u[0],-u[1],-u[2],p.max],_=[u[0],u[1],u[2],-p.min],y=[...h,0],x=[...c,0],v=[];return 0===e.y?v.push(pe(x,y,f),pe(x,y,m)):v.push(pe(g,y,f),pe(g,y,m),pe(g,x,f),pe(g,x,m)),e.y===(1<<e.z)-1?v.push(pe(x,y,f),pe(x,y,m)):v.push(pe(_,y,f),pe(_,y,m),pe(_,x,f),pe(_,x,m)),new Gv(v,[f,m,g,_,y,x],r,o)}}};function Xv(e,t){let i=1/0,r=-1/0;for(let a of t){let t=j(e,a);i=Math.min(i,t),r=Math.max(r,t)}return{min:i,max:r}}var Hv=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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._cachedClippingPlane=oe(),this._projectionMatrix=ue(),this._globeViewProjMatrix32f=he(),this._globeViewProjMatrixF64=ue(),this._globeViewProjMatrixF64Inverted=ue(),this._globeProjMatrixInverted=ue(),this._cameraPosition=se(),this.defaultConstrain=(e,t)=>{let i=De(e.lat,-He,He),r=De(+t,this.minZoom+jv(0,i),this.maxZoom);return{center:new jh(e.lng,i),zoom:r}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new uv({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Wv}clone(){let t=new e;return t.apply(this,!1),t}apply(e,t){this._helper.apply(e,t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let e=se();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){let{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!i,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:0===t?.canonical.z}}_computeClippingPlane(e){let t=this.pitchInRadians,i=this.cameraToCenterDistance/e,r=Math.sin(t)*i,a=Math.cos(t)*i+1,n=1/Math.sqrt(r*r+a*a)*1,o=-r,s=a,l=Math.sqrt(o*o+s*s);o/=l,s/=l;let u=[0,o,s];G(u,u,[0,0,0],-this.bearingInRadians),U(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),$(u,u,[0,0,0],this.center.lng*Math.PI/180);let h=1/z(u);return L(u,u,h),[...u,-n*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(zv(e))}transformLightDirection(e){let t=this._helper._center.lng*Math.PI/180,i=this._helper._center.lat*Math.PI/180,r=Math.cos(i),a=[Math.sin(t)*r,Math.sin(i),Math.cos(t)*r],n=[a[2],0,-a[0]],o=[0,0,0];V(o,n,a),O(n,n),O(o,o);let s=[0,0,0];return O(s,[n[0]*e[0]+o[0]*e[1]+a[0]*e[2],n[1]*e[0]+o[1]*e[1]+a[1]*e[2],n[2]*e[0]+o[2]*e[1]+a[2]*e[2]]),s}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,t,i){let r=Yh(e,t,i.canonical),a=function(e,t){return[ye(e*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-.5*Math.PI]}(r.x,r.y);return this.getCircleRadiusCorrection()/Math.cos(a[1])}projectTileCoordinates(e,t,i,r){let a,n=i.canonical,o=Mv(e,t,n.x,n.y,n.z),s=1+(r??0)/Oh,l=o[0]*s,u=o[1]*s,h=o[2]*s,d=[l,u,h,1];if(W(d,d,this._globeViewProjMatrixF64),s<=1){let e=this._cachedClippingPlane;a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2]+e[3]<0}else a=this._isLineOfSightBlocked(l,u,h);return{point:new c(d[0]/d[3],d[1]/d[3]),signedDistanceFromCamera:d[3],isOccluded:a}}_isLineOfSightBlocked(e,t,i){let r=this._cameraPosition,a=e-r[0],n=t-r[1],o=i-r[2],s=a*a+n*n+o*o;if(0===s)return!1;let l=De(-(r[0]*a+r[1]*n+r[2]*o)/s,0,1),u=r[0]+l*a,h=r[1]+l*n,c=r[2]+l*o;return u*u+h*h+c*c<1}_calcMatrices(){let e=Fv(this.worldSize,this.center.lat),t=le();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),I(t,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;t[8]=2*-i.x/this._helper._width,t[9]=2*i.y/this._helper._height,this._projectionMatrix=x(t),this._globeProjMatrixInverted=le(),b(this._globeProjMatrixInverted,t),T(t,t,[0,0,-this.cameraToCenterDistance]),P(t,t,this.rollInRadians),E(t,t,-this.pitchInRadians),P(t,t,this.bearingInRadians),T(t,t,[0,0,-e]);let r=se();r[0]=e,r[1]=e,r[2]=e,E(t,t,this.center.lat*Math.PI/180),S(t,t,-this.center.lng*Math.PI/180),D(t,t,r),this._globeViewProjMatrixF64=t,this._globeViewProjMatrix32f=new Float32Array(t),this._globeViewProjMatrixF64Inverted=le(),b(this._globeViewProjMatrixF64Inverted,t);let a=se();this._cameraPosition=se(),this._cameraPosition[2]=this.cameraToCenterDistance/e,G(this._cameraPosition,this._cameraPosition,a,-this.rollInRadians),U(this._cameraPosition,this._cameraPosition,a,this.pitchInRadians),G(this._cameraPosition,this._cameraPosition,a,-this.bearingInRadians),R(this._cameraPosition,this._cameraPosition,[0,0,1]),U(this._cameraPosition,this._cameraPosition,a,-this.center.lat*Math.PI/180),$(this._cameraPosition,this._cameraPosition,a,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);let n=x(this._globeViewProjMatrixF64Inverted);D(n,n,[1,1,-1]),this._cachedFrustum=jy.fromInvProjectionMatrix(n,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){Oe("calculateFogMatrix is not supported on globe projection.");let t=le();return v(t),t}getVisibleUnwrappedCoordinates(e){return[new of(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e?Oe("terrain is not fully supported on vertical perspective projection."):this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(z(this._cameraPosition)-1)*Oh}getCameraLngLat(){let e=se();return O(e,this._cameraPosition),kv(e)}lngLatToCameraDepth(e,t){let i=zv(e);L(i,i,1+t/Oh);let r=oe();return W(r,[i[0],i[1],i[2],1],this._globeViewProjMatrixF64),r[2]/r[3]}populateCache(e){}getBounds(){let e=.5*this.width,t=.5*this.height,i=[new c(0,0),new c(e,0),new c(this.width,0),new c(this.width,t),new c(this.width,this.height),new c(e,this.height),new c(0,this.height),new c(0,t)],r=[];for(let e of i)r.push(this.unprojectScreenPoint(e));let a=0,n=0,o=0,s=0,l=this.center;for(let e of r){let t=ge(l.lng,e.lng),i=ge(l.lat,e.lat);t<n&&(n=t),t>a&&(a=t),i<s&&(s=i),i>o&&(o=i)}let u=[l.lng+n,l.lat+s,l.lng+a,l.lat+o];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new ny(u)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}calculateCameraOptionsFromTo(e,t,i,r){let a=jh.convert(i),n=zv(jh.convert(e));L(n,n,1+t/Oh);let o=zv(a),s=L(se(),o,1+r/Oh),l=k(se(),n,o),u=z(l);if(u<1e-12||function(e,t){var i=t[0]-e[0],r=t[1]-e[1],a=t[2]-e[2];return Math.sqrt(i*i+r*r+a*a)}(n,s)<1e-12)throw Error("Can't calculate camera options with same From and To");let h=se();$(l,l,h,-Ge(a.lng)),U(l,l,h,Ge(a.lat));let c=Ze(Math.acos(De(l[2]/u,-1,1))),d=Math.hypot(l[0],l[1])<1e-9*u?this.bearing:Ze(Math.atan2(-l[0],-l[1]));return{center:a,elevation:r,zoom:Me(this.cameraToCenterDistance/u/Fv(this.tileSize,a.lat)),pitch:c,bearing:d}}setLocationAtPoint(e,t,i){let r=zv(this.unprojectScreenPoint(t)),a=zv(e),n=se();!function(e){e[0]=0,e[1]=0,e[2]=0}(n);let o=se();$(o,r,n,-this.center.lng*Math.PI/180),U(o,o,n,this.center.lat*Math.PI/180);let s=a[0]*a[0]+a[2]*a[2],l=o[0]*o[0];if(s<l)return;let u=Math.sqrt(s-l),h=-u,c=me(a[0],a[2],o[0],u),d=me(a[0],a[2],o[0],h),p=se();$(p,a,n,-c);let f=me(p[1],p[2],o[1],o[2]),m=se();$(m,a,n,-d);let g,_,y=me(m[1],m[2],o[1],o[2]),x=.5*Math.PI,v=f>=-x&&f<=x,b=y>=-x&&y<=x;if(v&&b){let e=this.center.lng*Math.PI/180,t=this.center.lat*Math.PI/180;_e(c,e)+_e(f,t)<_e(d,e)+_e(y,t)?(g=c,_=f):(g=d,_=y)}else if(v)g=c,_=f;else{if(!b)return;g=d,_=y}let w=g/Math.PI*180,T=_/Math.PI*180,D=this.center.lat;this.setCenter(new jh(w,De(T,-90,90))),this.setZoom(this.zoom+jv(D,this.center.lat))}locationToScreenPoint(e,t){let i=zv(e);return t&&L(i,i,1+t.getElevationForLngLatZoom(e,this._helper._tileZoom)/Oh),this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(e){let t=oe();return W(t,[...e,1],this._globeViewProjMatrixF64),t[0]/=t[3],t[1]/=t[3],new c((.5*t[0]+.5)*this.width,(.5*-t[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,t){if(t){let i=this.screenTerrainPointToMercatorCoordinate(e,t);if(i)return i}return Xh.fromLngLat(this.unprojectScreenPoint(e))}screenTerrainPointToMercatorCoordinate(e,t){let i=t.getCoverageIndex();if(!i)return null;let r=this.cameraPosition,a=this.getRayDirectionFromPixel(e),n=Uv(r,a,1+i.maxElevation/Oh);if(!n)return null;let o=Uv(r,a,1+i.minElevation/Oh),s=Math.max(n.tMin,0),l=o?o.tMin:n.tMax;if(l<=s)return null;let u={index:i,exaggeration:t.exaggeration,origin:r,direction:a},h=0;for(let e=0;e<=256;e++){let t=s+(l-s)*e/256;if(Kv(u,t)){let{hi:e}=yv(u,Kv,h,t,1e-12),{sample:i,mercator:r}=Yv(u,e);return new Xh(r.x,r.y,i.elevation)}h=t}return null}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToLocationAtElevation(e,t){return this.screenPointToLocation(e)}isPointOnMapSurface(e,t){return!!Uv(this._cameraPosition,this.getRayDirectionFromPixel(e))}getRayDirectionFromPixel(e){let t=oe();t[0]=e.x/this.width*2-1,t[1]=-1*(e.y/this.height*2-1),t[2]=1,t[3]=1,W(t,t,this._globeViewProjMatrixF64Inverted),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3];let i=se();i[0]=t[0]-this._cameraPosition[0],i[1]=t[1]-this._cameraPosition[1],i[2]=t[2]-this._cameraPosition[2];let r=se();return O(r,i),r}isSurfacePointVisible(e){let t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;let t=oe();return W(t,[...e,1],this._globeViewProjMatrixF64),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3],t[0]>-1&&t[0]<1&&t[1]>-1&&t[1]<1&&t[2]>-1&&t[2]<1}unprojectScreenPoint(e){let t=this._cameraPosition,i=this.getRayDirectionFromPixel(e),r=Uv(t,i);if(r){let e=se();R(e,t,[i[0]*r.tMin,i[1]*r.tMin,i[2]*r.tMin]);let a=se();return O(a,e),kv(a)}let a=this._cachedClippingPlane,n=a[0]*i[0]+a[1]*i[1]+a[2]*i[2],o=-de(a,t)/n,s=se();if(o>0)R(s,t,[i[0]*o,i[1]*o,i[2]*o]);else{let e=se();R(e,t,[2*i[0],2*i[1],2*i[2]]);let r=de(this._cachedClippingPlane,e);Z(s,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}let l=function(e){let t=se();return t[0]=e[0]*-e[3],t[1]=e[1]*-e[3],t[2]=e[2]*-e[3],{center:t,radius:Math.sqrt(1-e[3]*e[3])}}(a);return kv(function(e,t,i){let r=se();Z(r,i,e);let a=se();return B(a,e,r,t/q(r)),a}(l.center,l.radius,s))}getProjectionDataForCustomLayer(e=!0){let t=this.getProjectionData({overscaledTileID:new sf(0,0,0,0,0),applyGlobeMatrix:e});return t.tileMercatorCoords=[0,0,1,1],t}getFastPathSimpleProjectionMatrix(e){}};function Yv(e,t){let i=se();B(i,e.origin,e.direction,t);let r=z(i),a=se();L(a,i,1/r);let n=kv(a),o=Xh.fromLngLat(n),s=new Xh(o.x,De(o.y,0,.999999999)),l=gv(e.index,e.exaggeration,s.x,s.y),u=Math.abs(n.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:u},radius:r,mercator:s}}function Kv(e,t){let{sample:i,radius:r}=Yv(e,t);return _v(i,(r-1)*Oh)}var Jv=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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}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(e){this._globeness=e,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new uv({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new xv,this._verticalPerspectiveTransform=new Hv}clone(){let t=new e;return t._globeness=this._globeness,t.apply(this,!1),t}apply(e,t){this._helper.apply(e,t),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(e){let t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix,clipAntimeridian:i.clipAntimeridian}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return ve(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return ve(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,t,i){return ve(this._mercatorTransform.getPitchedTextCorrection(e,t,i),this._verticalPerspectiveTransform.getPitchedTextCorrection(e,t,i),this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_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(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this.currentTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}calculateCameraOptionsFromTo(e,t,i,r){return this.currentTransform.calculateCameraOptionsFromTo(e,t,i,r)}setLocationAtPoint(e,t,i){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t,i),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t,i),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenTerrainPointToMercatorCoordinate(e,t){return this.currentTransform.screenTerrainPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}screenPointToLocationAtElevation(e,t){return this.currentTransform.screenPointToLocationAtElevation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getProjectionDataForCustomLayer(e=!0){let t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;let i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i.projectionTransition=this._globeness,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}},Qv=class e{get useGlobeControls(){return!0}handlePanInertia(e,t){let i=function(e,t){let i=e.rotate(t.bearingInRadians),r=t.zoom+jv(t.center.lat,0),a=ve(1/Ov(t.center.lat),1/Ov(Math.min(Math.abs(t.center.lat),60)),xe(r,7,3,0,1)),n=function(e,t){return 360/Cv({worldSize:e,center:{lat:t}})}(t.worldSize,t.center.lat);return new jh(t.center.lng-i.x*n*a,De(t.center.lat+i.y*n,-He,He))}(e,t);return Math.abs(i.lng-t.center.lng)>180&&(i.lng=t.center.lng+179.5*Math.sign(i.lng-t.center.lng)),{easingCenter:i,easingOffset:new c(0,0)}}handleMapControlsRollPitchBearingZoom(e,t){let i=e.around,r=t.screenPointToLocation(i);e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta);let a=t.zoom;e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);let n=t.zoom-a;if(0===n)return;let o=ge(t.center.lng,r.lng),s=o/(Math.abs(o/180)+1),l=ge(t.center.lat,r.lat),u=t.getRayDirectionFromPixel(i),h=t.cameraPosition,c=-1*j(h,u),d=se();R(d,h,[u[0]*c,u[1]*c,u[2]*c]);let p=z(d),f=p-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=xe(p,.95,.999,0,1),_=xe(Fv(t.worldSize,t.center.lat)/Math.min(t.width,t.height),.9,.5,1,.25),y=Math.min(m,ve(1,_,g)),x=(1-Ce(-n))*y,v=t.center.lat,b=t.zoom,w=new jh(t.center.lng+s*x,De(t.center.lat+l*x,-He,He));t.setLocationAtPoint(r,i);let T=t.center,D=xe(Math.abs(o),45,85,0,1),E=Math.max(D,g)**.25,S=ge(T.lng,w.lng),P=ge(T.lat,w.lat);t.setCenter(new jh(T.lng+S*E,T.lat+P*E).wrap()),t.setZoom(b+jv(v,t.center.lat))}handleMapControlsPan(e,t,i){e.panDelta&&function(e,t,i,r,a=!0){let n=Bv(e,i),o=t;if(r)o=Bv(e,i.sub(r));else if(!e.isPointOnMapSurface(i))return;let s=zv(n),l=zv(o),u=function(e,t){return H(oe(),-e.lng,-e.lat,t)}(e.center,e.bearing),h=V(se(),l,s),c=Math.sqrt(j(h,h)),d=Math.acos(De(j(l,s),-1,1))/2,p=Math.sin(d),f=c?Y(h[1]/c*p,-h[0]/c*p,h[2]/c*p,Math.cos(d)):Y(0,0,0,1),{lng:m,lat:g,bearing:_}=function(e){let t=e[0],i=e[1],r=e[2],a=e[3];return{lng:180*-Math.atan2(2*(a*t+i*r),1-2*(t*t+i*i))/Math.PI,lat:180*-Math.asin(De(2*(a*i-r*t),-1,1))/Math.PI,bearing:180*Math.atan2(2*(a*r+t*i),1-2*(i*i+r*r))/Math.PI}}(function(e,t,i){var r=t[0],a=t[1],n=t[2],o=t[3],s=i[0],l=i[1],u=i[2],h=i[3];return e[0]=r*h+o*s+a*u-n*l,e[1]=a*h+o*l+n*s-r*u,e[2]=n*h+o*u+r*l-a*s,e[3]=o*h-r*s-a*l-n*u,e}(oe(),u,f)),y=e.center.lat,x=e.zoom,v=De(g,-90,90),b=a?function(e,t,i,r){let a=e.center.lng,n=e.center.lat,o=n>=0?90:-90,s=e.locationToScreenPoint(new jh(0,o)),l=t.x-s.x,u=t.y-s.y,h=l*l+u*u,c=De(1-(He-Math.abs(n))/12,0,1),d=c*c*(3-2*c),p=ye(r-a+180,360)-180,f=0;return d>0&&i&&(f=(o>0?1:-1)*((l*i.y-u*i.x)/Math.max(h,400))*180/Math.PI),a+(1-d)*p+d*f}(e,i,r,m):m;e.setCenter(new jh(Ee(b,-180,180),v)),a||e.setBearing(_),e.setZoom(x+jv(y,e.center.lat))}(t,i,t.isPointOnMapSurface(e.around)?e.around:t.centerPoint,e.panDelta)}cameraForBoxAndBearing(t,i,r,a,n){let o=Dv(t,i,r,a,n),s=i.left/n.width*2-1,l=(n.width-i.right)/n.width*2-1,u=i.top/n.height*-2+1,h=(n.height-i.bottom)/n.height*-2+1,c=ge(r.getWest(),r.getEast())<0,d=c?r.getEast():r.getWest(),p=c?r.getWest():r.getEast(),f=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),g=d+.5*ge(d,p),_=f+.5*ge(f,m),y=n.clone();y.setCenter(o.center),y.setBearing(o.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(o.zoom);let x=y.modelViewProjectionMatrix,v=[zv(r.getNorthWest()),zv(r.getNorthEast()),zv(r.getSouthWest()),zv(r.getSouthEast()),zv(new jh(p,_)),zv(new jh(d,_)),zv(new jh(g,f)),zv(new jh(g,m))],b=zv(o.center),w=1/0;for(let t of v)s<0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(t,b,x,"x",s))),l>0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(t,b,x,"x",l))),u>0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(t,b,x,"y",u))),h<0&&(w=e.getLesserNonNegativeNonNull(w,e.solveVectorScale(t,b,x,"y",h)));if(Number.isFinite(w)&&0!==w)return o.zoom=Math.min(y.zoom+Me(w),t.maxZoom),o;wv()}handleJumpToCenterZoom(e,t){let i=e.center.lat,r=e.applyConstrain(t.center?jh.convert(t.center):e.center,e.zoom).center;e.setCenter(r.wrap());let a=void 0===t.zoom?e.zoom+jv(i,r.lat):+t.zoom;e.zoom!==a&&e.setZoom(a)}handleEaseTo(e,t){let i=e.zoom,r=e.center,a=e.padding,n={roll:e.roll,pitch:e.pitch,bearing:e.bearing},o={roll:void 0===t.roll?e.roll:t.roll,pitch:void 0===t.pitch?e.pitch:t.pitch,bearing:void 0===t.bearing?e.bearing:t.bearing},s=void 0!==t.zoom,l=!e.isPaddingEqual(t.padding),u=!1,h=t.center?jh.convert(t.center):r,d=e.applyConstrain(h,i).center;sv(e,d);let p=e.clone();p.setCenter(d),p.setZoom(s?+t.zoom:i+jv(r.lat,h.lat)),p.setBearing(t.bearing);let f=new c(De(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),De(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);let m=(t.offset&&t.offsetAsPoint.mag())>0?p.center:d,g=s?+t.zoom:i+jv(r.lat,m.lat),_=i+jv(r.lat,0),y=g+jv(m.lat,0),x=ge(r.lng,m.lng),v=ge(r.lat,m.lat),b=Ce(y-_);return u=g!==i,{easeFunc:i=>{if(qe(n,o)||Tv({startEulerAngles:n,endEulerAngles:o,tr:e,k:i,useSlerp:n.roll!=o.roll}),l&&e.interpolatePadding(a,t.padding,i),t.around)Oe("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(t.around,t.aroundPoint);else{let t=i*(y>_?Math.min(2,b):Math.max(.5,b))**(1-i),a=Nv(r,x,v,t);e.setCenter(a.wrap())}if(u){let t=Oi.number(_,y,i)+jv(0,e.center.lat);e.setZoom(t)}},isZooming:u,elevationCenter:m}}handleFlyTo(e,t){let i=void 0!==t.zoom,r=e.center,a=e.zoom,n=e.padding,o=!e.isPaddingEqual(t.padding),s=e.applyConstrain(jh.convert(t.center||t.locationAtOffset),a).center,l=i?+t.zoom:e.zoom+jv(e.center.lat,s.lat),u=e.clone();u.setCenter(s),u.setZoom(l),u.setBearing(t.bearing);let h=new c(De(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),De(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(s,h);let d=u.center;sv(e,d);let p=function(e,t,i){let r=j(zv(t),zv(i)),a=Math.acos(r),n=Cv(e);return a/(2*Math.PI)*n}(e,r,d),f=a+jv(r.lat,0),m=l+jv(d.lat,0),g=Ce(m-f),_="number"==typeof t.minZoom?+t.minZoom:e.minZoom,y=Math.max(_,e.minZoom)+jv(d.lat,0),x=Math.min(y,f,m)+jv(0,d.lat),v=Ce(e.applyConstrain(d,x).zoom+jv(d.lat,0)-f),b=ge(r.lng,d.lng),w=ge(r.lat,d.lat);return{easeFunc:(i,a,s,u)=>{let h=Nv(r,b,w,s);o&&e.interpolatePadding(n,t.padding,i);let c=1===i?d:h;e.setCenter(c.wrap());let p=f+Me(a);e.setZoom(1===i?l:p+jv(0,c.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:v,pixelPathLength:p}}static solveVectorScale(e,t,i,r,a){let n=a,o="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],l=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],u=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],h=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],c=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return h+n*u===l+n*c||s[3]*(l-h)+o[3]*(c-u)+l*c===h*u?null:(h+o[3]-n*c-n*s[3])/(h-l-n*c+n*u)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&t<e?t:e}},eb=class{constructor(e){this._globe=e,this._mercatorCameraHelper=new Ev,this._verticalPerspectiveCameraHelper=new Qv}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,i){this.currentHelper.handleMapControlsPan(e,t,i)}cameraForBoxAndBearing(e,t,i,r,a){return this.currentHelper.cameraForBoxAndBearing(e,t,i,r,a)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}};const tb=function(){let e={},t=vt.$version;for(let i in vt.$root){let r=vt.$root[i];if(r.required){let a=null;a="version"===i?t:"array"===r.type?[]:{},null!=a&&(e[i]=a)}}return e}();var ib=class extends yt{constructor(e,t={}){super(),this._rtlPluginLoaded=()=>{for(let e in this.tileManagers){let t=this.tileManagers[e].getSource().type;("vector"===t||"geojson"===t)&&this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new J_(K_(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new D_,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new E_(this.imageManager);let i=e._container?.lang||typeof document<"u"&&document.documentElement?.lang||void 0;this.glyphManager=new V_(e._requestManager,t.localIdeographFontFamily,i),this.lineAtlas=new Z_(256,512),this.crossTileSymbolIndex=new Qx,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",ut()),Ry().on(My,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;let t=this.tileManagers[e.sourceId];if(!t)return;let i=t.getSource();if(i?.vectorLayerIds)for(let e in this._layers){let t=this._layers[e];t.source===i.id&&this._validateLayer(t)}})}_setInitialValues(){this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new oo,this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,t){this._checkLoaded();let i=null===t?this.stylesheet.state?.[e]?.default??null:t;if(ke(i,this._globalState[e]))return this;this._globalState[e]=i,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t=[];for(let i in e)ke(this._globalState[i],e[i].default)||(t.push(i),this._globalState[i]=e[i].default);this._applyGlobalStateChanges(t)}_applyGlobalStateChanges(e){if(0===e.length)return;let t=new Set,i={};for(let r of e){i[r]=this._globalState[r];for(let e in this._layers){let i=this._layers[e],a=i.getLayoutAffectingGlobalStateRefs(),n=i.getPaintAffectingGlobalStateRefs(),o=i.getVisibilityAffectingGlobalStateRefs();if(a.has(r)&&t.add(i.source),n.has(r))for(let{name:e,value:t}of n.get(r))this._updatePaintProperty(i,e,t);o?.has(r)&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(let e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}async loadURL(e,t={},i){this.fire(new t_("dataloading")),t.validate="boolean"!=typeof t.validate||t.validate,this._loadStyleRequest=new AbortController;let r=this._loadStyleRequest;try{let a=await this.map._requestManager.transformRequest(e,"Style");at(r.signal);let n=await ct(a,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(n.data,t,i)}catch(e){this._loadStyleRequest===r&&(this._loadStyleRequest=null),e&&!r.signal.aborted&&this.fire(new _t(ne(e)))}}loadJSON(e,t={},i){this.fire(new t_("dataloading")),this._frameRequest=new AbortController,qg.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,t.validate=!1!==t.validate,this._load(e,t,i)}).catch(()=>{})}loadEmpty(){this.fire(new t_("dataloading")),this._load(tb,{validate:!1})}_load(e,t,i){let r=t.transformStyle?t.transformStyle(i,e):e;if(!t.validate||!Hn(this,r)){r={...r},this._loaded=!0,this.stylesheet=r;for(let e in r.sources)this.addSource(e,r.sources[e],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this.glyphManager.setFontFaces(r["font-faces"]),this._createLayers(),this.light=new U_(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new G_(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new t_("data")),this.fire(new e_)}}_createLayers(){let e=d_(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",e),this._order=e.map(e=>e.id),this._layers={},this._serializedLayers=null;for(let t of e){let e=Qp(t,this._globalState);if(e.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=e,Co(e)&&this.tileManagers[e.source]){let i=t.paint?.["raster-fade-duration"]??e.paint.get("raster-fade-duration");this.tileManagers[e.source].setRasterFadeDuration(i)}}}async _loadSprite(e,t=!1,i=void 0){this.imageManager.setLoaded(!1);let r,a=new AbortController;this._spriteRequest=a;try{let i=await async function(e,t,i,r){let a=w_(e),n=i>1?"@2x":"",o={},s={};for(let{id:e,url:i}of a){let a=await t.transformRequest(T_(i,n,".json"),"SpriteJSON");o[e]=ct(a,r);let l=await t.transformRequest(T_(i,n,".png"),"SpriteImage");s[e]=Yg.getImage(l,r)}return await Promise.all([...Object.values(o),...Object.values(s)]),async function(e,t){let i={};for(let r in e){i[r]={};let a=(await t[r]).data;if(!a)throw Error(`Could not load sprite image for ${r}: the response is empty`);let n=qg.getImageCanvasContext(a),o=(await e[r]).data;for(let e in o){let{width:t,height:a,x:s,y:l,sdf:u,pixelRatio:h,stretchX:c,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e],g={width:t,height:a,x:s,y:l,context:n};i[r][e]={data:null,pixelRatio:h,sdf:u,stretchX:c,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:g}}}return i}(o,s)}(e,this.map._requestManager,this.map.getPixelRatio(),a);if(!i)return;for(let e in i){let{loaded:r,removed:a}=this.imageManager.setSpriteImages(e,i[e]);this._markImagesChanged(a),t&&this._markImagesChanged(r)}}catch(e){r=e,a.signal.aborted||this.fire(new _t(r))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new t_("data")),i?.(r)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new t_("data"))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let i=e.sourceLayer;if(!i)return;let r=t.getSource();("geojson"===r.type||r.vectorLayerIds&&!r.vectorLayerIds.includes(i))&&this.fire(new _t(Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,t=!1){let i=this._serializedAllLayers();if(!e||0===e.length)return Object.values(t?Le(i):i);let r=[];for(let a of e)if(i[a]){let e=t?Le(i[a]):i[a];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let i of t){let t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading.")}update(e){if(!this._loaded)return;let t=this._changed;if(t){this._imagesListDirty&&=(this.dispatcher.broadcast("SI",this.imageManager.listImages()),!1);let t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(let e in this._updatedSources){let t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this._resetUpdates()}let i={};for(let e in this.tileManagers){let t=this.tileManagers[e];i[e]=t.used,t.used=!1}let r=this.imageManager.listImages();for(let t of this._order){let i=this._layers[t];i.recalculate(e,r),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(let e in i){let t=this.tileManagers[e];!!i[e]!=!!t.used&&t.fire(new i_("data",{sourceDataType:"visibility",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,t&&this.fire(new t_("data"))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){this._checkLoaded();let i=this.serialize();if(e=t.transformStyle?t.transformStyle(i,e):e,(t.validate??1)&&Hn(this,e))return!1;(e=Le(e)).layers=d_(e.layers);let r=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!p_(e.version,t.version))return[{command:"setStyle",args:[t]}];p_(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),p_(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),p_(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),p_(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),p_(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),p_(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),p_(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),p_(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),p_(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),p_(e["font-faces"],t["font-faces"])||i.push({command:"setFontFaces",args:[t["font-faces"]]}),p_(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),p_(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),p_(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),p_(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),p_(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});let r={},a=[];!function(e,t,i,r){let a;for(a in e||={},t||={},e)Object.prototype.hasOwnProperty.call(e,a)&&(Object.prototype.hasOwnProperty.call(t,a)||g_(a,i,r));for(a in t)Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)?p_(e[a],t[a])||("geojson"===e[a].type&&"geojson"===t[a].type&&y_(e,t,a)?f_(i,{command:"setGeoJSONSourceData",args:[a,t[a].data]}):__(a,t,i,r)):m_(a,t,i))}(e.sources,t.sources,a,r);let n=[];e.layers&&e.layers.forEach(e=>{"source"in e&&r[e.source]?i.push({command:"removeLayer",args:[e.id]}):n.push(e)}),i=i.concat(a),function(e,t,i){e||=[],t||=[];let r,a,n,o,s,l=e.map(v_),u=t.map(v_),h=e.reduce(b_,{}),c=t.reduce(b_,{}),d=l.slice(),p=Object.create(null);for(let e=0,t=0;e<l.length;e++)r=l[e],Object.prototype.hasOwnProperty.call(c,r)?t++:(f_(i,{command:"removeLayer",args:[r]}),d.splice(d.indexOf(r,t),1));for(let e=0,t=0;e<u.length;e++)r=u[u.length-1-e],d[d.length-1-e]!==r&&(Object.prototype.hasOwnProperty.call(h,r)?(f_(i,{command:"removeLayer",args:[r]}),d.splice(d.lastIndexOf(r,d.length-t),1)):t++,o=d[d.length-e],f_(i,{command:"addLayer",args:[c[r],o]}),d.splice(d.length-e,0,r),p[r]=!0);for(let e=0;e<u.length;e++)if(r=u[e],a=h[r],n=c[r],!p[r]&&!p_(a,n)){if(!p_(a.source,n.source)||!p_(a["source-layer"],n["source-layer"])||!p_(a.type,n.type)){f_(i,{command:"removeLayer",args:[r]}),o=d[d.lastIndexOf(r)+1],f_(i,{command:"addLayer",args:[n,o]});continue}for(s in x_(a.layout,n.layout,i,r,null,"setLayoutProperty"),x_(a.paint,n.paint,i,r,null,"setPaintProperty"),p_(a.filter,n.filter)||f_(i,{command:"setFilter",args:[r,n.filter]}),(!p_(a.minzoom,n.minzoom)||!p_(a.maxzoom,n.maxzoom))&&f_(i,{command:"setLayerZoomRange",args:[r,n.minzoom,n.maxzoom]}),a)Object.prototype.hasOwnProperty.call(a,s)&&"layout"!==s&&"paint"!==s&&"filter"!==s&&"metadata"!==s&&"minzoom"!==s&&"maxzoom"!==s&&(0===s.indexOf("paint.")?x_(a[s],n[s],i,r,s.slice(6),"setPaintProperty"):p_(a[s],n[s])||f_(i,{command:"setLayerProperty",args:[r,s,n[s]]}));for(s in n)Object.prototype.hasOwnProperty.call(n,s)&&!Object.prototype.hasOwnProperty.call(a,s)&&"layout"!==s&&"paint"!==s&&"filter"!==s&&"metadata"!==s&&"minzoom"!==s&&"maxzoom"!==s&&(0===s.indexOf("paint.")?x_(a[s],n[s],i,r,s.slice(6),"setPaintProperty"):p_(a[s],n[s])||f_(i,{command:"setLayerProperty",args:[r,s,n[s]]}))}}(n,t.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:"setStyle",args:[t]}]}return i}(i,e),a=this._getOperationsToPerform(r);if(a.unimplemented.length>0)throw Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(0===a.operations.length)return!1;for(let e of a.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new e_({style:this})),!0}_getOperationsToPerform(e){let t=[],i=[];for(let r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,r.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,r.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,r.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,r.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,r.args));break;case"addSource":t.push(()=>this.addSource.apply(this,r.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,r.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,r.args));break;case"setLight":t.push(()=>this.setLight.apply(this,r.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,r.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,r.args));break;case"setFontFaces":t.push(()=>this.setFontFaces.apply(this,r.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,r.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,r.args));break;case"setSky":t.push(()=>this.setSky.apply(this,r.args));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,r.args));break;case"setTransition":t.push(()=>{});break;default:i.push(r.command)}return{operations:t,unimplemented:i}}addImage(e,t){this.getImage(e)?this.fire(new _t(Error(`An image named "${e}" already exists.`))):(this.imageManager.addImage(e,t),this._afterImageUpdated(e))}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}setMissingImageResolver(e){this.imageManager.setMissingImageResolver(e)}removeImage(e){this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e)):this.fire(new _t(Error(`An image named "${e}" does not exist.`)))}_markImagesChanged(e){for(let t of e)this._changedImages[t]=!0}_afterImageUpdated(e){this._changedImages[e]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new t_("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,i={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw Error(`Source "${e}" already exists.`);if(!t.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(Xn.has(t.type)&&this._validate(Wn.source,`sources.${e}`,t,null,i))return;this.map?._collectResourceTiming&&(t.collectResourceTiming=!0);let r=this.tileManagers[e]=new Qy(e,t,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw Error(`There is no source with this ID=${e}`);for(let t in this._layers)if(this._layers[t].source===e)return this.fire(new _t(Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new i_("data",{sourceDataType:"metadata",sourceId:e})),t.setEventedParent(null),t.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw Error(`There is no source with this ID=${e}`);let i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]?.getSource()}addLayer(e,t,i={}){this._checkLoaded();let r,a=e.id;if(this.getLayer(a))return void this.fire(new _t(Error(`Layer "${a}" already exists on this map.`)));if("custom"===e.type){if(Yn(this,function(e){let t=[],i=e.id;return void 0===i&&t.push(new wt(`layers.${i}`,null,'missing required property "id"')),void 0===e.render&&t.push(new wt(`layers.${i}`,null,'missing required method "render"')),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push(new wt(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),t}(e)))return;r=Qp(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(a,e.source),e=Se(e=Le(e),{source:a})),this._validate(Wn.layer,`layers.${a}`,e,{arrayIndex:-1},i))return;r=Qp(e,this._globalState),this._validateLayer(r),r.setEventedParent(this,{layer:{id:a}})}let n=t?this._order.indexOf(t):this._order.length;if(t&&-1===n)this.fire(new _t(Error(`Cannot add layer "${a}" before non-existing layer "${t}".`)));else{if(this._order.splice(n,0,a),this._layerOrderChanged=!0,this._layers[a]=r,this._removedLayers[a]&&r.source&&"custom"!==r.type){let e=this._removedLayers[a];delete this._removedLayers[a],e.type===r.type?(this._updatedSources[r.source]="reload",this.tileManagers[r.source].pause()):this._updatedSources[r.source]="clear"}this._updateLayer(r),r.onAdd&&r.onAdd(this.map)}}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new _t(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===t)return;if(t&&!this._order.includes(t))return void this.fire(new _t(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));let i=this._order.indexOf(e);this._order.splice(i,1);let r=t?this._order.indexOf(t):this._order.length;this._order.splice(r,0,e),this._layerOrderChanged=!0}removeLayer(e){this._checkLoaded();let t=this._layers[e];if(!t)return void this.fire(new _t(Error(`Cannot remove non-existing layer "${e}".`)));t.setEventedParent(null);let i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],"symbol"===t.type&&t.source&&this.tileManagers[t.source]?.resetMaxContentElevation(),t.onRemove&&t.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,t,i){this._checkLoaded();let r=this.getLayer(e);r?(r.minzoom!==t||r.maxzoom!==i)&&(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new _t(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,t,i={}){this._checkLoaded();let r=this.getLayer(e);if(r){if(!ke(r.filter,t)){if(null==t)return r.setFilter(void 0),void this._updateLayer(r);this._validate(Wn.filter,`layers.${r.id}.filter`,t,null,i)||(r.setFilter(Le(t)),this._updateLayer(r))}}else this.fire(new _t(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return Le(this.getLayer(e).filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);a?ke(a.getLayoutProperty(t),i)||(a.setLayoutProperty(t,i,r),this._updateLayer(a)):this.fire(new _t(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,t){let i=this.getLayer(e);if(i)return i.getLayoutProperty(t);this.fire(new _t(Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,t,i,r={}){this._checkLoaded();let a=this.getLayer(e);a?ke(a.getPaintProperty(t),i)||this._updatePaintProperty(a,t,i,r):this.fire(new _t(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,i,r={}){e.setPaintProperty(t,i,r)&&this._updateLayer(e),Co(e)&&"raster-fade-duration"===t&&this.tileManagers[e.source].setRasterFadeDuration(i),this._changed=!0,this._updatedPaintProps[e.id]=!0,"symbol"===e.type&&this.triggerSymbolPlacement(),this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();let i=e.source,r=e.sourceLayer,a=this.tileManagers[i];if(void 0===a)return void this.fire(new _t(Error(`The source '${i}' does not exist in the map's style.`)));let n=a.getSource().type;if("geojson"===n&&r)return void this.fire(new _t(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!r)return void this.fire(new _t(Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===e.id)return void this.fire(new _t(Error("The feature id parameter must be provided.")));let o=["__proto__","constructor","prototype"];t&&Object.keys(t).some(e=>o.includes(e))?this.fire(new _t(Error(`The feature state should not include one of the following keys: ${o}`))):a.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let i=e.source,r=this.tileManagers[i];if(void 0===r)return void this.fire(new _t(Error(`The source '${i}' does not exist in the map's style.`)));let a=r.getSource().type,n="vector"===a?e.sourceLayer:void 0;"vector"!==a||n?t&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new _t(Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,e.id,t):this.fire(new _t(Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();let t=e.source,i=e.sourceLayer,r=this.tileManagers[t];if(void 0!==r){if("vector"!==r.getSource().type||i)return void 0===e.id&&this.fire(new _t(Error("The feature id parameter must be provided."))),r.getFeatureState(i,e.id);this.fire(new _t(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new _t(Error(`The source '${t}' does not exist in the map's style.`)))}getTransition(){return Se({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let e=Fe(this.tileManagers,e=>e.serialize()),t=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return Re({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,"font-faces":r["font-faces"],transition:r.transition,projection:r.projection,state:r.state,sources:e,layers:t,terrain:i},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let a=this._order.length-1;a>=0;a--){let n=this._order[a];if(t(n)){i[n]=a;for(let t of e){let e=t[n];if(e)for(let t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);let a=[];for(let n=this._order.length-1;n>=0;n--){let o=this._order[n];if(t(o))for(let e=r.length-1;e>=0;e--){let t=r[e].feature;if(i[t.layer.id]<n)break;a.push(t),r.pop()}else for(let t of e){let e=t[o];if(e)for(let t of e)a.push(t.feature)}}return a}queryRenderedFeatures(e,t,i){t?.filter&&this._validate(Wn.filter,"queryRenderedFeatures.filter",t.filter,null,t);let r={};if(t?.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new _t(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let e of t.layers){let t=this._layers[e];if(!t)return this.fire(new _t(Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[t.source]=!0}}let a=[];t.availableImages=this.imageManager.listImages();let n=this._serializedAllLayers(),o=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,s={...t,layers:o,globalState:this._globalState};for(let o in this.tileManagers)(!t.layers||r[o])&&a.push(ty(this.tileManagers[o],this._layers,n,e,s,i,this.map.terrain?(e,t,i)=>this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&a.push(function(e,t,i,r,a,n,o){let s={},l=n.queryRenderedSymbols(r),u=[];for(let e of Object.keys(l).map(Number))u.push(o[e]);u.sort(iy);for(let i of u){let r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,{filterSpec:a.filter,globalState:a.globalState},a.layers,a.availableImages,e);for(let e in r){s[e]||=[];let t=r[e];t.sort((e,t)=>{let r=i.featureSortOrder;if(r){let i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(let i of t)s[e].push(i)}}return function(e,t,i){for(let r in e)for(let a of e[r])ry(a,i[t[r].source]);return e}(s,e,i)}(this._layers,n,this.tileManagers,e,s,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t?.filter&&this._validate(Wn.filter,"querySourceFeatures.filter",t.filter,null,t);let i=this.tileManagers[e];return i?function(e,t){let i=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],a={};for(let e of i){let i=e.tileID.canonical.key;a[i]||(a[i]=!0,e.querySourceFeatures(r,t))}return r}(i,t?{...t,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let i=this.light.getLight(),r=!1;for(let t in e)if(!ke(e[t],i[t])){r=!0;break}if(!r)return;let a={now:Xg(),transition:Se({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,t),this.light.updateTransitions(a)}getProjection(){return this.stylesheet?.projection}setProjection(e){this._checkLoaded();let t=e??{type:"mercator"};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){return this.stylesheet?.sky}setSky(e,t={}){this._checkLoaded();let i=this.getSky(),r=!1;if(!e&&!i)return;if(e&&!i)r=!0;else if(!e&&i)r=!0;else for(let t in e)if(!ke(e[t],i[t])){r=!0;break}if(!r)return;let a={now:Xg(),transition:Se({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,t),this.sky.updateTransitions(a)}_setProjectionInternal(e){let t=function(e,t,i){let r={constrainOverride:t};if(Array.isArray(e)){let t=new Av({type:e},i);return{projection:t,transform:new Jv(r),cameraHelper:new eb(t)}}switch(e){case"mercator":return{projection:new nv,transform:new xv(r),cameraHelper:new Ev};case"globe":{let e=new Av({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:e,transform:new Jv(r),cameraHelper:new eb(e)}}case"vertical-perspective":return{projection:new Iv,transform:new Hv(r),cameraHelper:new Qv};default:return Oe(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new nv,transform:new xv(r),cameraHelper:new Ev}}}(e,this.map._camera?.transform.constrainOverride,this._globalState);this.projection=t.projection,this.map.migrateProjection(t.transform,t.cameraHelper);for(let e in this.tileManagers)this.tileManagers[e].reload()}_validate(e,t,i,r,a={}){return!1!==a.validate&&Kn(this,e,{key:t,style:this.serialize(),value:i,...r},a)}_remove(e=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),Ry().off(My,this._rtlPluginLoaded);for(let e in this._layers)this._layers[e].setEventedParent(null);for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(let t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(e,t,i){let r=this.pauseablePlacement;return!r||this._symbolPlacementTriggered||this._placedProjectionTransition!==this.projection?.transitionState||r._showCollisionBoxes!==t||r.placement.collisionGroups.crossSourceCollisions!==i||r.placement.transform.renderWorldCopies!==e.renderWorldCopies||!function(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]}(r.placement.transform.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,i,r,a=!1){let n=!1,o=!1,s={};for(let t of this._order){let i=this._layers[t];if("symbol"!==i.type)continue;if(!s[i.source]){let e=this.tileManagers[i.source];s[i.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}let r=this.crossTileSymbolIndex.addLayer(i,s[i.source],e.center.lng);n||=r}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||=this._layerOrderChanged||0===i;let l=n||this._placementInputsChanged(e,t,r),u=this.pauseablePlacement?.isDone()&&!this.placement.stillRecent(Xg(),e.zoom);if((a||!this.pauseablePlacement||u&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=this.projection?.transitionState,this.pauseablePlacement=new Vx(e,this.map.terrain,this._order,a,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,s),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Xg()),o=!0),n&&this.pauseablePlacement.placement.setStale()),o||n)for(let e of this._order){let t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,s[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Xg())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let i=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,t.icons),i}async getGlyphs(e,t){let i=await this.glyphManager.getGlyphs(t.stacks),r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,[""]),i}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),(!e||!this._validate(Wn.glyphs,"glyphs",e,null,t))&&(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getFontFaces(){return this.stylesheet["font-faces"]||null}setFontFaces(e){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet["font-faces"]=e,this.glyphManager.setFontFaces(e)}async getDashes(e,t){let i={};for(let[e,r]of Object.entries(t.dashes))i[e]=this.lineAtlas.getDash(r.dasharray,r.round);return i}addSprite(e,t,i={},r){this._checkLoaded();let a=[{id:e,url:t}],n=[...w_(this.stylesheet.sprite),...a];this._validate(Wn.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(a,!0,r))}removeSprite(e){this._checkLoaded();let t=w_(this.stylesheet.sprite);if(!t.find(t=>t.id===e))return void this.fire(new _t(Error(`Sprite "${e}" doesn't exists on this map.`)));let i=this.imageManager.removeSpriteImages(e);this._markImagesChanged(i),t.splice(t.findIndex(t=>t.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new t_("data"))}getSprite(){return w_(this.stylesheet.sprite)}setSprite(e,t={},i){this._checkLoaded(),(!e||!this._validate(Wn.sprite,"sprite",e,null,t))&&(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,i):(this._unloadSprite(),i&&i(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.patternAtlas.destroy()),this.glyphManager&&this.glyphManager.destroy();for(let e in this._layers){let t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}};const rb=ko([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var ab=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,r,a,n,o,s,l){this.context=e;let u=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!u&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(u=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||u||this.boundIndexBuffer!==a||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,r,a,n,o,s,l):e.bindVertexArray.set(this.vao)}freshBind(e,t,i,r,a,n,o,s){let l=e.numAttributes,u=this.context,h=u.gl;this.vao&&this.destroy(),this.vao=u.createVertexArray(),u.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=a,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,t.enableAttributes(h,e);for(let t of i)t.enableAttributes(h,e);n&&n.enableAttributes(h,e),o&&o.enableAttributes(h,e),s&&s.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,a);for(let t of i)t.bind(),t.setVertexAttribPointers(h,e,a);n&&(n.bind(),n.setVertexAttribPointers(h,e,a)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(h,e,a)),s&&(s.bind(),s.setVertexAttribPointers(h,e,a)),u.currentNumAttributes=l}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}};const nb=(e,t,i,r,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:i?i.properties.get("fog-color"):fi.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:i?i.calculateFogBlendOpacity(r):0,u_horizon_color:i?i.properties.get("horizon-color"):fi.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!a}),ob=e=>({u_ele_delta:e}),sb={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2},lb={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function ub(e){let t={},i=0;for(let{name:r,type:a}of e){let[e,n]=lb[a];i=Math.ceil(i/n)*n,t[r]=i,i+=e}return{offsets:t,contentWords:i,sizeWords:4*Math.ceil(i/4)}}var hb=class{constructor(e,t,i){this.context=e,this.binding=t,this.contentWords=i.contentWords;let r=e.gl;this.buffer=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,this.buffer),r.bufferData(r.UNIFORM_BUFFER,4*i.sizeWords,r.DYNAMIC_DRAW),r.bindBufferBase(r.UNIFORM_BUFFER,t,this.buffer),this.uploaded=new Float32Array(i.sizeWords),this.pending=new Float32Array(i.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1,this.bindingDirty=!1}upload(){let e=this.context.gl,t=!this.hasData;if(!t){let e=this.pendingWords,i=this.uploadedWords;for(let r=0;r<this.contentWords;r++)if(e[r]!==i[r]){t=!0;break}}this.bindingDirty&&=(e.bindBufferBase(e.UNIFORM_BUFFER,this.binding,this.buffer),!1),t&&(e.bindBuffer(e.UNIFORM_BUFFER,this.buffer),e.bufferSubData(e.UNIFORM_BUFFER,0,this.pending),this.uploaded.set(this.pending),this.hasData=!0)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}};const cb=ub([{name:"u_projection_matrix",type:"mat4"},{name:"u_projection_fallback_matrix",type:"mat4"},{name:"u_projection_tile_mercator_coords",type:"vec4"},{name:"u_projection_clipping_plane",type:"vec4"},{name:"u_projection_transition",type:"float"},{name:"u_projection_clip_antimeridian",type:"int"}]),db=cb.offsets,pb=ub([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),fb=pb.offsets;function mb(e){let t=[];for(let i of e){if(null===i)continue;let e=i.split(" ");t.push(e.pop())}return t}var gb=class{constructor(e,t,i,r,a,n,o,s,l=[]){let u=e.gl;this.program=u.createProgram();let h=mb(t.staticAttributes),c=i?i.getBinderAttributes():[],d=h.concat(c),p=tv.prelude.staticUniforms?mb(tv.prelude.staticUniforms):[],f=t.staticUniforms?mb(t.staticUniforms):[],m=i?i.getBinderUniforms():[],g=p.concat(f).concat(m),_=[];for(let e of g)_.includes(e)||_.push(e);let y=i?i.defines():[];y.unshift("#version 300 es"),a&&y.push("#define OVERDRAW_INSPECTOR;"),n&&y.push("#define TERRAIN3D;"),s&&y.push(s),l&&y.push(...l);let x=y.concat(tv.prelude.fragmentSource,o.fragmentSource,t.fragmentSource).join("\n"),v=y.concat(tv.prelude.vertexSource,o.vertexSource,t.vertexSource).join("\n"),b=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);u.shaderSource(b,x),u.compileShader(b),u.attachShader(this.program,b);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);u.shaderSource(w,v),u.compileShader(w),u.attachShader(this.program,w),this.attributes={};let T={};if(this.numAttributes=d.length,u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS)){if(u.isContextLost())return void(this.failedToCreate=!0);throw u.getShaderParameter(b,u.COMPILE_STATUS)?u.getShaderParameter(w,u.COMPILE_STATUS)?Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`):Error(`Could not compile fragment shader: ${u.getShaderInfoLog(b)}`)}!function(e,t){for(let[i,r]of Object.entries(sb)){let a=e.getUniformBlockIndex(t,i);a!==e.INVALID_INDEX&&e.uniformBlockBinding(t,a,r)}}(u,this.program);let D=function(e,t){let i=new Set([e.INT,e.INT_VEC2,e.INT_VEC3,e.INT_VEC4,e.UNSIGNED_INT,e.UNSIGNED_INT_VEC2,e.UNSIGNED_INT_VEC3,e.UNSIGNED_INT_VEC4]),r=new Set,a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let n=0;n<a;n++){let a=e.getActiveAttrib(t,n);a&&i.has(a.type)&&r.add(a.name)}return r}(u,this.program);for(let e of d){if(!e)continue;let t=u.getAttribLocation(this.program,e);t>=0&&(this.attributes[e]={location:t,isInteger:D.has(e)})}u.deleteShader(w),u.deleteShader(b);for(let e of _)if(e&&!T[e]){let t=u.getUniformLocation(this.program,e);t&&(T[e]=t)}this.fixedUniforms=r(e,T),this.terrainUniforms=((e,t)=>({u_depth:new Qs(e,t.u_depth),u_terrain:new Qs(e,t.u_terrain)}))(e,T),this.binderUniforms=i?i.getUniforms(e,T):[]}draw(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m,g,_,y){let x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(a),e.setCullFace(n),s){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,s.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,s.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(s[e]);!function(e,t){let i=e.pending;i.set(t.u_terrain_matrix,fb.u_terrain_matrix),i.set(t.u_terrain_unpack,fb.u_terrain_unpack),i[fb.u_terrain_dim]=t.u_terrain_dim,i[fb.u_terrain_exaggeration]=t.u_terrain_exaggeration,e.upload()}(e.terrainUniformBuffer,s)}if(l&&function(e,t){let i=e.pending;i.set(t.mainMatrix,db.u_projection_matrix),i.set(t.fallbackMatrix,db.u_projection_fallback_matrix),i.set(t.tileMercatorCoords,db.u_projection_tile_mercator_coords),i.set(t.clippingPlane,db.u_projection_clipping_plane),i[db.u_projection_transition]=t.projectionTransition,e.pendingWords[db.u_projection_clip_antimeridian]=+!!t.clipAntimeridian,e.upload()}(e.projectionUniformBuffer,l),o)for(let e in this.fixedUniforms)this.fixedUniforms[e].set(o[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case x.LINES:v=2;break;case x.TRIANGLES:v=3;break;case x.LINE_STRIP:v=1}for(let i of d.get())i.vaos||={},i.vaos[u]||=new ab,i.vaos[u].bind(e,this,h,m?m.getPaintVertexBuffers():[],c,i.vertexOffset,g,_,y),x.drawElements(t,i.primitiveLength*v,x.UNSIGNED_SHORT,i.primitiveOffset*v*2)}};function _b(e,t,i){let r=1/ae(i,1,t.transform.tileZoom),a=2**i.tileID.overscaledZ,n=i.tileSize*2**t.transform.tileZoom/a,o=n*(i.tileID.canonical.x+i.tileID.wrap*a),s=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}const yb=(e,t,i,r)=>{let a=e.style.light,n=a.getCartesianPosition(),o=_();"viewport"===a.properties.get("anchor")&&function(e,t){var i=Math.sin(t),r=Math.cos(t);e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1}(o,e.transform.bearingInRadians),function(e,t,i){var r=t[0],a=t[1],n=t[2];e[0]=r*i[0]+a*i[3]+n*i[6],e[1]=r*i[1]+a*i[4]+n*i[7],e[2]=r*i[2]+a*i[5]+n*i[8]}(n,n,o);let s=e.transform.transformLightDirection(n),l=a.properties.get("color");return{u_lightpos:n,u_lightpos_globe:s,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+t,u_opacity:i,u_fill_translate:r}},xb=(e,t,i,r,a,n,o)=>Se(yb(e,t,i,r),_b(n,e,o),{u_height_factor:-(2**a.overscaledZ)/o.tileSize/8}),vb=(e,t,i,r,a)=>Se(_b(t,e,i),{u_fill_translate:r,u_sdf_pattern:+!!a}),bb=e=>({u_fill_translate:e}),wb=e=>({u_fill_translate:e}),Tb=(e,t,i,r,a)=>vb(e,t,i,r,a),Db=(e,t,i,r,a)=>{let n,o,s=e.transform,l=0;if("map"===i.paint.get("circle-pitch-alignment")){let e=ae(t,1,s.zoom);n=!0,o=[e,e],l=e/(re*2**t.tileID.overscaledZ)*2*Math.PI*a}else n=!1,o=s.pixelsToGLUnits;return{u_scale_with_map:+("map"===i.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_extrude_scale:o,u_globe_extrude_scale:l,u_translate:r}},Eb=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Sb=(e,t,i,r)=>{let a=ae(e,1,t)/(re*2**e.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:ae(e,1,t),u_intensity:i,u_globe_extrude_scale:a}},Pb=(e,t,i,r)=>{let a=y();return A(a,0,e.width,e.height,0,0,1),{u_matrix:a,u_image:i,u_color_ramp:r,u_opacity:t.paint.get("heatmap-opacity")}},Ib=(e,t,i)=>{let r,a=i.paint.get("hillshade-accent-color");switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}let n=i.getIlluminationProperties();for(let t=0;t<n.directionRadians.length;t++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(n.directionRadians[t]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:Cb(0,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:n.altitudeRadians,u_azimuths:n.directionRadians,u_accent:a,u_method:r,u_highlights:n.highlightColor,u_shadows:n.shadowColor}},Ab=(e,t)=>{let i=t.stride,r=y();return A(r,0,re,-re,0,0,1),T(r,r,[0,-re,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.getUnpackVector()}};function Cb(e,t){let i=2**t.canonical.z,r=t.canonical.y;return[new Xh(0,r/i).toLngLat().lat,new Xh(0,(r+1)/i).toLngLat().lat]}const Mb=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),zb=(e,t,i,r)=>{let a=e.transform;return{u_translation:Ob(e,t,i),u_ratio:r/ae(t,1,a.zoom)}},Fb=(e,t,i,r,a)=>Se(zb(e,t,i,r),{u_image:0,u_image_height:a}),Rb=(e,t,i,r,a)=>{let n=e.transform,o=Bb(t,n);return{u_translation:Ob(e,t,i),u_texsize:t.imageAtlasTexture.size,u_ratio:r/ae(t,1,n.zoom),u_image:0,u_scale:[o,a.fromScale,a.toScale],u_fade:a.t}},kb=(e,t,i,r,a)=>{let n=Bb(t,e.transform);return Se(zb(e,t,i,r),{u_tileratio:n,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image:0,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},Lb=(e,t,i,r,a,n)=>{let o=Bb(t,e.transform);return Se(zb(e,t,i,r),{u_image:0,u_image_height:n,u_tileratio:o,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image_dash:1,u_mix:a.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function Bb(e,t){return 1/ae(e,1,t.tileZoom)}function Ob(e,t,i){return ce(e.transform,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const jb=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f)=>({u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_rotate_symbol:+i,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:a,u_is_variable_anchor:n,u_texsize:c,u_texture:0,u_translation:u,u_pitched_scale:d,u_is_offset:p,u_height_anchor_ground:+f}),Vb=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f,m)=>{let g=o.transform;return Se(jb(e,t,i,r,a,n,0,s,l,u,h,c,p,f,m),{u_gamma_scale:r?Math.cos(g.pitch*Math.PI/180)*g.cameraToCenterDistance:1,u_is_halo:+!!d,u_is_plain:1})},Nb=(e,t,i,r,a,n,o,s,l,u,h,c,d,p,f)=>Se(Vb(e,t,i,r,a,n,o,s,l,u,!0,h,!0,d,p,f),{u_texsize_icon:c,u_texture_icon:1}),Ub=(e,t)=>({u_opacity:e,u_color:t}),$b=(e,t,i,r,a)=>Se(function(e,t,i,r){let a=i.patternAtlas.getPattern(e.from.toString()),n=i.patternAtlas.getPattern(e.to.toString()),{width:o,height:s}=i.patternAtlas.getPixelSize(),l=2**r.tileID.overscaledZ,u=r.tileSize*2**i.transform.tileZoom/l,h=u*(r.tileID.canonical.x+r.tileID.wrap*l),c=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[o,s],u_mix:t.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/ae(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,c>>16],u_pixel_coord_lower:[65535&h,65535&c]}}(i,a,t,r),{u_opacity:e}),Gb=(e,t)=>({}),Zb={fillExtrusion:(e,t)=>({u_lightpos:new il(e,t.u_lightpos),u_lightpos_globe:new il(e,t.u_lightpos_globe),u_lightintensity:new el(e,t.u_lightintensity),u_lightcolor:new il(e,t.u_lightcolor),u_vertical_gradient:new el(e,t.u_vertical_gradient),u_opacity:new el(e,t.u_opacity),u_fill_translate:new tl(e,t.u_fill_translate)}),fillExtrusionPattern:(e,t)=>({u_lightpos:new il(e,t.u_lightpos),u_lightpos_globe:new il(e,t.u_lightpos_globe),u_lightintensity:new el(e,t.u_lightintensity),u_lightcolor:new il(e,t.u_lightcolor),u_vertical_gradient:new el(e,t.u_vertical_gradient),u_height_factor:new el(e,t.u_height_factor),u_opacity:new el(e,t.u_opacity),u_fill_translate:new tl(e,t.u_fill_translate),u_image:new Qs(e,t.u_image),u_texsize:new tl(e,t.u_texsize),u_pixel_coord_upper:new tl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new tl(e,t.u_pixel_coord_lower),u_scale:new il(e,t.u_scale),u_fade:new el(e,t.u_fade)}),fill:(e,t)=>({u_fill_translate:new tl(e,t.u_fill_translate)}),fillPattern:(e,t)=>({u_image:new Qs(e,t.u_image),u_texsize:new tl(e,t.u_texsize),u_pixel_coord_upper:new tl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new tl(e,t.u_pixel_coord_lower),u_scale:new il(e,t.u_scale),u_fade:new el(e,t.u_fade),u_sdf_pattern:new Qs(e,t.u_sdf_pattern),u_fill_translate:new tl(e,t.u_fill_translate)}),fillOutline:(e,t)=>({u_fill_translate:new tl(e,t.u_fill_translate)}),fillOutlinePattern:(e,t)=>({u_image:new Qs(e,t.u_image),u_texsize:new tl(e,t.u_texsize),u_pixel_coord_upper:new tl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new tl(e,t.u_pixel_coord_lower),u_scale:new il(e,t.u_scale),u_fade:new el(e,t.u_fade),u_sdf_pattern:new Qs(e,t.u_sdf_pattern),u_fill_translate:new tl(e,t.u_fill_translate)}),circle:(e,t)=>({u_scale_with_map:new Qs(e,t.u_scale_with_map),u_pitch_with_map:new Qs(e,t.u_pitch_with_map),u_extrude_scale:new tl(e,t.u_extrude_scale),u_globe_extrude_scale:new el(e,t.u_globe_extrude_scale),u_translate:new tl(e,t.u_translate)}),collisionBox:Gb,collisionCircle:Gb,debug:(e,t)=>({u_color:new al(e,t.u_color),u_overlay:new Qs(e,t.u_overlay),u_overlay_scale:new el(e,t.u_overlay_scale)}),depth:Gb,clippingMask:Gb,heatmap:(e,t)=>({u_extrude_scale:new el(e,t.u_extrude_scale),u_intensity:new el(e,t.u_intensity),u_globe_extrude_scale:new el(e,t.u_globe_extrude_scale)}),heatmapTexture:(e,t)=>({u_matrix:new ll(e,t.u_matrix),u_image:new Qs(e,t.u_image),u_color_ramp:new Qs(e,t.u_color_ramp),u_opacity:new el(e,t.u_opacity)}),hillshade:(e,t)=>({u_image:new Qs(e,t.u_image),u_latrange:new tl(e,t.u_latrange),u_exaggeration:new el(e,t.u_exaggeration),u_altitudes:new ol(e,t.u_altitudes),u_azimuths:new ol(e,t.u_azimuths),u_accent:new al(e,t.u_accent),u_method:new Qs(e,t.u_method),u_shadows:new nl(e,t.u_shadows),u_highlights:new nl(e,t.u_highlights)}),hillshadePrepare:(e,t)=>({u_matrix:new ll(e,t.u_matrix),u_image:new Qs(e,t.u_image),u_dimension:new tl(e,t.u_dimension),u_zoom:new el(e,t.u_zoom),u_unpack:new rl(e,t.u_unpack)}),colorRelief:(e,t)=>({u_image:new Qs(e,t.u_image),u_unpack:new rl(e,t.u_unpack),u_dimension:new tl(e,t.u_dimension),u_elevation_stops:new Qs(e,t.u_elevation_stops),u_color_stops:new Qs(e,t.u_color_stops),u_color_ramp_size:new Qs(e,t.u_color_ramp_size),u_opacity:new el(e,t.u_opacity)}),line:(e,t)=>({u_translation:new tl(e,t.u_translation),u_ratio:new el(e,t.u_ratio)}),lineGradient:(e,t)=>({u_translation:new tl(e,t.u_translation),u_ratio:new el(e,t.u_ratio),u_image:new Qs(e,t.u_image),u_image_height:new el(e,t.u_image_height)}),linePattern:(e,t)=>({u_translation:new tl(e,t.u_translation),u_texsize:new tl(e,t.u_texsize),u_ratio:new el(e,t.u_ratio),u_image:new Qs(e,t.u_image),u_scale:new il(e,t.u_scale),u_fade:new el(e,t.u_fade)}),lineSDF:(e,t)=>({u_translation:new tl(e,t.u_translation),u_ratio:new el(e,t.u_ratio),u_image:new Qs(e,t.u_image),u_mix:new el(e,t.u_mix),u_tileratio:new el(e,t.u_tileratio),u_crossfade_from:new el(e,t.u_crossfade_from),u_crossfade_to:new el(e,t.u_crossfade_to),u_lineatlas_width:new el(e,t.u_lineatlas_width),u_lineatlas_height:new el(e,t.u_lineatlas_height)}),lineGradientSDF:(e,t)=>({u_translation:new tl(e,t.u_translation),u_ratio:new el(e,t.u_ratio),u_image:new Qs(e,t.u_image),u_image_height:new el(e,t.u_image_height),u_tileratio:new el(e,t.u_tileratio),u_crossfade_from:new el(e,t.u_crossfade_from),u_crossfade_to:new el(e,t.u_crossfade_to),u_image_dash:new Qs(e,t.u_image_dash),u_mix:new el(e,t.u_mix),u_lineatlas_width:new el(e,t.u_lineatlas_width),u_lineatlas_height:new el(e,t.u_lineatlas_height)}),layerOpacity:(e,t)=>({u_image:new Qs(e,t.u_image),u_opacity:new el(e,t.u_opacity)}),raster:(e,t)=>({u_tl_parent:new tl(e,t.u_tl_parent),u_scale_parent:new el(e,t.u_scale_parent),u_buffer_scale:new el(e,t.u_buffer_scale),u_image_warp:new il(e,t.u_image_warp),u_fade_t:new el(e,t.u_fade_t),u_opacity:new el(e,t.u_opacity),u_image0:new Qs(e,t.u_image0),u_image1:new Qs(e,t.u_image1),u_brightness_low:new el(e,t.u_brightness_low),u_brightness_high:new el(e,t.u_brightness_high),u_saturation_factor:new el(e,t.u_saturation_factor),u_contrast_factor:new el(e,t.u_contrast_factor),u_spin_weights:new il(e,t.u_spin_weights),u_coords_top:new rl(e,t.u_coords_top),u_coords_bottom:new rl(e,t.u_coords_bottom)}),symbolIcon:(e,t)=>({u_is_size_zoom_constant:new Qs(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new Qs(e,t.u_is_size_feature_constant),u_size_t:new el(e,t.u_size_t),u_size:new el(e,t.u_size),u_rotate_symbol:new Qs(e,t.u_rotate_symbol),u_label_plane_matrix:new ll(e,t.u_label_plane_matrix),u_coord_matrix:new ll(e,t.u_coord_matrix),u_is_text:new Qs(e,t.u_is_text),u_pitch_with_map:new Qs(e,t.u_pitch_with_map),u_is_along_line:new Qs(e,t.u_is_along_line),u_is_variable_anchor:new Qs(e,t.u_is_variable_anchor),u_texsize:new tl(e,t.u_texsize),u_texture:new Qs(e,t.u_texture),u_translation:new tl(e,t.u_translation),u_pitched_scale:new el(e,t.u_pitched_scale),u_is_offset:new Qs(e,t.u_is_offset),u_height_anchor_ground:new Qs(e,t.u_height_anchor_ground)}),symbolSDF:(e,t)=>({u_is_size_zoom_constant:new Qs(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new Qs(e,t.u_is_size_feature_constant),u_size_t:new el(e,t.u_size_t),u_size:new el(e,t.u_size),u_rotate_symbol:new Qs(e,t.u_rotate_symbol),u_label_plane_matrix:new ll(e,t.u_label_plane_matrix),u_coord_matrix:new ll(e,t.u_coord_matrix),u_is_text:new Qs(e,t.u_is_text),u_pitch_with_map:new Qs(e,t.u_pitch_with_map),u_is_along_line:new Qs(e,t.u_is_along_line),u_is_variable_anchor:new Qs(e,t.u_is_variable_anchor),u_texsize:new tl(e,t.u_texsize),u_texture:new Qs(e,t.u_texture),u_gamma_scale:new el(e,t.u_gamma_scale),u_is_halo:new Qs(e,t.u_is_halo),u_is_plain:new Qs(e,t.u_is_plain),u_translation:new tl(e,t.u_translation),u_pitched_scale:new el(e,t.u_pitched_scale),u_is_offset:new Qs(e,t.u_is_offset),u_height_anchor_ground:new Qs(e,t.u_height_anchor_ground)}),symbolTextAndIcon:(e,t)=>({u_is_size_zoom_constant:new Qs(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new Qs(e,t.u_is_size_feature_constant),u_size_t:new el(e,t.u_size_t),u_size:new el(e,t.u_size),u_rotate_symbol:new Qs(e,t.u_rotate_symbol),u_label_plane_matrix:new ll(e,t.u_label_plane_matrix),u_coord_matrix:new ll(e,t.u_coord_matrix),u_is_text:new Qs(e,t.u_is_text),u_pitch_with_map:new Qs(e,t.u_pitch_with_map),u_is_along_line:new Qs(e,t.u_is_along_line),u_is_variable_anchor:new Qs(e,t.u_is_variable_anchor),u_texsize:new tl(e,t.u_texsize),u_texsize_icon:new tl(e,t.u_texsize_icon),u_texture:new Qs(e,t.u_texture),u_texture_icon:new Qs(e,t.u_texture_icon),u_gamma_scale:new el(e,t.u_gamma_scale),u_is_halo:new Qs(e,t.u_is_halo),u_translation:new tl(e,t.u_translation),u_pitched_scale:new el(e,t.u_pitched_scale),u_is_offset:new Qs(e,t.u_is_offset),u_height_anchor_ground:new Qs(e,t.u_height_anchor_ground)}),background:(e,t)=>({u_opacity:new el(e,t.u_opacity),u_color:new al(e,t.u_color)}),backgroundPattern:(e,t)=>({u_opacity:new el(e,t.u_opacity),u_image:new Qs(e,t.u_image),u_pattern_tl_a:new tl(e,t.u_pattern_tl_a),u_pattern_br_a:new tl(e,t.u_pattern_br_a),u_pattern_tl_b:new tl(e,t.u_pattern_tl_b),u_pattern_br_b:new tl(e,t.u_pattern_br_b),u_texsize:new tl(e,t.u_texsize),u_mix:new el(e,t.u_mix),u_pattern_size_a:new tl(e,t.u_pattern_size_a),u_pattern_size_b:new tl(e,t.u_pattern_size_b),u_scale_a:new el(e,t.u_scale_a),u_scale_b:new el(e,t.u_scale_b),u_pixel_coord_upper:new tl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new tl(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new el(e,t.u_tile_units_to_pixels)}),terrain:(e,t)=>({u_texture:new Qs(e,t.u_texture),u_ele_delta:new el(e,t.u_ele_delta),u_fog_matrix:new ll(e,t.u_fog_matrix),u_fog_color:new al(e,t.u_fog_color),u_fog_ground_blend:new el(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new el(e,t.u_fog_ground_blend_opacity),u_horizon_color:new al(e,t.u_horizon_color),u_horizon_fog_blend:new el(e,t.u_horizon_fog_blend),u_is_globe_mode:new el(e,t.u_is_globe_mode)}),terrainDepth:(e,t)=>({u_ele_delta:new el(e,t.u_ele_delta)}),atmosphere:(e,t)=>({u_sun_pos:new il(e,t.u_sun_pos),u_atmosphere_blend:new el(e,t.u_atmosphere_blend),u_globe_position:new il(e,t.u_globe_position),u_globe_radius:new el(e,t.u_globe_radius),u_inv_proj_matrix:new ll(e,t.u_inv_proj_matrix)}),sky:(e,t)=>({u_sky_color:new al(e,t.u_sky_color),u_horizon_color:new al(e,t.u_horizon_color),u_horizon:new tl(e,t.u_horizon),u_horizon_normal:new tl(e,t.u_horizon_normal),u_sky_horizon_blend:new el(e,t.u_sky_horizon_blend),u_sky_blend:new el(e,t.u_sky_blend),u_inv_proj_matrix:new ll(e,t.u_inv_proj_matrix),u_globe_position:new il(e,t.u_globe_position),u_globe_radius:new el(e,t.u_globe_radius)})};var qb=class{constructor(e,t,i){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}};const Wb={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var Xb=class{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i of this.attributes){let r=t.attributes[i.name];void 0!==r&&e.enableVertexAttribArray(r.location)}}setVertexAttribPointers(e,t,i){for(let r of this.attributes){let a=t.attributes[r.name];if(void 0!==a){let t=r.offset+this.itemSize*(i||0);a.isInteger?e.vertexAttribIPointer(a.location,r.components,e[Wb[r.type]],this.itemSize,t):e.vertexAttribPointer(a.location,r.components,e[Wb[r.type]],!1,this.itemSize,t)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Hb=class{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}},Yb=class extends Hb{getDefault(){return fi.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},Kb=class extends Hb{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},Jb=class extends Hb{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},Qb=class extends Hb{getDefault(){return[!0,!0,!0,!0]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},ew=class extends Hb{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},tw=class extends Hb{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},iw=class extends Hb{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}},rw=class extends Hb{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}},aw=class extends Hb{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}},nw=class extends Hb{getDefault(){return[0,1]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}},ow=class extends Hb{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}},sw=class extends Hb{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},lw=class extends Hb{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}},uw=class extends Hb{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}},hw=class extends Hb{getDefault(){return fi.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},cw=class extends Hb{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},dw=class extends Hb{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}},pw=class extends Hb{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},fw=class extends Hb{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},mw=class extends Hb{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},gw=class extends Hb{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},_w=class extends Hb{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},yw=class extends Hb{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}},xw=class extends Hb{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},vw=class extends Hb{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}},bw=class extends Hb{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},ww=class extends Hb{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},Tw=class extends Hb{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},Dw=class extends Hb{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}},Ew=class extends Hb{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}},Sw=class extends Hb{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}},Pw=class extends Hb{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},Iw=class extends Pw{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}},Aw=class extends Pw{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},Cw=class extends Pw{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},Mw=class{constructor(e,t,i,r,a){this.context=e,this.width=t,this.height=i;let n=e.gl,o=this.framebuffer=n.createFramebuffer();if(this.colorAttachment=new Iw(e,o),r)this.depthAttachment=a?new Cw(e,o):new Aw(e,o);else if(a)throw Error("Stencil cannot be set without depth")}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}};const zw=ub([{name:"u_units_to_pixels",type:"vec2"},{name:"u_world_size",type:"vec2"},{name:"u_camera_to_center_distance",type:"float"},{name:"u_symbol_fade_change",type:"float"},{name:"u_aspect_ratio",type:"float"},{name:"u_device_pixel_ratio",type:"float"},{name:"u_viewport_size",type:"vec2"},{name:"u_pixel_extrude_scale",type:"vec2"},{name:"u_pitch",type:"float"}]),Fw=zw.offsets;var Rw=class{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}};Rw.Replace=[1,0],Rw.disabled=new Rw(Rw.Replace,fi.transparent,[!1,!1,!1,!1]),Rw.unblended=new Rw(Rw.Replace,fi.transparent,[!0,!0,!0,!0]),Rw.alphaBlended=new Rw([1,771],fi.transparent,[!0,!0,!0,!0]);var kw=class{constructor(e){this.gl=e,this.clearColor=new Yb(this),this.clearDepth=new Kb(this),this.clearStencil=new Jb(this),this.colorMask=new Qb(this),this.depthMask=new ew(this),this.stencilMask=new tw(this),this.stencilFunc=new iw(this),this.stencilOp=new rw(this),this.stencilTest=new aw(this),this.depthRange=new nw(this),this.depthTest=new ow(this),this.depthFunc=new sw(this),this.blend=new lw(this),this.blendFunc=new uw(this),this.blendColor=new hw(this),this.blendEquation=new cw(this),this.cullFace=new dw(this),this.cullFaceSide=new pw(this),this.frontFace=new fw(this),this.program=new mw(this),this.activeTexture=new gw(this),this.viewport=new _w(this),this.bindFramebuffer=new yw(this),this.bindRenderbuffer=new xw(this),this.bindTexture=new vw(this),this.bindVertexBuffer=new bw(this),this.bindElementBuffer=new ww(this),this.bindVertexArray=new Tw(this),this.pixelStoreUnpack=new Dw(this),this.pixelStoreUnpackPremultiplyAlpha=new Ew(this),this.pixelStoreUnpackFlipY=new Sw(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),e.getExtension("EXT_color_buffer_half_float"),e.getExtension("EXT_color_buffer_float"),this.projectionUniformBuffer=function(e){return new hb(e,sb.ProjectionUBO,cb)}(this),this.terrainUniformBuffer=function(e){return new hb(e,sb.TerrainUBO,pb)}(this),this.frameUniformBuffer=function(e){return new hb(e,sb.FrameUBO,zw)}(this)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0,this.projectionUniformBuffer.bindingDirty=!0,this.terrainUniformBuffer.bindingDirty=!0,this.frameUniformBuffer.bindingDirty=!0}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(e,t){return new qb(this,e,t)}createVertexBuffer(e,t,i){return new Xb(this,e,t,i)}createRenderbuffer(e,t,i){let r=this.gl,a=r.createRenderbuffer();return this.bindRenderbuffer.set(a),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),a}createFramebuffer(e,t,i,r){return new Mw(this,e,t,i,r)}clear({color:e,depth:t,stencil:i}){let r=this.gl,a=0;e&&(a|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(a|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(a|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(a)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){ke(e.blendFunction,Rw.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){return this.gl.createVertexArray()}deleteVertexArray(e){this.gl.deleteVertexArray(e)}unbindVAO(){this.bindVertexArray.set(null)}},Lw=class{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}};Lw.ReadOnly=!1,Lw.ReadWrite=!0,Lw.disabled=new Lw(519,Lw.ReadOnly,[0,1]);const Bw=7680;var Ow=class{constructor(e,t,i,r,a,n){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=a,this.pass=n}};Ow.disabled=new Ow({func:519,mask:0},0,0,Bw,Bw,Bw);const jw=2305;var Vw=class{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}};let Nw;function Uw(e,t,i,r,a){let n=e.context,o=e.transform,s=n.gl,l=e.useProgram("collisionBox"),u=[],h=0,c=0;for(let d of r){let r=t.getTile(d).getBucket(i);if(!r)continue;let p=a?r.textCollisionBox:r.iconCollisionBox,f=r.collisionCircleArray;f.length>0&&(u.push({circleArray:f,circleOffset:c,coord:d}),h+=f.length/4,c=h),p&&l.draw(n,s.LINES,Lw.disabled,Ow.disabled,e.colorModeForRenderPass(),Vw.disabled,null,e.style.map.terrain?.getTerrainData(d),o.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),i.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,null,e.transform.zoom,null,null,p.collisionVertexBuffer)}if(!a||!u.length)return;let d=e.useProgram("collisionCircle"),p=new Fs;p.resize(4*h),p._trim();let f=0;for(let e of u)for(let t=0;t<e.circleArray.length/4;t++){let i=4*t,r=e.circleArray[i+0],a=e.circleArray[i+1],n=e.circleArray[i+2],o=e.circleArray[i+3];p.emplace(f++,r,a,n,o,0),p.emplace(f++,r,a,n,o,1),p.emplace(f++,r,a,n,o,2),p.emplace(f++,r,a,n,o,3)}(!Nw||Nw.length<2*h)&&(Nw=function(e){let t=2*e,i=new ks;i.resize(t),i._trim();for(let e=0;e<t;e++){let t=6*e;i.uint16[t+0]=4*e+0,i.uint16[t+1]=4*e+1,i.uint16[t+2]=4*e+2,i.uint16[t+3]=4*e+2,i.uint16[t+4]=4*e+3,i.uint16[t+5]=4*e+0}return i}(h));let m=n.createIndexBuffer(Nw,!0),g=n.createVertexBuffer(p,zc.members,!0);for(let t of u)d.draw(n,s.TRIANGLES,Lw.disabled,Ow.disabled,e.colorModeForRenderPass(),Vw.disabled,null,e.style.map.terrain?.getTerrainData(t.coord),null,i.id,g,m,Ns.simpleSegment(0,2*t.circleOffset,t.circleArray.length,t.circleArray.length/2),null,e.transform.zoom,null,null,null);g.destroy(),m.destroy()}Vw.disabled=new Vw(!1,1029,jw),Vw.backCCW=new Vw(!0,1029,jw),Vw.frontCCW=new Vw(!0,1028,jw);const $w=v(new Float32Array(16));function Gw(e,t,i,r,a,n){let{horizontalAlign:o,verticalAlign:s}=$d(e),l=-(s-.5)*i;return new c((-(o-.5)*t/a+r[0])*n,(l/a+r[1])*n)}function Zw(e,t,i,r,a,n){let o=t.tileAnchorPoint.add(new c(t.translation[0],t.translation[1]));if(t.pitchWithMap){let e=r.mult(n);i||(e=e.rotate(-a));let s=o.add(e);return hx(s.x,s.y,t.pitchedLabelPlaneMatrix,ux(t,s.x,s.y)).point}if(i){let i=xx(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),a=Math.atan(i.y/i.x)+(i.x<0?Math.PI:0);return e.add(r.rotate(a))}return e.add(r)}function qw(e,t,i,r,a,n,o,s,l,u,h,d,p){let f=e.text.placedSymbolArray,m=e.text.dynamicLayoutVertexArray,g=e.icon.dynamicLayoutVertexArray,_={};m.clear();for(let g=0;g<f.length;g++){let y=f.get(g),x=e.allowVerticalPlacement&&!y.placedOrientation,v=y.hidden||!y.crossTileID||x?null:r[y.crossTileID];if(v){let r=new c(y.anchorX,y.anchorY),f={getElevation:d,heightOffset:y.heightOffset,heightAnchorGround:p,width:a.width,height:a.height,pitchedLabelPlaneMatrix:n,lineVertexArray:null,pitchWithMap:i,transform:a,projectionCache:null,tileAnchorPoint:r,translation:u,unwrappedTileID:h},g=i?bx(r.x,r.y,f):xx(r.x,r.y,f),x=cx(a.cameraToCenterDistance,g.signedDistanceFromCamera),b=np(e.textSizeData,s,y)*x/24;i&&(b*=e.tilePixelRatio/o);let{width:w,height:T,anchor:D,textOffset:E,textBoxScale:S}=v,P=Gw(D,w,T,E,S,b),I=a.getPitchedTextCorrection(r.x+u[0],r.y+u[1],h),A=Zw(g.point,f,t,P,-a.bearingInRadians,I),C=e.allowVerticalPlacement&&2===y.placedOrientation?Math.PI/2:0;for(let e=0;e<y.numGlyphs;e++)Op(m,A,C);l&&y.associatedIconIndex>=0&&(_[y.associatedIconIndex]={shiftedAnchor:A,angle:C})}else Sx(y.numGlyphs,m)}if(l){g.clear();let t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){let i=t.get(e);if(i.hidden)Sx(i.numGlyphs,g);else{let t=_[e];if(t)for(let e=0;e<i.numGlyphs;e++)Op(g,t.shiftedAnchor,t.angle);else Sx(i.numGlyphs,g)}}e.icon.dynamicLayoutVertexBuffer.updateData(g)}e.text.dynamicLayoutVertexBuffer.updateData(m)}function Ww(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function Xw(e,t,i,r,a,n,o,s,l,u,h,c,d){let p=e.context,f=p.gl,m=e.transform,g="map"===s,_="map"===l,x="viewport"!==s&&"point"!==i.layout.get("symbol-placement"),v=g&&!_&&!x,b=!i.layout.get("symbol-sort-key").isConstant(),w=!1,T=e.getDepthModeForSublayer(0,Lw.ReadOnly),D=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=[],S=m.getCircleRadiusCorrection();for(let s of r){let r=t.getTile(s),l=r.getBucket(i);if(!l)continue;let h=a?l.text:l.icon;if(!h?.segments.get().length||!h.hasVisibleVertices)continue;let c,p,T,P,I=h.programConfigurations.get(i.id),A=a||l.sdfIcons,C=a?l.textSizeData:l.iconSizeData,M=_||0!==m.pitch,z=e.useProgram(Ww(A,a,l),I),F=op(C,m.zoom),R=e.style.map.terrain?.getTerrainData(s),k=[0,0],L=null;if(a){if(p=r.glyphAtlasTexture,T=f.LINEAR,c=r.glyphAtlasTexture.size,l.iconsInText){k=r.imageAtlasTexture.size,L=r.imageAtlasTexture;let t="composite"===C.kind||"camera"===C.kind;P=M||e.options.rotating||e.options.zooming||t?f.LINEAR:f.NEAREST}}else{let t=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;p=r.imageAtlasTexture,T=A||e.options.rotating||e.options.zooming||t||M?f.LINEAR:f.NEAREST,c=r.imageAtlasTexture.size}let B=ae(r,1,e.transform.zoom),O=ox(g,e.transform,B),j=sx(_,g,e.transform,B),V=ce(m,r,n,o),N=m.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!d,applyTerrainMatrix:!0}),U=D&&l.hasTextData(),$="none"!==i.layout.get("icon-text-fit")&&U&&l.hasIconData(),G=i._unevaluatedLayout.hasValue("icon-offset"),Z="ground"===i.layout.get("symbol-height-anchor");if(x){let t=y();ax(t,O);let r=e.style.map.terrain?(t,i)=>e.style.map.terrain.getElevation(s,t,i):void 0;px(l,e,a,O,t,_,u,"map"===i.layout.get("text-rotation-alignment"),s.toUnwrapped(),m.width,m.height,V,r)}let q,W=a&&D||$,X=_?O:e.transform.clipSpaceToPixelsMatrix,H=x||W?$w:X,Y=A&&0!==i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);q=A?l.iconsInText?Nb(C.kind,F,v,_,x,W,e,H,j,V,c,k,S,G,Z):Vb(C.kind,F,v,_,x,W,e,H,j,V,a,c,Y,S,G,Z):jb(C.kind,F,v,_,x,W,0,H,j,V,a,c,S,G,Z);let K={program:z,buffers:h,uniformValues:q,projectionData:N,atlasTexture:p,atlasTextureIcon:L,atlasInterpolation:T,atlasInterpolationIcon:P,isSDF:A,hasHalo:Y};if(b&&l.canOverlap){w=!0;let e=h.segments.get();for(let t of e)E.push({segments:new Ns([t]),sortKey:t.sortKey,state:K,terrainData:R})}else E.push({segments:h.segments,sortKey:0,state:K,terrainData:R})}w&&E.sort((e,t)=>e.sortKey-t.sortKey);let P=i.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,I=24*i.layout.get("text-letter-spacing").constantOr(0)<0||P>1;for(let t of E){let r=t.state;p.activeTexture.set(f.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,f.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let a=r.isSDF&&r.hasHalo;if(a){let a=r.uniformValues;a.u_is_halo=1,I&&(a.u_is_plain=0,Hw(r.buffers,t.segments,i,e,r.program,T,h,c,a,r.projectionData,t.terrainData),a.u_is_halo=0,a.u_is_plain=1)}Hw(r.buffers,t.segments,i,e,r.program,T,h,c,r.uniformValues,r.projectionData,t.terrainData),a&&!I&&(r.uniformValues.u_is_halo=0)}}function Hw(e,t,i,r,a,n,o,s,l,u,h){let c=r.context,d=c.gl;a.draw(c,d.TRIANGLES,n,o,s,Vw.backCCW,l,h,u,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Yw(e,t,i,r,a){let n=e.context,o=n.gl,s=Ow.disabled,l=new Rw([o.ONE,o.ONE],fi.transparent,[!0,!0,!0,!0]),u=t.getBucket(i);if(!u)return;let h=r.key,c=i.heatmapFbos.get(h);c||(c=Jw(n,t.tileSize,t.tileSize),i.heatmapFbos.set(h,c)),n.bindFramebuffer.set(c.framebuffer),n.viewport.set([0,0,t.tileSize,t.tileSize]),n.clear({color:fi.transparent});let d=u.programConfigurations.get(i.id),p=e.useProgram("heatmap",d,!a),f=e.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),m=e.style.map.terrain.getTerrainData(r);p.draw(n,o.TRIANGLES,Lw.disabled,s,l,Vw.disabled,Sb(t,e.transform.zoom,i.paint.get("heatmap-intensity"),1),m,f,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,e.transform.zoom,d)}function Kw(e,t,i,r,a){let n=e.context,o=n.gl,s=e.transform;n.setColorMode(e.colorModeForRenderPass());let l=Qw(n,t),u=i.key,h=t.heatmapFbos.get(u);if(!h)return;n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,h.colorAttachment.get()),n.activeTexture.set(o.TEXTURE1),l.bind(o.LINEAR,o.CLAMP_TO_EDGE);let c=s.getProjectionData({overscaledTileID:i,applyTerrainMatrix:a,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(n,o.TRIANGLES,Lw.disabled,Ow.disabled,e.colorModeForRenderPass(),Vw.disabled,Pb(e,t,0,1),null,c,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,s.zoom),h.destroy(),t.heatmapFbos.delete(u)}function Jw(e,t,i){let r=e.gl,a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA16F,t,i);let n=e.createFramebuffer(t,i,!1,!1);return n.colorAttachment.set(a),n}function Qw(e,t){return t.colorRampTexture||=new _u(e,t.colorRamp,e.gl.RGBA),t.colorRampTexture}function eT(e,t,i,r){let a=e.context,n=a.bindFramebuffer.get(),o=a.viewport.get(),[,,s,l]=o;return function(e,t,i){let r=e.context.gl;if(!e.layerOpacityFbo){let a=e.context.createFramebuffer(t,i,!0,!0),n=r.createTexture();return r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),a.colorAttachment.set(n),a.depthAttachment.set(e.context.createRenderbuffer(r.DEPTH_STENCIL,t,i)),e.layerOpacityFbo=a,void e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer)}if(e.layerOpacityFbo.width===t&&e.layerOpacityFbo.height===i)return void e.context.bindFramebuffer.set(e.layerOpacityFbo.framebuffer);let a=e.layerOpacityFbo;r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,i,0,r.RGBA,r.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(a.depthAttachment.get()),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,i),e.context.bindRenderbuffer.set(null),a.width=t,a.height=i,e.context.bindFramebuffer.set(a.framebuffer)}(e,s,l),a.viewport.set([0,0,s,l]),a.clear({color:fi.transparent,depth:1,stencil:0}),e.currentStencilSource=void 0,e.renderTileClippingMasks(t,i,r),{compositeTarget:n,compositeViewport:o}}function tT(e,t,i,r){let a=e.context,n=a.gl;a.bindFramebuffer.set(i.compositeTarget),a.viewport.set(i.compositeViewport),a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e.layerOpacityFbo.colorAttachment.get()),e.useProgram("layerOpacity").draw(a,n.TRIANGLES,Lw.disabled,Ow.disabled,e.colorModeForRenderPass(),Vw.disabled,(e=>({u_image:0,u_opacity:e}))(t),null,null,r.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,r.paint,e.transform.zoom),e.currentStencilSource=void 0}function iT(e,t,i,r,a,n,o,s){let l=256;if(a.stepInterpolant){let r=t.getSource().maxzoom,a=o.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-o.canonical.z):1;l=De(function(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}(n.maxLineLength/re*1024*a),256,i.maxTextureSize)}return s.gradient=lu({expression:a.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:s.gradient||void 0,clips:n.lineClipsArray}),s.texture?s.texture.update(s.gradient):s.texture=new _u(i,s.gradient,r.RGBA),s.version=a.gradientVersion,s.texture}function rT(e,t,i,r,a){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(a)}function aT(e,t,i,r,a,n){(a||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(n)}function nT(e,t,i,r,a,n,o){let s=n.gradients[a.id],l=s.texture;a.gradientVersion!==s.version&&(l=iT(e,t,i,r,a,n,o,s)),i.activeTexture.set(r.TEXTURE0),l.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function oT(e,t,i,r,a,n,o,s,l){let u=n.gradients[a.id],h=u.texture;a.gradientVersion!==u.version&&(h=iT(e,t,i,r,a,n,o,u)),i.activeTexture.set(r.TEXTURE0),h.bind(a.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(i),s.updatePaintBuffers(l)}function sT(e,t,i,r,a,n){let o,{isRenderingToTexture:s}=a,l=e.getDepthModeForSublayer(0,Lw.ReadOnly),u=e.colorModeForRenderPass(),h=i.paint.get("line-dasharray"),c=h.constantOr(1),d=i.paint.get("line-pattern"),p=d.constantOr(1),f=i.paint.get("line-gradient"),m=i.getCrossfadeParameters();o=p?"linePattern":c&&f?"lineGradientSDF":c?"lineSDF":f?"lineGradient":"line";let g=e.context,_=g.gl,y=e.transform,x=!0;for(let a of r){let r=t.getTile(a);if(p&&!r.patternsLoaded())continue;let v=r.getBucket(i);if(!v)continue;let b=v.programConfigurations.get(i.id),w=e.context.program.get(),T=e.useProgram(o,b),D=x||T.program!==w,E=n?e.getTerrainDataForTile(a,s):null,S=d.constantOr(null),P=h?.constantOr(null);if(S&&r.imageAtlas){let e=r.imageAtlas,t=e.patternPositions[S.to.toString()],i=e.patternPositions[S.from.toString()];t&&i&&b.setConstantPatternPositions(t,i)}else if(P){let t="round"===i.layout.get("line-cap").constantOr(null),r=e.lineAtlas.getDash(P.to,t),a=e.lineAtlas.getDash(P.from,t);b.setConstantDashPositions(r,a)}let I,A=y.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),C=y.getPixelScale();p?(I=Rb(e,r,i,C,m),rT(g,_,r,b,m)):c&&f?(I=Lb(e,r,i,C,m,v.lineClipsArray.length),oT(e,t,g,_,i,v,a,b,m)):c?(I=kb(e,r,i,C,m),aT(e,g,_,b,D,m)):f?(I=Fb(e,r,i,C,v.lineClipsArray.length),nT(e,t,g,_,i,v,a)):I=zb(e,r,i,C);let M=e.stencilModeForClipping(a);T.draw(g,_.TRIANGLES,l,M,u,Vw.disabled,I,E,A,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,e.transform.zoom,b,v.layoutVertexBuffer2),x=!1}}function lT(e,t,i,r,a){if(!i||!r?.imageAtlas)return;let n=r.imageAtlas.patternPositions,o=n[i.to.toString()],s=n[i.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let e=a.getPaintProperty(t);o=n[e],s=n[e]}o&&s&&e.setConstantPatternPositions(o,s)}function uT(e,t,i,r,a){let{isRenderingToTexture:n}=a,o=e.colorModeForRenderPass();cT(e,t,i,r,e.getDepthModeForSublayer(1,Lw.ReadOnly),o,!1,n),hT(e,t,i,r,a)}function hT(e,t,i,r,a){if(!i.paint.get("fill-antialias"))return;let{isRenderingToTexture:n}=a,o=e.colorModeForRenderPass();cT(e,t,i,r,e.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,Lw.ReadOnly),o,!0,n)}function cT(e,t,i,r,a,n,o,s){let l,u,h,c,d,p=e.context.gl,f="fill-pattern",m=i.paint.get(f),g=m?.constantOr(1),_=i.getCrossfadeParameters(),y=e.transform,x=i.paint.get("fill-translate"),v=i.paint.get("fill-translate-anchor");o?(u=g&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",l=p.LINES):(u=g?"fillPattern":"fill",l=p.TRIANGLES);let b=m.constantOr(null);for(let m of r){let r=t.getTile(m);if(g&&!r.patternsLoaded())continue;let w=r.getBucket(i);if(!w)continue;let T=w.sdfPatterns[i.id]??!1,D=w.programConfigurations.get(i.id),E=e.useProgram(u,D),S=e.getTerrainDataForTile(m,s);g&&(e.context.activeTexture.set(p.TEXTURE0),r.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),D.updatePaintBuffers(_)),lT(D,f,b,r,i);let P=y.getProjectionData({overscaledTileID:m,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),I=ce(y,r,x,v);o?(c=w.indexBuffer2,d=w.segments2,h="fillOutlinePattern"===u&&g?Tb(e,_,r,I,T):wb(I)):(c=w.indexBuffer,d=w.segments,h=g?vb(e,_,r,I,T):bb(I));let A=e.stencilModeForClipping(m);E.draw(e.context,l,a,A,n,Vw.backCCW,h,S,P,i.id,w.layoutVertexBuffer,c,d,i.paint,e.transform.zoom,D)}}function dT(e,t,i,r,a,n,o,s){let l=e.context,u=l.gl,h="fill-extrusion-pattern",c=i.paint.get(h),d=c.constantOr(1),p=i.getCrossfadeParameters(),f=i.paint.get("fill-extrusion-opacity"),m=c.constantOr(null),g=e.transform;for(let c of r){let r=t.getTile(c),_=r.getBucket(i);if(!_)continue;let y=e.style.map.terrain?.getTerrainData(c),x=_.programConfigurations.get(i.id),v=e.useProgram(d?"fillExtrusionPattern":"fillExtrusion",x);d&&(e.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),x.updatePaintBuffers(p));let b=g.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!s,applyTerrainMatrix:!0});lT(x,h,m,r,i);let w=ce(g,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),T=i.paint.get("fill-extrusion-vertical-gradient"),D=d?xb(e,T,f,w,c,p,r):yb(e,T,f,w);v.draw(l,l.gl.TRIANGLES,a,n,o,Vw.backCCW,D,y,b,i.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,i.paint,e.transform.zoom,x,e.style.map.terrain&&_.centroidVertexBuffer)}}function pT(e,t,i,r,a,n,o,s,l){let u=e.style.projection,h=e.context,c=e.transform,d=h.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],f=e.useProgram("hillshade",null,!1,p),m=!e.options.moving;for(let p of r){let r=t.getTile(p),g=r.fbo;if(!g)continue;let _=u.getMeshFromTileID(h,p.canonical,s,!0,"raster"),y=e.getTerrainDataForTile(p,l);h.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,g.colorAttachment.get());let x=c.getProjectionData({overscaledTileID:p,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});f.draw(h,d.TRIANGLES,n,a[p.overscaledZ],o,Vw.backCCW,Ib(e,r,i),y,x,i.id,_.vertexBuffer,_.indexBuffer,_.segments)}}let fT=0;function mT(e,t,i,r,a,n,o,s,l){let u=e.style.projection,h=e.context,c=e.transform,d=h.gl,p=e.useProgram("colorRelief"),f=!e.options.moving,m="nearest"===i.paint.get("resampling")?d.NEAREST:d.LINEAR,g=!0,_=0;for(let y of r){let r=t.getTile(y),x=r.dem;if(!x?.data)continue;if(g){fT||=d.getParameter(d.MAX_TEXTURE_SIZE);let e=fT,{elevationTexture:t,colorTexture:r}=i.getColorRampTextures(h,e,x.getUnpackVector());h.activeTexture.set(d.TEXTURE1),t.bind(d.NEAREST,d.CLAMP_TO_EDGE),h.activeTexture.set(d.TEXTURE4),r.bind(d.LINEAR,d.CLAMP_TO_EDGE),g=!1,_=t.size[0]}let v=x.stride;h.activeTexture.set(d.TEXTURE0),(!r.demTexture||r.needsColorReliefPrepare)&&(h.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=e.getTileTexture(v)??new _u(h,{width:v,height:v,data:null},d.RGBA),r.demTexture.update(x.getPixels(),{premultiply:!1}),r.needsColorReliefPrepare=!1),r.demTexture.bind(m,d.CLAMP_TO_EDGE);let b=u.getMeshFromTileID(h,y.canonical,s,!0,"raster"),w=e.getTerrainDataForTile(y,l),T=c.getProjectionData({overscaledTileID:y,aligned:f,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(h,d.TRIANGLES,n,a[y.overscaledZ],o,Vw.backCCW,Mb(i,r.dem,_),w,T,i.id,b.vertexBuffer,b.indexBuffer,b.segments)}}const gT=[new c(0,0),new c(re,0),new c(re,re),new c(0,re)];function _T(e,t,i,r,a,n,o,s,l,u=!1,h=!1,c=null){let d=r[r.length-1].overscaledZ,p=e.context,f=p.gl,m=e.useProgram("raster"),g=e.transform,_=e.style.projection,y=e.colorModeForRenderPass(),x=!e.options.moving,v=i.paint.get("raster-opacity"),b="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?f.NEAREST:f.LINEAR,w=i.paint.get("raster-fade-duration"),T=!!e.style.map.terrain;for(let D of r){let r=e.getDepthModeForSublayer(D.overscaledZ-d,1===v?Lw.ReadWrite:Lw.ReadOnly,f.LESS),E=t.getTile(D);p.activeTexture.set(f.TEXTURE0),E.texture.bind(b,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(f.TEXTURE1);let{parentTile:S,parentScaleBy:P,parentTopLeft:I,fadeValues:A}=yT(E,t,w,T);E.fadeOpacity=A.tileOpacity,S?(S.fadeOpacity=A.parentTileOpacity,S.texture.bind(b,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):E.texture.bind(b,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),E.texture.useMipmap&&p.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let C=e.getTerrainDataForTile(D,h),M=g.getProjectionData({overscaledTileID:D,aligned:x,applyGlobeMatrix:!h,applyTerrainMatrix:!0}),z=xy(I,P,A.fadeMix,i,s,l),F=c??_.getMeshFromTileID(p,D.canonical,n,o,"raster"),R=a?a[D.overscaledZ]:Ow.disabled;m.draw(p,f.TRIANGLES,r,R,y,u?Vw.frontCCW:Vw.backCCW,z,C,M,i.id,F.vertexBuffer,F.indexBuffer,F.segments)}}function yT(e,t,i,r){let a={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===i||r)return a;if(e.fadingParentID){let r=t.getLoadedTile(e.fadingParentID);if(!r)return a;let n=2**(r.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:r,parentScaleBy:n,parentTopLeft:[e.tileID.canonical.x*n%1,e.tileID.canonical.y*n%1],fadeValues:xT(e,r,i)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:vT(e,i)}:a}function xT(e,t,i){let r=Xg(),a=(r-e.timeAdded)/i,n=(r-t.timeAdded)/i,o=1===e.fadingDirection,s=De(a,0,1),l=De(1-n,0,1),u=o?s:l;return{tileOpacity:u,parentTileOpacity:o?l:s,fadeMix:{opacity:1,mix:1-u}}}function vT(e,t){let i=De((Xg()-e.timeAdded)/t,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}const bT=new fi(1,0,0,1),wT=new fi(0,1,0,1),TT=new fi(0,0,1,1),DT=new fi(1,0,1,1),ET=new fi(0,1,1,1);function ST(e,t,i,r){IT(e,0,t+i/2,e.transform.width,i,r)}function PT(e,t,i,r){IT(e,t-i/2,0,i,e.transform.height,r)}function IT(e,t,i,r,a,n){let o=e.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,a*e.pixelRatio),o.clear({color:n}),s.disable(s.SCISSOR_TEST)}function AT(e,t,i){let r=e.context,a=r.gl,n=e.useProgram("debug"),o=Lw.disabled,s=Ow.disabled,l=e.colorModeForRenderPass(),u="$debug",h=e.style.map.terrain?.getTerrainData(i);r.activeTexture.set(a.TEXTURE0);let c=t.getTileByID(i.key).latestRawTileData?.byteLength||0,d=Math.floor(c/1024),p=t.getTile(i).tileSize,f=512/Math.min(p,512)*(i.overscaledZ/e.transform.zoom)*.5,m=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(m+=` => ${i.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();let i=e.debugOverlayCanvas,r=e.context.gl,a=e.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,i.width,i.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(t,5,5),a.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${m} ${d}kB`);let g=e.transform.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(r,a.TRIANGLES,o,s,Rw.alphaBlended,Vw.disabled,Eb(fi.transparent,f),null,g,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),n.draw(r,a.LINE_STRIP,o,s,l,Vw.disabled,Eb(fi.red),h,g,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function CT(e,t){if(!t.mesh){let i=new xs;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1);let r=new Ls;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),t.mesh=new Ty(e.createVertexBuffer(i,Dy.members),e.createIndexBuffer(r),Ns.simpleSegment(0,0,i.length,r.length))}return t.mesh}const MT={symbol:function(e,t,i,r,a,n){if("translucent"!==n.currentPass)return;let{isRenderingToTexture:o}=n,s=Ow.disabled,l=e.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,t,i,r,a,n,o,s,l){let u=t.transform,h=t.style.map.terrain,c="map"===a,d="map"===n;for(let a of e){let e=r.getTile(a),n=e.getBucket(i);if(!n?.text?.segments.get().length)continue;let p=op(n.textSizeData,u.zoom),f=ae(e,1,t.transform.zoom),m=ox(c,t.transform,f),g="none"!==i.layout.get("icon-text-fit")&&n.hasIconData();if(p){let t=2**(u.zoom-e.tileID.overscaledZ),r=h?(e,t)=>h.getElevation(a,e,t):void 0;qw(n,c,d,l,u,m,t,p,g,ce(u,e,o,s),a.toUnwrapped(),r,"ground"===i.layout.get("symbol-height-anchor"))}}}(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),a),0!==i.paint.get("icon-opacity").constantOr(1)&&Xw(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment").constantOr("viewport"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),s,l,o),0!==i.paint.get("text-opacity").constantOr(1)&&Xw(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),s,l,o),t.map.showCollisionBoxes&&(Uw(e,t,i,r,!0),Uw(e,t,i,r,!1))},circle:function(e,t,i,r,a){if("translucent"!==a.currentPass)return;let{isRenderingToTexture:n}=a,o=i.paint.get("circle-opacity"),s=i.paint.get("circle-stroke-width"),l=i.paint.get("circle-stroke-opacity"),u=!i.layout.get("circle-sort-key").isConstant();if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===l.constantOr(1)))return;let h=e.context,c=h.gl,d=e.transform,p=e.getDepthModeForSublayer(0,Lw.ReadOnly),f=Ow.disabled,m=e.colorModeForRenderPass(),g=[],_=d.getCircleRadiusCorrection();for(let a of r){let r=t.getTile(a),o=r.getBucket(i);if(!o)continue;let s=ce(d,r,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),l=o.programConfigurations.get(i.id),h=e.useProgram("circle",l),c=o.layoutVertexBuffer,p=o.indexBuffer,f=e.style.map.terrain?.getTerrainData(a),m={programConfiguration:l,program:h,layoutVertexBuffer:c,indexBuffer:p,uniformValues:Db(e,r,i,s,_),terrainData:f,projectionData:d.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!n,applyTerrainMatrix:!0})};if(u){let e=o.segments.get();for(let t of e)g.push({segments:new Ns([t]),sortKey:t.sortKey,state:m})}else g.push({segments:o.segments,sortKey:0,state:m})}u&&g.sort((e,t)=>e.sortKey-t.sortKey);for(let t of g){let{programConfiguration:r,program:a,layoutVertexBuffer:n,indexBuffer:o,uniformValues:s,terrainData:l,projectionData:u}=t.state,d=t.segments;a.draw(h,c.TRIANGLES,p,f,m,Vw.backCCW,s,l,u,i.id,n,o,d,i.paint,e.transform.zoom,r)}},heatmap:function(e,t,i,r,a){if(0===i.paint.get("heatmap-opacity"))return;let n=e.context,{isRenderingToTexture:o,isRenderingGlobe:s}=a;if(e.style.map.terrain){for(let n of r){let r=t.getTile(n);t.hasRenderableParent(n)||("offscreen"===a.currentPass?Yw(e,r,i,n,s):"translucent"===a.currentPass&&Kw(e,i,n,o,s))}n.viewport.set([0,0,e.width,e.height])}else"offscreen"===a.currentPass?function(e,t,i,r){let a=e.context,n=a.gl,o=e.transform,s=Ow.disabled,l=new Rw([n.ONE,n.ONE],fi.transparent,[!0,!0,!0,!0]);(function(e,t,i){let r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let a=i.heatmapFbos.get(uu);a?(r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=Jw(e,t.width/4,t.height/4),i.heatmapFbos.set(uu,a))})(a,e,i),a.clear({color:fi.transparent});for(let u of r){if(t.hasRenderableParent(u))continue;let r=t.getTile(u),h=r.getBucket(i);if(!h)continue;let c=h.programConfigurations.get(i.id),d=e.useProgram("heatmap",c),p=o.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),f=o.getCircleRadiusCorrection();d.draw(a,n.TRIANGLES,Lw.disabled,s,l,Vw.backCCW,Sb(r,o.zoom,i.paint.get("heatmap-intensity"),f),null,p,i.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,i.paint,o.zoom,c)}a.viewport.set([0,0,e.width,e.height])}(e,t,i,r):"translucent"===a.currentPass&&function(e,t){let i=e.context,r=i.gl;i.setColorMode(e.colorModeForRenderPass());let a=t.heatmapFbos.get(uu);a&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),Qw(i,t).bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(i,r.TRIANGLES,Lw.disabled,Ow.disabled,e.colorModeForRenderPass(),Vw.disabled,Pb(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom))}(e,i)},line:function(e,t,i,r,a){if("translucent"!==a.currentPass)return;let n=i.paint.get("line-opacity"),o=i.paint.get("line-width"),s=i.paint.get("line-layer-opacity");if(0===n.constantOr(1)||0===o.constantOr(1)||0===s)return;let l=!!e.style.map.terrain;if(s<1){let n=eT(e,i,r,l);return sT(e,t,i,r,a,l),void tT(e,s,n,i)}sT(e,t,i,r,a,l)},fill:function(e,t,i,r,a){let n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity"),s=i.paint.get("fill-layer-opacity");if(0===o.constantOr(1)||0===s)return;if(s<1){if("translucent"!==a.currentPass)return;let n=eT(e,i,r,!!e.style.map.terrain);return uT(e,t,i,r,a),void tT(e,s,n,i)}let l=i.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(fi.transparent).a&&1===o.constantOr(0);if(u&&"opaque"===a.currentPass){let{isRenderingToTexture:n}=a,o=e.colorModeForRenderPass();return void cT(e,t,i,r,e.getDepthModeForSublayer(1,Lw.ReadWrite),o,!1,n)}u&&"translucent"===a.currentPass?hT(e,t,i,r,a):"translucent"===a.currentPass&&uT(e,t,i,r,a)},fillExtrusion:function(e,t,i,r,a){let n=i.paint.get("fill-extrusion-opacity");if(0===n)return;let{isRenderingToTexture:o}=a;if("translucent"===a.currentPass){let s=new Lw(e.context.gl.LEQUAL,Lw.ReadWrite,a.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))dT(e,t,i,r,s,Ow.disabled,Rw.disabled,o),dT(e,t,i,r,s,e.stencilModeFor3D(),e.colorModeForRenderPass(),o);else{let a=e.colorModeForRenderPass();dT(e,t,i,r,s,Ow.disabled,a,o)}}},hillshade:function(e,t,i,r,a){if("offscreen"!==a.currentPass&&"translucent"!==a.currentPass)return;let{isRenderingToTexture:n}=a,o=e.context,s=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,Lw.ReadOnly),u=e.colorModeForRenderPass();if("offscreen"===a.currentPass)(function(e,t,i,r,a,n,o){let s=e.context,l=s.gl,u="nearest"===r.paint.get("resampling")?l.NEAREST:l.LINEAR;for(let h of i){let i=t.getTile(h),c=i.dem;if(!c?.data||!i.needsHillshadePrepare)continue;let d=c.dim+2,p=c.stride,f=c.getPixels();if(s.activeTexture.set(l.TEXTURE1),s.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||=e.getTileTexture(p),i.demTexture){let e=i.demTexture;e.update(f,{premultiply:!1}),e.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new _u(s,f,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);s.activeTexture.set(l.TEXTURE0);let m=i.fbo;if(!m){let e=new _u(s,{width:d,height:d,data:null},l.RGBA);e.bind(u,l.CLAMP_TO_EDGE),m=i.fbo=s.createFramebuffer(d,d,!0,!1),m.colorAttachment.set(e.texture)}s.bindFramebuffer.set(m.framebuffer),s.viewport.set([0,0,d,d]),e.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,a,n,o,Vw.disabled,Ab(i.tileID,c),null,null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),i.needsHillshadePrepare=!1}})(e,t,r,i,l,Ow.disabled,u),o.viewport.set([0,0,e.width,e.height]);else if("translucent"===a.currentPass)if(s){let[a,o,s]=e.stencilConfigForOverlapTwoPass(r);pT(e,t,i,s,a,l,u,!1,n),pT(e,t,i,s,o,l,u,!0,n)}else{let[a,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);pT(e,t,i,o,a,l,u,!1,n)}},colorRelief:function(e,t,i,r,a){if("translucent"!==a.currentPass||!r.length)return;let{isRenderingToTexture:n}=a,o=e.style.projection.useSubdivision,s=e.getDepthModeForSublayer(0,Lw.ReadOnly),l=e.colorModeForRenderPass();if(o){let[a,o,u]=e.stencilConfigForOverlapTwoPass(r);mT(e,t,i,u,a,s,l,!1,n),mT(e,t,i,u,o,s,l,!0,n)}else{let[a,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);mT(e,t,i,o,a,s,l,!1,n)}},raster:function(e,t,i,r,a){if("translucent"!==a.currentPass||0===i.paint.get("raster-opacity")||!r.length)return;let{isRenderingToTexture:n}=a,o=t.getSource(),s=e.style.projection.useSubdivision;if(o instanceof Sy)_T(e,t,i,r,null,!1,!1,o.tileCoords,o.imageWarp,o.flippedWindingOrder,n,o.getMesh(e.context,s));else if(s){let[a,o,s]=e.stencilConfigForOverlapTwoPass(r);_T(e,t,i,s,a,!1,!0,gT,yy,!1,n),_T(e,t,i,s,o,!0,!0,gT,yy,!1,n)}else{let[a,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);_T(e,t,i,o,a,!1,!0,gT,yy,!1,n)}},background:function(e,t,i,r,a){let n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;let{isRenderingToTexture:s}=a,l=e.context,u=l.gl,h=e.style.projection,c=e.transform,d=c.tileSize,p=i.paint.get("background-pattern");if(e.isPatternMissing(p))return;let f=!p&&1===n.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.currentPass!==f)return;let m=Ow.disabled,g=e.getDepthModeForSublayer(0,"opaque"===f?Lw.ReadWrite:Lw.ReadOnly),_=e.colorModeForRenderPass(),y=e.useProgram(p?"backgroundPattern":"background"),x=r||Zy(c,{tileSize:d,terrain:e.style.map.terrain});p&&(l.activeTexture.set(u.TEXTURE0),e.patternAtlas.bind(e.context));let v=i.getCrossfadeParameters();for(let t of x){let r=c.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),a=p?$b(o,e,p,{tileID:t,tileSize:d},v):Ub(o,n),f=e.getTerrainDataForTile(t,s),x=h.getMeshFromTileID(l,t.canonical,!1,!0,"raster");y.draw(l,u.TRIANGLES,g,m,_,Vw.backCCW,a,f,r,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}},sky:function(e,t){let i=e.context,r=i.gl,a=((e,t,i)=>{let r=Math.cos(t.rollInRadians),a=Math.sin(t.rollInRadians),n=Qh(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-n*a)*i,(t.height/2+n*r)*i],u_horizon_normal:[-a,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:o,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:Rv(t),u_globe_radius:Fv(t.worldSize,t.center.lat)}})(t,e.transform,e.pixelRatio),n=new Lw(r.LEQUAL,Lw.ReadWrite,[0,1]),o=Ow.disabled,s=e.colorModeForRenderPass(),l=e.useProgram("sky"),u=CT(i,t);l.draw(i,r.TRIANGLES,n,o,s,Vw.disabled,a,null,void 0,"sky",u.vertexBuffer,u.indexBuffer,u.segments)},atmosphere:function(e,t,i){let r=e.context,a=r.gl,n=e.useProgram("atmosphere"),o=new Lw(a.LEQUAL,Lw.ReadOnly,[0,1]),s=e.transform,l=function(e,t){let i=e.getCartesianPosition();!function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2]}(i,i);let r=v(new Float64Array(16));return"map"===e.properties.get("anchor")&&(P(r,r,t.rollInRadians),E(r,r,-t.pitchInRadians),P(r,r,t.bearingInRadians),E(r,r,t.center.lat*Math.PI/180),S(r,r,-t.center.lng*Math.PI/180)),function(e,t,i){var r=t[0],a=t[1],n=t[2],o=i[3]*r+i[7]*a+i[11]*n+i[15];o||=1,e[0]=(i[0]*r+i[4]*a+i[8]*n+i[12])/o,e[1]=(i[1]*r+i[5]*a+i[9]*n+i[13])/o,e[2]=(i[2]*r+i[6]*a+i[10]*n+i[14])/o}(i,i,r),i}(i,e.transform),u=s.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),h=t.properties.get("atmosphere-blend")*u.projectionTransition;if(0===h)return;let c=Fv(s.worldSize,s.center.lat),d=((e,t,i,r,a)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:a}))(l,h,Rv(s),c,s.inverseProjectionMatrix),p=CT(r,t);n.draw(r,a.TRIANGLES,o,Ow.disabled,Rw.alphaBlended,Vw.disabled,d,null,null,"atmosphere",p.vertexBuffer,p.indexBuffer,p.segments)},custom:function(e,t,i,r){let{isRenderingGlobe:a}=r,n=e.context,o=i.implementation,s=e.style.projection,l=e.transform,u=l.getProjectionDataForCustomLayer(a),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:s.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${s.shaderPreludeCode.vertexSource}`,define:s.shaderDefine},defaultProjectionData:u,getProjectionData:e=>l.getProjectionData({overscaledTileID:new sf(e.tileID.canonical.z,e.tileID.wrap??0,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),aligned:e.aligned,applyGlobeMatrix:e.applyGlobeMatrix,applyTerrainMatrix:e.applyTerrainMatrix})},c=o.renderingMode?o.renderingMode:"2d";if("offscreen"===r.currentPass){let t=o.prerender;t&&(e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),t.call(o,n.gl,h),n.setDirty(),e.setBaseState())}else if("translucent"===r.currentPass){e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(Ow.disabled);let t="3d"===c?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,Lw.ReadOnly);n.setDepthMode(t),o.render(n.gl,h),n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null)}},debug:function(e,t,i){for(let r of i)AT(e,t,r)},debugPadding:function(e){let t=e.transform.padding;ST(e,e.transform.height-(t.top||0),3,bT),ST(e,t.bottom||0,3,wT),PT(e,t.left||0,3,TT),PT(e,e.transform.width-(t.right||0),3,DT);let i=e.transform.centerPoint;!function(e,t,i,r){IT(e,t-1,i-10,2,20,r),IT(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,ET)},terrainDepth:function(e,t){let i=e.context,r=i.gl,a=e.transform,n=Rw.unblended,o=new Lw(r.LEQUAL,Lw.ReadWrite,[0,1]),s=t.tileManager.getRenderableTiles(),l=e.useProgram("terrainDepth");i.bindFramebuffer.set(t.getFramebuffer().framebuffer),i.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),i.clear({color:fi.white,depth:1});for(let e of s){let s=t.getTerrainMesh(e.tileID),u=t.getTerrainData(e.tileID),h=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),c=ob(t.getSkirtLength(a.zoom));l.draw(i,r.TRIANGLES,o,Ow.disabled,n,Vw.backCCW,c,u,h,"terrain",s.vertexBuffer,s.indexBuffer,s.segments)}i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height])}};var zT=class e{constructor(e,t){this.drawFunctions=MT,this.context=new kw(e),this.transform=t,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:v(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Qy.maxOverzooming+Qy.maxUnderzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new Qx}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let e of this.style._order)this.style._layers[e].resize()}setup(){let e=this.context,t=new xs;t.emplaceBack(0,0),t.emplaceBack(re,0),t.emplaceBack(0,re),t.emplaceBack(re,re),this.tileExtentBuffer=e.createVertexBuffer(t,Dy.members),this.tileExtentSegments=Ns.simpleSegment(0,0,4,2);let i=new xs;i.emplaceBack(0,0),i.emplaceBack(re,0),i.emplaceBack(0,re),i.emplaceBack(re,re),this.debugBuffer=e.createVertexBuffer(i,Dy.members),this.debugSegments=Ns.simpleSegment(0,0,4,5);let r=new bs;r.emplaceBack(0,0,0,0),r.emplaceBack(re,0,re,0),r.emplaceBack(0,re,0,re),r.emplaceBack(re,re,re,re),this.rasterBoundsBuffer=e.createVertexBuffer(r,rb.members),this.rasterBoundsSegments=Ns.simpleSegment(0,0,4,2);let a=new xs;a.emplaceBack(0,0),a.emplaceBack(re,0),a.emplaceBack(0,re),a.emplaceBack(re,re),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,Dy.members),this.rasterBoundsSegmentsPosOnly=Ns.simpleSegment(0,0,4,5);let n=new xs;n.emplaceBack(0,0),n.emplaceBack(1,0),n.emplaceBack(0,1),n.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(n,Dy.members),this.viewportSegments=Ns.simpleSegment(0,0,4,2);let o=new Os;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(o);let s=new Ls;s.emplaceBack(1,0,2),s.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s);let l=this.context.gl;this.stencilClearMode=new Ow({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new Ty(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let e=this.context,t=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let i=y();A(i,0,this.width,this.height,0,0,1),D(i,i,[t.drawingBufferWidth,t.drawingBufferHeight,0]);let r={mainMatrix:i,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:i,clipAntimeridian:!1};this.useProgram("clippingMask",null,!0).draw(e,t.TRIANGLES,Lw.disabled,this.stencilClearMode,Rw.disabled,Vw.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t?.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let r=this.context;r.setColorMode(Rw.disabled),r.setDepthMode(Lw.disabled);let a={};for(let e of t)a[e.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(a,t,i,!0),this._renderTileMasks(a,t,i,!1),this._tileClippingMaskIDs=a}_renderTileMasks(e,t,i,r){let a=this.context,n=a.gl,o=this.style.projection,s=this.transform,l=this.useProgram("clippingMask");for(let u of t){let t=e[u.key],h=this.getTerrainDataForTile(u,i),c=o.getMeshFromTileID(this.context,u.canonical,r,!0,"stencil"),d=s.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(a,n.TRIANGLES,Lw.disabled,new Ow({func:n.ALWAYS,mask:0},t,255,n.KEEP,n.KEEP,n.REPLACE),Rw.disabled,i?Vw.disabled:Vw.backCCW,null,h,d,"$clipping",c.vertexBuffer,c.indexBuffer,c.segments)}}getTerrainDataForTile(e,t){return t&&"mercator"===this.style.projection?.name?null:this.style.map.terrain?.getTerrainData(e)||null}_renderTilesDepthBuffer(){let e=this.context,t=e.gl,i=this.style.projection,r=this.transform,a=this.useProgram("depth"),n=this.getDepthModeFor3D(),o=Zy(r,{tileSize:r.tileSize});for(let s of o){let o=this.style.map.terrain?.getTerrainData(s),l=i.getMeshFromTileID(this.context,s.canonical,!0,!0,"raster"),u=r.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(e,t.TRIANGLES,n,Ow.disabled,Rw.disabled,Vw.backCCW,null,o,u,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new Ow({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new Ow({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,a=i[0].overscaledZ-r+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();let e={};for(let i=0;i<a;i++)e[i+r]=new Ow({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=a,[e,i]}return[{[r]:Ow.disabled},i]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,a=i[0].overscaledZ-r+1;if(this.clearStencil(),a>1){let e={},n={};for(let i=0;i<a;i++)e[i+r]=new Ow({func:t.GREATER,mask:255},a+1+i,255,t.KEEP,t.KEEP,t.REPLACE),n[i+r]=new Ow({func:t.GREATER,mask:255},1+i,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*a+1,[e,n,i]}return this.nextStencilID=3,[{[r]:new Ow({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new Ow({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}colorModeForRenderPass(){let e=this.context.gl;if(this._showOverdrawInspector){let t=1/8;return new Rw([e.CONSTANT_COLOR,e.ONE],new fi(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.renderOptions.currentPass?Rw.unblended:Rw.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return Lw.disabled;let r=1-((1+this.renderOptions.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Lw(i||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new Lw(this.context.gl.LEQUAL,Lw.ReadWrite,this.renderOptions.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.renderOptions.currentLayer<this.renderOptions.opaquePassCutoff}render(e,t){this.style=e,this.options=t;let i=this.renderOptions=function(e,t,i){let r=t?.transitionState??0;return{currentPass:"offscreen",currentLayer:0,opaquePassCutoff:1/0,depthRangeFor3D:[0,1],isRenderingToTexture:!1,transform:e,terrain:i,projectionTransition:r,isRenderingGlobe:r>0}}(this.transform,e.projection,e.map.terrain??null);this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.patternAtlas=e.patternAtlas,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(Xg()),function(e,t){let i=e.pending,{transform:r}=t,a=t.context.gl;i[Fw.u_units_to_pixels]=1/r.pixelsToGLUnits[0],i[Fw.u_units_to_pixels+1]=1/r.pixelsToGLUnits[1],i[Fw.u_world_size]=a.drawingBufferWidth,i[Fw.u_world_size+1]=a.drawingBufferHeight,i[Fw.u_camera_to_center_distance]=r.cameraToCenterDistance,i[Fw.u_symbol_fade_change]=t.options.fadeDuration?t.symbolFadeChange:1,i[Fw.u_aspect_ratio]=r.width/r.height,i[Fw.u_device_pixel_ratio]=t.pixelRatio,i[Fw.u_viewport_size]=r.width,i[Fw.u_viewport_size+1]=r.height,i[Fw.u_pixel_extrude_scale]=1/r.width,i[Fw.u_pixel_extrude_scale+1]=1/r.height,i[Fw.u_pitch]=r.pitch/360*2*Math.PI,e.upload()}(this.context.frameUniformBuffer,this),this.imageManager.beginFrame();let r=this.style._order,a=this.style.tileManagers,n={},o={},s={};for(let e in a){let t=a[e];t.used&&t.prepare(this.context),n[e]=t.getVisibleCoordinates(!1),o[e]=n[e].slice().reverse(),s[e]=t.getVisibleCoordinates(!0).reverse()}i.opaquePassCutoff=1/0;for(let e=0;e<r.length;e++){let t=r[e];if(this.style._layers[t].is3D()){i.opaquePassCutoff=e;break}}this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),i.opaquePassCutoff=0),i.currentPass="offscreen";for(let e of r){let t=this.style._layers[e];if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;let r=o[t.source];("custom"===t.type||r.length)&&this.renderLayer(this,a[t.source],t,r,i)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:t.showOverdrawInspector?fi.black:fi.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=t.showOverdrawInspector,i.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(i.currentPass="opaque",i.currentLayer=r.length-1;i.currentLayer>=0;i.currentLayer--){let e=this.style._layers[r[i.currentLayer]];if(e.isHidden(this.transform.zoom))continue;let t=a[e.source],o=n[e.source];this.renderTileClippingMasks(e,o,!1),this.renderLayer(this,t,e,o,i)}i.currentPass="translucent";let l=!1;for(i.currentLayer=0;i.currentLayer<r.length;i.currentLayer++){let e=this.style._layers[r[i.currentLayer]];if(e.isHidden(this.transform.zoom))continue;let t=a[e.source];if(this.renderToTexture?.renderLayer(e,i))continue;!this.opaquePassEnabledForLayer()&&!l&&(l=!0,i.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let u=("symbol"===e.type?s:o)[e.source];this.renderTileClippingMasks(e,n[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,u,i)}if(i.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let e=function(e,t){let i=null,r=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[]),a=r.filter(e=>"vector"===e.getSource().type),n=r.filter(e=>"vector"!==e.getSource().type),o=e=>{(!i||i.getSource().maxzoom<e.getSource().maxzoom)&&(i=e)};for(let e of a)o(e);if(!i)for(let e of n)o(e);return i}(this.style,this.transform.zoom);e&&this.drawFunctions.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(){if(!this.style?.projection||!this.style.map?.terrain)return;let e=this.terrainFacilitator.matrix,t=this.transform.modelViewProjectionMatrix,i=this.terrainFacilitator.depthDirty;i||=!function(e,t){var i=e[0],r=e[1],a=e[2],n=e[3],o=e[4],s=e[5],l=e[6],u=e[7],h=e[8],c=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],_=e[15],y=t[0],x=t[1],v=t[2],b=t[3],w=t[4],T=t[5],D=t[6],E=t[7],S=t[8],P=t[9],I=t[10],A=t[11],C=t[12],M=t[13],z=t[14],F=t[15];return Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(a-v)<=1e-6*Math.max(1,Math.abs(a),Math.abs(v))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-T)<=1e-6*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(l-D)<=1e-6*Math.max(1,Math.abs(l),Math.abs(D))&&Math.abs(u-E)<=1e-6*Math.max(1,Math.abs(u),Math.abs(E))&&Math.abs(h-S)<=1e-6*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(c-P)<=1e-6*Math.max(1,Math.abs(c),Math.abs(P))&&Math.abs(d-I)<=1e-6*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(p-A)<=1e-6*Math.max(1,Math.abs(p),Math.abs(A))&&Math.abs(f-C)<=1e-6*Math.max(1,Math.abs(f),Math.abs(C))&&Math.abs(m-M)<=1e-6*Math.max(1,Math.abs(m),Math.abs(M))&&Math.abs(g-z)<=1e-6*Math.max(1,Math.abs(g),Math.abs(z))&&Math.abs(_-F)<=1e-6*Math.max(1,Math.abs(_),Math.abs(F))}(e,t),i||=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),i&&(function(e,t){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,t),this.terrainFacilitator.renderTime=Xg(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}renderLayer(e,t,i,r,a){if(i.isHidden(this.transform.zoom)||"background"!==i.type&&"custom"!==i.type&&!(r||[]).length)return;this.id=i.id;let n=this.drawFunctions;Wp(i)?n.symbol(e,t,i,r,this.style.placement.variableOffsets,a):(e=>"circle"===e.type)(i)?n.circle(e,t,i,r,a):(e=>"heatmap"===e.type)(i)?n.heatmap(e,t,i,r,a):(e=>"line"===e.type)(i)?n.line(e,t,i,r,a):(e=>"fill"===e.type)(i)?n.fill(e,t,i,r,a):(e=>"fill-extrusion"===e.type)(i)?n.fillExtrusion(e,t,i,r,a):(e=>"hillshade"===e.type)(i)?n.hillshade(e,t,i,r,a):(e=>"color-relief"===e.type)(i)?n.colorRelief(e,t,i,r,a):Co(i)?n.raster(e,t,i,r,a):(e=>"background"===e.type)(i)?n.background(e,t,i,r,a):(e=>"custom"===e.type)(i)&&n.custom(e,t,i,a)}static{this.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50}saveTileTexture(t){let i=this._tileTextures[t.size[0]];i?i.length<e.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?i.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(e){let t=this._tileTextures[e];return t&&t.length>0?t.pop():null}acquireRTT(e){let t=this.context.gl,i=this._rttObjectRecyclePool.pop();if(i)return i.size!==e&&(i.texture.update({width:e,height:e,data:null},{premultiply:!1,useMipmap:!0}),i.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE,t.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),i.size=e),i;let r=new _u(this.context,{width:e,height:e,data:null},t.RGBA,{premultiply:!1,useMipmap:!0});return r.bind(t.LINEAR,t.CLAMP_TO_EDGE,t.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:r,size:e}}bindRTT(e){let t=this.context.gl,i=e.size;if(!this._rttSharedFbo){let e=this.context.createFramebuffer(i,i,!0,!0),r=this.context.createRenderbuffer(t.DEPTH_STENCIL,i,i);e.depthAttachment.set(r),this._rttSharedFbo={fbo:e,depthRenderbuffer:r,size:i}}this._rttSharedFbo.size!==i&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i,i),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=i,this._rttSharedFbo.fbo.height=i,this._rttSharedFbo.size=i),this._rttSharedFbo.fbo.colorAttachment.set(e.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(e){this._rttObjectRecyclePool.push(e)}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.patternAtlas.getPattern(e.from.toString()),i=this.patternAtlas.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,r=[]){this.cache||={};let a=!!this.style.map.terrain,n=this.style.projection,o=i?tv.projectionMercator:n.shaderPreludeCode,s=i?rv:n.shaderDefine,l=`/${i?av:n.shaderVariantName}`,u=e+(t?t.cacheKey:"")+l+(this._showOverdrawInspector?"/overdraw":"")+(a?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[u]||=new gb(this.context,tv[e],t,Zb[e],this._showOverdrawInspector,a,o,s,r),this.cache[u]}setCustomLayerDefaults(){this.context.setCustomLayerDefaults()}setBaseState(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){if(null==this.debugOverlayCanvas){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;let e=this.context.gl;this.debugOverlayTexture=new _u(this.context,this.debugOverlayCanvas,e.RGBA)}}destroy(){if(this._tileTextures){for(let e in this._tileTextures){let t=this._tileTextures[e];if(t)for(let e of t)e.destroy()}this._tileTextures={}}for(let e of this._rttObjectRecyclePool)e.texture.destroy();if(this._rttObjectRecyclePool=[],this._rttSharedFbo){this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let e=this.context.gl;e.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),e.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.context.projectionUniformBuffer.destroy(),this.context.terrainUniformBuffer.destroy(),this.context.frameUniformBuffer.destroy(),this.cache){for(let e in this.cache){let t=this.cache[e];t?.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}},FT=class extends Error{constructor(e,t){super("WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL"),this.name="GPUInitializationError",this.requestedAttributes=e,this.statusMessage=t?.statusMessage??null}};function RT(e,t){let i,r=!1,a=null,n=()=>{a=null,r&&=(e(...i),a=setTimeout(n,t),!1)};return(...e)=>(r=!0,i=e,a||n(),a)}var kT=class{constructor(e){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let e=this._getHashParams();return this._hashName?(e.get(this._hashName)||"").split("/"):([...e.keys()][0]??"").split("/")},this._onHashChange=()=>{let e=this._getCurrentHash();if(!this._isValidHash(e))return!1;let t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{let e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{let e=this._getHashParams();if(this._hashName)e.delete(this._hashName);else{let t=Array.from(e.keys());t.length>0&&e.delete(t[0])}let t=decodeURIComponent(e.toString()).replace(/=&/g,"&").replace(/=$/g,""),i=t?`#${t}`:"",r=window.location.href.replace(/(#.+)?$/,i);r=r.replace("&&","&"),window.history.replaceState(window.history.state,null,r)},this._updateHash=RT(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=10**Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.round(t.lng*r)/r,n=Math.round(t.lat*r)/r,o=this._map.getBearing(),s=this._map.getPitch(),l="";if(l+=e?`/${a}/${n}/${i}`:`${i}/${n}/${a}`,(o||s)&&(l+="/"+Math.round(10*o)/10),s&&(l+=`/${Math.round(s)}`),this._hashName){let e=this._getHashParams();return e.set(this._hashName,l),`#${decodeURIComponent(e.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${l}`}_isValidHash(e){if(e.length<3||e.some(e=>isNaN(+e)))return!1;try{new jh(+e[2],+e[1])}catch{return!1}let t=+e[0],i=+(e[3]||0),r=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&i>=-180&&i<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}};const LT={linearity:.3,easing:we(0,0,.3,1)},BT=Se({deceleration:2500,maxSpeed:1400},LT),OT=Se({deceleration:20,maxSpeed:1400},LT),jT=Se({deceleration:1e3,maxSpeed:360},LT),VT=Se({deceleration:1e3,maxSpeed:90},LT),NT=Se({deceleration:1e3,maxSpeed:360},LT);var UT=class{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Xg(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=Xg();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=Xg()-60,i=Math.max(0,e.length-2);for(;i>0&&e[i-1].time>=t;)i--;return e.slice(i)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2)return void this.clear();let i={zoom:0,bearing:0,pitch:0,roll:0,pan:new c(0,0),pinchAround:void 0,around:void 0};for(let{settings:e}of t)e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);for(let{settings:e}of t.slice(1))i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta);if(!(i.pan.mag()||i.zoom||i.bearing||i.pitch||i.roll))return void this.clear();let r=Xg()-t[0].time,a={};if(i.pan.mag()){let t=GT(i.pan.mag(),r,Se({},BT,e||{})),n=i.pan.mult(t.amount/i.pan.mag()),o=this._map._camera.cameraHelper.handlePanInertia(n,this._map._camera.transform);a.center=o.easingCenter,a.offset=o.easingOffset,$T(a,t)}if(i.zoom){let e=GT(i.zoom,r,OT);a.zoom=ze(this._map.getZoom()+e.amount,this._map.getZoomSnap(),e.amount),$T(a,e)}if(i.bearing){let e=GT(i.bearing,r,jT);a.bearing=this._map.getBearing()+De(e.amount,-179,179),$T(a,e)}if(i.pitch){let e=GT(i.pitch,r,VT);a.pitch=this._map.getPitch()+e.amount,$T(a,e)}if(i.roll){let e=GT(i.roll,r,NT);a.roll=this._map.getRoll()+De(e.amount,-179,179),$T(a,e)}if(a.zoom||a.bearing){let e=void 0===i.pinchAround?i.around:i.pinchAround;a.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),Se(a,{noMoveStart:!0})}};function $T(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function GT(e,t,i){let{maxSpeed:r,linearity:a,deceleration:n}=i,o=De(e*a/(t/1e3),-r,r),s=Math.abs(o)/(n*a);return{easing:i.easing,duration:1e3*s,amount:s/2*o}}var ZT=class{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new n_(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new r_(e.type,this._map,e))}mouseup(e){this._map.fire(new r_(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new r_(e.type,this._map,e))}dblclick(e){return this._firePreventable(new r_(e.type,this._map,e))}mouseover(e){this._map.fire(new r_(e.type,this._map,e))}mouseout(e){this._map.fire(new r_(e.type,this._map,e))}touchstart(e){return this._firePreventable(new a_(e.type,this._map,e))}touchmove(e){this._map.fire(new a_(e.type,this._map,e))}touchend(e){this._map.fire(new a_(e.type,this._map,e))}touchcancel(e){this._map.fire(new a_(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},qT=class{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new r_(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new r_("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new r_(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},WT=class{constructor(e,t,i){this._map=e,this._tr=i,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&"object"==typeof t.boxZoom&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(Hg.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=i,this._box||(this._box=Hg.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));let a=Math.min(r.x,i.x),n=Math.max(r.x,i.x),o=Math.min(r.y,i.y),s=Math.max(r.y,i.y);this._box.style.transform=`translate(${a}px,${o}px)`,this._box.style.width=n-a+"px",this._box.style.height=s-o+"px"}mouseupWindow(e,t){if(!this._active||0!==e.button)return;let i=this._startPos,r=t;if(this.reset(),Hg.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new o_("boxzoomend",{originalEvent:e})),this._boxZoomEnd?void this._boxZoomEnd(this._map,i,r,e):{cameraAnimation:e=>e.fitScreenCoordinates(i,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&=(this._box.remove(),null),Hg.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new o_(e,{originalEvent:t}))}};function XT(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}var HT=class{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(void 0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){let t=new c(0,0);for(let i of e)t._add(i);return t.div(e.length)}(t),this.touches=XT(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;let r=XT(i,t);for(let e in this.touches){let t=this.touches[e],i=r[e];(!i||i.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}},YT=class{constructor(e){this.singleTap=new HT(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){let r=this.singleTap.touchend(e,t,i);if(r){let t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if((!t||!i)&&this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}},KT=class{constructor(e,t){this._tr=t,this._zoomIn=new YT({numTouches:1,numTaps:2}),this._zoomOut=new YT({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){let r=this._zoomIn.touchend(e,t,i),a=this._zoomOut.touchend(e,t,i),n=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:ze(n.zoom+1,t.getZoomSnap()),around:n.unproject(r)},{originalEvent:e})}):a?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:ze(n.zoom-1,t.getZoomSnap()),around:n.unproject(a)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},JT=class{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let r=Array.isArray(t)?t[0]:t;return!this._moved&&r.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(i,r))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&Hg.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}};const QT={0:1,2:2};var eD=class{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=e.button}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,t){let i=QT[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}};const tD=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};var iD=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new c(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active)return this._shouldBePrevented(i.length)?void this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e):(e.preventDefault(),this._calculateTransform(e,t,i))}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);let r=XT(i,t),a=new c(0,0),n=new c(0,0),o=0;for(let e in r){let t=r[e],i=this._touches[e];i&&(a._add(t),n._add(t.sub(i)),o++,r[e]=t)}if(this._touches=r,this._shouldBePrevented(o)||!n.mag())return;let s=n.div(o);return this._sum._add(s),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(o),panDelta:s}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},rD=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){if(!this._firstTwoTouches)return;e.preventDefault();let[r,a]=this._firstTwoTouches,n=aD(i,t,r),o=aD(i,t,a);if(!n||!o)return;let s=this._aroundCenter?null:n.add(o).div(2);return this._move([n,o],s,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;let[r,a]=this._firstTwoTouches,n=aD(i,t,r),o=aD(i,t,a);n&&o||(this._active&&Hg.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}};function aD(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function nD(e,t){return Math.log(e/t)/Math.LN2}var oD=class extends rD{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(e){this._zoomRate=e??1}setZoomThreshold(e){this._zoomThreshold=e??.1}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(nD(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:nD(this._distance,i)*this._zoomRate,pinchAround:t}}};function sD(e,t){return 180*e.angleWith(t)/Math.PI}var lD=class extends rD{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,i){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:sD(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,i=sD(e,this._startVector);return Math.abs(i)<t}};function uD(e){return Math.abs(e.y)>Math.abs(e.x)}var hD=class extends rD{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,uD(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),a=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,a,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+a.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;let r=e.mag()>=2,a=t.mag()>=2;if(!r&&!a)return;if(!r||!a)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;let n=e.y>0==t.y>0;return uD(e)&&uD(t)&&n}};const cD={panStep:100,bearingStep:15,pitchStep:10};var dD=class{constructor(e,t){this._tr=t;let i=cD;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,a=0,n=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:o=>{let s=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:pD,zoom:t?ze(s.zoom+t*(e.shiftKey?2:1),o.getZoomSnap()):s.zoom,bearing:s.bearing+i*this._bearingStep,pitch:s.pitch+r*this._pitchStep,offset:[-a*this._panStep,-n*this._panStep],center:s.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function pD(e){return e*(2-e)}const fD=4.000244140625;var mD=class{constructor(e,t,i){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=i,this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,i=Xg(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%fD==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let t=Hg.mousePos(this._map.getCanvas(),e),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(jh.convert(i.center)):t,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){let t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){let t="wheel"===this._type&&Math.abs(this._delta)>fD?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==i&&(i=1/i);let r="number"==typeof this._targetZoom?Ce(this._targetZoom):e.scale,a=e.applyConstrain(e.getCameraLngLat(),Me(r*i)).zoom,n=this._map.getZoomSnap();if("wheel"===this._type&&n>0){let t=ze(e.zoom,n);this._targetZoom=ze(a,n,a-t)}else this._targetZoom=a;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let t,i="number"==typeof this._targetZoom?this._targetZoom:e.zoom,r=this._startZoom,a=this._easing,n=!1;if("wheel"===this._type&&r&&a){let e=Xg()-this._lastWheelEventTime,o=Math.min((e+5)/200,1),s=a(o);t=Oi.number(r,i,s),o<1?this._needsRerender=!0:n=!0}else t=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=t,{noInertia:!0,needsRenderFrame:!n,zoomDelta:t-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=Te;if(this._prevEase){let e=this._prevEase,i=(Xg()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),a=.27/Math.sqrt(r*r+1e-4)*.01;t=we(a,Math.sqrt(.0729-a*a),.25,1)}return this._prevEase={start:Xg(),duration:e,easing:t},t}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},gD=class{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}},_D=class{constructor(e,t){this._tr=t,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:ze(this._tr.zoom+(e.shiftKey?-1:1),i.getZoomSnap()),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},yD=class{constructor(){this._tap=new YT({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){let r=t[0],a=e.timeStamp-this._tapTime<500,n=this._tapPoint.dist(r)<30;a&&n?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;let r=t[0],a=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:a/128*this._zoomRate}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{let r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},xD=class{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}},vD=class{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r}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()}},bD=class{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},wD=class{constructor(e,t){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=Hg.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);let a=document.createElement("div");a.className="maplibregl-mobile-message",a.textContent=i,this._container.appendChild(a),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,t){this._enabled&&(this._map.fire(new Jg("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},TD=class{constructor(e){this._camera=e}get transform(){return this._camera._requestedCameraState||this._camera.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(c.convert(e),this._camera.terrain)}};const DD=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;var ED=class extends gt{};function SD(e){return e.panDelta?.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var PD=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(e,t,i){this._terrainGestureAnchorElevation=null,this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,t)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;let i="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},a={},n={};for(let{handlerName:o,handler:s,allowed:l}of this._handlers){if(!s.isEnabled())continue;let u;if(this._blockedByActive(n,l,o))s.reset();else if(s[t||e.type]){if(Qe(e,t||e.type)){let i=Hg.mousePos(this._map.getCanvas(),e);u=s[t||e.type](e,i)}else if(Je(e,t||e.type)){let i=e.touches,r=this._getMapTouches(i),a=Hg.touchPos(this._map.getCanvas(),r);u=s[t||e.type](e,a,r)}else et(t||e.type)||(u=s[t||e.type](e));this.mergeHandlerResult(r,a,u,o,i),u?.needsRenderFrame&&this._triggerRenderFrame()}(u||s.isActive())&&(n[o]=s)}let o={};for(let e in this._previousActiveHandlers)n[e]||(o[e]=i);this._previousActiveHandlers=n,(Object.keys(o).length||SD(r))&&(this._changes.push([r,a,o]),this._triggerRenderFrame()),(Object.keys(n).length||SD(r))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:s}=r;s&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],s(this._map))},this._map=e,this._camera=t,this._transformProvider=new TD(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new UT(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);let r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[e,t,i]of this._listeners)e.addEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(let[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){let t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new ZT(t,e));let r=t.boxZoom=new WT(t,e,this._transformProvider);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();let a=t.cooperativeGestures=new wD(t,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();let n=new KT(t,this._transformProvider),o=new _D(t,this._transformProvider);t.doubleClickZoom=new gD(o,n),this._add("tapZoom",n),this._add("clickZoom",o),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();let s=new yD;this._add("tapDragZoom",s);let l=t.touchPitch=new hD(t);this._add("touchPitch",l),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);let u=()=>t.project(t.getCenter()),h=function({enable:e,clickTolerance:t,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateSpeed:a=.8},n){return new JT({clickTolerance:t,move:(e,t)=>{let o=n();if(i&&Math.abs(o.y-e.y)>r)return{bearingDelta:We(new c(e.x,t.y),t,o)};let s=(t.x-e.x)*a;return i&&t.y<o.y&&(s=-s),{bearingDelta:s}},moveStateManager:new eD({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button&&!e.ctrlKey}),enable:e,assignEvents:tD})}(e,u),d=function({enable:e,clickTolerance:t,pitchSpeed:i=-.5}){return new JT({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:new eD({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button}),enable:e,assignEvents:tD})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){return new JT({clickTolerance:t,move:(e,t)=>{let a=r(),n=(t.x-e.x)*i;return t.y<a.y&&(n=-n),{rollDelta:n}},moveStateManager:new eD({checkCorrectEvent:e=>2===e.button&&e.ctrlKey}),enable:e,assignEvents:tD})}(e,u);t.dragRotate=new vD(e,h,d,p),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",p,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable();let f=function({enable:e,clickTolerance:t}){return new JT({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:new eD({checkCorrectEvent:e=>0===e.button&&!e.ctrlKey}),enable:e,assignEvents:tD})}(e),m=new iD(e,t);t.dragPan=new xD(i,f,m),this._add("mousePan",f),this._add("touchPan",m,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);let g=new lD,_=new oD;t.touchZoomRotate=new bD(i,_,g,s),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new qT(t));let y=t.scrollZoom=new mD(t,()=>this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);let x=t.keyboard=new dD(t,this._transformProvider);this._add("keyboard",x),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!DD(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(let r in e)if(r!==i&&!t?.includes(r))return!0;return!1}_getMapTouches(e){let t=[];for(let i of e){let e=i.target;this._el.contains(e)&&t.push(i)}return t}mergeHandlerResult(e,t,i,r,a){if(!i)return;Se(e,i);let n={handlerName:r,originalEvent:i.originalEvent||a};void 0!==i.zoomDelta&&(t.zoom=n),void 0!==i.panDelta&&(t.drag=n),void 0!==i.rollDelta&&(t.roll=n),void 0!==i.pitchDelta&&(t.pitch=n),void 0!==i.bearingDelta&&(t.rotate=n)}_applyChanges(){let e={},t={},i={};for(let[r,a,n]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new c(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),Se(t,a),Se(i,n);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){let r=this._map,a=this._camera.getTransformForUpdate(),n=r.terrain;if(!(SD(e)||n&&this._terrainMovement))return void this._fireEvents(t,i,!0);this._camera.stop(!0);let{panDelta:o,zoomDelta:s,bearingDelta:l,pitchDelta:u,rollDelta:h}=e,{around:c,aroundOnSurface:d}=this._resolveAround(e,n,a),p=n?this._terrainGestureElevation(n,c,d,a,t):void 0,f={panDelta:o,zoomDelta:s,rollDelta:h,pitchDelta:u,bearingDelta:l,around:c,aroundElevation:p};this._camera.cameraHelper.useGlobeControls&&!a.isPointOnMapSurface(c)&&(c=a.centerPoint);let m=this._computePreZoomAroundLoc(a,c,o,p);this._handleMapControls({terrain:n,tr:a,deltasForHelper:f,preZoomAroundLoc:m,combinedEventsInProgress:t,panDelta:o}),this._camera.applyUpdatedTransform(a),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_resolveAround(e,t,i){let r=void 0===e.pinchAround?e.around:e.pinchAround;return r||=this._camera.transform.centerPoint,t&&!i.isPointOnMapSurface(r)?{around:i.centerPoint,aroundOnSurface:!1}:{around:r,aroundOnSurface:!0}}_terrainGestureElevation(e,t,i,r,a){if(!i)return;if(!this._terrainMovement&&(a.drag||a.zoom)){let i=r.screenTerrainPointToMercatorCoordinate(t,e);this._terrainGestureAnchorElevation=i?i.z:null}if(null===this._terrainGestureAnchorElevation)return;let n=this._terrainGestureAnchorElevation;return t.distSqr(r.centerPoint)<.01||n-r.elevation>=.9*(r.getCameraAltitude()-r.elevation)?void 0:n}_computePreZoomAroundLoc(e,t,i,r){if(t.distSqr(e.centerPoint)<.01)return e.center;let a=i?t.sub(i):t;return void 0===r?e.screenPointToLocation(a):e.screenPointToLocationAtElevation(a,r)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:a,panDelta:n}){let o=this._camera.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(i,t),e)return o.useGlobeControls?(!this._terrainMovement&&(a.drag||a.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),void o.handleMapControlsPan(i,t,r)):this._terrainMovement||!a.drag&&!a.zoom?void(void 0===i.aroundElevation&&a.drag&&this._terrainMovement&&n?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(n))):o.handleMapControlsPan(i,t,r)):(this._terrainMovement=!0,this._camera.elevationFreeze=!0,void o.handleMapControlsPan(i,t,r));o.handleMapControlsPan(i,t,r)}_fireEvents(e,t,i){let r=DD(this._eventsInProgress),a=DD(e),n={};for(let t in e){let{originalEvent:i}=e[t];this._eventsInProgress[t]||(n[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&a&&this._fireEvent("movestart",a.originalEvent);for(let e in n)this._fireEvent(e,n[e]);a&&this._fireEvent("move",a.originalEvent);for(let t in e){let{originalEvent:i}=e[t];this._fireEvent(t,i)}let o,s={};for(let e in this._eventsInProgress){let{handlerName:i,originalEvent:r}=this._eventsInProgress[e];this._handlersById[i].isActive()||(delete this._eventsInProgress[e],o=t[i]||r,s[`${e}end`]=o)}for(let e in s)this._fireEvent(e,s[e]);let l=DD(this._eventsInProgress),u=(r||a)&&!l;if(u&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1,this._terrainGestureAnchorElevation=null;let e=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(e)}if(i&&u){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&qg.prefersReducedMotion?(this._map.fire(new Qg("moveend",{originalEvent:o})),t(this._map.getBearing())&&this._map.resetNorth()):(t(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:o})),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new Qg(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new ED("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},ID=class extends yt{constructor(e){super(),this._renderFrameCallback=()=>{let e=Math.min((Xg()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new xv,this.cameraHelper=new Ev,void 0!==e.minZoom&&this.transform.setMinZoom(e.minZoom),void 0!==e.maxZoom&&this.transform.setMaxZoom(e.maxZoom),void 0!==e.minPitch&&this.transform.setMinPitch(e.minPitch),void 0!==e.maxPitch&&this.transform.setMaxPitch(e.maxPitch),void 0!==e.renderWorldCopies&&this.transform.setRenderWorldCopies(e.renderWorldCopies),null!==e.transformConstrain&&this.transform.setConstrainOverride(e.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=e.bearingSnap,this._zoomSnap=e.zoomSnap,this._requestRenderFrame=e.requestRenderFrame,this._cancelRenderFrame=e.cancelRenderFrame,this.terrain=e.terrain,this._centerClampedToGround=e.centerClampedToGround??!0,this.transformCameraUpdate=e.transformCameraUpdate??null,this._stopHandlers=e.stopHandlers??(()=>{}),this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){if(e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t,this._requestedCameraState){let t=e.clone();t.apply(this._requestedCameraState,!0),this._requestedCameraState=t}}getCenter(){return new jh(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,t,i){return e=c.convert(e).mult(-1),this.panTo(this.transform.center,Se({offset:e},t),i)}panTo(e,t,i){return this.easeTo(Se({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(Se({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(ze(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(ze(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,t){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new Qg("movestart",t)).fire(new Qg("move",t)).fire(new Qg("moveend",t))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(Se({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Se({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Se({bearing:0,pitch:0,roll:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=ny.convert(e).adjustAntiMeridian();let i=t?.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,t,i,r){let a={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=Se({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){let e=r.padding;r.padding={top:e,bottom:e,right:e,left:e}}let n=Se(a,r.padding);r.padding=n;let o=this.transform,s=new ny(e,t),l=this.cameraHelper.cameraForBoxAndBearing(r,n,s,i,o);return l&&this._zoomSnap&&(l.zoom=ze(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,t,i,r,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(c.convert(e)),this.transform.screenPointToLocation(c.convert(t)),i,r),r,a)}_fitInternal(e,t,i){return e?(delete(t=Se(e,t)).padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop(),void 0!==e.zoom&&this._zoomSnap&&(e.zoom=ze(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,a=!1,n=!1,o=i.zoom;this.terrain&&i.setElevation(this.terrain.getElevationForLngLat(e.center?jh.convert(e.center):i.center,i)),this.cameraHelper.handleJumpToCenterZoom(i,e);let s=i.zoom!==o;return void 0!==e.elevation&&i.elevation!==+e.elevation&&i.setElevation(+e.elevation),void 0!==e.bearing&&i.bearing!==+e.bearing&&(r=!0,i.setBearing(+e.bearing)),void 0!==e.pitch&&i.pitch!==+e.pitch&&(a=!0,i.setPitch(+e.pitch)),void 0!==e.roll&&i.roll!==+e.roll&&(n=!0,i.setRoll(+e.roll)),null!=e.padding&&!i.isPaddingEqual(e.padding)&&i.setPadding(e.padding),this.applyUpdatedTransform(i),this.fire(new Qg("movestart",t)).fire(new Qg("move",t)),s&&this.fire(new Qg("zoomstart",t)).fire(new Qg("zoom",t)).fire(new Qg("zoomend",t)),r&&this.fire(new Qg("rotatestart",t)).fire(new Qg("rotate",t)).fire(new Qg("rotateend",t)),a&&this.fire(new Qg("pitchstart",t)).fire(new Qg("pitch",t)).fire(new Qg("pitchend",t)),n&&this.fire(new Qg("rollstart",t)).fire(new Qg("roll",t)).fire(new Qg("rollend",t)),this.fire(new Qg("moveend",t))}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){let n=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,r);return{center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:i,pitch:r,roll:a}}easeTo(e,t){this._stop(!1,e.easeId),void 0!==(e=Se({offset:[0,0],duration:500,easing:Te},e)).zoom&&this._zoomSnap&&(e.zoom=ze(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&qg.prefersReducedMotion)&&(e.duration=0);let i,r,a=this.getTransformForUpdate(),n=this.getBearing(),o=a.pitch,s=a.roll,l=void 0===e.bearing?n:this._normalizeBearing(e.bearing,n),u=void 0===e.pitch?o:+e.pitch,h=void 0===e.roll?s:this._normalizeBearing(e.roll,s),d=void 0===e.padding?a.padding:e.padding,p=c.convert(e.offset);e.around&&(i=jh.convert(e.around),r=a.locationToScreenPoint(i));let f={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},m=this.cameraHelper.handleEaseTo(a,{bearing:l,pitch:u,roll:h,padding:d,around:i,aroundPoint:r,offsetAsPoint:p,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||=n!==l,this._pitching||=u!==o,this._rolling||=h!==s,this._padding=!a.isPaddingEqual(d),this._zooming||=m.isZooming,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,f),this.terrain&&this._prepareElevation(m.elevationCenter),this._ease(i=>{m.easeFunc(i),this.terrain&&!e.freezeElevation&&this._updateElevation(i),this.applyUpdatedTransform(a),this._fireMoveEvents(t)},i=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t,i)},e),this}_prepareEase(e,t,i={}){this._moving=!0,!t&&!i.moving&&this.fire(new Qg("movestart",e)),this._zooming&&!i.zooming&&this.fire(new Qg("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new Qg("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new Qg("pitchstart",e)),this._rolling&&!i.rolling&&this.fire(new Qg("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(e,this.transform),this.elevationFreeze=!0}_updateElevation(e){(void 0===this._elevationStart||void 0===this._elevationCenter)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let t=this.terrain.getElevationForLngLat(this._elevationCenter,this.transform);if(e<1&&t!==this._elevationTarget){let i=this._elevationTarget-this._elevationStart,r=(t-(i*e+this._elevationStart))/(1-e);this._elevationStart+=e*(i-r),this._elevationTarget=t}this.transform.setElevation(Oi.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(i<r){let i=e.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}applyUpdatedTransform(e){let t=[];if(t.push(e=>this._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;let i=e.clone();for(let e of t){let t=i.clone(),{center:r,zoom:a,roll:n,pitch:o,bearing:s,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==a&&t.setZoom(a),void 0!==n&&t.setRoll(n),void 0!==o&&t.setPitch(o),void 0!==s&&t.setBearing(s),i.apply(t,!1)}this.transform.apply(i,!1)}_fireMoveEvents(e){this.fire(new Qg("move",e)),this._zooming&&this.fire(new Qg("zoom",e)),this._rotating&&this.fire(new Qg("rotate",e)),this._pitching&&this.fire(new Qg("pitch",e)),this._rolling&&this.fire(new Qg("roll",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;delete this._easeId;let i=this._zooming,r=this._rotating,a=this._pitching,n=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,i&&this.fire(new Qg("zoomend",e)),r&&this.fire(new Qg("rotateend",e)),a&&this.fire(new Qg("pitchend",e)),n&&this.fire(new Qg("rollend",e)),this.fire(new Qg("moveend",e))}flyTo(e,t){if(!e.essential&&qg.prefersReducedMotion){let i=Pe(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(i,t)}this.stop(),void 0!==(e=Se({offset:[0,0],speed:1.2,curve:1.42,easing:Te},e)).zoom&&this._zoomSnap&&(e.zoom=ze(e.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=i.bearing,a=i.pitch,n=i.roll,o=i.padding,s=void 0===e.bearing?r:this._normalizeBearing(e.bearing,r),l=void 0===e.pitch?a:+e.pitch,u=void 0===e.roll?n:this._normalizeBearing(e.roll,n),h=void 0===e.padding?i.padding:e.padding,d=c.convert(e.offset),p=i.centerPoint.add(d),f=i.screenPointToLocation(p),m=this.cameraHelper.handleFlyTo(i,{bearing:s,pitch:l,roll:u,padding:h,locationAtOffset:f,offsetAsPoint:d,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),g=e.curve,_=Math.max(i.width,i.height),y=_/m.scaleOfZoom,x=m.pixelPathLength,v=_/m.scaleOfMinZoom;g=Math.min(g,Math.sqrt(v/x*2));let b=g*g;function w(e){let t=(y*y-_*_+(e?-1:1)*b*b*x*x)/(2*(e?y:_)*b*x);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return(Math.exp(e)-Math.exp(-e))/2}function D(e){return(Math.exp(e)+Math.exp(-e))/2}let E=w(!1),S=function(e){return D(E)/D(E+g*e)},P=function(e){return _*((D(E)*function(e){return T(e)/D(e)}(E+g*e)-T(E))/b)/x},I=(w(!0)-E)/g;if(Math.abs(x)<2e-6||!isFinite(I)){if(Math.abs(_-y)<1e-6)return this.easeTo(e,t);let i=y<_?-1:1;I=Math.abs(Math.log(y/_))/g,P=()=>0,S=e=>Math.exp(i*g*e)}if(void 0!==e.duration)e.duration=+e.duration;else{let t=void 0===e.screenSpeed?+e.speed:+e.screenSpeed/g;e.duration=1e3*I/t}return e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==s,this._pitching=l!==a,this._rolling=u!==n,this._padding=!i.isPaddingEqual(h),this._prepareEase(t,!1),this.terrain&&this._prepareElevation(m.targetCenter),this._ease(c=>{let f=c*I,g=1/S(f),_=P(f);this._rotating&&i.setBearing(Oi.number(r,s,c)),this._pitching&&i.setPitch(Oi.number(a,l,c)),this._rolling&&i.setRoll(Oi.number(n,u,c)),this._padding&&(i.interpolatePadding(o,h,c),p=i.centerPoint.add(d)),m.easeFunc(c,g,_,p),this.terrain&&!e.freezeElevation&&this._updateElevation(c),this.applyUpdatedTransform(i),this._fireMoveEvents(t)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t)},e),this}isEasing(){return!!this._easeFrameId}stop(e){return this._stop(e)}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||this._stopHandlers(),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=Xg(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=Ee(e,-180,180);let i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};const AD={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var CD=class{constructor(e=AD){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=e=>{e&&("terrain"===e.type||"style"===e.dataType||"source"===e.dataType&&("metadata"===e.sourceDataType||"visibility"===e.sourceDataType))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):!this._container.classList.contains("maplibregl-compact")&&!this._container.classList.contains("maplibregl-attrib-empty")&&(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=Hg.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=Hg.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=Hg.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){let i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"==typeof e?e:"")):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let t=this._map.style.tileManagers;for(let i in t){let r=t[i];if(r.used||r.usedForTerrain){let t=r.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let r=i+1;r<e.length;r++)if(e[r].includes(t))return!1;return!0});let i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=Hg.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},MD=class{constructor(e={}){this._updateCompact=()=>{let e=this._container.children;if(e.length){let t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options?.compact,this._container=Hg.create("div","maplibregl-ctrl");let t=Hg.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}},zD=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(let t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let t=this._currentlyRunning=this._queue;this._queue=[];let i,r=!1;for(let a of t)if(!a.cancelled){try{a.callback(e)}catch(e){r||(r=!0,i=e)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,r)throw i}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const FD=["none","zoom","sourceTiles","visibleLayers","revision"];var RD=class{constructor(e,t,i,r){this._tileKeys=e.map(e=>e.key).sort().join(),this._revision=t,this._zoom=i,this._visibleLayerIds=r}difference(e){return this._revision===e?._revision?this._visibleLayerIds===e._visibleLayerIds?this._tileKeys===e._tileKeys?this._zoom===e._zoom?"none":"zoom":"sourceTiles":"visibleLayers":"revision"}};const kD={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var LD=class{constructor(e,t){this.needsFollowUpFrame=!1,this.painter=e,this.terrain=t,this.rttSize=t.tileManager.tileSize*t.qualityFactor}getTexture(e){return e.getRTT(this._stacks.length-1).texture}prepareForRender(e,t){let i=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t));let r=this._renderableLayerIds.join(),a=new Set;for(let t of this._renderableLayerIds){let i=e._layers[t],r=i.source;r&&kD[i.type]&&a.add(r)}this._coordsAscending={},this._rttFingerprints={};for(let i of a){let a=e.tileManagers[i];if(!a)continue;this._coordsAscending[i]={};let n=this._coordsAscending[i],o=a.getSource(),s=o instanceof Sy?o.terrainTileRanges:null;for(let e of a.getVisibleCoordinates()){let t=this.terrain.tileManager.getTerrainCoords(e,s);for(let e in t)n[e]||=[],n[e].push(t[e])}this._rttFingerprints[i]={};let l=this._rttFingerprints[i],u=a.getState().revision;for(let e in n)l[e]=new RD(n[e],u,t,r)}this.needsFollowUpFrame=!1;let n=i||this.painter.options.moving,o=!1;for(let e of this._renderableTiles){let t=this._textureDifference(e);"none"!==t&&("zoom"===t&&n||"visibleLayers"===t&&i?this.needsFollowUpFrame=!0:"zoom"===t||"sourceTiles"===t?(o?this.needsFollowUpFrame=!0:e.releaseRTT(this.painter),o=!0):e.releaseRTT(this.painter))}}_textureDifference(e){let t="none";for(let i in this._rttFingerprints){let r=this._rttFingerprints[i][e.tileID.key];if(!r)continue;let a=r.difference(e.rttFingerprint[i]);FD.indexOf(a)>FD.indexOf(t)&&(t=a)}return t}renderLayer(e,t){if(e.isHidden(this.painter.transform.zoom))return!1;let i={...t,isRenderingToTexture:!0},r=e.type,a=this.painter,n=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(kD[r]&&((!this._prevType||!kD[this._prevType])&&this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!n))return!0;if(kD[this._prevType]||kD[r]&&n){this._prevType=r;let e=this._stacks.length-1,t=this._stacks[e]||[];for(let r of this._renderableTiles){if(this._rttTiles.push(r),r.getRTT(e))continue;let n=r.acquireRTT(a,e,this.rttSize);a.bindRTT(n),a.context.clear({color:fi.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e of t){let t=a.style._layers[e],n=t.source?this._coordsAscending[t.source][r.tileID.key]:[r.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),a.renderTileClippingMasks(t,n,!0),a.renderLayer(a,a.style.tileManagers[t.source],t,n,i),t.source&&(r.rttFingerprint[t.source]=this._rttFingerprints[t.source][r.tileID.key])}n.texture.generateMipmap()}return function(e,t,i,r){let{isRenderingGlobe:a}=r,n=e.context,o=n.gl,s=e.transform,l=e.colorModeForRenderPass(),u=e.getDepthModeFor3D(),h=e.useProgram("terrain");n.bindFramebuffer.set(null),n.viewport.set([0,0,e.width,e.height]);for(let r of i){let i=t.getTerrainMesh(r.tileID),c=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);n.activeTexture.set(o.TEXTURE0),c.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_LINEAR);let p=t.getSkirtLength(s.zoom),f=s.calculateFogMatrix(r.tileID.toUnwrapped()),m=nb(p,f,e.style.sky,s.pitch,a),g=s.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(n,o.TRIANGLES,u,Ow.disabled,l,Vw.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],kD[r]}return!1}};const BD={"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"},OD={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:AD,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:nt.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 jD=class extends yt{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(e){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new zD,this._controls=[],this._mapId=Ae(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(let e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(let[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' 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 u_("webglcontextlost",{originalEvent:e}))}else this.fire(new u_("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{if(this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style){this.style.imageManager.images=this._lostContextStyle.images;for(let e in this._lostContextStyle.images){let t=this._lostContextStyle.images[e];t.isWebGLImage&&this.style.imageManager.updateImage(e,t,!1)}}this._lostContextStyle={style:null,images:null};try{this._setupPainter()}catch(e){return void this.fire(new _t(e))}this.resize(),this._update(),this._resizeInternal(),this.fire(new u_("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let t={...OD,...e,canvasContextAttributes:{...OD.canvasContextAttributes,...e.canvasContextAttributes}};if(null!=t.minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");this._camera=new ID({minZoom:t.minZoom,maxZoom:t.maxZoom,minPitch:t.minPitch,maxPitch:t.maxPitch,bearingSnap:t.bearingSnap,zoomSnap:t.zoomSnap,renderWorldCopies:t.renderWorldCopies,centerClampedToGround:t.centerClampedToGround,terrain:this.terrain,transformConstrain:t.transformConstrain,requestRenderFrame:e=>this._requestRenderFrame(e),cancelRenderFrame:e=>this._cancelRenderFrame(e),transformCameraUpdate:t.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._canvasContextAttributes={...t.canvasContextAttributes},this._trackResize=!0===t.trackResize,this._terrainSkirtLength=t.terrainSkirtLength,this._refreshExpiredTiles=!0===t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=!0===t.crossSourceCollisions,this._collectResourceTiming=!0===t.collectResourceTiming,this._locale={...BD,...t.locale},this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this._zoomLevelsToOverscale=t.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=!0===t.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(t.anisotropicFilterPitch),void 0!==t.reduceMotion&&(qg.prefersReducedMotion=t.reduceMotion),this._requestManager=new Kg(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer();try{this._setupPainter()}catch(e){throw this._cleanupContainer(),e}this._imageQueueHandle=Yg.addThrottleControl(()=>this.isMoving()),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),this._handlers=new PD(this,this._camera,t),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let i="string"==typeof t.hash&&t.hash||void 0;this._hash=t.hash?new kT(i).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:t.center,elevation:t.elevation,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch,roll:t.roll}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,Se({},t.fitBoundsOptions,{duration:0}))));let r="string"==typeof t.style||"globe"!==t.style?.projection?.type;this.resize(null,r),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new CD("boolean"==typeof t.attributionControl?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new MD,t.logoPosition),this.on("style.load",()=>{if(r||this._resizeTransform(),this._camera.transform.unmodified){let e=Pe(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire("style"===e.dataType?new t_("styledata",e):new i_("sourcedata",e))}),this.on("dataloading",e=>{this.fire("style"===e.dataType?new t_("styledataloading",e):new i_("sourcedataloading",e))}),this.on("dataabort",e=>{this.fire(new i_("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e?.onAdd)return this.fire(new _t(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let i=e.onAdd(this);this._controls.push(e);let r=this._controlPositions[t];return t.includes("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e?.onRemove)return this.fire(new _t(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return Zy(this._camera.transform,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return new jh(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(e,t){return this._camera.setCenter(e,t),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(e,t){return this._camera.setCenterElevation(e,t),this}setCenterClampedToGround(e){this._camera.setCenterClampedToGround(e)}panBy(e,t,i){return this._camera.panBy(e,t,i),this}panTo(e,t,i){return this._camera.panTo(e,t,i),this}getZoom(){return this._camera.transform.zoom}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,i){return this._camera.zoomTo(e,t,i),this}zoomIn(e,t){return this._camera.zoomIn(e,t),this}zoomOut(e,t){return this._camera.zoomOut(e,t),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(e,t){return this._camera.setVerticalFieldOfView(e,t),this}getBearing(){return this._camera.transform.bearing}setBearing(e,t){return this._camera.setBearing(e,t),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(e){return this._camera.setZoomSnap(e),this}getPadding(){return this._camera.transform.padding}setPadding(e,t){return this._camera.setPadding(e,t),this}rotateTo(e,t,i){return this._camera.rotateTo(e,t,i),this}resetNorth(e,t){return this._camera.resetNorth(e,t),this}resetNorthPitch(e,t){return this._camera.resetNorthPitch(e,t),this}snapToNorth(e,t){return this._camera.snapToNorth(e,t),this}getPitch(){return this._camera.transform.pitch}setPitch(e,t){return this._camera.setPitch(e,t),this}getRoll(){return this._camera.transform.roll}setRoll(e,t){return this._camera.setRoll(e,t),this}cameraForBounds(e,t){return this._camera.cameraForBounds(e,t)}fitBounds(e,t,i){return this._camera.fitBounds(e,t,i),this}fitScreenCoordinates(e,t,i,r,a){return this._camera.fitScreenCoordinates(e,t,i,r,a),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,a)}easeTo(e,t){return this._camera.easeTo(e,t),this}flyTo(e,t){return this._camera.flyTo(e,t),this}stop(){return this._camera.stop(),this}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(jh.convert(e),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(e,t,i,r??0)}resize(e,t=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(t);let i=!this._camera._moving;return i&&(this.stop(),this.fire(new Qg("movestart",e)).fire(new Qg("move",e))),this.fire(new Jg("resize",e)),i&&this.fire(new Qg("moveend",e)),this}_resizeInternal(e=!0){let[t,i]=this._containerDimensions(),r=this._getClampedPixelRatio(t,i);if(this._resizeCanvas(t,i,r),this.painter.resize(t,i,r),this.painter.overLimit()){let e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];let r=this._getClampedPixelRatio(t,i);this._resizeCanvas(t,i,r),this.painter.resize(t,i,r)}this._resizeTransform(e)}_resizeTransform(e=!0){let[t,i]=this._containerDimensions();this._camera.transform.resize(t,i,e),this._camera._requestedCameraState?.resize(t,i,e)}_getClampedPixelRatio(e,t){let{0:i,1:r}=this._maxCanvasSize,a=this.getPixelRatio(),n=e*a,o=t*a,s=n>i?i/n:1,l=o>r?r/o:1,u=Math.min(s,l);return u<1&&Oe("The canvas is larger than maxCanvasSize and is rendered at a lower pixel ratio to fit. Increase maxCanvasSize, within MAX_TEXTURE_SIZE, to render at full resolution."),u*a}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(e){return this._camera.transform.setMaxBounds(ny.convert(e)),this._update()}setMinZoom(e){if(e??=-2,e>=-2&&e<=this._camera.transform.maxZoom){let t=this._camera.transform.zoom,i=this._camera.getTransformForUpdate();return i.setMinZoom(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.zoom&&this.fire(new Qg("zoomstart")).fire(new Qg("zoom")).fire(new Qg("zoomend")).fire(new Qg("movestart")).fire(new Qg("move")).fire(new Qg("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(e=!1){let t=this._camera.transform;return e?t.applyConstrain(t.center,t.minZoom).zoom:t.minZoom}setMaxZoom(e){if(e??=22,e>=this._camera.transform.minZoom){let t=this._camera.transform.zoom,i=this._camera.getTransformForUpdate();return i.setMaxZoom(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.zoom&&this.fire(new Qg("zoomstart")).fire(new Qg("zoom")).fire(new Qg("zoomend")).fire(new Qg("movestart")).fire(new Qg("move")).fire(new Qg("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(e){if(e??=0,e<0)throw Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this._camera.transform.maxPitch){let t=this._camera.transform.pitch,i=this._camera.getTransformForUpdate();return i.setMinPitch(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.pitch&&this.fire(new Qg("pitchstart")).fire(new Qg("pitch")).fire(new Qg("pitchend")).fire(new Qg("movestart")).fire(new Qg("move")).fire(new Qg("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(e){if(e??=60,e>180)throw Error("maxPitch must be less than or equal to 180");if(e>=this._camera.transform.minPitch){let t=this._camera.transform.pitch,i=this._camera.getTransformForUpdate();return i.setMaxPitch(e),this._camera.applyUpdatedTransform(i),this._update(),t!==this._camera.transform.pitch&&this.fire(new Qg("pitchstart")).fire(new Qg("pitch")).fire(new Qg("pitchend")).fire(new Qg("movestart")).fire(new Qg("move")).fire(new Qg("moveend")),this}throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if(e??=20,e>180)throw Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(e){return this._camera.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this._camera.transform.setConstrainOverride(e),this._update()}project(e){return this._camera.transform.locationToScreenPoint(jh.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.transform.screenPointToLocation(c.convert(e),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(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;return{layers:t,listener:i,delegates:{mousemove:a=>{let n=t.filter(e=>this.getLayer(e)),o=0===n.length?[]:this.queryRenderedFeatures(a.point,{layers:n});o.length?r||(r=!0,i.call(this,new r_(e,this,a.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;return{layers:t,listener:i,delegates:{mousemove:a=>{let n=t.filter(e=>this.getLayer(e));(0===n.length?[]:this.queryRenderedFeatures(a.point,{layers:n})).length?r=!0:r&&(r=!1,i.call(this,new r_(e,this,a.originalEvent)))},mouseout:t=>{r&&(r=!1,i.call(this,new r_(e,this,t.originalEvent)))}}}}{let r=e=>{let r=t.filter(e=>this.getLayer(e)),a=0===r.length?[]:this.queryRenderedFeatures(e.point,{layers:r});a.length&&(e.features=a,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners||={},this._delegatedListeners[e]||=[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners?.[e])return;let r=this._delegatedListeners[e];for(let e=0;e<r.length;e++){let a=r[e];if(a.listener===i&&a.layers.length===t.length&&a.layers.every(e=>t.includes(e))){for(let e in a.delegates)this.off(e,a.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);let r="string"==typeof t?[t]:t,a=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,a);for(let e in a.delegates)this.on(e,a.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);let r="string"==typeof t?[t]:t,a=this._createDelegatedListener(e,r,i);for(let t in a.delegates){let n=a.delegates[t];a.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),n(...t)}}this._saveDelegatedListener(e,a);for(let e in a.delegates)this.once(e,a.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);let r="string"==typeof t?[t]:t;return this._removeDelegatedListener(e,r,i),this}queryRenderedFeatures(e,t){if(!this.style)return[];let i,r=e instanceof c||Array.isArray(e),a=r?e:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(t||=(r?{}:e)||{},a instanceof c||"number"==typeof a[0])i=[c.convert(a)];else{let e=c.convert(a[0]),t=c.convert(a[1]);i=[e,new c(t.x,e.y),t,new c(e.x,t.y),e]}return this.style.queryRenderedFeatures(i,t,this._camera.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return t=Se({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t),this._styleUrl="string"==typeof e?e:null,!1!==t.diff&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(e,t))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(null==t)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));let i=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new ib(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,i):this.style.loadJSON(e,t,i),this):(this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new ib(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(e,t){if(this._diffStyleRequest?.abort(),"string"==typeof e){let i=e;this._diffStyleRequest=new AbortController;let r=this._diffStyleRequest;try{let e=await this._requestManager.transformRequest(i,"Style");if(r.signal.aborted)return void(this._diffStyleRequest=null);let a=await ct(e,r);this._diffStyleRequest=null,this._updateDiff(a.data,t)}catch(e){this._diffStyleRequest=null,rt(e)||this.fire(new _t(ne(e)))}}else"object"==typeof e&&(this._diffStyleRequest=null,this._updateDiff(e,t))}_updateDiff(e,t){try{this.style.setState(e,t)&&this._update(!0)}catch(i){Oe(`Unable to perform style diff: ${ne(i).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();Oe("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){let t=this.style?.tileManagers[e];if(void 0!==t)return t.loaded();this.fire(new _t(Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&Kn(this,Wn.terrain,{value:e},t))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){let t=this.style.tileManagers[e.source];if(!t)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&t.reload();for(let t in this.style._layers){let i=this.style._layers[t];"hillshade"===i.type&&i.source===e.source&&Oe("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===i.type&&i.source===e.source&&Oe("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 fv(this.painter,t,e,this._terrainSkirtLength),this.painter.renderToTexture=new LD(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.getElevationForLngLat(this._camera.transform.center,this._camera.transform)),this._terrainDataCallback=t=>this._handleTerrainDataEvent(t,e.source),this.style.on("data",this._terrainDataCallback)}else 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);return this.style.triggerSymbolPlacement(),this.fire(new s_({terrain:e})),this}_handleTerrainDataEvent(e,t){if("style"===e.dataType)return void this.terrain.tileManager.releaseAllRTT();let i=e.sourceId===t;if(i&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),i&&e.tile&&!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.getElevationForLngLat(this._camera.transform.center,this._camera.transform))),e.tile){if("image"===e.source?.type)return void this.terrain.tileManager.releaseAllRTT();this.terrain.tileManager.releaseRTT(e.tile.tileID)}}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let e=this.style?.tileManagers;for(let t of Object.values(e))if(!t.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style?.getSource(e)}setSourceTileLodParams(e,t,i){if(i){let r=this.getSource(i);if(!r)throw Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=Uy(Math.max(1,e),Math.max(1,t))}else for(let i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=Uy(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let i=this.style.tileManagers[e];if(!i)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===t?i.reload(!0):i.refreshTiles(t.map(e=>new nf(e.z,e.x,e.y)))}addImage(e,t,i={}){this._lazyInitEmptyStyle();let r=this._createStyleImage(t,i);return r?(this.style.addImage(e,r),r.userImage?.onAdd&&r.userImage.onAdd(this,e),this):this}setMissingStyleImageResolver(e){return this._missingStyleImageResolver=e,this.style?.setMissingImageResolver(e),this}_createStyleImage(e,t={}){let{pixelRatio:i=1,sdf:r=!1,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l}=t;if(e instanceof HTMLImageElement||Ue(e)){let{width:t,height:u,data:h}=qg.getImageData(e);return{data:new ou({width:t,height:u},h),pixelRatio:i,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l,sdf:r,version:0}}if(void 0===e.width||void 0===e.height)return this.fire(new _t(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`"))),null;{let{width:t,height:u,data:h}=e,c=e,d=Fd(c.data);return{data:d?new ou({width:t,height:u}):new ou({width:t,height:u},new Uint8Array(h)),pixelRatio:i,stretchX:a,stretchY:n,content:o,textFitWidth:s,textFitHeight:l,sdf:r,version:0,isWebGLImage:d,userImage:c}}}updateImage(e,t){let i=this.style.getImage(e);if(!i)return this.fire(new _t(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:a,data:n}=t instanceof HTMLImageElement||Ue(t)?qg.getImageData(t):t;if(void 0===r||void 0===a)return this.fire(new _t(Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(r!==i.data.width||a!==i.data.height)return this.fire(new _t(Error("The width and height of the updated image must be that same as the previous version of the image")));if(i.isWebGLImage=Fd(n),i.isWebGLImage)i.userImage=t;else{let e=!(t instanceof HTMLImageElement||Ue(t));i.data.replace(n,e)}return this.style.updateImage(e,i),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new _t(Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await Yg.getImage(await this._requestManager.transformRequest(e,"Image"),new AbortController);if(!t.data)throw Error(`Could not load image ${e}: the response is empty`);return t}listImages(){return this.style?.listImages()??[]}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style?.getLayer(e)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style?.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style?.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}setFontFaces(e){return this._lazyInitEmptyStyle(),this.style.setFontFaces(e),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_shouldHandleInitialResize(){if(!this._container?.clientWidth||!this._container.clientHeight)return!1;let[e,t]=this._containerDimensions();return e!==this._camera.transform.width||t!==this._camera.transform.height}_setupResizeObserver(){let e=!1,t=RT(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50),i=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new i(i=>{!e&&(e=!0,!this._shouldHandleInitialResize())||t(i)}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&"object"==typeof e&&1===e.nodeType)return e;throw Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){let e=this._container;e.classList.add("maplibregl-map");let t=this._canvasContainer=Hg.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=Hg.create("canvas","maplibregl-canvas",t),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 i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);let a=this._controlContainer=Hg.create("div","maplibregl-control-container",e),n=this._controlPositions={};for(let e of["top-left","top-right","bottom-left","bottom-right"])n[e]=Hg.create("div",`maplibregl-ctrl-${e} `,a);this._container.addEventListener("scroll",this._onMapScroll,!1)}_cleanupContainer(){this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map")}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener("webglcontextcreationerror",e=>{t=e},{once:!0});let i=this._canvas.getContext("webgl2",e);if(!i)throw new FT(e,t);this.painter=new zT(i,this._camera.transform)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.painter.transform=e,this.fire(new l_({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?._loaded?(this._styleDirty||=e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){let t=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this._camera.transform.zoom,i=Xg();this.style.zoomHistory.update(e,i);let a=new so(e,{now:i,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=a.crossFadingFactor();(1!==n||n!==this._crossFadingFactor)&&(r=!0,this._crossFadingFactor=n),this.style.update(a)}let a=this.style.projection?.transitionState>0!==i;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.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,t,this._crossSourceCollisions,a),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new Jg("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Jg("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let n=this._sourcesDirty||this._styleDirty||this._placementDirty||this.painter.renderToTexture?.needsFollowUpFrame;return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new Jg("idle")),this._loaded&&!this._fullyLoaded&&!n&&(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 e of this._controls)e.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),Yg.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new Jg("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,qg.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!rt(e))throw e}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return"6.9.0"}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};function VD(e){nt.WORKER_URL=e}["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ")}}]);
|