7 lines
949 KiB
JavaScript
7 lines
949 KiB
JavaScript
/**
|
||
* MapLibre GL JS
|
||
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.24.0/LICENSE.txt
|
||
*/
|
||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).maplibregl={})}(this,(function(e){"use strict";var t,i,r="5.24.0";function n(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))}function o(e,t){this.x=e,this.y=t}function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError,o.prototype={clone(){return new o(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){const 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){const t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,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(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround(e,t){const i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:o},o.convert=function(e){if(e instanceof o)return e;if(Array.isArray(e))return new o(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new o(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var a=function(){if(i)return t;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return i=1,t=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)<t)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var s=0,a=1;for(i=e,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-e)<t));r++)e>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},t}(),l=s(a);let c,h;function u(){return null!=c||(c="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),c}var d=1e-6,p="undefined"!=typeof Float32Array?Float32Array:Array;function f(){var e=new p(4);return p!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function m(){var e=new p(9);return p!=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 _(){var e=new p(16);return p!=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 g(e){var t=new p(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 y(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 v(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,v=i*l-n*s,x=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,S=h*m-u*f,P=h*_-d*f,I=h*g-p*f,M=u*_-d*m,E=u*g-p*m,C=d*g-p*_,A=y*C-v*E+x*M+b*I-w*P+T*S;return A?(e[0]=(a*C-l*E+c*M)*(A=1/A),e[1]=(n*E-r*C-o*M)*A,e[2]=(m*T-_*w+g*b)*A,e[3]=(d*w-u*T-p*b)*A,e[4]=(l*I-s*C-c*P)*A,e[5]=(i*C-n*I+o*P)*A,e[6]=(_*x-f*T-g*v)*A,e[7]=(h*T-d*x+p*v)*A,e[8]=(s*E-a*I+c*S)*A,e[9]=(r*I-i*E-o*S)*A,e[10]=(f*w-m*x+g*y)*A,e[11]=(u*x-h*w-p*y)*A,e[12]=(a*P-s*M-l*S)*A,e[13]=(i*M-r*P+n*S)*A,e[14]=(m*v-f*b-_*y)*A,e[15]=(h*b-u*v+d*y)*A,e):null}function x(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],v=i[0],x=i[1],b=i[2],w=i[3];return e[0]=v*r+x*a+b*u+w*m,e[1]=v*n+x*l+b*d+w*_,e[2]=v*o+x*c+b*p+w*g,e[3]=v*s+x*h+b*f+w*y,e[4]=(v=i[4])*r+(x=i[5])*a+(b=i[6])*u+(w=i[7])*m,e[5]=v*n+x*l+b*d+w*_,e[6]=v*o+x*c+b*p+w*g,e[7]=v*s+x*h+b*f+w*y,e[8]=(v=i[8])*r+(x=i[9])*a+(b=i[10])*u+(w=i[11])*m,e[9]=v*n+x*l+b*d+w*_,e[10]=v*o+x*c+b*p+w*g,e[11]=v*s+x*h+b*f+w*y,e[12]=(v=i[12])*r+(x=i[13])*a+(b=i[14])*u+(w=i[15])*m,e[13]=v*n+x*l+b*d+w*_,e[14]=v*o+x*c+b*p+w*g,e[15]=v*s+x*h+b*f+w*y,e}function b(e,t,i){var r,n,o,s,a,l,c,h,u,d,p,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=h,e[8]=u,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*_+u*g+t[12],e[13]=n*m+l*_+d*g+t[13],e[14]=o*m+c*_+p*g+t[14],e[15]=s*m+h*_+f*g+t[15]),e}function w(e,t,i){var r=i[0],n=i[1],o=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]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function T(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],h=t[9],u=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]=o*n+c*r,e[5]=s*n+h*r,e[6]=a*n+u*r,e[7]=l*n+d*r,e[8]=c*n-o*r,e[9]=h*n-s*r,e[10]=u*n-a*r,e[11]=d*n-l*r,e}function S(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],h=t[9],u=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]=o*n-c*r,e[1]=s*n-h*r,e[2]=a*n-u*r,e[3]=l*n-d*r,e[8]=o*r+c*n,e[9]=s*r+h*n,e[10]=a*r+u*n,e[11]=l*r+d*n,e}function P(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],h=t[5],u=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]=o*n+c*r,e[1]=s*n+h*r,e[2]=a*n+u*r,e[3]=l*n+d*r,e[4]=c*n-o*r,e[5]=h*n-s*r,e[6]=u*n-a*r,e[7]=d*n-l*r,e}var I=function(e,t,i,r,n){var o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,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!=n&&n!==1/0){var s=1/(r-n);e[10]=(n+r)*s,e[14]=2*n*r*s}else e[10]=-1,e[14]=-2*r;return e},M=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,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*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e};function E(){var e=new p(3);return p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function C(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function A(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function z(e,t,i){var r=new p(3);return r[0]=e,r[1]=t,r[2]=i,r}function D(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function R(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function k(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function L(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function F(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e}function B(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],h=n*c-o*l,u=o*a-r*c,d=r*l-n*a;return e[0]=a+s*(h+=h)+n*(d+=d)-o*(u+=u),e[1]=l+s*u+o*h-r*d,e[2]=c+s*d+r*u-n*h,e}function O(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e}function V(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e}function j(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e}var N,U=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},G=A;function $(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e}function Z(){var e=new p(4);return p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function q(e,t,i,r){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",o=Math.PI/360;t*=o,r*=o,i*=o;var s=Math.sin(t),a=Math.cos(t),l=Math.sin(i),c=Math.cos(i),h=Math.sin(r),u=Math.cos(r);switch(n){case"xyz":e[0]=s*c*u+a*l*h,e[1]=a*l*u-s*c*h,e[2]=a*c*h+s*l*u,e[3]=a*c*u-s*l*h;break;case"xzy":e[0]=s*c*u-a*l*h,e[1]=a*l*u-s*c*h,e[2]=a*c*h+s*l*u,e[3]=a*c*u+s*l*h;break;case"yxz":e[0]=s*c*u+a*l*h,e[1]=a*l*u-s*c*h,e[2]=a*c*h-s*l*u,e[3]=a*c*u+s*l*h;break;case"yzx":e[0]=s*c*u+a*l*h,e[1]=a*l*u+s*c*h,e[2]=a*c*h-s*l*u,e[3]=a*c*u-s*l*h;break;case"zxy":e[0]=s*c*u-a*l*h,e[1]=a*l*u+s*c*h,e[2]=a*c*h+s*l*u,e[3]=a*c*u-s*l*h;break;case"zyx":e[0]=s*c*u-a*l*h,e[1]=a*l*u+s*c*h,e[2]=a*c*h-s*l*u,e[3]=a*c*u+s*l*h;break;default:throw new Error("Unknown angle order "+n)}return e}function W(){var e=new p(2);return p!=Float32Array&&(e[0]=0,e[1]=0),e}function H(e,t){var i=new p(2);return i[0]=e,i[1]=t,i}function X(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function Y(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function K(e){return e[0]=0,e[1]=0,e}E(),N=new p(4),p!=Float32Array&&(N[0]=0,N[1]=0,N[2]=0,N[3]=0),E(),z(1,0,0),z(0,1,0),Z(),Z(),m();var J=function(e){var t=e[0],i=e[1];return t*t+i*i};W();const Q=8192;function ee(e,t,i){return t*(Q/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function te(e){return e instanceof Error?e:new Error("string"==typeof e?e:String(e))}function ie(){return new Float64Array(4)}function re(){return new Float64Array(3)}function ne(){return new Float64Array(16)}function oe(){const e=new Float64Array(16);return y(e),e}function se(){const e=new Float32Array(16);return y(e),e}function ae(e,t,i,r,n=!1){if(!i[0]&&!i[1])return[0,0];const o=n?"map"===r?-e.bearingInRadians:0:"viewport"===r?e.bearingInRadians:0;if(o){const e=Math.sin(o),t=Math.cos(o);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}return[n?i[0]:ee(t,i[0],e.zoom),n?i[1]:ee(t,i[1],e.zoom)]}function le(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function ce(e,t,i){const r=(n=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((h=n[8])*(s=n[4])-(a=n[5])*(c=n[7]))+n[1]*(-h*(o=n[3])+a*(l=n[6]))+n[2]*(c*o-s*l);var n,o,s,a,l,c,h;if(0===r)return null;const u=F([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=F([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=F([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=R([],u,-e[3]);return D(f,f,R([],d,-t[3])),D(f,f,R([],p,-i[3])),R(f,f,1/r),f}function he(e,t,i){const r=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===r?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/r}function ue(e,t,i,r){const n=Math.sqrt(e*e+t*t),o=Math.sqrt(i*i+r*r);e/=n,t/=n,i/=o,r/=o;const s=Math.acos(e*i+t*r);return-t*i+e*r>0?s:-s}function de(e,t){const i=fe(e,360),r=fe(t,360),n=r-i,o=r>i?n-360:n+360;return Math.abs(n)<Math.abs(o)?n:o}function pe(e,t){const i=fe(e,2*Math.PI),r=fe(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 fe(e,t){return(e%t+t)%t}function me(e,t,i,r,n){return _e(r,n,be((e-t)/(i-t),0,1))}function _e(e,t,i){return e*(1-i)+t*i}function ge(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return[t,i,r,n]}function ye(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function ve(e,t,i,r){const n=new l(e,t,i,r);return e=>n.solve(e)}const xe=ve(.25,.1,.25,1);function be(e,t,i){return Math.min(i,Math.max(t,e))}function we(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function Te(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function Se(e,t){const i={};for(const r of t)r in e&&(i[r]=e[r]);return i}let Pe=1;function Ie(){return Pe++}function Me(e){return Math.pow(2,e)}function Ee(e){return Math.log(e)/Math.LN2}function Ce(e,t,i){if(t<=0)return e;const 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 Ae(e,t,i){const r={};for(const i in e)r[i]=t.call(this,e[i],i,e);return r}function ze(e,t,i){const r={};for(const i in e)t.call(this,e[i],i,e)&&(r[i]=e[i]);return r}function De(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(!De(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!De(e[i],t[i]))return!1;return!0}return e===t}function Re(e){return Array.isArray(e)?e.map(Re):"object"==typeof e&&e?Ae(e,Re):e}const ke={};function Le(e){ke[e]||("undefined"!=typeof console&&console.warn(e),ke[e]=!0)}function Fe(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function Be(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Oe=null;function Ve(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const je="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Ne(e,t,i,r){return e.addEventListener(t,i,r),{unsubscribe:()=>{e.removeEventListener(t,i,r)}}}function Ue(e){return e*Math.PI/180}function Ge(e){return e/Math.PI*180}function $e(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function Ze(e,t,i){const r=H(t.x-i.x,t.y-i.y),n=H(e.x-i.x,e.y-i.y);var o,s;return Ge(Math.atan2(r[0]*n[1]-r[1]*n[0],(o=r)[0]*(s=n)[0]+o[1]*s[1]))}function qe(e,t,i){const r=new Float64Array(4);return q(r,e,t-90,i),r}const We=85.051129,He={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Xe={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Ye(e,t){var i;if(!Xe[t])return!1;const r=null==e?void 0:e.target,n=(null===(i=null==r?void 0:r.ownerDocument)||void 0===i?void 0:i.defaultView)||window;return e instanceof n.MouseEvent||e instanceof n.WheelEvent}const Ke="AbortError";class Je extends Error{constructor(e=Ke){super(e instanceof Error?e.message:e),this.name=Ke,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function Qe(e){return e instanceof Error&&e.name===Ke}function et(e){if(e.aborted)throw new Je(e.reason)}let tt,it,rt;const nt={frame(e,t,i,r){const n=r||window,o=n.requestAnimationFrame((e=>{s(),t(e)})),{unsubscribe:s}=Ne(e.signal,"abort",(()=>{s(),n.cancelAnimationFrame(o),i(new Je(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){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(tt||(tt=document.createElement("a")),tt.href=e,tt.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==rt?rt:!!matchMedia&&(null!=it||(it=matchMedia("(prefers-reduced-motion: reduce)")),it.matches)},set prefersReducedMotion(e){rt=e}},ot=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:performance.now()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function st(){return ot.getCurrentTime()}var at;class lt{static create(e,t,i){const 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(){lt.docStyle&<.selectProp&&(lt.userSelect=lt.docStyle[lt.selectProp],lt.docStyle[lt.selectProp]="none")}static enableDrag(){lt.docStyle&<.selectProp&&(lt.docStyle[lt.selectProp]=lt.userSelect)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",lt.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",lt.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",lt.suppressClickInternal,!0)}),0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,t,i){const r=t.boundingClientRect;return new o((i.clientX-r.left)/t.x-e.clientLeft,(i.clientY-r.top)/t.y-e.clientTop)}static mousePos(e,t){const i=lt.getScale(e);return lt.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=lt.getScale(e);for(const n of t)i.push(lt.getPoint(e,r,n));return i}static sanitize(e){const t=(new DOMParser).parseFromString(e,"text/html").body||document.createElement("body"),i=t.querySelectorAll("script");for(const e of i)e.remove();return lt.clean(t),t.innerHTML}static isPossiblyDangerous(e,t){const i=t.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!i.includes("javascript:")&&!i.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const t=e.children;for(const e of t)lt.removeAttributes(e),lt.clean(e)}static removeAttributes(e){for(const{name:t,value:i}of e.attributes)lt.isPossiblyDangerous(t,i)&&e.removeAttribute(t)}}lt.docStyle="undefined"!=typeof window&&(null===(at=window.document)||void 0===at?void 0:at.documentElement.style),lt.selectProp=!lt.docStyle||"userSelect"in lt.docStyle?"userSelect":"webkitUserSelect";const ct={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ht(e){return ct.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const ut="global-dispatcher";class dt extends Error{constructor(e,t,i,r){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=r}}const pt=()=>{var e;return Be(self)?null===(e=self.worker)||void 0===e?void 0:e.referrer:("blob:"===window.location.protocol?window.parent:window).location.href},ft=function(e,t){return n(this,void 0,void 0,(function*(){var i,r;if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){const r=ht(e.url);if(r){const i=yield r(e,t);return i.data||"arrayBuffer"!==e.type?i:Te(i,{data:new ArrayBuffer(0)})}if(Be(self)&&(null===(i=self.worker)||void 0===i?void 0:i.actor))return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:ut},t)}if(!(e=>{var t;return e.startsWith("file:")||(null===(t=pt())||void 0===t?void 0:t.startsWith("file:"))&&!/^\w+:/.test(e)})(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return function(e,t){return n(this,void 0,void 0,(function*(){const i=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:pt(),referrerPolicy:e.referrerPolicy,signal:t.signal});let r,n;"json"!==e.type||i.headers.has("Accept")||i.headers.set("Accept","application/json");try{r=yield fetch(i)}catch(t){if(Qe(t))throw t;throw new dt(0,te(t).message,e.url,new Blob)}if(!r.ok){const t=yield r.blob();throw new dt(r.status,r.statusText,e.url,t)}n="arrayBuffer"===e.type||"image"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text();const o=yield n;return et(t.signal),{data:o,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),etag:r.headers.get("ETag")}}))}(e,t);if(Be(self)&&(null===(r=self.worker)||void 0===r?void 0:r.actor))return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:ut},t)}return function(e,t){return new Promise(((i,r)=>{var n;const o=new XMLHttpRequest;o.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(o.responseType="arraybuffer");for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);"json"===e.type&&(o.responseType="text",(null===(n=e.headers)||void 0===n?void 0:n.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===e.credentials,o.onerror=()=>{r(new Error(o.statusText))},o.onload=()=>{if(!t.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let t=o.response;if("json"===e.type)try{t=JSON.parse(o.response)}catch(e){return void r(e)}i({data:t,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires"),etag:o.getResponseHeader("ETag")})}else{const t=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});r(new dt(o.status,o.statusText,e.url,t))}},t.signal.addEventListener("abort",(()=>{o.abort(),r(new Je(t.signal.reason))})),o.send(e.body)}))}(e,t)}))},mt=(e,t)=>ft(Te(e,{type:"json"}),t);function _t(e){if(!e||e.indexOf("://")<=0||e.startsWith("data:image/")||e.startsWith("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}var gt;!function(e){let t,i,r,o;e.resetRequestQueue=()=>{t=[],i=0,r=0,o={}},e.addThrottleControl=e=>{const t=r++;return o[t]=e,t},e.removeThrottleControl=e=>{delete o[e],a()},e.getImage=(e,i,r=!0)=>new Promise(((n,o)=>{e.headers||(e.headers={}),e.headers.accept="image/webp,*/*",Te(e,{type:"image"});const s={abortController:i,requestParameters:e,supportImageRefresh:r,state:"queued",onError:e=>{o(e)},onSuccess:e=>{n(e)}};t.push(s),a()}));const s=e=>n(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:t,supportImageRefresh:r,onError:o,onSuccess:s,abortController:c}=e,h=!1===r&&!Be(self)&&!ht(t.url)&&(!t.headers||Object.keys(t.headers).reduce(((e,t)=>e&&"accept"===t),!0));i++;const u=h?l(t,c):ft(t,c);try{const t=yield u;delete e.abortController,e.state="completed",t.data instanceof HTMLImageElement||Ve(t.data)?s(t):t.data&&s({data:yield(d=t.data,"function"==typeof createImageBitmap?(e=>n(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}catch(e){throw new Error(`Could not load image because of ${te(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})))(d):(e=>new Promise(((t,i)=>{const r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>r.src=je))},r.onerror=()=>i(new 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."));const n=new Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?URL.createObjectURL(n):je})))(d)),cacheControl:t.cacheControl,expires:t.expires})}catch(t){delete e.abortController,o(te(t))}finally{i--,a()}var d})),a=()=>{const e=(()=>{for(const e of Object.keys(o))if(o[e]())return!0;return!1})()?ct.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:ct.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r<e&&t.length>0;r++){const e=t.shift();e.abortController.signal.aborted?r--:s(e)}},l=(e,t)=>new Promise(((i,r)=>{const n=new Image,o=e.url,s=e.credentials;s&&"include"===s?n.crossOrigin="use-credentials":(s&&"same-origin"===s||!_t(o))&&(n.crossOrigin="anonymous"),t.signal.addEventListener("abort",(()=>{n.src="",r(new Je(t.signal.reason))})),n.fetchPriority="high",n.onload=()=>{n.onerror=n.onload=null,i({data:n})},n.onerror=()=>{n.onerror=n.onload=null,t.signal.aborted||r(new 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."))},n.src=o}))}(gt||(gt={})),gt.resetRequestQueue();class yt{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function vt(e,t,i){var r;(null===(r=i[e])||void 0===r?void 0:r.includes(t))||(i[e]||(i[e]=[]),i[e].push(t))}function xt(e,t,i){if(null==i?void 0:i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class bt{constructor(e,t={}){Te(this,t),this.type=e}}class wt extends bt{constructor(e,t={}){super("error",Te({error:e},t))}}class Tt{on(e,t){return this._listeners||(this._listeners={}),vt(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return xt(e,t,this._listeners),xt(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||(this._oneTimeListeners={}),vt(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){var i,r;"string"==typeof e&&(e=new bt(e,t||{}));const n=e.type;if(this.listens(n)){e.target=this;const t=(null===(i=this._listeners)||void 0===i?void 0:i[n])?this._listeners[n].slice():[];for(const i of t)i.call(this,e);const o=(null===(r=this._oneTimeListeners)||void 0===r?void 0:r[n])?this._oneTimeListeners[n].slice():[];for(const t of o)xt(n,t,this._oneTimeListeners),t.call(this,e);const s=this._eventedParent;s&&(Te(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(e))}else e instanceof wt&&console.error(e.error);return this}listens(e){var t,i,r,n,o;return(null===(i=null===(t=this._listeners)||void 0===t?void 0:t[e])||void 0===i?void 0:i.length)>0||(null===(n=null===(r=this._oneTimeListeners)||void 0===r?void 0:r[e])||void 0===n?void 0:n.length)>0||(null===(o=this._eventedParent)||void 0===o?void 0:o.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var St={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-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 Pt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function It(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return Pt.forEach((e=>{e in t&&(i[e]=t[e])})),i}function Mt(e){e=e.slice();const 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]=It(e[i],t[e[i].ref]));return e}function Et(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(!Et(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!Et(e[i],t[i]))return!1;return!0}return e===t}function Ct(e,t){e.push(t)}function At(e,t,i){Ct(i,{command:"addSource",args:[e,t[e]]})}function zt(e,t,i){Ct(t,{command:"removeSource",args:[e]}),i[e]=!0}function Dt(e,t,i,r){zt(e,i,r),At(e,t,i)}function Rt(e,t,i){let r;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!Et(e[i][r],t[i][r]))return!1;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!Et(e[i][r],t[i][r]))return!1;return!0}function kt(e,t,i,r,n,o){e=e||{},t=t||{};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Et(e[s],t[s])||i.push({command:o,args:[r,s,t[s],n]}));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!Object.prototype.hasOwnProperty.call(e,s)&&(Et(e[s],t[s])||i.push({command:o,args:[r,s,t[s],n]}))}function Lt(e){return e.id}function Ft(e,t){return e[t.id]=t,e}class Bt{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Ot(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}class Vt extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class jt{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new jt(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Nt={kind:"null"},Ut={kind:"number"},Gt={kind:"string"},$t={kind:"boolean"},Zt={kind:"color"},qt={kind:"projectionDefinition"},Wt={kind:"object"},Ht={kind:"value"},Xt={kind:"collator"},Yt={kind:"formatted"},Kt={kind:"padding"},Jt={kind:"colorArray"},Qt={kind:"numberArray"},ei={kind:"resolvedImage"},ti={kind:"variableAnchorOffsetCollection"};function ii(e,t){return{kind:"array",itemType:e,N:t}}function ri(e){if("array"===e.kind){const t=ri(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const ni=[Nt,Ut,Gt,$t,Zt,qt,Yt,Wt,ii(Ht),Kt,Qt,Jt,ei,ti];function oi(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!oi(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(const e of ni)if(!oi(e,t))return null}return`Expected ${ri(e)} but found ${ri(t)} instead.`}function si(e,t){return t.some((t=>t.kind===e.kind))}function ai(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 li(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const ci=.96422,hi=.82521,ui=4/29,di=6/29,pi=3*di*di,fi=di*di*di,mi=Math.PI/180,_i=180/Math.PI;function gi(e){return(e%=360)<0&&(e+=360),e}function yi([e,t,i,r]){let n,o;const s=xi((.2225045*(e=vi(e))+.7168786*(t=vi(t))+.0606169*(i=vi(i)))/1);e===t&&t===i?n=o=s:(n=xi((.4360747*e+.3850649*t+.1430804*i)/ci),o=xi((.0139322*e+.0971045*t+.7141733*i)/hi));const a=116*s-16;return[a<0?0:a,500*(n-s),200*(s-o),r]}function vi(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function xi(e){return e>fi?Math.pow(e,1/3):e/pi+ui}function bi([e,t,i,r]){let n=(e+16)/116,o=isNaN(t)?n:n+t/500,s=isNaN(i)?n:n-i/200;return n=1*Ti(n),o=ci*Ti(o),s=hi*Ti(s),[wi(3.1338561*o-1.6168667*n-.4906146*s),wi(-.9787684*o+1.9161415*n+.033454*s),wi(.0719453*o-.2289914*n+1.4052427*s),r]}function wi(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function Ti(e){return e>di?e*e*e:pi*(e-ui)}const Si=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function Pi(e,t){return Si(e,t)?e[t]:void 0}function Ii(e){return parseInt(e.padEnd(2,e),16)/255}function Mi(e,t){return Ei(t?e/100:e,0,1)}function Ei(e,t,i){return Math.min(Math.max(t,e),i)}function Ci(e){return!e.some(Number.isNaN)}const Ai={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 zi(e,t,i){return e+i*(t-e)}function Di(e,t,i){return e.map(((e,r)=>zi(e,t[r],i)))}class Ri{constructor(e,t,i,r=1,n=!0){this.r=e,this.g=t,this.b=i,this.a=r,n||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[e,t,i,r]))}static parse(e){if(e instanceof Ri)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=Pi(Ai,e);if(t){const[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)){const t=e.length<6?1:2;let i=1;return[Ii(e.slice(i,i+=t)),Ii(e.slice(i,i+=t)),Ii(e.slice(i,i+=t)),Ii(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,r,n,o,s,a,l,c,h,u,d]=t,p=[n||" ",a||" ",h].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[r,s,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[Ei(+i/t,0,1),Ei(+o/t,0,1),Ei(+l/t,0,1),u?Mi(+u,d):1];if(Ci(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,r,n,o,s,a,l,c]=i,h=[r||" ",o||" ",a].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){const e=[+t,Ei(+n,0,100),Ei(+s,0,100),l?Mi(+l,c):1];if(Ci(e))return function([e,t,i,r]){function n(r){const n=(r+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(n-3,9-n,1))}return e=gi(e),t/=100,i/=100,[n(0),n(8),n(4),r]}(e)}}}(e);return t?new Ri(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:r}=this,n=r||1/0;return this.overwriteGetter("rgb",[e/n,t/n,i/n,r])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,r,n]=yi(e),o=Math.sqrt(i*i+r*r);return[Math.round(1e4*o)?gi(Math.atan2(r,i)*_i):NaN,o,t,n]}(this.rgb))}get lab(){return this.overwriteGetter("lab",yi(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,r]=this.rgb;return`rgba(${[e,t,i].map((e=>Math.round(255*e))).join(",")},${r})`}static interpolate(e,t,i,r="rgb"){switch(r){case"rgb":{const[r,n,o,s]=Di(e.rgb,t.rgb,i);return new Ri(r,n,o,s,!1)}case"hcl":{const[r,n,o,s]=e.hcl,[a,l,c,h]=t.hcl;let u,d;if(isNaN(r)||isNaN(a))isNaN(r)?isNaN(a)?u=NaN:(u=a,1!==o&&0!==o||(d=l)):(u=r,1!==c&&0!==c||(d=n));else{let e=a-r;a>r&&e>180?e-=360:a<r&&r-a>180&&(e+=360),u=r+i*e}const[p,f,m,_]=function([e,t,i,r]){return e=isNaN(e)?0:e*mi,bi([i,Math.cos(e)*t,Math.sin(e)*t,r])}([u,null!=d?d:zi(n,l,i),zi(o,c,i),zi(s,h,i)]);return new Ri(p,f,m,_,!1)}case"lab":{const[r,n,o,s]=bi(Di(e.lab,t.lab,i));return new Ri(r,n,o,s,!1)}}}}Ri.black=new Ri(0,0,0,1),Ri.white=new Ri(1,1,1,1),Ri.transparent=new Ri(0,0,0,0),Ri.red=new Ri(1,0,0,1);class ki{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}}const Li=["bottom","center","top"];class Fi{constructor(e,t,i,r,n,o){this.text=e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n,this.verticalAlign=o}}class Bi{constructor(e){this.sections=e}static fromString(e){return new Bi([new Fi(e,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(e){return e instanceof Bi?e:Bi.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class Oi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Oi)return e;if("number"==typeof e)return new Oi([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Oi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Oi(Di(e.values,t.values,i))}}class Vi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Vi)return e;if("number"==typeof e)return new Vi([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Vi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Vi(Di(e.values,t.values,i))}}class ji{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ji)return e;if("string"==typeof e){const t=Ri.parse(e);if(!t)return;return new ji([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Ri.parse(i);if(!e)return;t.push(e)}return new ji(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,r="rgb"){const n=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o<e.values.length;o++)n.push(Ri.interpolate(e.values[o],t.values[o],i,r));return new ji(n)}}class Ni extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const Ui=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Gi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Gi)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){const i=e[t],r=e[t+1];if("string"!=typeof i||!Ui.has(i))return;if(!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new Gi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){const r=e.values,n=t.values;if(r.length!==n.length)throw new Ni(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${t.toString()}`);const o=[];for(let e=0;e<r.length;e+=2){if(r[e]!==n[e])throw new Ni(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${r[e]}, to[${e}]: ${n[e]}`);o.push(r[e]);const[t,s]=r[e+1],[a,l]=n[e+1];o.push([zi(t,a,i),zi(s,l,i)])}return new Gi(o)}}class $i{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new $i({name:e,available:!1}):null}}class Zi{constructor(e,t,i){this.from=e,this.to=t,this.transition=i}static interpolate(e,t,i){return new Zi(e,t,i)}static parse(e){return e instanceof Zi?e:Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]?new Zi(e[0],e[1],e[2]):"object"==typeof e&&"string"==typeof e.from&&"string"==typeof e.to&&"number"==typeof e.transition?new Zi(e.from,e.to,e.transition):"string"==typeof e?new Zi(e,e,1):void 0}}function qi(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 Wi(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Zi||e instanceof Ri||e instanceof ki||e instanceof Bi||e instanceof Oi||e instanceof Vi||e instanceof ji||e instanceof Gi||e instanceof $i)return!0;if(Array.isArray(e)){for(const t of e)if(!Wi(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Wi(e[t]))return!1;return!0}return!1}function Hi(e){if(null===e)return Nt;if("string"==typeof e)return Gt;if("boolean"==typeof e)return $t;if("number"==typeof e)return Ut;if(e instanceof Ri)return Zt;if(e instanceof Zi)return qt;if(e instanceof ki)return Xt;if(e instanceof Bi)return Yt;if(e instanceof Oi)return Kt;if(e instanceof Vi)return Qt;if(e instanceof ji)return Jt;if(e instanceof Gi)return ti;if(e instanceof $i)return ei;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Hi(t);if(i){if(i===e)continue;i=Ht;break}i=e}return ii(i||Ht,t)}return Wt}function Xi(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ri||e instanceof Zi||e instanceof Bi||e instanceof Oi||e instanceof Vi||e instanceof ji||e instanceof Gi||e instanceof $i?e.toString():JSON.stringify(e)}class Yi{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Wi(e[1]))return t.error("invalid value");const i=e[1];let r=Hi(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Yi(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Ki={string:Gt,number:Ut,boolean:$t,object:Wt};class Ji{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Ki)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=Ki[i],r++}else n=Ht;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}i=ii(n,o)}else{if(!Ki[n])throw new Error(`Types doesn't contain name = ${n}`);i=Ki[n]}const o=[];for(;r<e.length;r++){const i=t.parse(e[r],r,Ht);if(!i)return null;o.push(i)}return new Ji(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!oi(this.type,Hi(i)))return i;if(t===this.args.length-1)throw new Ni(`Expected value to be of type ${ri(this.type)}, but found ${ri(Hi(i))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Qi={"to-boolean":$t,"to-color":Zt,"to-number":Ut,"to-string":Gt};class er{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if(!Qi[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const r=Qi[i],n=[];for(let i=1;i<e.length;i++){const r=t.parse(e[i],i,Ht);if(!r)return null;n.push(r)}return new er(r,n)}evaluate(e){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(e));case"color":{let t,i;for(const r of this.args){if(t=r.evaluate(e),i=null,t instanceof Ri)return t;if("string"==typeof t){const 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.`:qi(t[0],t[1],t[2],t[3]),!i))return new Ri(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ni(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const r=Oi.parse(t);if(r)return r}throw new Ni(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const r=Vi.parse(t);if(r)return r}throw new Ni(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const r=ji.parse(t);if(r)return r}throw new Ni(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const r=Gi.parse(t);if(r)return r}throw new Ni(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Ni(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Bi.fromString(Xi(this.args[0].evaluate(e)));case"resolvedImage":return $i.fromString(Xi(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return Xi(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const tr=["Unknown","Point","LineString","Polygon"];class ir{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?tr[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=Ri.parse(e),this._parseColorCache.set(e,t)),t}}class rr{constructor(e,t,i=[],r,n=new jt,o=[]){this.registry=e,this.path=i,this.key=i.map((e=>`[${e}]`)).join(""),this.scope=n,this.errors=o,this.expectedType=r,this._isConstant=t}parse(e,t,i,r,n={}){return t?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return"assert"===i?new Ji(t,[e]):"coerce"===i?new er(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),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", []].');const r=e[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,n=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(n.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(n.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(n.kind)||"colorArray"===e.kind&&["value","string","array"].includes(n.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(n.kind))r=i(r,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,n))return null}else r=i(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Yi)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const e=new ir;try{r=new Yi(r.type,r.evaluate(e))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new rr(this.registry,this._isConstant,r,t||null,n,this.errors)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Vt(i,e))}checkSubtype(e,t){const i=oi(e,t);return i&&this.error(i),i}}class nr{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r<e.length-1;r+=2){const n=e[r];if("string"!=typeof n)return t.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return t.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=t.parse(e[r+1],r+1);if(!o)return null;i.push([n,o])}const r=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return r?new nr(i,r):null}outputDefined(){return this.result.outputDefined()}}class or{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new or(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class sr{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ut),r=t.parse(e[2],2,ii(t.expectedType||Ht));return i&&r?new sr(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new Ni(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new Ni(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ni(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ar{constructor(e,t){this.type=$t,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ht),r=t.parse(e[2],2,Ht);return i&&r?si(i.type,[$t,Gt,Ut,Nt,Ht])?new ar(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ri(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!ai(t,["boolean","string","number","null"]))throw new Ni(`Expected first argument to be of type boolean, string, number or null, but found ${ri(Hi(t))} instead.`);if(!ai(i,["string","array"]))throw new Ni(`Expected second argument to be of type array or string, but found ${ri(Hi(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class lr{constructor(e,t,i){this.type=Ut,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ht),r=t.parse(e[2],2,Ht);if(!i||!r)return null;if(!si(i.type,[$t,Gt,Ut,Nt,Ht]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ri(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Ut);return n?new lr(i,r,n):null}return new lr(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!ai(t,["boolean","string","number","null"]))throw new Ni(`Expected first argument to be of type boolean, string, number or null, but found ${ri(Hi(t))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(e)),ai(i,["string"])){const e=i.indexOf(t,r);return-1===e?-1:[...i.slice(0,e)].length}if(ai(i,["array"]))return i.indexOf(t,r);throw new Ni(`Expected second argument to be of type array or string, but found ${ri(Hi(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class cr{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;s<e.length-1;s+=2){let a=e[s];const l=e[s+1];Array.isArray(a)||(a=[a]);const c=t.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Hi(e)))return null}else i=Hi(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const h=t.parse(l,s,r);if(!h)return null;r=r||h.type,o.push(h)}const s=t.parse(e[1],1,Ht);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new cr(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Hi(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()}}class hr{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;n<e.length-1;n+=2){const o=t.parse(e[n],n,$t);if(!o)return null;const s=t.parse(e[n+1],n+1,i);if(!s)return null;r.push([o,s]),i=i||s.type}const n=t.parse(e[e.length-1],e.length-1,i);if(!n)return null;if(!i)throw new Error("Can't infer output type");return new hr(i,r,n)}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}}class ur{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ht),r=t.parse(e[2],2,Ut);if(!i||!r)return null;if(!si(i.type,[ii(Ht),Gt,Ht]))return t.error(`Expected first argument to be of type array or string, but found ${ri(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Ut);return n?new ur(i.type,i,r,n):null}return new ur(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let r;if(this.endIndex&&(r=this.endIndex.evaluate(e)),ai(t,["string"]))return[...t].slice(i,r).join("");if(ai(t,["array"]))return t.slice(i,r);throw new Ni(`Expected first argument to be of type array or string, but found ${ri(Hi(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function dr(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||t<n)return a;o=a+1}else{if(!(r>t))throw new Ni("Input is not a number.");s=a-1}return 0}class pr{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Ut);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],s=e[i+1],a=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new pr(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[dr(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function fr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mr,_r,gr=function(){if(_r)return mr;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return _r=1,mr=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)<t)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var s=0,a=1;for(i=e,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-e)<t));r++)e>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},mr}(),yr=fr(gr);class vr{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=xr(t,e.base,i,r);else if("linear"===e.name)n=xr(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new yr(o[0],o[1],o[2],o[3]).solve(xr(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Ut),!n)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==Jt?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=Zt;for(let e=0;e<o.length;e+=2){const i=o[e],r=o[e+1],n=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return li(a,Ut)||li(a,qt)||li(a,Zt)||li(a,Kt)||li(a,Qt)||li(a,Jt)||li(a,ti)||li(a,ii(Ut))?new vr(a,i,r,n,s):t.error(`Type ${ri(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=dr(t,r),s=vr.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return zi(a,l,s);case"color":return Ri.interpolate(a,l,s);case"padding":return Oi.interpolate(a,l,s);case"colorArray":return ji.interpolate(a,l,s);case"numberArray":return Vi.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Gi.interpolate(a,l,s);case"array":return Di(a,l,s);case"projectionDefinition":return Zi.interpolate(a,l,s)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ri.interpolate(a,l,s,"hcl");case"colorArray":return ji.interpolate(a,l,s,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ri.interpolate(a,l,s,"lab");case"colorArray":return ji.interpolate(a,l,s,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function xr(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}const br={color:Ri.interpolate,number:zi,padding:Oi.interpolate,numberArray:Vi.interpolate,colorArray:ji.interpolate,variableAnchorOffsetCollection:Gi.interpolate,array:Di};class wr{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}if(!i)throw new Error("No output type");const o=r&&n.some((e=>oi(r,e.type)));return new wr(o?Ht:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args)if(r++,i=n.evaluate(e),i&&i instanceof $i&&!i.available&&(t||(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 Tr(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 Sr(e,t,i,r){return 0===r.compare(t,i)}function Pr(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=$t,this.lhs=e,this.rhs=t,this.collator=i,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.");const i=e[0];let o=t.parse(e[1],1,Ht);if(!o)return null;if(!Tr(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${ri(o.type)}'.`);let s=t.parse(e[2],2,Ht);if(!s)return null;if(!Tr(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${ri(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${ri(o.type)}' and '${ri(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Ji(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Ji(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,Xt),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=Hi(o),i=Hi(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ni(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Hi(o),i=Hi(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const Ir=Pr("==",(function(e,t,i){return t===i}),Sr),Mr=Pr("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return!Sr(0,t,i,r)})),Er=Pr("<",(function(e,t,i){return t<i}),(function(e,t,i,r){return r.compare(t,i)<0})),Cr=Pr(">",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),Ar=Pr("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),zr=Pr(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class Dr{constructor(e,t,i){this.type=Xt,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,$t);if(!r)return null;const n=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,$t);if(!n)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,Gt),!o)?null:new Dr(r,n,o)}evaluate(e){return new ki(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}}class Rr{constructor(e,t,i,r,n,o){this.type=Gt,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Ut);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,Gt),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,Gt),!o))return null;let s=null;if(r.unit&&(s=t.parse(r.unit,1,Gt),!s))return null;if(o&&s)return t.error("NumberFormat options `currency` and `unit` are mutually exclusive");let a=null;if(r["min-fraction-digits"]&&(a=t.parse(r["min-fraction-digits"],1,Ut),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,Ut),!l)?null:new Rr(i,n,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class kr{constructor(e){this.type=Yt,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,Ut),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,ii(Gt)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,Zt),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!Li.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,Gt),!a)return null}const l=r[r.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,Ht);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new kr(r)}evaluate(e){return new Bi(this.sections.map((t=>{const i=t.content.evaluate(e);return Hi(i)===ei?new Fi("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new Fi(Xi(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(const 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}}class Lr{constructor(e){this.type=ei,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Gt);return i?new Lr(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=$i.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Fr{constructor(e){this.type=Ut,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${ri(i.type)} instead.`):new Fr(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return[...t].length;if(Array.isArray(t))return t.length;throw new Ni(`Expected value to be of type string or array, but found ${ri(Hi(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Br=8192;function Or(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(i*n*Br),Math.round(r*n*Br)]}function Vr(e,t){const i=Math.pow(2,t.z);return[(n=(e[0]/Br+t.x)/i,360*n-180),(r=(e[1]/Br+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,n}function jr(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 Nr(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Ur(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Gr(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!Xr(e,t,i,r)||!Xr(i,r,e,t));var n,o}function $r(e,t,i){for(const r of i)for(let i=0;i<r.length-1;++i)if(Gr(e,t,r[i],r[i+1]))return!0;return!1}function Zr(e,t,i=!1){let r=!1;for(const a of t)for(let t=0;t<a.length-1;t++){if(Ur(e,a[t],a[t+1]))return i;(o=a[t])[1]>(n=e)[1]!=(s=a[t+1])[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}var n,o,s;return r}function qr(e,t){for(const i of t)if(Zr(e,i))return!0;return!1}function Wr(e,t){for(const i of e)if(!Zr(i,t))return!1;for(let i=0;i<e.length-1;++i)if($r(e[i],e[i+1],t))return!1;return!0}function Hr(e,t){for(const i of t)if(Wr(e,i))return!0;return!1}function Xr(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Yr(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=[];for(let r=0;r<e[n].length;r++){const s=Or(e[n][r],i);jr(t,s),o.push(s)}r.push(o)}return r}function Kr(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=Yr(e[n],t,i);r.push(o)}return r}function Jr(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}jr(t,e)}function Qr(e,t,i,r){const n=Math.pow(2,r.z)*Br,o=[r.x*Br,r.y*Br],s=[];for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];Jr(r,t,i,n),s.push(r)}return s}function en(e,t,i,r){const n=Math.pow(2,r.z)*Br,o=[r.x*Br,r.y*Br],s=[];for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];jr(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)Jr(r,t,i,n)}var a;return s}class tn{constructor(e,t){this.type=$t,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Wi(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:r}=i.geometry;"Polygon"===t&&e.push(r),"MultiPolygon"===t&&e.push(...r)}if(e.length)return new tn(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new tn(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new tn(t,t)}return t.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){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if("Polygon"===t.type){const o=Yr(t.coordinates,r,n),s=Qr(e.geometry(),i,r,n);if(!Nr(i,r))return!1;for(const e of s)if(!Zr(e,o))return!1}if("MultiPolygon"===t.type){const o=Kr(t.coordinates,r,n),s=Qr(e.geometry(),i,r,n);if(!Nr(i,r))return!1;for(const e of s)if(!qr(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if("Polygon"===t.type){const o=Yr(t.coordinates,r,n),s=en(e.geometry(),i,r,n);if(!Nr(i,r))return!1;for(const e of s)if(!Wr(e,o))return!1}if("MultiPolygon"===t.type){const o=Kr(t.coordinates,r,n),s=en(e.geometry(),i,r,n);if(!Nr(i,r))return!1;for(const e of s)if(!Hr(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class rn{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){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;const 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){const{data:t,compare:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e<r;){let r=1+(e<<1);const o=r+1;if(o<this.length&&i(t[o],t[r])<0&&(r=o),i(t[r],n)>=0)break;t[e]=t[r],e=r}t[e]=n}}function nn(e,t,i=0,r=e.length-1,n=sn){for(;r>i;){if(r-i>600){const o=r-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);nn(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(r,Math.floor(t+(o-s)*l/o+c)),n)}const o=e[t];let s=i,a=r;for(on(e,i,t),n(e[r],o)>0&&on(e,i,r);s<a;){for(on(e,s,a),s++,a--;n(e[s],o)<0;)s++;for(;n(e[a],o)>0;)a--}0===n(e[i],o)?on(e,i,a):(a++,on(e,a,r)),a<=t&&(i=a+1),t<=a&&(r=a-1)}}function on(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function sn(e,t){return e<t?-1:e>t?1:0}function an(e,t){if(e.length<=1)return[e];const i=[];let r,n;for(const t of e){const e=cn(t);0!==e&&(t.area=Math.abs(e),void 0===n&&(n=e<0),n===e<0?(r&&i.push(r),r=[t]):r.push(t))}if(r&&i.push(r),t>1)for(let e=0;e<i.length;e++)i[e].length<=t||(nn(i[e],t,1,i[e].length-1,ln),i[e]=i[e].slice(0,t));return i}function ln(e,t){return t.area-e.area}function cn(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}const hn=1/298.257223563,un=hn*(2-hn),dn=Math.PI/180;class pn{constructor(e){const t=6378.137*dn*1e3,i=Math.cos(e*dn),r=1/(1-un*(1-i*i)),n=Math.sqrt(r);this.kx=t*n*i,this.ky=t*n*r*(1-un)}distance(e,t){const 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,n,o,s=1/0;for(let a=0;a<e.length-1;a++){let l=e[a][0],c=e[a][1],h=this.wrap(e[a+1][0]-l)*this.kx,u=(e[a+1][1]-c)*this.ky,d=0;0===h&&0===u||(d=(this.wrap(t[0]-l)*this.kx*h+(t[1]-c)*this.ky*u)/(h*h+u*u),d>1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=this.wrap(t[0]-l)*this.kx,u=(t[1]-c)*this.ky;const p=h*h+u*u;p<s&&(s=p,i=l,r=c,n=a,o=d)}return{point:[i,r],index:n,t:Math.max(0,Math.min(1,o))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function fn(e,t){return t[0]-e[0]}function mn(e){return e[1]-e[0]+1}function _n(e,t){return e[1]>=e[0]&&e[1]<t}function gn(e,t){if(e[0]>e[1])return[null,null];const i=mn(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(1===i)return[e,null];const r=Math.floor(i/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function yn(e,t){if(!_n(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)jr(i,e[r]);return i}function vn(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)jr(t,e);return t}function xn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function bn(e,t,i){if(!xn(e)||!xn(t))return NaN;let r=0,n=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]<t[1]&&(n=t[1]-e[3]),i.distance([0,0],[r,n])}function wn(e,t,i){const r=i.pointOnLine(t,e);return i.distance(e,r.point)}function Tn(e,t,i,r,n){const o=Math.min(wn(e,[i,r],n),wn(t,[i,r],n)),s=Math.min(wn(i,[e,t],n),wn(r,[e,t],n));return Math.min(o,s)}function Sn(e,t,i,r,n){if(!_n(t,e.length)||!_n(r,i.length))return 1/0;let o=1/0;for(let s=t[0];s<t[1];++s){const t=e[s],a=e[s+1];for(let e=r[0];e<r[1];++e){const r=i[e],s=i[e+1];if(Gr(t,a,r,s))return 0;o=Math.min(o,Tn(t,a,r,s,n))}}return o}function Pn(e,t,i,r,n){if(!_n(t,e.length)||!_n(r,i.length))return NaN;let o=1/0;for(let s=t[0];s<=t[1];++s)for(let t=r[0];t<=r[1];++t)if(o=Math.min(o,n.distance(e[s],i[t])),0===o)return o;return o}function In(e,t,i){if(Zr(e,t,!0))return 0;let r=1/0;for(const n of t){const t=n[0],o=n[n.length-1];if(t!==o&&(r=Math.min(r,wn(e,[o,t],i)),0===r))return r;const s=i.pointOnLine(n,e);if(r=Math.min(r,i.distance(e,s.point)),0===r)return r}return r}function Mn(e,t,i,r){if(!_n(t,e.length))return NaN;for(let r=t[0];r<=t[1];++r)if(Zr(e[r],i,!0))return 0;let n=1/0;for(let o=t[0];o<t[1];++o){const t=e[o],s=e[o+1];for(const e of i)for(let i=0,o=e.length,a=o-1;i<o;a=i++){const o=e[a],l=e[i];if(Gr(t,s,o,l))return 0;n=Math.min(n,Tn(t,s,o,l,r))}}return n}function En(e,t){for(const i of e)for(const e of i)if(Zr(e,t,!0))return!0;return!1}function Cn(e,t,i,r=1/0){const n=vn(e),o=vn(t);if(r!==1/0&&bn(n,o,i)>=r)return r;if(Nr(n,o)){if(En(e,t))return 0}else if(En(t,e))return 0;let s=1/0;for(const r of e)for(let e=0,n=r.length,o=n-1;e<n;o=e++){const n=r[o],a=r[e];for(const e of t)for(let t=0,r=e.length,o=r-1;t<r;o=t++){const r=e[o],l=e[t];if(Gr(n,a,r,l))return 0;s=Math.min(s,Tn(n,a,r,l,i))}}return s}function An(e,t,i,r,n,o){if(!o)return;const s=bn(yn(r,o),n,i);s<t&&e.push([s,o,[0,0]])}function zn(e,t,i,r,n,o,s){if(!o||!s)return;const a=bn(yn(r,o),yn(n,s),i);a<t&&e.push([a,o,s])}function Dn(e,t,i,r,n=1/0){let o=Math.min(r.distance(e[0],i[0][0]),n);if(0===o)return o;const s=new rn([[0,[0,e.length-1],[0,0]]],fn),a=vn(i);for(;s.length>0;){const n=s.pop();if(n[0]>=o)continue;const l=n[1],c=t?50:100;if(mn(l)<=c){if(!_n(l,e.length))return NaN;if(t){const t=Mn(e,l,i,r);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const n=In(e[t],i,r);if(o=Math.min(o,n),0===o)return 0}}else{const i=gn(l,t);An(s,o,r,e,a,i[0]),An(s,o,r,e,a,i[1])}}return o}function Rn(e,t,i,r,n,o=1/0){let s=Math.min(o,n.distance(e[0],i[0]));if(0===s)return s;const a=new rn([[0,[0,e.length-1],[0,i.length-1]]],fn);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],h=t?50:100,u=r?50:100;if(mn(l)<=h&&mn(c)<=u){if(!_n(l,e.length)&&_n(c,i.length))return NaN;let o;if(t&&r)o=Sn(e,l,i,c,n),s=Math.min(s,o);else if(t&&!r){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=wn(i[e],t,n),s=Math.min(s,o),0===s)return s}else if(!t&&r){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=wn(e[i],t,n),s=Math.min(s,o),0===s)return s}else o=Pn(e,l,i,c,n),s=Math.min(s,o)}else{const o=gn(l,t),h=gn(c,r);zn(a,s,n,e,i,o[0],h[0]),zn(a,s,n,e,i,o[0],h[1]),zn(a,s,n,e,i,o[1],h[0]),zn(a,s,n,e,i,o[1],h[1])}}return s}function kn(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]}class Ln{constructor(e,t){this.type=Ut,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Wi(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Ln(t,t.features.map((e=>kn(e.geometry))).flat());if("Feature"===t.type)return new Ln(t,kn(t.geometry));if("type"in t&&"coordinates"in t)return new Ln(t,kn(t))}return t.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){const i=e.geometry(),r=i.flat().map((t=>Vr([t.x,t.y],e.canonical)));if(0===i.length)return NaN;const n=new pn(r[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Rn(r,!1,[e.coordinates],!1,n,o));break;case"LineString":o=Math.min(o,Rn(r,!1,e.coordinates,!0,n,o));break;case"Polygon":o=Math.min(o,Dn(r,!1,e.coordinates,n,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),r=i.flat().map((t=>Vr([t.x,t.y],e.canonical)));if(0===i.length)return NaN;const n=new pn(r[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Rn(r,!0,[e.coordinates],!1,n,o));break;case"LineString":o=Math.min(o,Rn(r,!0,e.coordinates,!0,n,o));break;case"Polygon":o=Math.min(o,Dn(r,!0,e.coordinates,n,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const r=an(i,0).map((t=>t.map((t=>t.map((t=>Vr([t.x,t.y],e.canonical))))))),n=new pn(r[0][0][0][1]);let o=1/0;for(const e of t)for(const t of r){switch(e.type){case"Point":o=Math.min(o,Dn([e.coordinates],!1,t,n,o));break;case"LineString":o=Math.min(o,Dn(e.coordinates,!0,t,n,o));break;case"Polygon":o=Math.min(o,Cn(t,e.coordinates,n,o))}if(0===o)return o}return o}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Fn{constructor(e){this.type=Ht,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Fn(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?Pi(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Bn={"==":Ir,"!=":Mr,">":Cr,"<":Er,">=":zr,"<=":Ar,array:Ji,at:sr,boolean:Ji,case:hr,coalesce:wr,collator:Dr,format:kr,image:Lr,in:ar,"index-of":lr,interpolate:vr,"interpolate-hcl":vr,"interpolate-lab":vr,length:Fr,let:nr,literal:Yi,match:cr,number:Ji,"number-format":Rr,object:Ji,slice:ur,step:pr,string:Ji,"to-boolean":er,"to-color":er,"to-number":er,"to-string":er,var:or,within:tn,distance:Ln,"global-state":Fn};class On{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],r=On.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let a=null;for(const[r,o]of s){a=new rr(t.registry,Gn,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t<e.length;t++){const i=e[t],n=Array.isArray(r)?r[t-1]:r.type,o=a.parse(i,1+s.length,n);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(r)&&r.length!==s.length)a.error(`Expected ${r.length} arguments, but found ${s.length} instead.`);else{for(let e=0;e<s.length;e++){const t=Array.isArray(r)?r[e]:r.type,i=s[e];a.concat(e+1).checkSubtype(t,i.type)}if(0===a.errors.length)return new On(i,n,o,s)}}if(1===s.length)t.errors.push(...a.errors);else{const i=(s.length?s:o).map((([e])=>{return t=e,Array.isArray(t)?`(${t.map(ri).join(", ")})`:`(${ri(t.type)}...)`;var t})).join(" | "),r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],1+r.length);if(!n)return null;r.push(ri(n.type))}t.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(e,t){On.definitions=t;for(const i in t)e[i]=On}}function Vn(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=qi(t,i,r,o);if(s)throw new Ni(s);return new Ri(t/255,i/255,r/255,o,!1)}function jn(e,t){return e in t}function Nn(e,t){const i=t[e];return void 0===i?null:i}function Un(e){return{type:e}}function Gn(e){if(e instanceof or)return Gn(e.boundExpression);if(e instanceof On&&"error"===e.name)return!1;if(e instanceof Dr)return!1;if(e instanceof tn)return!1;if(e instanceof Ln)return!1;if(e instanceof Fn)return!1;const t=e instanceof er||e instanceof Ji;let i=!0;return e.eachChild((e=>{i=t?i&&Gn(e):i&&e instanceof Yi})),!!i&&$n(e)&&qn(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function $n(e){if(e instanceof On){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof tn)return!1;if(e instanceof Ln)return!1;let t=!0;return e.eachChild((e=>{t&&!$n(e)&&(t=!1)})),t}function Zn(e){if(e instanceof On&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!Zn(e)&&(t=!1)})),t}function qn(e,t){if(e instanceof On&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild((e=>{i&&!qn(e,t)&&(i=!1)})),i}function Wn(e){return{result:"success",value:e}}function Hn(e){return{result:"error",value:e}}function Xn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Yn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Kn(e){return!!e.expression&&e.expression.interpolated}function Jn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Qn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Hi(e)===Wt}function eo(e){return e}function to(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],r=i||!(i||void 0!==e.property),n=e.type||(Kn(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Ri.parse;case"padding":return Oi.parse;case"numberArray":return Vi.parse;case"colorArray":return ji.parse;default:return null}}(t);if(o&&((e=Ot({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],o(e[1])]))),e.default=o(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(s=e.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${e.colorSpace}"`);var s;const a=function(e){switch(e){case"exponential":return oo;case"interval":return no;case"categorical":return ro;case"identity":return so;default:throw new Error(`Unknown function type "${e}"`)}}(n);let l,c;if("categorical"===n){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},r=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const e of r)n.push([i[e].zoom,to(i[e],t)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:vr.interpolationFactor.bind(void 0,o),zoomStops:n.map((e=>e[0])),evaluate:({zoom:i},r)=>oo({stops:n,base:e.base},t,i).evaluate(i,r)}}if(r){const i="exponential"===n?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:vr.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?io(e.default,t.default):a(e,t,n,l,c)}}}function io(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function ro(e,t,i,r,n){return io(typeof i===n?r[i]:void 0,e.default,t.default)}function no(e,t,i){if("number"!==Jn(i))return io(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=dr(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function oo(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==Jn(i))return io(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=dr(e.stops.map((e=>e[0])),i),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1],c=br[t.type]||eo;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==r)return c(i,r,s,e.colorSpace)}}:c(a,l,s,e.colorSpace)}function so(e,t,i){switch(t.type){case"color":i=Ri.parse(i);break;case"formatted":i=Bi.fromString(i.toString());break;case"resolvedImage":i=$i.fromString(i.toString());break;case"padding":i=Oi.parse(i);break;case"colorArray":i=ji.parse(i);break;case"numberArray":i=Vi.parse(i);break;default:Jn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return io(i,e.default,t.default)}On.register(Bn,{error:[{kind:"error"},[Gt],(e,[t])=>{throw new Ni(t.evaluate(e))}],typeof:[Gt,[Ht],(e,[t])=>ri(Hi(t.evaluate(e)))],"to-rgba":[ii(Ut,4),[Zt],(e,[t])=>{const[i,r,n,o]=t.evaluate(e).rgb;return[255*i,255*r,255*n,o]}],rgb:[Zt,[Ut,Ut,Ut],Vn],rgba:[Zt,[Ut,Ut,Ut,Ut],Vn],has:{type:$t,overloads:[[[Gt],(e,[t])=>jn(t.evaluate(e),e.properties())],[[Gt,Wt],(e,[t,i])=>jn(t.evaluate(e),i.evaluate(e))]]},get:{type:Ht,overloads:[[[Gt],(e,[t])=>Nn(t.evaluate(e),e.properties())],[[Gt,Wt],(e,[t,i])=>Nn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ht,[Gt],(e,[t])=>Nn(t.evaluate(e),e.featureState||{})],properties:[Wt,[],e=>e.properties()],"geometry-type":[Gt,[],e=>e.geometryType()],id:[Ht,[],e=>e.id()],zoom:[Ut,[],e=>e.globals.zoom],"heatmap-density":[Ut,[],e=>e.globals.heatmapDensity||0],elevation:[Ut,[],e=>e.globals.elevation||0],"line-progress":[Ut,[],e=>e.globals.lineProgress||0],accumulated:[Ht,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Ut,Un(Ut),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Ut,Un(Ut),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Ut,overloads:[[[Ut,Ut],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Ut],(e,[t])=>-t.evaluate(e)]]},"/":[Ut,[Ut,Ut],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Ut,[Ut,Ut],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Ut,[],()=>Math.LN2],pi:[Ut,[],()=>Math.PI],e:[Ut,[],()=>Math.E],"^":[Ut,[Ut,Ut],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Ut,[Ut],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))],log2:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Ut,[Ut],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Ut,[Ut],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Ut,[Ut],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Ut,[Ut],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Ut,[Ut],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Ut,[Ut],(e,[t])=>Math.atan(t.evaluate(e))],min:[Ut,Un(Ut),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Ut,Un(Ut),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Ut,[Ut],(e,[t])=>Math.abs(t.evaluate(e))],round:[Ut,[Ut],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ut,[Ut],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Ut,[Ut],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[$t,[Gt,Ht],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[$t,[Ht],(e,[t])=>e.id()===t.value],"filter-type-==":[$t,[Gt],(e,[t])=>e.geometryType()===t.value],"filter-<":[$t,[Gt,Ht],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[$t,[Ht],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[$t,[Gt,Ht],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[$t,[Ht],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[$t,[Gt,Ht],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[$t,[Ht],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[$t,[Gt,Ht],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[$t,[Ht],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[$t,[Ht],(e,[t])=>t.value in e.properties()],"filter-has-id":[$t,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[$t,[ii(Gt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[$t,[ii(Ht)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[$t,[Gt,ii(Ht)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[$t,[Gt,ii(Ht)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:$t,overloads:[[[$t,$t],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Un($t),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:$t,overloads:[[[$t,$t],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Un($t),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[$t,[$t],(e,[t])=>!t.evaluate(e)],"is-supported-script":[$t,[Gt],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Gt,[Gt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Gt,[Gt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Gt,Un(Ht),(e,t)=>t.map((t=>Xi(t.evaluate(e)))).join("")],split:[ii(Gt),[Gt,Gt],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[Gt,[ii(Gt),Gt],(e,[t,i])=>t.evaluate(e).join(i.evaluate(e))],"resolved-locale":[Gt,[Xt],(e,[t])=>t.evaluate(e).resolvedLocale()]});class ao{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new ir,this._defaultValue=t?function(e){if("color"===e.type&&Qn(e.default))return new Ri(0,0,0,0);switch(e.type){case"color":return Ri.parse(e.default)||null;case"padding":return Oi.parse(e.default)||null;case"numberArray":return Vi.parse(e.default)||null;case"colorArray":return ji.parse(e.default)||null;case"variableAnchorOffsetCollection":return Gi.parse(e.default)||null;case"projectionDefinition":return Zi.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._globalState&&(e=go(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o){this._globalState&&(e=go(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null;try{const 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 Ni(`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){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function lo(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Bn}function co(e,t,i){const r=new rr(Bn,Gn,[],t?function(e){const t={color:Zt,string:Gt,number:Ut,enum:Gt,boolean:$t,formatted:Yt,padding:Kt,numberArray:Qt,colorArray:Jt,projectionDefinition:qt,resolvedImage:ei,variableAnchorOffsetCollection:ti};return"array"===e.type?ii(t[e.value]||Ht,e.length):t[e.type]}(t):void 0),n=r.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?Wn(new ao(n,t,i)):Hn(r.errors)}class ho{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!Zn(t.expression),this.globalStateRefs=_o(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._globalState&&(e=go(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._globalState&&(e=go(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,n,o)}}class uo{constructor(e,t,i,r,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Zn(t.expression),this.globalStateRefs=_o(t.expression),this.interpolationType=r,this._globalState=n}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._globalState&&(e=go(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._globalState&&(e=go(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?vr.interpolationFactor(this.interpolationType,e,t,i):0}}function po(e,t,i){const r=co(e,t,i);if("error"===r.result)return r;const n=r.value.expression,o=$n(n);if(!o&&!Xn(t))return Hn([new Vt("","data expressions not supported")]);const s=qn(n,["zoom"]);if(!s&&!Yn(t))return Hn([new Vt("","zoom expressions not supported")]);const a=mo(n);return a||s?a instanceof Vt?Hn([a]):a instanceof vr&&!Kn(t)?Hn([new Vt("",'"interpolate" expressions cannot be used with this property')]):Wn(a?new uo(o?"camera":"composite",r.value,a.labels,a instanceof vr?a.interpolation:void 0,i):new ho(o?"constant":"source",r.value,i)):Hn([new Vt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class fo{constructor(e,t){this._parameters=e,this._specification=t,Ot(this,to(this._parameters,this._specification))}static deserialize(e){return new fo(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function mo(e){let t=null;if(e instanceof nr)t=mo(e.result);else if(e instanceof wr){for(const i of e.args)if(t=mo(i),t)break}else(e instanceof pr||e instanceof vr)&&e.input instanceof On&&"zoom"===e.input.name&&(t=e);return t instanceof Vt||e.eachChild((e=>{const i=mo(e);i instanceof Vt?t=i:!t&&i?t=new Vt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Vt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}function _o(e,t=new Set){return e instanceof Fn&&t.add(e.key),e.eachChild((e=>{_o(e,t)})),t}function go(e,t){const{zoom:i,heatmapDensity:r,elevation:n,lineProgress:o,isSupportedScript:s,accumulated:a}=null!=e?e:{};return{zoom:i,heatmapDensity:r,elevation:n,lineProgress:o,isSupportedScript:s,accumulated:a,globalState:t}}function yo(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!yo(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const vo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function xo(e,t){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};yo(e)||(e=To(e));const i=co(e,vo,t);if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,t,r)=>i.value.evaluate(e,t,{},r),needGeometry:wo(e),getGlobalStateRefs:()=>_o(i.value.expression)}}function bo(e,t){return e<t?-1:e>t?1:0}function wo(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(wo(e[t]))return!0;return!1}function To(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?So(e[1],e[2],"=="):"!="===t?Mo(So(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?So(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(To))):"all"===t?["all"].concat(e.slice(1).map(To)):"none"===t?["all"].concat(e.slice(1).map(To).map(Mo)):"in"===t?Po(e[1],e.slice(2)):"!in"===t?Mo(Po(e[1],e.slice(2))):"has"===t?Io(e[1]):"!has"!==t||Mo(Io(e[1]));var i}function So(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 Po(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(bo)]]:["filter-in-small",e,["literal",t]]}}function Io(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Mo(e){return["!",e]}function Eo(e){const t=e.value;return t?[new Bt(e.key,t,"constants have been deprecated as of v8")]:[]}function Co(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ao(e){if(Array.isArray(e))return e.map(Ao);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Ao(e[i]);return t}return Co(e)}function zo(e){const t=e.key,i=e.value,r=e.valueSpec||{},n=e.objectElementValidators||{},o=e.style,s=e.styleSpec,a=e.validateSpec;let l=[];const c=Jn(i);if("object"!==c)return[new Bt(t,i,`object expected, ${c} found`)];for(const e in i){const c=e.split(".")[0],h=Pi(r,c)||r["*"];let u;if(Pi(n,c))u=n[c];else if(Pi(r,c)){if(void 0===i[e])continue;u=a}else if(n["*"])u=n["*"];else{if(!r["*"]){l.push(new Bt(t,i[e],`unknown property "${e}"`));continue}u=a}l=l.concat(u({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:h,style:o,styleSpec:s,object:i,objectKey:e,validateSpec:a},i))}for(const e in r)n[e]||r[e].required&&void 0===r[e].default&&void 0===i[e]&&l.push(new Bt(t,i,`missing required property "${e}"`));return l}function Do(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||e.validateSpec;if("array"!==Jn(t))return[new Bt(o,t,`array expected, ${Jn(t)} found`)];if(i.length&&t.length!==i.length)return[new Bt(o,t,`array length ${i.length} expected, length ${t.length} found`)];let a={type:i.value,values:i.values};n.$version<7&&(a.function=i.function),"object"===Jn(i.value)&&(a=i.value);let l=[];for(let i=0;i<t.length;i++)l=l.concat(s({array:t,arrayIndex:i,value:t[i],valueSpec:a,validateSpec:e.validateSpec,style:r,styleSpec:n,key:`${o}[${i}]`}));return l}function Ro(e){const t=e.key,i=e.value,r=e.valueSpec;let n=Jn(i);return"number"===n&&i!=i&&(n="NaN"),"number"!==n?[new Bt(t,i,`number expected, ${n} found`)]:"minimum"in r&&i<r.minimum?[new Bt(t,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new Bt(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function ko(e){const t=e.valueSpec,i=Co(e.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Jn(e.value.stops)&&"array"===Jn(e.value.stops[0])&&"object"===Jn(e.value.stops[0][0]),h=zo({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"===i)return[new Bt(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Do({key:e.key,value:r,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:u})),"array"===Jn(r)&&0===r.length&&t.push(new Bt(e.key,r,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&h.push(new Bt(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||h.push(new Bt(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Kn(e.valueSpec)&&h.push(new Bt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Xn(e.valueSpec)?h.push(new Bt(e.key,e.value,"property functions not supported")):a&&!Yn(e.valueSpec)&&h.push(new Bt(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||h.push(new Bt(e.key,e.value,'"property" property is required')),h;function u(e){let i=[];const r=e.value,a=e.key;if("array"!==Jn(r))return[new Bt(a,r,`array expected, ${Jn(r)} found`)];if(2!==r.length)return[new Bt(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Jn(r[0]))return[new Bt(a,r,`object expected, ${Jn(r[0])} found`)];if(void 0===r[0].zoom)return[new Bt(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Bt(a,r,"object stop key must have value")];if(o&&o>Co(r[0].zoom))return[new Bt(a,r[0].zoom,"stop zoom values must appear in ascending order")];Co(r[0].zoom)!==o&&(o=Co(r[0].zoom),n=void 0,s={}),i=i.concat(zo({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Ro,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:r[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},r));return lo(Ao(r[1]))?i.concat([new Bt(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Jn(e.value),l=Co(e.value),c=null!==e.value?e.value:o;if(r){if(a!==r)return[new Bt(e.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Bt(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return Xn(t)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Bt(e.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&l<n?[new Bt(e.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in s?[new Bt(e.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new Bt(e.key,c,`integer expected, found ${l}`)]}}function Lo(e){const t=("property"===e.expressionContext?po:co)(Ao(e.value),e.valueSpec);if("error"===t.result)return t.value.map((t=>new Bt(`${e.key}${t.key}`,e.value,t.message)));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new Bt(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&&!Zn(i))return[new Bt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!Zn(i))return[new Bt(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!qn(i,["zoom","feature-state"]))return[new Bt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!$n(i))return[new Bt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Fo(e){const t=e.key,i=e.value,r=Jn(i);return"string"!==r?[new Bt(t,i,`color expected, ${r} found`)]:Ri.parse(String(i))?[]:[new Bt(t,i,`color expected, "${i}" found`)]}function Bo(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Co(i))&&n.push(new Bt(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Co(i))&&n.push(new Bt(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Oo(e){return yo(Ao(e.value))?Lo(Ot({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Vo(e)}function Vo(e){const t=e.value,i=e.key;if("array"!==Jn(t))return[new Bt(i,t,`array expected, ${Jn(t)} found`)];const r=e.styleSpec;let n,o=[];if(t.length<1)return[new Bt(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Bo({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),Co(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===Co(t[1])&&o.push(new Bt(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Bt(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(n=Jn(t[1]),"string"!==n&&o.push(new Bt(`${i}[1]`,t[1],`string expected, ${n} found`)));for(let s=2;s<t.length;s++)n=Jn(t[s]),"$type"===Co(t[1])?o=o.concat(Bo({key:`${i}[${s}]`,value:t[s],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new Bt(`${i}[${s}]`,t[s],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<t.length;r++)o=o.concat(Vo({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":n=Jn(t[1]),2!==t.length?o.push(new Bt(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new Bt(`${i}[1]`,t[1],`string expected, ${n} found`))}return o}function jo(e,t){const i=e.key,r=e.validateSpec,n=e.style,o=e.styleSpec,s=e.value,a=e.objectKey,l=o[`${t}_${e.layerType}`];if(!l)return[];const c=a.match(/^(.*)-transition$/);if("paint"===t&&c&&l[c[1]]&&l[c[1]].transition)return r({key:i,value:s,valueSpec:o.transition,style:n,styleSpec:o});const h=e.valueSpec||l[a];if(!h)return[new Bt(i,s,`unknown property "${a}"`)];let u;if("string"===Jn(s)&&Xn(h)&&!h.tokens&&(u=/^{([^}]+)}$/.exec(s)))return[new Bt(i,s,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const d=[];return"symbol"===e.layerType&&"text-font"===a&&Qn(Ao(s))&&"identity"===Co(s.type)&&d.push(new Bt(i,s,'"text-font" does not support identity functions')),d.concat(r({key:e.key,value:s,valueSpec:h,style:n,styleSpec:o,expressionContext:"property",propertyType:t,propertyKey:a}))}function No(e){return jo(e,"paint")}function Uo(e){return jo(e,"layout")}function Go(e){var t,i;let r=[];const n=e.value,o=e.key,s=e.style,a=e.styleSpec;if("object"!==Jn(n))return[new Bt(o,n,`object expected, ${Jn(n)} found`)];n.type||n.ref||r.push(new Bt(o,n,'either "type" or "ref" is required'));let l=Co(n.type);const c=Co(n.ref);if(n.id){const t=Co(n.id);for(let i=0;i<e.arrayIndex;i++){const e=s.layers[i];Co(e.id)===t&&r.push(new Bt(o,n.id,`duplicate layer id "${n.id}", previously used at line ${e.id.__line__}`))}}if("ref"in n){let e;["type","source","source-layer","filter","layout"].forEach((e=>{e in n&&r.push(new Bt(o,n[e],`"${e}" is prohibited for ref layers`))})),s.layers.forEach((t=>{Co(t.id)===c&&(e=t)})),e?e.ref?r.push(new Bt(o,n.ref,"ref cannot reference another ref layer")):l=Co(e.type):r.push(new Bt(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l)if(n.source){const e=s.sources&&s.sources[n.source],t=e&&Co(e.type);e?"vector"===t&&"raster"===l?r.push(new Bt(o,n.source,`layer "${n.id}" requires a raster source`)):"raster-dem"!==t&&"hillshade"===l||"raster-dem"!==t&&"color-relief"===l?r.push(new Bt(o,n.source,`layer "${n.id}" requires a raster-dem source`)):"raster"===t&&"raster"!==l?r.push(new Bt(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==t||n["source-layer"]?"raster-dem"===t&&"hillshade"!==l&&"color-relief"!==l?r.push(new Bt(o,n.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==l||!n.paint||!n.paint["line-gradient"]||"geojson"===t&&e.lineMetrics||r.push(new Bt(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new Bt(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new Bt(o,n.source,`source "${n.source}" not found`))}else r.push(new Bt(o,n,'missing required property "source"'));return"raster"===l&&(null===(t=n.paint)||void 0===t?void 0:t.resampling)&&(null===(i=n.paint)||void 0===i?void 0:i["raster-resampling"])&&r.push(new Bt(o,n.paint,`layer "${n.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),r=r.concat(zo({key:o,value:n,valueSpec:a.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:n,objectKey:"type"}),filter:Oo,layout:e=>zo({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Uo(Ot({layerType:l},e))}}),paint:e=>zo({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>No(Ot({layerType:l},e))}})}})),r}function $o(e){const t=e.value,i=e.key,r=Jn(t);return"string"!==r?[new Bt(i,t,`string expected, ${r} found`)]:[]}const Zo={promoteId:function({key:e,value:t}){if("string"===Jn(t))return $o({key:e,value:t});{const i=[];for(const r in t)i.push(...$o({key:`${e}.${r}`,value:t[r]}));return i}}};function qo(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style,o=e.validateSpec;if(!t.type)return[new Bt(i,t,'"type" is required')];const s=Co(t.type);let a;switch(s){case"vector":case"raster":return a=zo({key:i,value:t,valueSpec:r[`source_${s.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Zo,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",r=e.value,n=e.styleSpec,o=n.source_raster_dem,s=e.style;let a=[];const l=Jn(r);if(void 0===r)return a;if("object"!==l)return a.push(new Bt("source_raster_dem",r,`object expected, ${l} found`)),a;const c="custom"===Co(r.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in r)!c&&h.includes(t)?a.push(new Bt(t,r[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:r[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:n})):a.push(new Bt(t,r[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:o}),a;case"geojson":if(a=zo({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,validateSpec:o,objectElementValidators:Zo}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...Lo({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...Lo({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return zo({key:i,value:t,valueSpec:r.source_video,style:n,validateSpec:o,styleSpec:r});case"image":return zo({key:i,value:t,valueSpec:r.source_image,style:n,validateSpec:o,styleSpec:r});case"canvas":return[new Bt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Bo({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Wo(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let o=[];const s=Jn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Bt("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:n,styleSpec:i}):r[s]?e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:n,styleSpec:i}):[new Bt(s,t[s],`unknown property "${s}"`)])}return o}function Ho(e){const t=e.value,i=e.styleSpec,r=i.sky,n=e.style,o=Jn(t);if(void 0===t)return[];if("object"!==o)return[new Bt("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],style:n,styleSpec:i}):[new Bt(o,t[o],`unknown property "${o}"`)]);return s}function Xo(e){const t=e.value,i=e.styleSpec,r=i.terrain,n=e.style;let o=[];const s=Jn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Bt("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=o.concat(r[s]?e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:n,styleSpec:i}):[new Bt(s,t[s],`unknown property "${s}"`)]);return o}function Yo(e){let t=[];const i=e.value,r=e.key;if(Array.isArray(i)){const n=[],o=[];for(const s in i)i[s].id&&n.includes(i[s].id)&&t.push(new Bt(r,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),n.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new Bt(r,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),t=t.concat(zo({key:`${r}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return $o({key:r,value:i})}function Ko(e){return Boolean(e)&&e.constructor===Object}function Jo(e){return Ko(e.value)?[]:[new Bt(e.key,e.value,`object expected, ${Jn(e.value)} found`)]}const Qo={"*":()=>[],array:Do,boolean:function(e){const t=e.value,i=e.key,r=Jn(t);return"boolean"!==r?[new Bt(i,t,`boolean expected, ${r} found`)]:[]},number:Ro,color:Fo,constants:Eo,enum:Bo,filter:Oo,function:ko,layer:Go,object:zo,source:qo,light:Wo,sky:Ho,terrain:Xo,projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style,o=Jn(t);if(void 0===t)return[];if("object"!==o)return[new Bt("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],style:n,styleSpec:i}):[new Bt(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const r=Jn(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 Bt(t,i,`projection expected, invalid type "${r}" found`)]:[new Bt(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:$o,formatted:function(e){return 0===$o(e).length?[]:Lo(e)},resolvedImage:function(e){return 0===$o(e).length?[]:Lo(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Jn(i)){if(i.length<1||i.length>4)return[new Bt(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const r={type:"number"};let n=[];for(let o=0;o<i.length;o++)n=n.concat(e.validateSpec({key:`${t}[${o}]`,value:i[o],validateSpec:e.validateSpec,valueSpec:r}));return n}return Ro({key:t,value:i,valueSpec:{}})},numberArray:function(e){const t=e.key,i=e.value;if("array"===Jn(i)){const r={type:"number"};if(i.length<1)return[new Bt(t,i,"array length at least 1 expected, length 0 found")];let n=[];for(let o=0;o<i.length;o++)n=n.concat(e.validateSpec({key:`${t}[${o}]`,value:i[o],validateSpec:e.validateSpec,valueSpec:r}));return n}return Ro({key:t,value:i,valueSpec:{}})},colorArray:function(e){const t=e.key,i=e.value;if("array"===Jn(i)){if(i.length<1)return[new Bt(t,i,"array length at least 1 expected, length 0 found")];let e=[];for(let r=0;r<i.length;r++)e=e.concat(Fo({key:`${t}[${r}]`,value:i[r]}));return e}return Fo({key:t,value:i})},variableAnchorOffsetCollection:function(e){const t=e.key,i=e.value,r=Jn(i),n=e.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new Bt(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let o=[];for(let r=0;r<i.length;r+=2)o=o.concat(Bo({key:`${t}[${r}]`,value:i[r],valueSpec:n.layout_symbol["text-anchor"]})),o=o.concat(Do({key:`${t}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:n}));return o},sprite:Yo,state:Jo,fontFaces:function(e){const t=e.key,i=e.value,r=e.validateSpec,n=e.styleSpec,o=e.style;if(!Ko(i))return[new Bt(t,i,`object expected, ${Jn(i)} found`)];const s=[];for(const e in i){const a=i[e],l=Jn(a);if("string"===l)s.push(...$o({key:`${t}.${e}`,value:a}));else if("array"===l){const i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[l,c]of a.entries())s.push(...zo({key:`${t}.${e}[${l}]`,value:c,valueSpec:i,styleSpec:n,style:o,validateSpec:r}))}else s.push(new Bt(`${t}.${e}`,a,`string or array expected, ${l} found`))}return s}};function es(e){const t=e.value,i=e.valueSpec,r=e.styleSpec;return e.validateSpec=es,i.expression&&Qn(Co(t))?ko(e):i.expression&&lo(Ao(t))?Lo(e):i.type&&Qo[i.type]?Qo[i.type](e):zo(Ot({},e,{valueSpec:i.type?r[i.type]:i}))}function ts(e){const t=e.value,i=e.key,r=$o(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new Bt(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new Bt(i,t,'"glyphs" url must include a "{range}" token'))),r}function is(e,t=St){let i=[];return i=i.concat(es({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:es,objectElementValidators:{glyphs:ts,"*":()=>[]}})),e.constants&&(i=i.concat(Eo({key:"constants",value:e.constants}))),ns(i)}function rs(e){return function(t){return e(Object.assign({},t,{validateSpec:es}))}}function ns(e){return[].concat(e).sort(((e,t)=>e.line-t.line))}function os(e){return function(...t){return ns(e.apply(this,t))}}is.source=os(rs(qo)),is.sprite=os(rs(Yo)),is.glyphs=os(rs(ts)),is.light=os(rs(Wo)),is.sky=os(rs(Ho)),is.terrain=os(rs(Xo)),is.state=os(rs(Jo)),is.layer=os(rs(Go)),is.filter=os(rs(Oo)),is.paintProperty=os(rs(No)),is.layoutProperty=os(rs(Uo));const ss={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class as{constructor(e,t){this._globalState=t,this.setValue(e)}evaluate(){var e;return null!==(e=this._literalValue)&&void 0!==e?e: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);const t=co(e,ss,this._globalState);if("error"===t.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=_o(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const ls=St,cs=is,hs=cs.light,us=cs.sky,ds=cs.paintProperty,ps=cs.layoutProperty;function fs(e,t){let i=!1;if(null==t?void 0:t.length)for(const r of t)e.fire(new wt(new Error(r.message))),i=!0;return i}class ms{constructor(e,t,i){const r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(let e=0;e<this.d*this.d;e++){const t=n[3+e],i=n[3+e+1];r.push(t===i?null:n.subarray(t,i))}const o=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],o),this.bboxes=n.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;const n=i/t*e;this.min=-n,this.max=e+n}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,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(n)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,t,i,r,n,o){this.cells[n].push(o)}query(e,t,i,r,n){const o=this.min,s=this.max;if(e<=o&&t<=o&&s<=i&&s<=r&&!n)return[...this.keys];{const o=[];return this._forEachCell(e,t,i,r,this._queryCell,o,{},n),o}}_queryCell(e,t,i,r,n,o,s,a){const l=this.cells[n];if(null!==l){const n=this.keys,c=this.bboxes;for(const h of l)if(void 0===s[h]){const l=4*h;(a?a(c[l+0],c[l+1],c[l+2],c[l+3]):e<=c[l+2]&&t<=c[l+3]&&i>=c[l+0]&&r>=c[l+1])?(s[h]=!0,o.push(n[h])):s[h]=!1}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&n.call(this,e,t,i,r,c,o,s,a))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;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(const e of this.cells)i+=e.length;const r=new Int32Array(t+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let n=t;for(let t=0;t<e.length;t++){const i=e[t];r[3+t]=n,r.set(i,n),n+=i.length}return r[3+e.length]=n,r.set(this.keys,n),n+=this.keys.length,r[3+e.length+1]=n,r.set(this.bboxes,n),n+=this.bboxes.length,r.buffer}static serialize(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}}static deserialize(e){return new ms(e.buffer)}}const _s={};function gs(e,t,i={}){if(_s[e])throw new Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),_s[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}gs("Object",Object),gs("Set",Set),gs("TransferableGridIndex",ms),gs("Color",Ri),gs("Error",Error),gs("AJAXError",dt),gs("ResolvedImage",$i),gs("StylePropertyFunction",fo),gs("StyleExpression",ao,{omit:["_evaluator"]}),gs("ZoomDependentExpression",uo),gs("ZoomConstantExpression",ho),gs("CompoundExpression",On,{omit:["_evaluate"]});for(const e in Bn)Bn[e]._classRegistryKey||gs(`Expression_${e}`,Bn[e]);function ys(e){var t;return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||"ArrayBuffer"===(null===(t=e.constructor)||void 0===t?void 0:t.name))}function vs(e){return e.$name||e.constructor._classRegistryKey}function xs(e){return!function(e){if(null===e||"object"!=typeof e)return!1;const t=vs(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||ys(e)||Ve(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function bs(e,t){if(xs(e))return(ys(e)||Ve(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)){const i=[];for(const r of e)i.push(bs(r,t));return i}if("object"!=typeof e)throw new Error("can't serialize object of type "+typeof e);const i=vs(e);if(!i)throw new Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!_s[i])throw new Error(`${i} is not registered.`);const{klass:r}=_s[i],n=r.serialize?r.serialize(e,t):{};if(r.serialize){if(n===(null==t?void 0:t[t.length-1]))throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const r in e){if(!e.hasOwnProperty(r))continue;if(_s[i].omit.includes(r))continue;const o=e[r];n[r]=_s[i].shallow.includes(r)?o:bs(o,t)}e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(n.$name=i),n}function ws(e){if(xs(e))return e;if(Array.isArray(e))return e.map(ws);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=vs(e)||"Object";if(!_s[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=_s[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const i of Object.keys(e)){if("$name"===i)continue;const n=e[i];r[i]=_s[t].shallow.includes(i)?n:ws(n)}return r}class Ts{constructor(){this.first=!0}update(e,t){const 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))}}function Ss(e){for(const i of e)if(t=i.codePointAt(0),/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\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]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\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(t)))return!0;var t;return!1}function Ps(e){const t=e.map((e=>{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(t.join("|"),"u")}Ps(["Arab","Dupl","Mong","Ougr","Syrc"]);const Is=Ps(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Ms(e){return Is.test(String.fromCodePoint(e))}function Es(e,t){return!(!t&&Ms(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function Cs(e){for(const t of e)if(Ms(t.codePointAt(0)))return!0;return!1}const As=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(As.isParsed())throw new 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}syncState(e,t){return n(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const i=e.pluginURL,r=new Promise((e=>{this.loadScriptResolve=e}));t(i);const n=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([r,n]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:i};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${i}`)}))}};class zs{constructor(e,t){this.isSupportedScript=Ds,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new Ts,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ts,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const 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}}}function Ds(e){return function(e,t){for(const i of e)if(!Es(i.codePointAt(0),t))return!1;return!0}(e,"loaded"===As.getRTLTextPluginStatus())}const Rs="-transition";class ks{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if(Qn(e))return new fo(e,t);if(lo(e)){const r=po(e,t,i);if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return r.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Ri.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Gi.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=Zi.parse(e)):i=ji.parse(e):i=Vi.parse(e):i=Oi.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i)}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)}}class Ls{constructor(e,t){this.property=e,this.value=new ks(e,void 0,t)}transitioned(e,t){return new Bs(this.property,this.value,t,Te({},e.transition,this.transition),e.now)}untransitioned(){return new Bs(this.property,this.value,null,{},0)}}class Fs{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return Re(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].value=new ks(this._values[e].property,null===t?void 0:Re(t),this._globalState)}getTransition(e){return Re(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].transition=Re(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}${Rs}`]=r)}return e}transitioned(e,t){const i=new Os(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Os(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Bs{constructor(e,t,i,r,n){this.property=e,this.value=t,this.begin=n+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(e,t,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),n,ye(s))}}return n}}class Os{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const r=new Ns(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Vs{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=t}hasValue(e){return void 0!==this._values[e].value}hasProperty(e){return e in this._properties.defaultPropertyValues}getValue(e){return Re(this._values[e].value)}setValue(e,t){this._values[e]=new ks(this._values[e].property,null===t?void 0:Re(t),this._globalState)}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){const r=new Ns(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}}class js{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)}}class Ns{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Us{constructor(e){this.specification=e}possiblyEvaluate(e,t){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(t)}interpolate(e,t,i){const r=br[this.specification.type];return r?r(e,t,i):e}}class Gs{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,r){return new js(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)}: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 js(this,{kind:"constant",value:void 0},e.parameters);const r=br[this.specification.type];if(r){const n=r(e.value.value,t.value.value,i);return new js(this,{kind:"constant",value:n},e.parameters)}return e}evaluate(e,t,i,r,n,o){return"constant"===e.kind?e.value:e.evaluate(t,i,r,n,o)}}class $s extends Gs{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new js(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r),o="resolvedImage"===e.property.specification.type&&"string"!=typeof n?n.name:n,s=this._calculate(o,o,o,t);return new js(this,{kind:"constant",value:s},t)}if("camera"===e.expression.kind){const 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 js(this,{kind:"constant",value:i},t)}return new js(this,e.expression,t)}evaluate(e,t,i,r,n,o){if("source"===e.kind){const s=e.evaluate(t,i,r,n,o);return this._calculate(s,s,s,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}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r);return this._calculate(n,n,n,t)}return this._calculate(e.expression.evaluate(new zs(Math.floor(t.zoom-1),t)),e.expression.evaluate(new zs(Math.floor(t.zoom),t)),e.expression.evaluate(new zs(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}}class qs{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class Ws{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const r=this.defaultPropertyValues[t]=new ks(i,void 0,void 0),n=this.defaultTransitionablePropertyValues[t]=new Ls(i,void 0);this.defaultTransitioningPropertyValues[t]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}}gs("DataDrivenProperty",Gs),gs("DataConstantProperty",Us),gs("CrossFadedDataDrivenProperty",$s),gs("CrossFadedProperty",Zs),gs("ColorRampProperty",qs);const Hs=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Xs=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";class Ys extends Tt{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){return new as(e,t)}(this.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=xo(e.filter,i)),t.layout&&(this._unevaluatedLayout=new Vs(t.layout,i)),t.paint)){this._transitionablePaint=new Fs(t.paint,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ns(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=xo(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){var t;if("visibility"===e)return this.visibility;if(null===(t=this._transitionablePaint)||void 0===t?void 0:t.hasProperty(e))throw new Error(e+Hs);if(!this._unevaluatedLayout)throw new Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var e;const t=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const r=this._transitionablePaint._values[i].value;for(const n of r.getGlobalStateRefs()){const o=null!==(e=t.get(n))&&void 0!==e?e:[];o.push({name:i,value:r.value}),t.set(n,o)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,i={}){var r;if("visibility"===e)return this.visibility=t,this._visibilityExpression.setValue(t),void this.recalculateVisibility();(null===(r=this._transitionablePaint)||void 0===r?void 0:r.hasProperty(e))?this.fire(new wt(new Error(e+Hs))):null!=t&&this._validate(ps,`layers.${this.id}.layout.${e}`,e,t,i)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){var t,i;if(e.endsWith(Rs)){const i=e.slice(0,-11);if("visibility"===i||(null===(t=this._unevaluatedLayout)||void 0===t?void 0:t.hasProperty(i)))throw new Error(e+Xs);return this._transitionablePaint.getTransition(i)}if("visibility"===e||(null===(i=this._unevaluatedLayout)||void 0===i?void 0:i.hasProperty(e)))throw new Error(e+Xs);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){var r;if("visibility"===e||(null===(r=this._unevaluatedLayout)||void 0===r?void 0:r.hasProperty(e)))return this.fire(new wt(new Error(e+Xs))),!1;if(null!=t&&this._validate(ds,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Rs))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_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(){var e,t;const i={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:null===(e=this._unevaluatedLayout)||void 0===e?void 0:e.serialize(),paint:null===(t=this._transitionablePaint)||void 0===t?void 0:t.serialize()};return this.visibility&&(i.layout||(i.layout={}),i.layout.visibility=this.visibility),ze(i,((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,i,r,n={}){return!1!==(null==n?void 0:n.validate)&&fs(this,e.call(cs,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:St,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof js&&Xn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}let Ks;var Js={get paint(){return Ks=Ks||new Ws({"raster-opacity":new Us(St.paint_raster["raster-opacity"]),"raster-hue-rotate":new Us(St.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Us(St.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Us(St.paint_raster["raster-brightness-max"]),"raster-saturation":new Us(St.paint_raster["raster-saturation"]),"raster-contrast":new Us(St.paint_raster["raster-contrast"]),resampling:new Us(St.paint_raster.resampling),"raster-resampling":new Us(St.paint_raster["raster-resampling"]),"raster-fade-duration":new Us(St.paint_raster["raster-fade-duration"])})}};const Qs=e=>"raster"===e.type;class ea extends Ys{constructor(e,t){super(e,Js,t)}}const ta={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ia{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}}class ra{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){const 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);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}}function na(e,t=1){let i=0,r=0;return{members:e.map((e=>{const n=ta[e.type].BYTES_PER_ELEMENT,o=i=oa(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}})),size:oa(i,Math.max(r,t)),alignment:t}}function oa(e,t){return Math.ceil(e/t)*t}class sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}sa.prototype.bytesPerElement=4,gs("StructArrayLayout2i4",sa);class aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}aa.prototype.bytesPerElement=6,gs("StructArrayLayout3i6",aa);class la extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}la.prototype.bytesPerElement=8,gs("StructArrayLayout4i8",la);class ca extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}ca.prototype.bytesPerElement=12,gs("StructArrayLayout2i4i12",ca);class ha extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=n,this.uint8[l+6]=o,this.uint8[l+7]=s,e}}ha.prototype.bytesPerElement=8,gs("StructArrayLayout2i4ub8",ha);class ua extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}ua.prototype.bytesPerElement=8,gs("StructArrayLayout2f8",ua);class da extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,n,o,s,a,l,c)}emplace(e,t,i,r,n,o,s,a,l,c,h){const u=10*e;return this.uint16[u+0]=t,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=o,this.uint16[u+5]=s,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,e}}da.prototype.bytesPerElement=20,gs("StructArrayLayout10ui20",da);class pa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,n,o,s,a)}emplace(e,t,i,r,n,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}pa.prototype.bytesPerElement=16,gs("StructArrayLayout8ui16",pa);class fa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,h,u)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,e}}fa.prototype.bytesPerElement=24,gs("StructArrayLayout4i4ui4i24",fa);class ma extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}ma.prototype.bytesPerElement=12,gs("StructArrayLayout3f12",ma);class _a extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}_a.prototype.bytesPerElement=4,gs("StructArrayLayout1ul4",_a);class ga extends ra{_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,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,r,n,o,s,a,l)}emplace(e,t,i,r,n,o,s,a,l,c){const h=10*e,u=5*e;return this.int16[h+0]=t,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=n,this.int16[h+4]=o,this.int16[h+5]=s,this.uint32[u+3]=a,this.uint16[h+8]=l,this.uint16[h+9]=c,e}}ga.prototype.bytesPerElement=20,gs("StructArrayLayout6i1ul2ui20",ga);class ya extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}ya.prototype.bytesPerElement=12,gs("StructArrayLayout2i2i2i12",ya);class va extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}va.prototype.bytesPerElement=16,gs("StructArrayLayout2f1f2i16",va);class xa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.int16[c+6]=o,this.int16[c+7]=s,e}}xa.prototype.bytesPerElement=16,gs("StructArrayLayout2ub2f2i16",xa);class ba extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}ba.prototype.bytesPerElement=6,gs("StructArrayLayout3ui6",ba);class wa extends ra{_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,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=24*e,v=12*e,x=48*e;return this.int16[y+0]=t,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=n,this.uint32[v+2]=o,this.uint32[v+3]=s,this.uint32[v+4]=a,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[v+7]=u,this.float32[v+8]=d,this.uint8[x+36]=p,this.uint8[x+37]=f,this.uint8[x+38]=m,this.uint32[v+10]=_,this.int16[y+22]=g,e}}wa.prototype.bytesPerElement=48,gs("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",wa);class Ta extends ra{_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,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,P,I,M){const E=this.length;return this.resize(E+1),this.emplace(E,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,P,I,M)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,P,I,M,E){const C=32*e,A=16*e;return this.int16[C+0]=t,this.int16[C+1]=i,this.int16[C+2]=r,this.int16[C+3]=n,this.int16[C+4]=o,this.int16[C+5]=s,this.int16[C+6]=a,this.int16[C+7]=l,this.uint16[C+8]=c,this.uint16[C+9]=h,this.uint16[C+10]=u,this.uint16[C+11]=d,this.uint16[C+12]=p,this.uint16[C+13]=f,this.uint16[C+14]=m,this.uint16[C+15]=_,this.uint16[C+16]=g,this.uint16[C+17]=y,this.uint16[C+18]=v,this.uint16[C+19]=x,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=T,this.uint32[A+12]=S,this.float32[A+13]=P,this.float32[A+14]=I,this.uint16[C+30]=M,this.uint16[C+31]=E,e}}Ta.prototype.bytesPerElement=64,gs("StructArrayLayout8i15ui1ul2f2ui64",Ta);class Sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Sa.prototype.bytesPerElement=4,gs("StructArrayLayout1f4",Sa);class Pa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[6*e+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}Pa.prototype.bytesPerElement=12,gs("StructArrayLayout1ui2f12",Pa);class Ia extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=4*e;return this.uint32[2*e+0]=t,this.uint16[n+2]=i,this.uint16[n+3]=r,e}}Ia.prototype.bytesPerElement=8,gs("StructArrayLayout1ul2ui8",Ia);class Ma extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}Ma.prototype.bytesPerElement=4,gs("StructArrayLayout2ui4",Ma);class Ea extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Ea.prototype.bytesPerElement=2,gs("StructArrayLayout1ui2",Ea);class Ca extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}Ca.prototype.bytesPerElement=16,gs("StructArrayLayout4f16",Ca);class Aa extends ia{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 o(this.anchorPointX,this.anchorPointY)}}Aa.prototype.size=20;class za extends ga{get(e){return new Aa(this,e)}}gs("CollisionBoxArray",za);class Da extends ia{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]}}Da.prototype.size=48;class Ra extends wa{get(e){return new Da(this,e)}}gs("PlacedSymbolArray",Ra);class ka extends ia{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]}}ka.prototype.size=64;class La extends Ta{get(e){return new ka(this,e)}}gs("SymbolInstanceArray",La);class Fa extends Sa{getoffsetX(e){return this.float32[1*e+0]}}gs("GlyphOffsetArray",Fa);class Ba extends aa{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}gs("SymbolLineVertexArray",Ba);class Oa extends ia{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]}}Oa.prototype.size=12;class Va extends Pa{get(e){return new Oa(this,e)}}gs("TextAnchorOffsetArray",Va);class ja extends ia{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]}}ja.prototype.size=8;class Na extends Ia{get(e){return new ja(this,e)}}gs("FeatureIndexArray",Na);class Ua extends sa{}class Ga extends aa{}class $a extends la{}class Za extends sa{}class qa extends sa{}class Wa extends ca{}class Ha extends ha{}class Xa extends ua{}class Ya extends da{}class Ka extends pa{}class Ja extends fa{}class Qa extends ma{}class el extends _a{}class tl extends ya{}class il extends va{}class rl extends xa{}class nl extends ba{}class ol extends ba{}class sl extends Ma{}class al extends Ea{}const ll=na([{name:"a_pos",components:2,type:"Int16"}],4),{members:cl}=ll;class hl{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,r){const n=this.segments[this.segments.length-1];return e>hl.MAX_VERTEX_ARRAY_LENGTH&&Le(`Max vertices per segment is ${hl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${hl.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+e>hl.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r?this.createNewSegment(t,i,r):n}createNewSegment(e,t,i){const 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(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new hl([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function ul(e,t){return 256*(e=be(Math.floor(e),0,255))+be(Math.floor(t),0,255)}hl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,gs("SegmentVector",hl);const dl=na([{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"}]),pl=na([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var fl,ml,_l,gl={exports:{}},yl={exports:{}},vl={exports:{}},xl=function(){if(_l)return gl.exports;_l=1;var e=(fl||(fl=1,function(e){e.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}}(yl)),yl.exports),t=(ml||(ml=1,function(e){e.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}}(vl)),vl.exports);return gl.exports=e,gl.exports.murmur3=e,gl.exports.murmur2=t,gl.exports}(),bl=s(xl);class wl{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(Tl(e)),this.positions.push(t,i,r)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=Tl(e);let i=0,r=this.ids.length-1;for(;i<r;){const e=i+r>>1;this.ids[e]>=t?r=e:i=e+1}const n=[];for(;this.ids[i]===t;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Sl(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){const t=new wl;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function Tl(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:bl(String(e))}function Sl(e,t,i,r){for(;i<r;){const n=e[i+r>>1];let o=i-1,s=r+1;for(;;){do{o++}while(e[o]<n);do{s--}while(e[s]>n);if(o>=s)break;Pl(e,o,s),Pl(t,3*o,3*s),Pl(t,3*o+1,3*s+1),Pl(t,3*o+2,3*s+2)}s-i<r-s?(Sl(e,t,i,s),i=s+1):(Sl(e,t,s+1,r),r=s)}}function Pl(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}gs("FeaturePositionMap",wl);class Il{constructor(e,t){this.gl=e.gl,this.location=t}}class Ml extends Il{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}}class El extends Il{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Cl extends Il{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]))}}class Al extends Il{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]))}}class zl extends Il{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]))}}class Dl extends Il{constructor(e,t){super(e,t),this.current=Ri.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))}}class Rl extends Il{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const 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)}}}class kl extends Il{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}}const Ll=new Float32Array(16);class Fl extends Il{constructor(e,t){super(e,t),this.current=Ll}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 Bl(e){return[ul(255*e.r,255*e.g),ul(255*e.b,255*e.a)]}class Ol{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 Dl(e,t):new El(e,t)}}class Vl{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 n=null;"u_pattern_to"===r?n=this.patternTo:"u_pattern_from"===r?n=this.patternFrom:"u_dasharray_to"===r?n=this.dashTo:"u_dasharray_from"===r?n=this.dashFrom:"u_pixel_ratio_to"===r?n=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(n=this.pixelRatioFrom),null!==n&&e.set(n)}getBinding(e,t,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new zl(e,t):new El(e,t)}}class jl{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){const r=this.paintVertexArray.length,n=this.expression.evaluate(new zs(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,n)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate(new zs(0,n),i,r);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const r=Bl(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){var t,i;(null===(t=this.paintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&((null===(i=this.paintVertexBuffer)||void 0===i?void 0:i.buffer)?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Nl{constructor(e,t,i,r,n,o){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,i){const r=this.expression.evaluate(new zs(this.zoom,i),t,{},i.canonical,[],i.formattedSection),n=this.expression.evaluate(new zs(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(o,e,r,n)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate(new zs(this.zoom,n),i,r),s=this.expression.evaluate(new zs(this.zoom+1,n),i,r);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Bl(i),o=Bl(r);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){var t,i;(null===(t=this.paintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&((null===(i=this.paintVertexBuffer)||void 0===i?void 0:i.buffer)?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){const i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=be(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new El(e,t)}}class Ul{constructor(e,t,i,r,n,o){this.expression=e,this.type=t,this.useIntegerZoom=i,this.zoom=r,this.layerId=o,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(e,t,i){const 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,n){this._setPaintValues(e,t,this.getPositionIds(i),n)}_setPaintValues(e,t,i,r){const n=this.getPositions(r);if(!n||!i)return;const o=n[i.min],s=n[i.mid],a=n[i.max];if(o&&s&&a)for(let i=e;i<t;i++)this.emplace(this.zoomInPaintVertexArray,i,s,o),this.emplace(this.zoomOutPaintVertexArray,i,s,a)}upload(e){var t,i;if((null===(t=this.zoomInPaintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&(null===(i=this.zoomOutPaintVertexArray)||void 0===i?void 0:i.arrayBuffer.byteLength)){const 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()}}class Gl extends Ul{getPositions(e){return e.imagePositions}getPositionIds(e){var t;return null===(t=e.patterns)||void 0===t?void 0:t[this.layerId]}getVertexAttributes(){return dl.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)}}class $l extends Ul{getPositions(e){return e.dashPositions}getPositionIds(e){var t;return null===(t=e.dashes)||void 0===t?void 0:t[this.layerId]}getVertexAttributes(){return pl.members}emplace(e,t,i,r){e.emplace(t,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}}class Zl{constructor(e,t,i){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){if(!i(n))continue;const o=e.paint.get(n);if(!(o instanceof js&&Xn(o.property.specification)))continue;const s=Wl(n,e.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,h=o.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===a.kind)this.binders[n]=u?new Vl(a.value,s):new Ol(a.value,s,l),r.push(`/u_${n}`);else if("source"===a.kind||u){const i=Hl(n,l,"source");this.binders[n]=u?"line-dasharray"===n?new $l(a,l,c,t,i,e.id):new Gl(a,l,c,t,i,e.id):new jl(a,s,l,i),r.push(`/a_${n}`)}else{const e=Hl(n,l,"composite");this.binders[n]=new Nl(a,s,l,c,t,e),r.push(`/z_${n}`)}}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof jl||t instanceof Nl?t.maxValue:0}populatePaintArrays(e,t,i){for(const r in this.binders){const n=this.binders[r];(n instanceof jl||n instanceof Nl||n instanceof Ul)&&n.populatePaintArray(e,t,i)}}setConstantPatternPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof Vl&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof Vl&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,i,r,n){let o=!1;for(const s in e){const a=t.getPositions(s);for(const t of a){const a=i.feature(t.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof jl||l instanceof Nl||l instanceof Ul)&&!0===l.expression.isStateDependent){const c=r.paint.get(i);l.expression=c.value,l.updatePaintArray(t.start,t.end,a,e[s],n),o=!0}}}}return o}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Ol||i instanceof Vl)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof jl||i instanceof Nl)for(const t of i.paintVertexAttributes)e.push(t.name);else if(i instanceof Ul){const t=i.getVertexAttributes();for(const i of t)e.push(i.name)}}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ol||i instanceof Vl||i instanceof Nl)for(const t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Ol||n instanceof Vl||n instanceof Nl)for(const o of n.uniformNames)if(t[o]){const s=n.getBinding(e,t[o],o);i.push({name:o,property:r,binding:s})}}return i}setUniforms(e,t,i,r){for(const{name:e,property:n,binding:o}of t)this.binders[n].setUniform(o,r,i.get(n),e)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const i=this.binders[t];if(e&&i instanceof Ul){const t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof jl||i instanceof Nl)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof jl||i instanceof Nl||i instanceof Ul)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof jl||t instanceof Nl||t instanceof Ul)&&t.destroy()}}}class ql{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Zl(r,t,i);this.needsUpload=!1,this._featureMap=new wl,this._bufferOffset=0}populatePaintArrays(e,t,i,r){for(const 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(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(e,this._featureMap,t,n,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Wl(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 Hl(e,t,i){const r={color:{source:ua,composite:Ca},number:{source:Sa,composite:ua}},n=function(e){return{"line-pattern":{source:Ya,composite:Ya},"fill-pattern":{source:Ya,composite:Ya},"fill-extrusion-pattern":{source:Ya,composite:Ya},"line-dasharray":{source:Ka,composite:Ka}}[e]}(e);return(null==n?void 0:n[i])||r[t][i]}gs("ConstantBinder",Ol),gs("CrossFadedConstantBinder",Vl),gs("SourceExpressionBinder",jl),gs("CrossFadedPatternBinder",Gl),gs("CrossFadedDasharrayBinder",$l),gs("CompositeExpressionBinder",Nl),gs("ProgramConfiguration",Zl,{omit:["_buffers"]}),gs("ProgramConfigurationSet",ql);const Xl=Math.pow(2,14)-1,Yl=-Xl-1;function Kl(e){const t=Q/e.extent,i=e.loadGeometry();for(const e of i)for(const i of e){const e=Math.round(i.x*t),r=Math.round(i.y*t);i.x=be(e,Yl,Xl),i.y=be(r,Yl,Xl),(e<i.x||e>i.x+1||r<i.y||r>i.y+1)&&Le("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function Jl(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Kl(e):[]}}const Ql=-32768;function ec(e,t,i,r,n){e.emplaceBack(Ql+8*t+r,Ql+8*i+n)}class tc{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 Za,this.indexArray=new ol,this.segments=new hl,this.programConfigurations=new ql(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i){const r=this.layers[0],n=[];let o=null,s=!1,a="heatmap"===r.type;if("circle"===r.type){const e=r;o=e.layout.get("circle-sort-key"),s=!o.isConstant(),a||(a="map"===e.paint.get("circle-pitch-alignment"))}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:r,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Jl(t,e);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),c,i))continue;const h=s?o.evaluate(c,{},i):void 0,u={id:r,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Kl(t),patterns:{},sortKey:h};n.push(u)}s&&n.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r,a=e[o].feature;this.addFeature(r,n,o,i,l),t.featureIndex.insert(a,n,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,cl),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,n=1){let o;switch(n){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=Q||r<0||r>=Q)continue;const n=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),a=n.vertexLength;for(let e=0;e<s;e++)for(let t=0;t<s;t++)ec(this.layoutVertexArray,i,r,o[t],o[e]);for(let e=0;e<s-1;e++)for(let t=0;t<s-1;t++){const i=a+e*s+t,r=a+(e+1)*s+t;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}n.vertexLength+=s*s,n.primitiveLength+=(s-1)*(s-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:{},canonical:r})}}function ic(e,t){for(const i of e)if(uc(t,i))return!0;for(const i of t)if(uc(e,i))return!0;return sc(e,t)}function rc(e,t,i){return!!uc(e,t)||lc(t,e,i)}function nc(e,t){if(1===e.length)return hc(t,e[0]);for(const i of t)for(const t of i)if(uc(e,t))return!0;for(const i of e)if(hc(t,i))return!0;for(const i of t)if(sc(e,i))return!0;return!1}function oc(e,t,i){if(e.length>1){if(sc(e,t))return!0;for(const r of t)if(lc(r,e,i))return!0}for(const r of e)if(lc(r,t,i))return!0;return!1}function sc(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)if(ac(r,n,t[e],t[e+1]))return!0}return!1}function ac(e,t,i,r){return Fe(e,i,r)!==Fe(t,i,r)&&Fe(e,t,i)!==Fe(e,t,r)}function lc(e,t,i){const r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let i=1;i<t.length;i++)if(cc(e,t[i-1],t[i])<r)return!0;return!1}function cc(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return e.distSqr(n<0?t:n>1?i:i.sub(t)._mult(n)._add(t))}function hc(e,t){let i,r,n,o=!1;for(const s of e){i=s;for(let e=0,s=i.length-1;e<i.length;s=e++)r=i[e],n=i[s],r.y>t.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function uc(e,t){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const o=e[r],s=e[n];o.y>t.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function dc(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return!1;const o=Fe(e,t,i[0]);return o!==Fe(e,t,i[1])||o!==Fe(e,t,i[2])||o!==Fe(e,t,i[3])}function pc(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function fc(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function mc(e,t,i,r,n){if(!t[0]&&!t[1])return e;const s=o.convert(t)._mult(n);"viewport"===i&&s._rotate(-r);const a=[];for(const t of e)a.push(t.sub(s));return a}function _c(e){const t=[];for(let i=0;i<e.length;i++){const r=e[i],n=t.at(-1);(0===i||n&&!r.equals(n))&&t.push(r)}return t}function gc({queryGeometry:e,size:t},i){return rc(e,i,t)}function yc({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n},o){return rc(e,o,t*(i.projectTileCoordinates(o.x,o.y,r,n).signedDistanceFromCamera/i.cameraToCenterDistance))}function vc({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n},o){const s=i.projectTileCoordinates(o.x,o.y,r,n).signedDistanceFromCamera,a=t*(i.cameraToCenterDistance/s);return rc(e,wc(o,i,r,n),a)}function xc({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n},o){return rc(e,wc(o,i,r,n),t)}function bc({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n,pitchAlignment:o="map",pitchScale:s="map"},a){const l="map"===o?"map"===s?gc:yc:"map"===s?vc:xc,c={queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n};for(const e of a)for(const t of e)if(l(c,t))return!0;return!1}function wc(e,t,i,r){const n=t.projectTileCoordinates(e.x,e.y,i,r).point;return new o((.5*n.x+.5)*t.width,(.5*-n.y+.5)*t.height)}let Tc,Sc;gs("CircleBucket",tc,{omit:["layers"]});var Pc={get paint(){return Sc=Sc||new Ws({"circle-radius":new Gs(St.paint_circle["circle-radius"]),"circle-color":new Gs(St.paint_circle["circle-color"]),"circle-blur":new Gs(St.paint_circle["circle-blur"]),"circle-opacity":new Gs(St.paint_circle["circle-opacity"]),"circle-translate":new Us(St.paint_circle["circle-translate"]),"circle-translate-anchor":new Us(St.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Us(St.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Us(St.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Gs(St.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Gs(St.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Gs(St.paint_circle["circle-stroke-opacity"])})},get layout(){return Tc=Tc||new Ws({"circle-sort-key":new Gs(St.layout_circle["circle-sort-key"])})}};class Ic extends Ys{constructor(e,t){super(e,Pc,t)}createBucket(e){return new tc(e)}queryRadius(e){const t=e;return pc("circle-radius",this,t)+pc("circle-stroke-width",this,t)+fc(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:n,pixelsToTileUnits:o,unwrappedTileID:s,getElevation:a}){const l=mc(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,o),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i),h=this.paint.get("circle-pitch-scale"),u=this.paint.get("circle-pitch-alignment");let d,p;return"map"===u?(d=l,p=c*o):(d=function(e,t,i,r){return e.map((e=>wc(e,t,i,r)))}(l,n,s,a),p=c),bc({queryGeometry:d,size:p,transform:n,unwrappedTileID:s,getElevation:a,pitchAlignment:u,pitchScale:h},r)}}class Mc extends tc{}let Ec;gs("HeatmapBucket",Mc,{omit:["layers"]});var Cc={get paint(){return Ec=Ec||new Ws({"heatmap-radius":new Gs(St.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Gs(St.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Us(St.paint_heatmap["heatmap-intensity"]),"heatmap-color":new qs(St.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Us(St.paint_heatmap["heatmap-opacity"])})}};function Ac(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError(`mismatched image size. expected: ${n.length} but got: ${t*i*r}`)}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function zc(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;const n=Ac({},{width:t,height:i},r);Dc(e,n,{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=n.data}function Dc(e,t,i,r,n,o){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l<n.height;l++){const c=((i.y+l)*e.width+i.x)*o,h=((r.y+l)*t.width+r.x)*o;for(let e=0;e<n.width*o;e++)a[h+e]=s[c+e]}return t}class Rc{constructor(e,t){Ac(this,e,1,t)}resize(e){zc(this,e,1)}clone(){return new Rc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){Dc(e,t,i,r,n,1)}}class kc{constructor(e,t){Ac(this,e,4,t)}resize(e){zc(this,e,4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new kc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){Dc(e,t,i,r,n,4)}setPixel(e,t,i){const 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 Lc(e){const t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=4){const 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 Fc(e){const t={},i=e.resolution||256,r=e.clips?e.clips.length:1,n=e.image||new kc({width:i,height:r});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const o=(r,o,s)=>{t[e.evaluationKey]=s;const a=e.expression.evaluate(t);n.setPixel(r/4/i,o/4,a)};if(e.clips)for(let t=0,n=0;t<r;++t,n+=4*i)for(let r=0,s=0;r<i;r++,s+=4){const a=r/(i-1),{start:l,end:c}=e.clips[t];o(n,s,l*(1-a)+c*a)}else for(let e=0,t=0;e<i;e++,t+=4)o(0,t,e/(i-1));return n}gs("AlphaImage",Rc),gs("RGBAImage",kc);const Bc="big-fb";class Oc extends Ys{createBucket(e){return new Mc(e)}constructor(e,t){super(e,Cc,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Fc({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Bc)&&this.heatmapFbos.delete(Bc)}queryRadius(e){return pc("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:n,pixelsToTileUnits:o,unwrappedTileID:s,getElevation:a}){return bc({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(t,i)*o,transform:n,unwrappedTileID:s,getElevation:a},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}}let Vc;var jc={get paint(){return Vc=Vc||new Ws({"hillshade-illumination-direction":new Us(St.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Us(St.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Us(St.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Us(St.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Us(St.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Us(St.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Us(St.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Us(St.paint_hillshade["hillshade-method"]),resampling:new Us(St.paint_hillshade.resampling)})}};class Nc extends Ys{constructor(e,t){super(e,jc,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;const n=Math.max(e.length,t.length,i.length,r.length);e=e.concat(Array(n-e.length).fill(e.at(-1))),t=t.concat(Array(n-t.length).fill(t.at(-1))),i=i.concat(Array(n-i.length).fill(i.at(-1))),r=r.concat(Array(n-r.length).fill(r.at(-1)));const o=t.map(Ue);return{directionRadians:e.map(Ue),altitudeRadians:o,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}}let Uc;var Gc={get paint(){return Uc=Uc||new Ws({"color-relief-opacity":new Us(St["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new qs(St["paint_color-relief"]["color-relief-color"]),resampling:new Us(St["paint_color-relief"].resampling)})}};function $c(e){return"data"in e}class Zc{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,i){var r;const{width:n,height:o}=e,s=((null===(r=this.size)||void 0===r?void 0:r[0])!==n||this.size[1]!==o)&&!i,{context:a}=this,{gl:l}=a;this.useMipmap=Boolean(null==t?void 0:t.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1);const c=this.format===l.RGBA&&!1!==(null==t?void 0:t.premultiply);if(s)this.size=[n,o],$c(e)?(a.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,c,n,o,l)):(a.pixelStoreUnpackPremultiplyAlpha.set(c),this._uploadDomImage(e,l));else{const{x:t,y:r}=i||{x:0,y:0};$c(e)?(a.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,c,t,r,n,o,l)):(a.pixelStoreUnpackPremultiplyAlpha.set(c),this._updateDomImage(e,t,r,l))}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D),a.pixelStoreUnpackFlipY.setDefault(),a.pixelStoreUnpack.setDefault(),a.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,i,r,n){let{data:o}=e;t&&o&&(o=Lc(o)),n.texImage2D(n.TEXTURE_2D,0,this.format,i,r,0,this.format,n.UNSIGNED_BYTE,o)}_updateDomImage(e,t,i,r){r.texSubImage2D(r.TEXTURE_2D,0,t,i,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,i,r,n,o,s){let{data:a}=e;t&&a&&(a=Lc(a)),s.texSubImage2D(s.TEXTURE_2D,0,i,r,n,o,s.RGBA,s.UNSIGNED_BYTE,a)}bind(e,t,i){const{context:r}=this,{gl:n}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),n.bindTexture(n.TEXTURE_2D,this.texture),i!==n.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=n.LINEAR),e!==this.filter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}}function qc(e,t){const i=t[0],r=t[1],n=t[2],o=t[3],s=Math.min(i,r,n),a=Math.round((e+o)/s);return{r:Math.floor(a*s/i)%256,g:Math.floor(a*s/r)%256,b:Math.floor(a*s/n)%256}}gs("DEMData",class{constructor(e,t,i,r=1,n=1,o=1,s=0){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i))return void Le(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=t.height;const a=this.dim=t.height-2;switch(this.data=new Uint32Array(t.data.buffer),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=r,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=0;e<a;e++)this.data[this._idx(-1,e)]=this.data[this._idx(0,e)],this.data[this._idx(a,e)]=this.data[this._idx(a-1,e)],this.data[this._idx(e,-1)]=this.data[this._idx(e,0)],this.data[this._idx(e,a)]=this.data[this._idx(e,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let e=0;e<a;e++)for(let t=0;t<a;t++){const i=this.get(e,t);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(e,t){const i=new Uint8Array(this.data.buffer),r=4*this._idx(e,t);return this.unpack(i[r],i[r+1],i[r+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+1)*this.stride+(e+1)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return qc(e,this.getUnpackVector())}getPixels(){return new kc({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t<s;t++)for(let i=r;i<n;i++)this.data[this._idx(i,t)]=e.data[this._idx(i+a,t+l)]}});class Wc extends Ys{constructor(e,t){super(e,Gc,t)}_createColorRamp(e){const t={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof ho&&i._styleExpression.expression instanceof vr){this.colorRampExpression=i;const e=i._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(const i of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:i}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[Ri.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;const r={elevationStops:[],colorStops:[]},n=(t.elevationStops.length-1)/(e-1);for(let e=0;e<t.elevationStops.length-.5;e+=n)r.elevationStops.push(t.elevationStops[Math.round(e)]),r.colorStops.push(t.colorStops[Math.round(e)]);return Le(`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;const r=this._createColorRamp(t),n=new kc({width:r.colorStops.length,height:1}),o=new kc({width:r.colorStops.length,height:1});for(let e=0;e<r.elevationStops.length;e++){const t=qc(r.elevationStops[e],i);o.setPixel(0,e,new Ri(t.r/255,t.g/255,t.b/255,1)),n.setPixel(0,e,r.colorStops[e])}return this.colorRampTextures={elevationTexture:new Zc(e,o,e.gl.RGBA),colorTexture:new Zc(e,n,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const Hc=na([{name:"a_pos",components:2,type:"Int16"}],4),{members:Xc}=Hc;function Yc(e,t,i){const r=i.patternDependencies;let n=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(n=!0);const o=t.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function Kc(e,t,i,r,n){const{zoom:o}=r,s=n.patternDependencies;for(const r of t){const t=r.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:o-1},i,{},n.availableImages),a=t.evaluate({zoom:o},i,{},n.availableImages),l=t.evaluate({zoom:o+1},i,{},n.availableImages);e=(null==e?void 0:e.name)?e.name:e,a=(null==a?void 0:a.name)?a.name:a,l=(null==l?void 0:l.name)?l.name:l,s[e]=!0,s[a]=!0,s[l]=!0,i.patterns[r.id]={min:e,mid:a,max:l}}}return i}function Jc(e,t,i,r,n){let o;if(n===function(e,t,i,r){let n=0;for(let o=t,s=i-r;o<i;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}(e,t,i,r)>0)for(let n=t;n<i;n+=r)o=xh(n/r|0,e[n],e[n+1],o);else for(let n=i-r;n>=t;n-=r)o=xh(n/r|0,e[n],e[n+1],o);return o&&fh(o,o.next)&&(bh(o),o=o.next),o}function Qc(e,t){if(!e)return e;t||(t=e);let i,r=e;do{if(i=!1,r.steiner||!fh(r,r.next)&&0!==ph(r.prev,r,r.next))r=r.next;else{if(bh(r),r=t=r.prev,r===r.next)break;i=!0}}while(i||r!==t);return t}function eh(e,t,i,r,n,o,s){if(!e)return;!s&&o&&function(e,t,i,r){let n=e;do{0===n.z&&(n.z=lh(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){let t,i=1;do{let r,n=e;e=null;let o=null;for(t=0;n;){t++;let s=n,a=0;for(let e=0;e<i&&(a++,s=s.nextZ,s);e++);let l=i;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||n.z<=s.z)?(r=n,n=n.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=s}o.nextZ=null,i*=2}while(t>1)}(n)}(e,r,n,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?ih(e,r,n,o):th(e))t.push(l.i,e.i,c.i),bh(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?eh(e=rh(Qc(e),t),t,i,r,n,o,2):2===s&&nh(e,t,i,r,n,o):eh(Qc(e),t,i,r,n,o,1);break}}}function th(e){const t=e.prev,i=e,r=e.next;if(ph(t,i,r)>=0)return!1;const n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,h=Math.min(n,o,s),u=Math.min(a,l,c),d=Math.max(n,o,s),p=Math.max(a,l,c);let f=r.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&uh(n,a,o,l,s,c,f.x,f.y)&&ph(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ih(e,t,i,r){const n=e.prev,o=e,s=e.next;if(ph(n,o,s)>=0)return!1;const a=n.x,l=o.x,c=s.x,h=n.y,u=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(h,u,d),m=Math.max(a,l,c),_=Math.max(h,u,d),g=lh(p,f,t,i,r),y=lh(m,_,t,i,r);let v=e.prevZ,x=e.nextZ;for(;v&&v.z>=g&&x&&x.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&uh(a,h,l,u,c,d,v.x,v.y)&&ph(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&uh(a,h,l,u,c,d,x.x,x.y)&&ph(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&uh(a,h,l,u,c,d,v.x,v.y)&&ph(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&uh(a,h,l,u,c,d,x.x,x.y)&&ph(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function rh(e,t){let i=e;do{const r=i.prev,n=i.next.next;!fh(r,n)&&mh(r,i,i.next,n)&&yh(r,n)&&yh(n,r)&&(t.push(r.i,i.i,n.i),bh(i),bh(i.next),i=e=n),i=i.next}while(i!==e);return Qc(i)}function nh(e,t,i,r,n,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&dh(s,e)){let a=vh(s,e);return s=Qc(s,s.next),a=Qc(a,a.next),eh(s,t,i,r,n,o,0),void eh(a,t,i,r,n,o,0)}e=e.next}s=s.next}while(s!==e)}function oh(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function sh(e,t){const i=function(e,t){let i=t;const r=e.x,n=e.y;let o,s=-1/0;if(fh(e,i))return i;do{if(fh(e,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const e=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,o=i.x<i.next.x?i:i.next,e===r))return o}i=i.next}while(i!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;i=o;do{if(r>=i.x&&i.x>=l&&r!==i.x&&hh(n<c?r:s,n,l,c,n<c?s:r,n,i.x,i.y)){const t=Math.abs(n-i.y)/(r-i.x);yh(i,e)&&(t<h||t===h&&(i.x>o.x||i.x===o.x&&ah(o,i)))&&(o=i,h=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const r=vh(i,e);return Qc(r,r.next),Qc(i,i.next)}function ah(e,t){return ph(e.prev,e,t.prev)<0&&ph(t.next,e,e.next)<0}function lh(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ch(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 hh(e,t,i,r,n,o,s,a){return(n-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function uh(e,t,i,r,n,o,s,a){return!(e===s&&t===a)&&hh(e,t,i,r,n,o,s,a)}function dh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&mh(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(yh(e,t)&&yh(t,e)&&function(e,t){let i=e,r=!1;const n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(ph(e.prev,e,t.prev)||ph(e,t.prev,t))||fh(e,t)&&ph(e.prev,e,e.next)>0&&ph(t.prev,t,t.next)>0)}function ph(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function fh(e,t){return e.x===t.x&&e.y===t.y}function mh(e,t,i,r){const n=gh(ph(e,t,i)),o=gh(ph(e,t,r)),s=gh(ph(i,r,e)),a=gh(ph(i,r,t));return n!==o&&s!==a||!(0!==n||!_h(e,i,t))||!(0!==o||!_h(e,r,t))||!(0!==s||!_h(i,e,r))||!(0!==a||!_h(i,t,r))}function _h(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 gh(e){return e>0?1:e<0?-1:0}function yh(e,t){return ph(e.prev,e,e.next)<0?ph(e,t,e.next)>=0&&ph(e,e.prev,t)>=0:ph(e,t,e.prev)<0||ph(e,e.next,t)<0}function vh(e,t){const i=wh(e.i,e.x,e.y),r=wh(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function xh(e,t,i,r){const n=wh(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function bh(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)}function wh(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Th{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class Sh{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}Sh.noSubdivision=new Sh({fill:new Th(0,0),line:new Th(0,0),tile:new Th(0,0),stencil:new Th(0,0),circle:1}),gs("SubdivisionGranularityExpression",Th),gs("SubdivisionGranularitySetting",Sh);const Ph=-32768,Ih=32767;class Mh{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=Q/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 new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),r=0|Math.round(t),n=this._getKey(i,r);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,o),this._vertexBuffer.push(i,r),o}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let r=0;r<t.length;r+=3){const n=t[r],o=t[r+1],s=t[r+2],a=e[2*n],l=e[2*n+1];(e[2*o]-a)*(e[2*s+1]-l)-(e[2*o+1]-l)*(e[2*s]-a)>0?(i.push(n),i.push(s),i.push(o)):(i.push(n),i.push(o),i.push(s))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let r=0;r<i;r+=3){const i=[e[r+0],e[r+1],e[r+2]],n=[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]];let o=1/0,s=1/0,a=-1/0,l=-1/0;for(let e=0;e<3;e++){const t=n[2*e],i=n[2*e+1];o=Math.min(o,t),a=Math.max(a,t),s=Math.min(s,i),l=Math.max(l,i)}if(o===a||s===l)continue;const c=Math.floor(o/this._granularityCellSize),h=Math.ceil(a/this._granularityCellSize),u=Math.floor(s/this._granularityCellSize),d=Math.ceil(l/this._granularityCellSize);if(c!==h||u!==d)for(let e=u;e<d;e++){const r=this._scanlineGenerateVertexRingForCellRow(e,n,i);Ah(this._vertexBuffer,r,t)}else t.push(...i)}return t}_scanlineGenerateVertexRingForCellRow(e,t,i){const r=e*this._granularityCellSize,n=r+this._granularityCellSize,o=[];for(let e=0;e<3;e++){const s=t[2*e],a=t[2*e+1],l=t[2*(e+1)%6],c=t[(2*(e+1)+1)%6],h=t[2*(e+2)%6],u=t[(2*(e+2)+1)%6],d=l-s,p=c-a,f=0===d,m=0===p,_=(r-a)/p,g=(n-a)/p,y=Math.min(_,g),v=Math.max(_,g);if(!m&&(y>=1||v<=0)||m&&(a<r||a>n)){c>=r&&c<=n&&o.push(i[(e+1)%3]);continue}!m&&y>0&&o.push(this._vertexToIndex(s+d*y,a+p*y));const x=s+d*Math.max(y,0),b=s+d*Math.min(v,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,x,b),!m&&v<1&&o.push(this._vertexToIndex(s+d*v,a+p*v)),(m||c>=r&&c<=n)&&o.push(i[(e+1)%3]),!m&&(c<=r||c>=n)&&this._generateInterEdgeVertices(o,s,a,l,c,h,u,b,r,n)}return o}_generateIntraEdgeVertices(e,t,i,r,n,o,s){const a=r-t,l=n-i,c=0===l,h=c?Math.min(t,r):Math.min(o,s),u=c?Math.max(t,r):Math.max(o,s),d=Math.floor(h/this._granularityCellSize)+1,p=Math.ceil(u/this._granularityCellSize)-1;if(c?t<r:o<s)for(let r=d;r<=p;r++){const n=r*this._granularityCellSize;e.push(this._vertexToIndex(n,i+l*(n-t)/a))}else for(let r=p;r>=d;r--){const n=r*this._granularityCellSize;e.push(this._vertexToIndex(n,i+l*(n-t)/a))}}_generateInterEdgeVertices(e,t,i,r,n,o,s,a,l,c){const h=n-i,u=o-r,d=s-n,p=(l-n)/d,f=(c-n)/d,m=Math.min(p,f),_=Math.max(p,f),g=r+u*m;let y=Math.floor(Math.min(g,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,a)/this._granularityCellSize)-1,x=a<g;const b=0===d;if(b&&(s===l||s===c))return;if(b||m>=1||_<=0){const e=i-s,r=o+(t-o)*Math.min((l-s)/e,(c-s)/e);y=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,x=a<r}const w=h>0?c:l;if(x)for(let t=y;t<=v;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,w));else for(let t=v;t>=y;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,w))}_generateOutline(e){const t=[];for(const i of e){const e=Ch(i,this._granularity,!0),r=this._pointArrayToIndices(e),n=[];for(let e=1;e<r.length;e++)n.push(r[e-1]),n.push(r[e]);t.push(n)}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(){const e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){const i=e[t+1];i===Ph&&(e[t+1]=-32767),i===Ih&&(e[t+1]=32766)}}_generatePoleQuad(e,t,i,r,n,o){r>n!=(o===Ph)?(e.push(t),e.push(i),e.push(this._vertexToIndex(r,o)),e.push(i),e.push(this._vertexToIndex(n,o)),e.push(this._vertexToIndex(r,o))):(e.push(i),e.push(t),e.push(this._vertexToIndex(r,o)),e.push(this._vertexToIndex(n,o)),e.push(i),e.push(this._vertexToIndex(r,o)))}_fillPoles(e,t,i){const r=this._vertexBuffer,n=Q,o=e.length;for(let s=2;s<o;s+=3){const o=e[s-2],a=e[s-1],l=e[s],c=r[2*o],h=r[2*o+1],u=r[2*a],d=r[2*a+1],p=r[2*l],f=r[2*l+1];t&&(0===h&&0===d&&this._generatePoleQuad(e,o,a,c,u,Ph),0===d&&0===f&&this._generatePoleQuad(e,a,l,u,p,Ph),0===f&&0===h&&this._generatePoleQuad(e,l,o,p,c,Ph)),i&&(h===n&&d===n&&this._generatePoleQuad(e,o,a,c,u,Ih),d===n&&f===n&&this._generatePoleQuad(e,a,l,u,p,Ih),f===n&&h===n&&this._generatePoleQuad(e,l,o,p,c,Ih))}}_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 new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:i,holeIndices:r}=function(e){const t=[],i=[];for(const r of e)if(0!==r.length){r!==e[0]&&t.push(i.length/2);for(const e of r)i.push(e.x),i.push(e.y)}return{flattened:i,holeIndices:t}}(e);let n;this._initializeVertices(i);try{const e=function(e,t,i=2){const r=t&&t.length,n=r?t[0]*i:e.length;let o=Jc(e,0,n,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c;if(r&&(o=function(e,t,i,r){const n=[];for(let i=0,o=t.length;i<o;i++){const s=Jc(e,t[i]*r,i<o-1?t[i+1]*r:e.length,r,!1);s===s.next&&(s.steiner=!0),n.push(ch(s))}n.sort(oh);for(let e=0;e<n.length;e++)i=sh(n[e],i);return i}(e,t,o,i)),e.length>80*i){a=e[0],l=e[1];let t=a,r=l;for(let o=i;o<n;o+=i){const i=e[o],n=e[o+1];i<a&&(a=i),n<l&&(l=n),i>t&&(t=i),n>r&&(r=n)}c=Math.max(t-a,r-l),c=0!==c?32767/c:0}return eh(o,s,i,a,l,c,0),s}(i,r),t=this._convertIndices(i,e);n=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let o=[];return t&&(o=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(n),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:o}}_convertIndices(e,t){const i=[];for(const r of t)i.push(this._vertexToIndex(e[2*r],e[2*r+1]));return i}_pointArrayToIndices(e){const t=[];for(const i of e)t.push(this._vertexToIndex(i.x,i.y));return t}}function Eh(e,t,i,r=!0){return new Mh(i,t).subdividePolygonInternal(e,r)}function Ch(e,t,i=!1){if(!e||e.length<1)return[];if(e.length<2)return[];const r=e[0],n=e[e.length-1],s=i&&(r.x!==n.x||r.y!==n.y);if(t<2)return s?[...e,e[0]]:[...e];const a=Math.floor(Q/t),l=[];l.push(new o(e[0].x,e[0].y));const c=e.length,h=s?c:c-1;for(let t=0;t<h;t++){const i=e[t],r=t<c-1?e[t+1]:e[0],n=i.x,s=i.y,h=r.x,u=r.y,d=n!==h,p=s!==u;if(!d&&!p)continue;const f=h-n,m=u-s,_=Math.abs(f),g=Math.abs(m);let y=n,v=s;for(;;){const e=f>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,t=m>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,i=Math.abs(y-e),r=Math.abs(v-t),n=Math.abs(y-h),s=Math.abs(v-u),c=d?i/_:Number.POSITIVE_INFINITY,x=p?r/g:Number.POSITIVE_INFINITY;if((n<=i||!d)&&(s<=r||!p))break;if(c<x&&d||!p){y=e,v+=m*c;const t=new o(y,Math.round(v));l[l.length-1].x===t.x&&l[l.length-1].y===t.y||l.push(t)}else{y+=f*x,v=t;const e=new o(Math.round(y),v);l[l.length-1].x===e.x&&l[l.length-1].y===e.y||l.push(e)}}const x=new o(h,u);l[l.length-1].x===x.x&&l[l.length-1].y===x.y||l.push(x)}return l}function Ah(e,t,i){if(0===t.length)throw new Error("Subdivision vertex ring is empty.");let r=0,n=e[2*t[0]];for(let i=1;i<t.length;i++){const o=e[2*t[i]];o<n&&(n=o,r=i)}const o=t.length;let s=r,a=(s+1)%o;for(;;){const r=s-1>=0?s-1:o-1,n=(a+1)%o,l=e[2*t[r]],c=e[2*t[n]],h=e[2*t[s]],u=e[2*t[s]+1],d=e[2*t[a]+1];let p=!1;if(l<c)p=!0;else if(l>c)p=!1;else{const i=d-u,o=-(e[2*t[a]]-h),s=u<d?1:-1;((l-h)*i+(e[2*t[r]+1]-u)*o)*s>((c-h)*i+(e[2*t[n]+1]-u)*o)*s&&(p=!0)}if(p){const e=t[r],n=t[s],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),s--,s<0&&(s=o-1)}else{const e=t[n],r=t[s],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),a++,a>=o&&(a=0)}if(r===n)break}}function zh(e,t,i,r,n,o,s,a,l){const c=n.length/2,h=s&&a&&l;if(c<hl.MAX_VERTEX_ARRAY_LENGTH){const u=t.prepareSegment(c,i,r),d=u.vertexLength;for(let e=0;e<o.length;e+=3)r.emplaceBack(d+o[e],d+o[e+1],d+o[e+2]);let p,f;u.vertexLength+=c,u.primitiveLength+=o.length/3,h&&(f=s.prepareSegment(c,i,a),p=f.vertexLength,f.vertexLength+=c);for(let t=0;t<n.length;t+=2)e(n[t],n[t+1]);if(h)for(const e of l){for(let t=1;t<e.length;t+=2)a.emplaceBack(p+e[t-1],p+e[t]);f.primitiveLength+=e.length/2}}else!function(e,t,i,r,n,o){const s=[];for(let e=0;e<r.length/2;e++)s.push(-1);const a={count:0};let l=0,c=e.getOrCreateLatestSegment(t,i),h=c.vertexLength;for(let u=2;u<n.length;u+=3){const d=n[u-2],p=n[u-1],f=n[u];let m=s[d]<l,_=s[p]<l,g=s[f]<l;c.vertexLength+((m?1:0)+(_?1:0)+(g?1:0))>hl.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,_=!0,g=!0,h=0);const y=Dh(s,r,o,a,d,m,c),v=Dh(s,r,o,a,p,_,c),x=Dh(s,r,o,a,f,g,c);i.emplaceBack(h+y-l,h+v-l,h+x-l),c.primitiveLength++}}(t,i,r,n,o,e),h&&function(e,t,i,r,n,o){const s=[];for(let e=0;e<r.length/2;e++)s.push(-1);const a={count:0};let l=0,c=e.getOrCreateLatestSegment(t,i),h=c.vertexLength;for(const u of n)for(let n=1;n<u.length;n+=2){const d=u[n-1],p=u[n];let f=s[d]<l,m=s[p]<l;c.vertexLength+((f?1:0)+(m?1:0))>hl.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,h=0);const _=Dh(s,r,o,a,d,f,c),g=Dh(s,r,o,a,p,m,c);i.emplaceBack(h+_-l,h+g-l),c.primitiveLength++}}(s,i,a,n,l,e),t.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function Dh(e,t,i,r,n,o,s){if(o){const o=r.count;return i(t[2*n],t[2*n+1]),e[n]=r.count,r.count++,s.vertexLength++,o}return e[n]}class Rh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new qa,this.indexArray=new ol,this.indexArray2=new sl,this.programConfigurations=new ql(e.layers,e.zoom),this.segments=new hl,this.segments2=new hl,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i){this.hasDependencies=Yc("fill",this.layers,t);const r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,h=Jl(s,e);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),h,i))continue;const u=n?r.evaluate(h,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?h.geometry:Kl(s),patterns:{},sortKey:u};o.push(d)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasDependencies){const e=Kc("fill",this.layers,r,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e,t,i){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xc),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,n,o){for(const e of an(t,500)){const t=Eh(e,r,o.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;zh(((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:n,canonical:r})}}let kh,Lh;gs("FillBucket",Rh,{omit:["layers","patternFeatures"]});var Fh={get paint(){return Lh=Lh||new Ws({"fill-antialias":new Us(St.paint_fill["fill-antialias"]),"fill-opacity":new Gs(St.paint_fill["fill-opacity"]),"fill-color":new Gs(St.paint_fill["fill-color"]),"fill-outline-color":new Gs(St.paint_fill["fill-outline-color"]),"fill-translate":new Us(St.paint_fill["fill-translate"]),"fill-translate-anchor":new Us(St.paint_fill["fill-translate-anchor"]),"fill-pattern":new $s(St.paint_fill["fill-pattern"])})},get layout(){return kh=kh||new Ws({"fill-sort-key":new Gs(St.layout_fill["fill-sort-key"])})}};class Bh extends Ys{constructor(e,t){super(e,Fh,t)}recalculate(e,t){super.recalculate(e,t);const 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 Rh(e)}queryRadius(){return fc(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:r}){return nc(mc(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),t)}isTileClipped(){return!0}}const Oh=na([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Vh=na([{name:"a_centroid",components:2,type:"Int16"}],4),{members:jh}=Oh;class Nh{constructor(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(Uh,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,i=[];let r,n=1,s=0,a=0,l=0;for(;e.pos<t;){if(s<=0){const t=e.readVarint();n=7&t,s=t>>3}if(s--,1===n||2===n)a+=e.readSVarint(),l+=e.readSVarint(),1===n&&(r&&i.push(r),r=[]),r&&r.push(new o(a,l));else{if(7!==n)throw new Error(`unknown command ${n}`);r&&r.push(r[0].clone())}}return r&&i.push(r),i}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos<t;){if(r<=0){const t=e.readVarint();i=7&t,r=t>>3}if(r--,1===i||2===i)n+=e.readSVarint(),o+=e.readSVarint(),n<s&&(s=n),n>a&&(a=n),o<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const r=this.extent*Math.pow(2,i),n=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+n)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/r)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=Gh(s),t=[];for(const i of e)t.push(i.map(l));c=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}}const h={type:"Feature",geometry:c,properties:this.properties};return null!=this.id&&(h.id=this.id),h}}function Uh(e,t,i){1===e?t.id=i.readVarint():2===e?function(e,t){const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[i]=r}}(i,t):3===e?t.type=i.readVarint():4===e&&(t._geometry=i.pos)}function Gh(e){const t=e.length;if(t<=1)return[e];const i=[];let r,n;for(let o=0;o<t;o++){const t=$h(e[o]);0!==t&&(void 0===n&&(n=t<0),n===t<0?(r&&i.push(r),r=[e[o]]):r&&r.push(e[o]))}return r&&i.push(r),i}function $h(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}Nh.types=["Unknown","Point","LineString","Polygon"];class Zh{constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(qh,this,t),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Nh(this._pbf,t,this.extent,this._keys,this._values)}}function qh(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=e.readVarint()>>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class Wh{constructor(e,t){this.layers=e.readFields(Hh,{},t)}}function Hh(e,t,i){if(3===e){const e=new Zh(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Xh=Math.pow(2,13);function Yh(e,t,i,r,n,o,s,a){e.emplaceBack(t,i,2*Math.floor(r*Xh)+s,n*Xh*2,o*Xh*2,Math.round(a))}class Kh{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 Wa,this.centroidVertexArray=new Ua,this.indexArray=new ol,this.programConfigurations=new ql(e.layers,e.zoom),this.segments=new hl,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i){this.features=[],this.hasDependencies=Yc("fill-extrusion",this.layers,t);for(const{feature:r,id:n,index:o,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,a=Jl(r,e);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),a,i))continue;const l={id:n,sourceLayerIndex:s,index:o,geometry:e?a.geometry:Kl(r),properties:r.properties,type:r.type,patterns:{}};this.hasDependencies?this.features.push(Kc("fill-extrusion",this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,o,i,{},t.subdivisionGranularity),t.featureIndex.insert(r,l.geometry,o,s,this.index,!0)}}addFeatures(e,t,i){for(const r of this.features){const{geometry:n}=r;this.addFeature(r,n,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,jh),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Vh.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,n,o){for(const i of an(t,500)){const t={x:0,y:0,sampleCount:0},n=this.layoutVertexArray.length;this.processPolygon(t,r,e,i,o);const s=this.layoutVertexArray.length-n,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e<s;e++)this.centroidVertexArray.emplaceBack(a,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:n,canonical:r})}processPolygon(e,t,i,r,n){if(r.length<1)return;if(eu(r[0]))return;for(const t of r)0!==t.length&&Jh(e,t);const o={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},s=n.fill.getGranularityForZoomLevel(t.z),a="Polygon"===Nh.types[i.type];for(const e of r){if(0===e.length)continue;if(eu(e))continue;const t=Ch(e,s,a);this._generateSideFaces(t,o)}if(!a)return;const l=Eh(r,t,s,!1),c=this.layoutVertexArray;zh(((e,t)=>{Yh(c,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++){const n=e[r],o=e[r-1];if(Qh(n,o))continue;t.segment.vertexLength+4>hl.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=n.sub(o)._perp()._unit(),a=o.dist(n);i+a>32768&&(i=0),Yh(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,0,i),Yh(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,1,i),i+=a,Yh(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),Yh(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const 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 Jh(e,t){for(let i=0;i<t.length;i++){const 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++)}}function Qh(e,t){return e.x===t.x&&(e.x<0||e.x>Q)||e.y===t.y&&(e.y<0||e.y>Q)}function eu(e){return e.every((e=>e.x<0))||e.every((e=>e.x>Q))||e.every((e=>e.y<0))||e.every((e=>e.y>Q))}let tu;gs("FillExtrusionBucket",Kh,{omit:["layers","features"]});var iu={get paint(){return tu=tu||new Ws({"fill-extrusion-opacity":new Us(St["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Gs(St["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Us(St["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Us(St["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new $s(St["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Gs(St["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Gs(St["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Us(St["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class ru extends Ys{constructor(e,t){super(e,iu,t)}createBucket(e){return new Kh(e)}queryRadius(){return fc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,pixelPosMatrix:a}){const l=mc(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-n.bearingInRadians,s),c=this.paint.get("fill-extrusion-height").evaluate(t,i),h=this.paint.get("fill-extrusion-base").evaluate(t,i),u=function(e,t){const i=[];for(const r of e){const e=[r.x,r.y,0,1];$(e,e,t),i.push(new o(e[0]/e[3],e[1]/e[3]))}return i}(l,a),d=function(e,t,i,r){const n=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,h=r[11]*t,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const t of e){const e=[],i=[];for(const n of t){const t=n.x,s=n.y,m=r[0]*t+r[4]*s+r[12],_=r[1]*t+r[5]*s+r[13],g=r[2]*t+r[6]*s+r[14],y=r[3]*t+r[7]*s+r[15],v=g+c,x=y+h,b=m+u,w=_+d,T=g+p,S=y+f,P=new o((m+a)/x,(_+l)/x);P.z=v/x,e.push(P);const I=new o(b/S,w/S);I.z=T/S,i.push(I)}n.push(e),s.push(i)}return[n,s]}(r,h,c,a);return function(e,t,i){let r=1/0;nc(i,t)&&(r=ou(i,t[0]));for(let n=0;n<t.length;n++){const o=t[n],s=e[n];for(let e=0;e<o.length-1;e++){const t=o[e],n=[t,o[e+1],s[e+1],s[e],t];ic(i,n)&&(r=Math.min(r,ou(i,n)))}}return r!==1/0&&r}(d[0],d[1],u)}}function nu(e,t){return e.x*t.x+e.y*t.y}function ou(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(n=t[i++],!n)return 1/0;for(;i<t.length;i++){const o=t[i],s=e[0],a=n.sub(r),l=o.sub(r),c=s.sub(r),h=nu(a,a),u=nu(a,l),d=nu(l,l),p=nu(c,a),f=nu(c,l),m=h*d-u*u,_=(d*p-u*f)/m,g=(h*f-u*p)/m,y=r.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}const su=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class au{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=su[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new au(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=su.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return lu(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=s){for(let s=u;s<=h;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s])}continue}const d=u+h>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u<=o){for(let i=u;i<=h;i++)du(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];du(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(u),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function lu(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;cu(e,t,s,r,n,o),lu(e,t,i,r,s-1,1-o),lu(e,t,i,s+1,n,1-o)}function cu(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);cu(e,t,i,Math.max(r,Math.floor(i-a*c/s+h)),Math.min(n,Math.floor(i+(s-a)*c/s+h)),o)}const s=t[2*i+o];let a=r,l=n;for(hu(e,t,r,i),t[2*n+o]>s&&hu(e,t,r,n);a<l;){for(hu(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--}t[2*r+o]===s?hu(e,t,r,l):(l++,hu(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function hu(e,t,i,r){uu(e,i,r),uu(t,2*i,2*r),uu(t,2*i+1,2*r+1)}function uu(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function du(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}var pu;!function(e){e[e.X=0]="X",e[e.Y=1]="Y"}(pu||(pu={}));const fu="geojsonvt_clip_start",mu="geojsonvt_clip_end",_u=na([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:gu}=_u,yu=na([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:vu}=yu,xu=Math.cos(Math.PI/180*37.5),bu=Math.pow(2,14)/.5;class wu{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(const e of this.layers)this.gradients[e.id]={};this.layoutVertexArray=new Ha,this.layoutVertexArray2=new Xa,this.indexArray=new ol,this.programConfigurations=new ql(e.layers,e.zoom),this.segments=new hl,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i){this.hasDependencies=Yc("line",this.layers,t)||this.hasLineDasharray(this.layers);const r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Jl(t,e);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),c,i))continue;const h=n?r.evaluate(c,{},i):void 0,u={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Kl(t),patterns:{},dashes:{},sortKey:h};o.push(u)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;this.hasDependencies?(Yc("line",this.layers,t)?Kc("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,n,o,i,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures(e,t,i,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.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,vu)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gu),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,fu)&&Object.hasOwn(e.properties,mu))return{start:+e.properties[fu],end:+e.properties[mu]}}addFeature(e,t,i,r,n,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap").evaluate(e,{}),h=a.get("line-miter-limit").evaluate(e,{}),u=a.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,h,u,r,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:n,dashPositions:o,canonical:r})}addLine(e,t,i,r,n,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Ch(e,s?a.line.getGranularityForZoomLevel(s.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)}const l="Polygon"===Nh.types[t.type];let c=e.length;for(;c>=2&&e[c-1].equals(e[c-2]);)c--;let h=0;for(;h<c-1&&e[h].equals(e[h+1]);)h++;if(c<(l?3:2))return;"bevel"===i&&(n=1.05);const u=this.overscaling<=16?122880/(512*this.overscaling):0,d=this.segments.prepareSegment(10*c,this.layoutVertexArray,this.indexArray);let p,f,m,_,g;this.e1=this.e2=-1,l&&(p=e[c-2],g=e[h].sub(p)._unit()._perp());for(let t=h;t<c;t++){if(m=t===c-1?l?e[h+1]:void 0:e[t+1],m&&e[t].equals(m))continue;g&&(_=g),p&&(f=p),p=e[t],g=m?m.sub(p)._unit()._perp():_,_||(_=g);let s=_.add(g);0===s.x&&0===s.y||s._unit();const a=_.x*g.x+_.y*g.y,y=s.x*g.x+s.y*g.y,v=0!==y?1/y:1/0,x=2*Math.sqrt(2-2*y),b=y<xu&&f&&m,w=_.x*g.y-_.y*g.x>0;if(b&&t>h){const e=p.dist(f);if(e>2*u){const t=p.sub(p.sub(f)._mult(u/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,_,0,0,d),f=t}}const T=f&&m;let S=T?i:l?"butt":r;if(T&&"round"===S&&(v<o?S="miter":v<=2&&(S="fakeround")),"miter"===S&&v>n&&(S="bevel"),"bevel"===S&&(v>2&&(S="flipbevel"),v<n&&(S="miter")),f&&this.updateDistance(f,p),"miter"===S)s._mult(v),this.addCurrentVertex(p,s,0,0,d);else if("flipbevel"===S){if(v>100)s=g.mult(-1);else{const e=v*_.add(g).mag()/_.sub(g).mag();s._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===S||"fakeround"===S){const e=-Math.sqrt(v*v-1),t=w?e:0,i=w?0:e;if(f&&this.addCurrentVertex(p,_,t,i,d),"fakeround"===S){const e=Math.round(180*x/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+a*(a*(3.55645-1.43519*a)-3.2452))*e*e+(.848013+a*(.215638*a-1.06021)))}const r=g.sub(_)._mult(i)._add(_)._unit()._mult(w?-1:1);this.addHalfVertex(p,r.x,r.y,!1,w,0,d)}}m&&this.addCurrentVertex(p,g,-t,-i,d)}else if("butt"===S)this.addCurrentVertex(p,s,0,0,d);else if("square"===S){const e=f?1:-1;this.addCurrentVertex(p,s,e,e,d)}else"round"===S&&(f&&(this.addCurrentVertex(p,_,0,0,d),this.addCurrentVertex(p,_,1,1,d,!0)),m&&(this.addCurrentVertex(p,g,-1,-1,d,!0),this.addCurrentVertex(p,g,0,0,d)));if(b&&t<c-1){const e=p.dist(m);if(e>2*u){const t=p.add(m.sub(p)._mult(u/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,g,0,0,d),p=t}}}}addCurrentVertex(e,t,i,r,n,o=!1){const s=t.y*r-t.x,a=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,n),this.addHalfVertex(e,s,a,o,!0,-r,n),this.distance>bu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,n,o))}addHalfVertex({x:e,y:t},i,r,n,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(bu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}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(const t of e){const e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,r){for(const n of e){const e=n.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const o="round"===n.layout.get("line-cap").evaluate(t,{}),s={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:o},a={dasharray:e.value.evaluate({zoom:i},t,{}),round:o},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:o},c=`${s.dasharray.join(",")},${s.round}`,h=`${a.dasharray.join(",")},${a.round}`,u=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[c]=s,r.dashDependencies[h]=a,r.dashDependencies[u]=l,t.dashes[n.id]={min:c,mid:h,max:u}}}}let Tu,Su;gs("LineBucket",wu,{omit:["layers","patternFeatures"]});var Pu={get paint(){return Su=Su||new Ws({"line-opacity":new Gs(St.paint_line["line-opacity"]),"line-color":new Gs(St.paint_line["line-color"]),"line-translate":new Us(St.paint_line["line-translate"]),"line-translate-anchor":new Us(St.paint_line["line-translate-anchor"]),"line-width":new Gs(St.paint_line["line-width"]),"line-gap-width":new Gs(St.paint_line["line-gap-width"]),"line-offset":new Gs(St.paint_line["line-offset"]),"line-blur":new Gs(St.paint_line["line-blur"]),"line-dasharray":new $s(St.paint_line["line-dasharray"]),"line-pattern":new $s(St.paint_line["line-pattern"]),"line-gradient":new qs(St.paint_line["line-gradient"])})},get layout(){return Tu=Tu||new Ws({"line-cap":new Gs(St.layout_line["line-cap"]),"line-join":new Gs(St.layout_line["line-join"]),"line-miter-limit":new Gs(St.layout_line["line-miter-limit"]),"line-round-limit":new Gs(St.layout_line["line-round-limit"]),"line-sort-key":new Gs(St.layout_line["line-sort-key"])})}};class Iu extends Gs{possiblyEvaluate(e,t){return t=new zs(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=Te({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}let Mu;class Eu extends Ys{constructor(e,t){super(e,Pu,t),this.gradientVersion=0,Mu||(Mu=new Iu(Pu.paint.properties["line-width"].specification),Mu.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof pr,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Mu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new wu(e)}queryRadius(e){const t=e,i=Cu(pc("line-width",this,t),pc("line-gap-width",this,t)),r=pc("line-offset",this,t);return i/2+Math.abs(r)+fc(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s}){const a=mc(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-n.bearingInRadians,s),l=s/2*Cu(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),c=this.paint.get("line-offset").evaluate(t,i);return c&&(r=function(e,t){const i=[];for(const r of e){const e=_c(r),n=[];for(let i=0;i<e.length;i++){const r=e[i],s=e[i-1],a=e[i+1],l=0===i?new o(0,0):r.sub(s)._unit()._perp(),c=i===e.length-1?new o(0,0):a.sub(r)._unit()._perp(),h=l._add(c)._unit(),u=h.x*c.x+h.y*c.y;0!==u&&h._mult(1/u),n.push(h._mult(t)._add(r))}i.push(n)}return i}(r,c*s)),function(e,t,i){for(const r of t){if(e.length>=3)for(const t of r)if(uc(e,t))return!0;if(oc(e,r,i))return!0}return!1}(a,r,l)}isTileClipped(){return!0}}function Cu(e,t){return t>0?t+2*e:e}const Au=na([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),zu=na([{name:"a_projected_pos",components:3,type:"Float32"}],4);na([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Du=na([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);na([{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 Ru=na([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),ku=na([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Lu(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),As.applyArabicShaping&&(e=As.applyArabicShaping(e)),e}function Fu(e,t,i){for(const r of e.sections)r.text=Lu(r.text,t,i);return e}na([{name:"triangle",components:3,type:"Uint16"}]),na([{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"}]),na([{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"}]),na([{type:"Float32",name:"offsetX"}]),na([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),na([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Bu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Ou=4294967296,Vu=1/Ou,ju="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Nu{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos<i;){const i=this.readVarint(),r=i>>3,n=this.pos;this.type=7&i,e(r,t,this),this.pos===n&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Ou;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Ou;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,r;return r=t[this.pos++],i=127&r,r<128?i:(r=t[this.pos++],i|=(127&r)<<7,r<128?i:(r=t[this.pos++],i|=(127&r)<<14,r<128?i:(r=t[this.pos++],i|=(127&r)<<21,r<128?i:(r=t[this.pos],i|=(15&r)<<28,function(e,t,i){const r=i.buf;let n,o;if(o=r[i.pos++],n=(112&o)>>4,o<128)return Uu(e,n,t);if(o=r[i.pos++],n|=(127&o)<<3,o<128)return Uu(e,n,t);if(o=r[i.pos++],n|=(127&o)<<10,o<128)return Uu(e,n,t);if(o=r[i.pos++],n|=(127&o)<<17,o<128)return Uu(e,n,t);if(o=r[i.pos++],n|=(127&o)<<24,o<128)return Uu(e,n,t);if(o=r[i.pos++],n|=(1&o)<<31,o<128)return Uu(e,n,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&ju?ju.decode(this.buf.subarray(t,e)):function(e,t,i){let r="",n=t;for(;n<i;){const t=e[n];let o,s,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(n+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[n+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const 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}skip(e){const 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 new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){const e=new Uint8Array(t);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Vu),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Vu),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(i=~(-e%4294967296),r=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){const i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let r,n,o=0;o<t.length;o++){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&Gu(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i<t;i++)this.buf[this.pos++]=e[i]}writeRawMessage(e,t){this.pos++;const i=this.pos;e(t,this);const r=this.pos-i;r>=128&&Gu(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,$u,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Zu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Hu,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,qu,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Wu,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Xu,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Yu,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Ku,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Ju,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function Uu(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Gu(e,t,i){const r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(let t=i.pos-1;t>=e;t--)i.buf[t+r]=i.buf[t]}function $u(e,t){for(let i=0;i<e.length;i++)t.writeVarint(e[i])}function Zu(e,t){for(let i=0;i<e.length;i++)t.writeSVarint(e[i])}function qu(e,t){for(let i=0;i<e.length;i++)t.writeFloat(e[i])}function Wu(e,t){for(let i=0;i<e.length;i++)t.writeDouble(e[i])}function Hu(e,t){for(let i=0;i<e.length;i++)t.writeBoolean(e[i])}function Xu(e,t){for(let i=0;i<e.length;i++)t.writeFixed32(e[i])}function Yu(e,t){for(let i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Ku(e,t){for(let i=0;i<e.length;i++)t.writeFixed64(e[i])}function Ju(e,t){for(let i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Qu(e,t,i){1===e&&i.readMessage(ed,t)}function ed(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(td,{});t.push({id:e,bitmap:new Rc({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}}function td(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 id(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const 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:n,h:o,fill:t/(n*o)||0}}class rd{constructor(e,{pixelRatio:t,version:i,stretchX:r,stretchY:n,content:o,textFitWidth:s,textFitHeight:a}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i,this.textFitWidth=s,this.textFitHeight=a}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]}}var nd;function od(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 sd(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new zs(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n<t.length&&t[n]<=e;)n++;n=Math.max(0,n-1);let o=n;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const s=t[n],a=t[o];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new zs(s)),maxSize:i.evaluate(new zs(a)),interpolationType:r}}}function ad(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/128:"composite"===e.kind?br.number(r/128,n/128,i):t}function ld(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=e,a=n?be(vr.interpolationFactor(n,t,o,s),0,1):0;"camera"===e.kind?r=br.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:r}}function cd(e,t,i){let r="never";const n=e.get(t);return n?r=n:e.get(i)&&(r="always"),r}gs("ImagePosition",rd),gs("ImageAtlas",class{constructor(e,t){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(e,i,n),this.addImages(t,r,n);const{w:o,h:s}=id(n),a=new kc({width:o||1,height:s||1});for(const t in e){const r=e[t],n=i[t].paddedRect;kc.copy(r.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const e in t){const i=t[e],n=r[e].paddedRect,o=n.x+1,s=n.y+1,l=i.data.width,c=i.data.height;kc.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),kc.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),kc.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),kc.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),kc.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(const r in e){const n=e[r],o={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(o),t[r]=new rd(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in e.updatedImages)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,void 0,{x:r,y:n})}}),function(e){e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly"}(nd||(nd={}));const hd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ud(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=a?Math.min(32640,Math.round(a[0])):0,f=a?Math.min(32640,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),f,16*c,16*h,256*u,256*d)}function dd(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 pd(e){for(const t of e.sections)if(Cs(t.text))return!0;return!1}class fd{constructor(e){this.layoutVertexArray=new Ja,this.indexArray=new ol,this.programConfigurations=e,this.segments=new hl,this.dynamicLayoutVertexArray=new Qa,this.opacityVertexArray=new el,this.hasVisibleVertices=!1,this.placedSymbolArray=new Ra}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,Au.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,zu.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,hd,!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())}}gs("SymbolBuffers",fd);class md{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new hl,this.collisionVertexArray=new rl}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Du.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}gs("CollisionBuffers",md);class _d{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=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=sd(this.zoom,t["text-size"]),this.iconSizeData=sd(this.zoom,t["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap="never"!==cd(i,"text-overlap","text-allow-overlap")||"never"!==cd(i,"icon-overlap","icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map((e=>nd[e]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID}createArrays(){this.text=new fd(new ql(this.layers,this.zoom,(e=>e.startsWith("text")))),this.icon=new fd(new ql(this.layers,this.zoom,(e=>e.startsWith("icon")))),this.glyphOffsetArray=new Fa,this.lineVertexArray=new Ba,this.symbolInstances=new La,this.textAnchorOffsets=new Va}calculateGlyphDependencies(e,t,i,r,n){for(const o of e)if(t[o.codePointAt(0)]=!0,(i||r)&&n){const e=Bu[o];e&&(t[e.codePointAt(0)]=!0)}}populate(e,t,i){var r;const n=this.layers[0],o=n.layout,s=o.get("text-font"),a=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Bi&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const d=t.iconDependencies,p=t.glyphDependencies,f=t.availableImages,m=new zs(this.zoom);for(const{feature:t,id:a,index:l,sourceLayerIndex:_}of e){const e=n._featureFilter.needGeometry,g=Jl(t,e);if(!n._featureFilter.filter(m,g,i))continue;let y,v;if(e||(g.geometry=Kl(t)),c){const e=n.getValueAndResolveTokens("text-field",g,i,f),t=Bi.factory(e);this.hasRTLText||(this.hasRTLText=pd(t)),(!this.hasRTLText||"unavailable"===As.getRTLTextPluginStatus()||this.hasRTLText&&As.isParsed())&&(y=Fu(t,n,g))}if(h){const e=n.getValueAndResolveTokens("icon-image",g,i,f);v=e instanceof $i?e:$i.fromString(e)}if(!y&&!v)continue;const x=this.sortFeaturesByKey?u.evaluate(g,{},i):void 0;if(this.features.push({id:a,text:y,icon:v,index:l,sourceLayerIndex:_,geometry:g.geometry,properties:t.properties,type:Nh.types[t.type],sortKey:x}),v&&(d[v.name]=!0),y){const e=s.evaluate(g,{},i).join(","),t="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=null===(r=this.writingModes)||void 0===r?void 0:r.includes(nd.vertical);for(const i of y.sections)if(i.image)d[i.image.name]=!0;else{const r=Ss(y.toString()),n=i.fontStack||e;p[n]||(p[n]={}),this.calculateGlyphDependencies(i.text,p[n],t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;c<e.length;c++){const h=e[c],u=h.geometry,d=h.text?h.text.toString():null;if(!d){o(c);continue}const p=l(d,u),f=l(d,u,!0);if(p in i&&f in t&&i[p]!==t[f]){const e=a(p,f,u),n=s(p,f,r[e].geometry);delete t[p],delete i[f],i[l(d,r[n].geometry,!0)]=n,r[e].geometry=null}else p in i?s(p,f,u):f in t?a(p,f,u):(o(c),t[p]=n-1,i[f]=n-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}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]);const n={};for(let r=e.segment+1;r<t.length;r++)n[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--)n[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++){const t=n[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,s,a,l,c,h,u){const d=e.indexArray,p=e.layoutVertexArray,f=e.segments.prepareSegment(4*t.length,p,d,this.canOverlap?o.sortKey:void 0),m=this.glyphOffsetArray.length,_=f.vertexLength,g=this.allowVerticalPlacement&&s===nd.vertical?Math.PI/2:0,y=o.text&&o.text.sections;for(let r=0;r<t.length;r++){const{tl:n,tr:s,bl:l,br:c,tex:h,pixelOffsetTL:m,pixelOffsetBR:_,minFontScaleX:v,minFontScaleY:x,glyphOffset:b,isSDF:w,sectionIndex:T}=t[r],S=f.vertexLength,P=b[1];ud(p,a.x,a.y,n.x,P+n.y,h.x,h.y,i,w,m.x,m.y,v,x),ud(p,a.x,a.y,s.x,P+s.y,h.x+h.w,h.y,i,w,_.x,m.y,v,x),ud(p,a.x,a.y,l.x,P+l.y,h.x,h.y+h.h,i,w,m.x,_.y,v,x),ud(p,a.x,a.y,c.x,P+c.y,h.x+h.w,h.y+h.h,i,w,_.x,_.y,v,x),dd(e.dynamicLayoutVertexArray,a,g),d.emplaceBack(S,S+2,S+1),d.emplaceBack(S+1,S+2,S+3),f.vertexLength+=4,f.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),r!==t.length-1&&T===t[r+1].sectionIndex||e.programConfigurations.populatePaintArrays(p.length,o,o.index,{imagePositions:{},canonical:u,formattedSection:null==y?void 0:y[T]})}e.placedSymbolArray.emplaceBack(a.x,a.y,m,this.glyphOffsetArray.length-m,_,l,c,a.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,!1,0,h)}_addCollisionDebugVertex(e,t,i,r,n,o){return t.emplaceBack(0,0),e.emplaceBack(i.x,i.y,r,n,Math.round(o.x),Math.round(o.y))}addCollisionDebugVertices(e,t,i,r,n,s,a){const l=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),c=l.vertexLength,h=n.layoutVertexArray,u=n.collisionVertexArray,d=a.anchorX,p=a.anchorY;this._addCollisionDebugVertex(h,u,s,d,p,new o(e,t)),this._addCollisionDebugVertex(h,u,s,d,p,new o(i,t)),this._addCollisionDebugVertex(h,u,s,d,p,new o(i,r)),this._addCollisionDebugVertex(h,u,s,d,p,new o(e,r)),l.vertexLength+=4;const f=n.indexArray;f.emplaceBack(c,c+1),f.emplaceBack(c+1,c+2),f.emplaceBack(c+2,c+3),f.emplaceBack(c+3,c),l.primitiveLength+=4}addDebugCollisionBoxes(e,t,i,r){for(let n=e;n<t;n++){const e=this.collisionBoxArray.get(n);this.addCollisionDebugVertices(e.x1,e.y1,e.x2,e.y2,r?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new md(tl,Ru.members,sl),this.iconCollisionBox=new md(tl,Ru.members,sl);for(let e=0;e<this.symbolInstances.length;e++){const 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,n,o,s,a,l){const c={};for(let r=t;r<i;r++){const t=e.get(r);c.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},c.textFeatureIndex=t.featureIndex;break}for(let t=r;t<n;t++){const i=e.get(t);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let t=o;t<s;t++){const i=e.get(t);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.iconFeatureIndex=i.featureIndex;break}for(let t=a;t<l;t++){const i=e.get(t);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const 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){const 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;const t=Math.sin(e),i=Math.cos(e),r=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);r.push(0|Math.round(t*s.anchorX+i*s.anchorY)),n.push(s.featureIndex)}return o.sort(((e,t)=>r[e]-r[t]||n[t]-n[e])),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];(null==i?void 0:i.sortKey)===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const i=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let e=0;e<i.length;e++){const 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 gd,yd;gs("SymbolBucket",_d,{omit:["layers","collisionBoxArray","features","compareText"]}),_d.MAX_GLYPHS=65535,_d.addDynamicAttributes=dd;var vd={get paint(){return yd=yd||new Ws({"icon-opacity":new Gs(St.paint_symbol["icon-opacity"]),"icon-color":new Gs(St.paint_symbol["icon-color"]),"icon-halo-color":new Gs(St.paint_symbol["icon-halo-color"]),"icon-halo-width":new Gs(St.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Gs(St.paint_symbol["icon-halo-blur"]),"icon-translate":new Us(St.paint_symbol["icon-translate"]),"icon-translate-anchor":new Us(St.paint_symbol["icon-translate-anchor"]),"text-opacity":new Gs(St.paint_symbol["text-opacity"]),"text-color":new Gs(St.paint_symbol["text-color"],{runtimeType:Zt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Gs(St.paint_symbol["text-halo-color"]),"text-halo-width":new Gs(St.paint_symbol["text-halo-width"]),"text-halo-blur":new Gs(St.paint_symbol["text-halo-blur"]),"text-translate":new Us(St.paint_symbol["text-translate"]),"text-translate-anchor":new Us(St.paint_symbol["text-translate-anchor"])})},get layout(){return gd=gd||new Ws({"symbol-placement":new Us(St.layout_symbol["symbol-placement"]),"symbol-spacing":new Us(St.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Us(St.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Gs(St.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Us(St.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Us(St.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Us(St.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Us(St.layout_symbol["icon-ignore-placement"]),"icon-optional":new Us(St.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Us(St.layout_symbol["icon-rotation-alignment"]),"icon-size":new Gs(St.layout_symbol["icon-size"]),"icon-text-fit":new Us(St.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Us(St.layout_symbol["icon-text-fit-padding"]),"icon-image":new Gs(St.layout_symbol["icon-image"]),"icon-rotate":new Gs(St.layout_symbol["icon-rotate"]),"icon-padding":new Gs(St.layout_symbol["icon-padding"]),"icon-keep-upright":new Us(St.layout_symbol["icon-keep-upright"]),"icon-offset":new Gs(St.layout_symbol["icon-offset"]),"icon-anchor":new Gs(St.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Us(St.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Us(St.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Us(St.layout_symbol["text-rotation-alignment"]),"text-field":new Gs(St.layout_symbol["text-field"]),"text-font":new Gs(St.layout_symbol["text-font"]),"text-size":new Gs(St.layout_symbol["text-size"]),"text-max-width":new Gs(St.layout_symbol["text-max-width"]),"text-line-height":new Us(St.layout_symbol["text-line-height"]),"text-letter-spacing":new Gs(St.layout_symbol["text-letter-spacing"]),"text-justify":new Gs(St.layout_symbol["text-justify"]),"text-radial-offset":new Gs(St.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Us(St.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Gs(St.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Gs(St.layout_symbol["text-anchor"]),"text-max-angle":new Us(St.layout_symbol["text-max-angle"]),"text-writing-mode":new Us(St.layout_symbol["text-writing-mode"]),"text-rotate":new Gs(St.layout_symbol["text-rotate"]),"text-padding":new Us(St.layout_symbol["text-padding"]),"text-keep-upright":new Us(St.layout_symbol["text-keep-upright"]),"text-transform":new Gs(St.layout_symbol["text-transform"]),"text-offset":new Gs(St.layout_symbol["text-offset"]),"text-allow-overlap":new Us(St.layout_symbol["text-allow-overlap"]),"text-overlap":new Us(St.layout_symbol["text-overlap"]),"text-ignore-placement":new Us(St.layout_symbol["text-ignore-placement"]),"text-optional":new Us(St.layout_symbol["text-optional"])})}};class xd{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Nt,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(null==t?void 0: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}}gs("FormatSectionOverride",xd,{omit:["defaultValue"]});const bd=e=>"symbol"===e.type;class wd extends Ys{constructor(e,t){super(e,vd,t)}recalculate(e,t){if(super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="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")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const 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){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||lo(o.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>e&&i in e?String(e[i]):""))}(t.properties,n)}createBucket(e){return new _d(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of vd.paint.overridableProperties){if(!wd.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new xd(t),r=new ao(i,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new ho("source",r):new uo("composite",r,t.value.zoomStops),this.paint._values[e]=new js(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&wd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=vd.paint.properties[t];let n=!1;const o=e=>{var t;for(const i of e)if(null===(t=r.overrides)||void 0===t?void 0:t.hasOverride(i))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Bi)o(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const e=t=>{n||(t instanceof Yi&&Hi(t.value)===Yt?o(t.value.sections):t instanceof kr?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}}let Td;var Sd={get paint(){return Td=Td||new Ws({"background-color":new Us(St.paint_background["background-color"]),"background-pattern":new Zs(St.paint_background["background-pattern"]),"background-opacity":new Us(St.paint_background["background-opacity"])})}};class Pd extends Ys{constructor(e,t){super(e,Sd,t)}}class Id extends Ys{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 new Error("Custom layers cannot be serialized")}}function Md(e,t){if("custom"===e.type)return new Id(e,t);switch(e.type){case"background":return new Pd(e,t);case"circle":return new Ic(e,t);case"color-relief":return new Wc(e,t);case"fill":return new Bh(e,t);case"fill-extrusion":return new ru(e,t);case"heatmap":return new Oc(e,t);case"hillshade":return new Nc(e,t);case"line":return new Eu(e,t);case"raster":return new ea(e,t);case"symbol":return new wd(e,t)}}function Ed(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:n}of e){const e=`${r}${n}`;i.includes(e)||(i.push(e),t.push({id:r,url:n}))}}return t}function Cd(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function Ad(e){const{userImage:t}=e;return!(!(null==t?void 0:t.render)||!t.render()||(e.data.replace(new Uint8Array(t.data.buffer)),0))}class zd extends Tt{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new kc({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new kc({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const t=this.images[e];if(t&&!t.data&&t.spriteData){const e=t.spriteData;t.data=new kc({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 new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,t){let i=!0;const r=t.data||t.spriteData;return this._validateStretch(t.stretchX,null==r?void 0:r.width)||(this.fire(new wt(new Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,null==r?void 0:r.height)||(this.fire(new wt(new Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new wt(new Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(const 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;const i=t.spriteData,r=(null==i?void 0:i.width)||t.data.width,n=(null==i?void 0:i.height)||t.data.height;return!(e[0]<0||r<e[0]||e[1]<0||n<e[1]||e[2]<0||r<e[2]||e[3]<0||n<e[3]||e[2]<e[0]||!(e[3]>=e[1]))}updateImage(e,t,i=!0){const r=this.getImage(e);if(i&&(r.data.width!==t.data.width||r.data.height!==t.data.height))throw new Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${t.data.width}x${t.data.height}).`);t.version=r.version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){var t;const i=this.images[e];delete this.images[e],delete this.patterns[e],(null===(t=i.userImage)||void 0===t?void 0:t.onRemove)&&i.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise(((t,i)=>{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})}))}_getImagesForIds(e){var t;const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new bt("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={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:Boolean(null===(t=e.userImage)||void 0===t?void 0:t.render)}:Le(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const t=this.patterns[e],i=this.getImage(e);if(!i)return null;if(t&&t.position.version===i.version)return t.position;if(t)t.position.version=i.version;else{const t={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new rd(t,i);this.patterns[e]={bin:t,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new Zc(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:t,h:i}=id(e),r=this.atlasImage;r.resize({width:t||1,height:i||1});for(const e in this.patterns){const{bin:t}=this.patterns[e],i=t.x+1,n=t.y+1,o=this.getImage(e).data,s=o.width,a=o.height;kc.copy(o,r,{x:0,y:0},{x:i,y:n},{width:s,height:a}),kc.copy(o,r,{x:0,y:a-1},{x:i,y:n-1},{width:s,height:1}),kc.copy(o,r,{x:0,y:0},{x:i,y:n+a},{width:s,height:1}),kc.copy(o,r,{x:s-1,y:0},{x:i-1,y:n},{width:1,height:a}),kc.copy(o,r,{x:0,y:0},{x:i+s,y:n},{width:1,height:a})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const t of e){if(this.callbackDispatchedThisFrame[t])continue;this.callbackDispatchedThisFrame[t]=!0;const e=this.getImage(t);e||Le(`Image with ID: "${t}" was not found`),Ad(e)&&this.updateImage(t,e)}}cloneImages(){const e={};for(const t in this.images){const i=this.images[t];e[t]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return e}}const Dd=1e20,Rd=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);Rd[e]=t*Math.abs(t)}function kd(e,t,i,r,n,o,s,a,l){for(let c=t;c<t+r;c++)Ld(e,i*o+c,o,n,s,a,l);for(let c=i;c<i+n;c++)Ld(e,c*o+t,1,r,s,a,l)}function Ld(e,t,i,r,n,o,s){o[0]=0,s[0]=-Dd,s[1]=Dd,n[0]=e[t];for(let a=1,l=0,c=0;a<r;a++){n[a]=e[t+a*i];const r=a*a;do{const e=o[l];c=(n[a]-n[e]+r-e*e)/(a-e)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=Dd}for(let a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;const r=o[l],c=a-r;e[t+a*i]=n[r]+c*c}}Rd[255]=-Dd;const Fd=ls.layout_symbol["text-font"].default.join(",");class Bd{constructor(e,t,i){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i}setURL(e){this.url=e}getGlyphs(e){return n(this,void 0,void 0,(function*(){const t=[];for(const i in e)for(const r of e[i])t.push(this._getAndCacheGlyphsPromise(i,r));const i=yield Promise.all(t),r={};for(const{stack:e,id:t,glyph:n}of i)r[e]||(r[e]={}),r[e][t]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics};return r}))}_getAndCacheGlyphsPromise(e,t){return n(this,void 0,void 0,(function*(){var i,r;null!==(i=(r=this.entries)[e])&&void 0!==i||(r[e]={glyphs:{},requests:{},ranges:{}});const n=this.entries[e];let o=n.glyphs[t];return void 0!==o?{stack:e,id:t,glyph:o}:!this.url||this._charUsesLocalIdeographFontFamily(t)?(o=n.glyphs[t]=this._drawGlyph(n,e,t),{stack:e,id:t,glyph:o}):yield this._downloadAndCacheRangePromise(e,t)}))}_downloadAndCacheRangePromise(e,t){return n(this,void 0,void 0,(function*(){var i;const r=this.entries[e],n=Math.floor(t/256);if(r.ranges[n])return{stack:e,id:t,glyph:null};(i=r.requests)[n]||(i[n]=Bd.loadGlyphRange(e,n,this.url,this.requestManager));try{const i=yield r.requests[n];for(const e in i)r.glyphs[+e]=i[+e];return r.ranges[n]=!0,{stack:e,id:t,glyph:i[t]||null}}catch(i){const o=r.glyphs[t]=this._drawGlyph(r,e,t);return this._warnOnMissingGlyphRange(o,n,t,te(i)),{stack:e,id:t,glyph:o}}}))}_warnOnMissingGlyphRange(e,t,i,r){const n=256*t;Le(`Unable to load glyph range ${t}, ${n}-${n+255}. Rendering codepoint U+${i.toString(16).padStart(4,"0").toUpperCase()} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&/[\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))}_drawGlyph(e,t,i){const r=t===Fd&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(i),n=r?"ideographTinySDF":"tinySDF";e[n]||(e[n]=this._createTinySDF(r?this.localIdeographFontFamily:t));const o=e[n].draw(String.fromCodePoint(i)),s=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(i));return{id:i,bitmap:new Rc({width:o.width||60,height:o.height||60},o.data),metrics:{width:s?0:o.glyphWidth/2||24,height:o.glyphHeight/2||24,left:o.glyphLeft/2+.5||0,top:o.glyphTop/2-27.5||-8,advance:s?0:o.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(e){const t=e?e.split(","):[];t.push("sans-serif");const i=t.map((e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(",");return new Bd.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[r,n]of Object.entries(t))new RegExp(`\\b${r}\\b`,"i").test(e)&&(i=`${n}`);return i}destroy(){for(const e in this.entries){const t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}Bd.loadGlyphRange=function(e,t,i,r){return n(this,void 0,void 0,(function*(){const n=256*t,o=n+255,s=yield r.transformRequest(i.replace("{fontstack}",e).replace("{range}",`${n}-${o}`),"Glyphs"),a=yield(l=s,c=new AbortController,ft(Te(l,{type:"arrayBuffer"}),c));var l,c;if(!(null==a?void 0:a.data))throw new Error(`Could not load glyph range. range: ${t}, ${n}-${o}`);const h={};for(const e of new Nu(a.data).readFields(Qu,[]))h[e.id]=e;return h}))},Bd.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.radius=i,this.cutoff=r,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),h=this.ctx=c.getContext("2d",{willReadFrequently:!0});h.font=`${s} ${o} ${e}px ${n}`,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("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,e);const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.floor(n),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o)-a)),c=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(r))),h=l+2*this.buffer,u=c+2*this.buffer,d=Math.max(h*u,0),p=new Uint8ClampedArray(d),f={data:p,width:h,height:u,glyphWidth:l,glyphHeight:c,glyphTop:s,glyphLeft:a,glyphAdvance:t};if(0===l||0===c)return f;const{ctx:m,buffer:_,gridInner:g,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(_,_,l,c),m.fillText(e,_-a,_+s);const v=m.getImageData(_,_,l,c);y.fill(Dd,0,d),g.fill(0,0,d);let x=3;for(let e=0;e<c;e++){let t=(e+_)*h+_;for(let e=0;e<l;e++,x+=4,t++){const e=v.data[x];if(0===e)continue;const i=Rd[e];y[t]=Math.max(0,i),g[t]=Math.max(0,-i)}}kd(y,0,0,h,u,h,this.f,this.v,this.z),kd(g,_,_,l,c,h,this.f,this.v,this.z);const b=255/this.radius,w=255*(1-this.cutoff);for(let e=0;e<d;e++){const t=Math.sqrt(y[e])-Math.sqrt(g[e]);p[e]=Math.round(w-b*t)}return f}};class Od{constructor(){this.specification=St.light.position}possiblyEvaluate(e,t){return function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:br.number(e.x,t.x,i),y:br.number(e.y,t.y,i),z:br.number(e.z,t.z,i)}}}let Vd;class jd extends Tt{constructor(e){super(),Vd||(Vd=new Ws({anchor:new Us(St.light.anchor),position:new Od,color:new Us(St.light.color),intensity:new Us(St.light.intensity)})),this._transitionable=new Fs(Vd,void 0),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t={}){if(!this._validate(hs,e,t))for(const t in e){const i=e[t];t.endsWith(Rs)?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!1!==(null==i?void 0:i.validate)&&fs(this,e.call(cs,{value:t,style:{glyphs:!0,sprite:!0},styleSpec:St}))}}const Nd=new Ws({"sky-color":new Us(St.sky["sky-color"]),"horizon-color":new Us(St.sky["horizon-color"]),"fog-color":new Us(St.sky["fog-color"]),"fog-ground-blend":new Us(St.sky["fog-ground-blend"]),"horizon-fog-blend":new Us(St.sky["horizon-fog-blend"]),"sky-horizon-blend":new Us(St.sky["sky-horizon-blend"]),"atmosphere-blend":new Us(St.sky["atmosphere-blend"])});class Ud extends Tt{constructor(e){super(),this._transitionable=new Fs(Nd,void 0),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new zs(0))}setSky(e,t={}){if(!this._validate(us,e,t)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const t in e){const i=e[t];t.endsWith(Rs)?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!1!==(null==i?void 0:i.validate)&&fs(this,e.call(cs,Te({value:t,style:{glyphs:!0,sprite:!0},styleSpec:St})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class Gd{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){var i;const r=e.join(",")+String(t);return(i=this.dashEntry)[r]||(i[r]=this.addDash(e,t)),this.dashEntry[r]}getDashRanges(e,t,i){const r=[];let n=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];n=a*i,a+=l,o=a*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l})}return r}addRoundDash(e,t,i){const r=t/2;for(let t=-i;t<=i;t++){const n=this.width*(this.nextRow+i+t);let o=0,s=e[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e)}else u=r-Math.sqrt(h*h+d*d);this.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let n=0,o=e[n];for(let t=0;t<this.width;t++){t/o.right>1&&(o=e[++n]);const i=Math.abs(t-o.left),s=Math.abs(t-o.right),a=Math.min(i,s);this.data[r+t]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(e,t){const i=t?7:0,r=2*i+1;if(this.nextRow+r>this.height)return Le("LineAtlas out of space"),null;let n=0;for(const t of e)n+=t;if(0!==n){const r=this.width/n,o=this.getDashRanges(e,this.width,r);t?this.addRoundDash(o,r,i):this.addRegularDash(o)}const o={y:this.nextRow+i,height:2*i,width:n};return this.nextRow+=r,this.dirty=!0,o}bind(e){const 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))}}class $d{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var e;this._triggered||(this._triggered=!0,null===(e=this._channel)||void 0===e||e.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Zd={once:!0};class qd{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new $d((()=>this.process())),this.subscription=Ne(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Be(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise(((i,r)=>{const n=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=t?Ne(t.signal,"abort",(()=>{null==o||o.unsubscribe(),delete this.resolveRejects[n];const t={id:n,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)}),Zd):null;this.resolveRejects[n]={resolve:e=>{null==o||o.unsubscribe(),i(e)},reject:e=>{null==o||o.unsubscribe(),r(e)}};const s=[],a=Object.assign(Object.assign({},e),{id:n,sourceMapId:this.mapId,origin:location.origin,data:bs(e.data,s)});this.target.postMessage(a,{transfer:s})}))}receive(e){const t=e.data,i=t.id,r=["file://","resource://android","null"],n=[t.origin,location.origin],o=t.origin===location.origin,s=n.some((e=>r.includes(e)));if((o||s)&&(!t.targetMapId||this.mapId===t.targetMapId)){if("<cancel>"===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if(Be(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;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,t){return n(this,void 0,void 0,(function*(){if("<response>"===t.type){const i=this.resolveRejects[e];if(delete this.resolveRejects[e],!i)return;return void(t.error?i.reject(te(ws(t.error))):i.resolve(ws(t.data)))}if(!this.messageHandlers[t.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const i=ws(t.data),r=new AbortController;this.abortControllers[e]=r;try{const n=yield this.messageHandlers[t.type](t.sourceMapId,i,r);this.completeTask(e,null,n)}catch(t){this.completeTask(e,te(t))}}))}completeTask(e,t,i){const r=[];delete this.abortControllers[e];const n={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?bs(t):null,data:bs(i,r)};this.target.postMessage(n,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}}const Wd="maplibre_preloaded_worker_pool";class Hd{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<Hd.workerCount;)this.workers.push(new Worker(ct.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){if(delete this.active[e],0===this.numActive()){for(const e of this.workers)e.terminate();this.workers=null}}isPreloaded(){return!!this.active[Wd]}numActive(){return Object.keys(this.active).length}}const Xd=Math.floor(nt.hardwareConcurrency/2);let Yd,Kd;function Jd(){return Yd||(Yd=new Hd),Yd}Hd.workerCount=function(e){if(null==Oe){const t=e.navigator?e.navigator.userAgent:null;Oe=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Oe}(globalThis)?Math.max(Math.min(Xd,3),1):1;class Qd{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t;const i=this.workerPool.acquire(t);for(let e=0;e<i.length;e++){const r=new qd(i[e],t);r.name=`Worker ${e}`,this.actors.push(r)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,t){const i=[];for(const r of this.actors)i.push(r.sendAsync({type:e,data:t}));return Promise.all(i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){for(const e of this.actors)e.remove();this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(const t of this.actors)t.unregisterMessageHandler(e)}}function ep(){return Kd||(Kd=new Qd(Jd(),ut),Kd.registerMessageHandler("GR",((e,t,i)=>ft(t,i)))),Kd}function tp(e,t){const i=_();return b(i,i,[1,1,0]),w(i,i,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?x(i,i,e.calculatePosMatrix(t.toUnwrapped())):i}function ip(e,t,i,r,n,o,s){var a;const l=function(e,t,i){if(e)for(const r of e){const e=t[r];if((null==e?void 0:e.source)===i&&"fill-extrusion"===e.type)return!0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(null!==(a=null==n?void 0:n.layers)&&void 0!==a?a:null,t,e.id),c=o.maxPitchScaleFactor(),h=e.tilesIn(r,c,l);h.sort(rp);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,n,o,c,tp(o,r.tileID),s?(e,t)=>s(r.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const r of e[i])np(r,t);return e}(function(e){const t={},i={};for(const{queryResults:r,wrappedTileID:n}of e){i[n]||(i[n]={});const e=i[n];for(const i in r){const n=r[i];e[i]||(e[i]={});const o=e[i];t[i]||(t[i]=[]);for(const e of n)o[e.featureIndex]||(o[e.featureIndex]=!0,t[i].push(e))}}return t}(u),e)}function rp(e,t){const 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 np(e,t){const 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}function op(e,t,i,r){return n(this,void 0,void 0,(function*(){let n=e;if(e.url?n=(yield mt(yield t.transformRequest(e.url,"Source"),i)).data:yield nt.frameAsync(i,r),!n)return null;const o=Se(Te(n,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in n&&n.vector_layers&&(o.vectorLayerIds=n.vector_layers.map((e=>e.id))),o}))}const sp=6371008.8;class ap{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ap(we(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return sp*Math.acos(Math.min(n,1))}static convert(e){if(e instanceof ap)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new ap(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new ap(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new 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>]")}}class lp{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 ap?new ap(e.lng,e.lat):ap.convert(e),this}setSouthWest(e){return this._sw=e instanceof ap?new ap(e.lng,e.lat):ap.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof ap)r=e,n=e;else{if(!(e instanceof lp))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(lp.convert(e)):this.extend(ap.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(ap.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new ap(r.lng,r.lat),this._ne=new ap(n.lng,n.lat)),this}getCenter(){return new ap((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 ap(this.getWest(),this.getNorth())}getSouthEast(){return new ap(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){const{lng:t,lat:i}=ap.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}intersects(e){if(!((e=lp.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;const t=Math.abs(this.getEast()-this.getWest()),i=Math.abs(e.getEast()-e.getWest());if(t>=360||i>=360)return!0;const r=we(this.getWest(),-180,180),n=we(this.getEast(),-180,180),o=we(e.getWest(),-180,180),s=we(e.getEast(),-180,180),a=r>n,l=o>s;return!(!a||!l)||(a?s>=r||o<=n:l?n>=o||r<=s:o<=n&&s>=r)}static convert(e){return e instanceof lp?e:e?new lp(e):e}static fromLngLat(e,t=0){const i=360*t/40075017,r=i/Math.cos(Math.PI/180*e.lat);return new lp(new ap(e.lng-r,e.lat-i),new ap(e.lng+r,e.lat+i))}adjustAntiMeridian(){const e=new ap(this._sw.lng,this._sw.lat),t=new ap(this._ne.lng,this._ne.lat);return new lp(e,e.lng>t.lng?new ap(t.lng+360,t.lat):t)}}const cp=2*Math.PI*sp;function hp(e){return cp*Math.cos(e*Math.PI/180)}function up(e){return(180+e)/360}function dp(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function pp(e,t){return e/hp(t)}function fp(e){return 360*e-180}function mp(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function _p(e,t){return e*hp(mp(t))}class gp{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=ap.convert(e);return new gp(up(i.lng),dp(i.lat),pp(t,i.lat))}toLngLat(){return new ap(fp(this.x),mp(this.y))}toAltitude(){return _p(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/cp*(e=mp(this.y),1/Math.cos(e*Math.PI/180));var e}}class yp{constructor(e,t,i){this.bounds=lp.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){const t=Math.pow(2,e.z),i=Math.floor(up(this.bounds.getWest())*t),r=Math.floor(dp(this.bounds.getNorth())*t),n=Math.ceil(up(this.bounds.getEast())*t),o=Math.ceil(dp(this.bounds.getSouth())*t);return e.x>=i&&e.x<n&&e.y>=r&&e.y<o}}class vp extends Tt{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,Te(this,Se(t,["url","scheme","tileSize","promoteId","encoding"])),this._options=Te({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}load(){return n(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new bt("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield op(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(Te(this,t),t.bounds&&(this.tileBounds=new yp(t.bounds,this.minzoom,this.maxzoom)),this.fire(new bt("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new bt("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,Qe(e)||this.fire(new wt(te(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._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return Te({},this._options)}loadTile(e){return n(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:yield 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:yield this._getOverzoomParameters(e),etag:e.etag};i.request.collectResourceTiming=this._collectResourceTiming;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.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);const n={};return(null==t?void 0:t.etagUnmodified)&&(n.unmodified=!0),n}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){return n(this,void 0,void 0,(function*(){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:yield this.map._requestManager.transformRequest(i,"Tile")}}))}_afterTileLoadWorkerResponse(e,t){if((null==t?void 0:t.resourceTiming)&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=null==t?void 0:t.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return n(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return n(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class xp extends Tt{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._options=Te({type:"raster"},t),Te(this,Se(t,["url","scheme","tileSize"]))}load(){return n(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new bt("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield op(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(Te(this,t),t.bounds&&(this.tileBounds=new yp(t.bounds,this.minzoom,this.maxzoom)),this.fire(new bt("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new bt("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,Qe(e)||this.fire(new wt(te(e)))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return Te({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return n(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const i=yield gt.getImage(yield this.map._requestManager.transformRequest(t,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(null==i?void 0:i.data){this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const t=this.map.painter.context,r=t.gl,n=i.data;e.texture=this.map.painter.getTileTexture(n.width),e.texture?e.texture.update(n,{useMipmap:!0}):(e.texture=new Zc(t,n,r.RGBA,{useMipmap:!0}),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}}))}abortTile(e){return n(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return n(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}function bp(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}function wp(e,t){const{x:i,y:r}=gp.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||i<0||i>=1)}class Tp{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=Ip(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const r=(o=this.y,s=this.z,a=bp(256*(n=this.x),256*(o=Math.pow(2,s)-o-1),s),l=bp(256*(n+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var n,o,s,a,l;const c=function(e,t,i){let r="";for(let n=e;n>0;n--){const e=1<<n-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?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new o((e.x*t-this.x)*Q,(e.y*t-this.y)*Q)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Sp{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Ip(e,t.z,t.z,t.x,t.y)}}class Pp{constructor(e,t,i,r,n){if(this.terrainRttPosMatrix32f=null,e<i)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Tp(i,+r,+n),this.key=Ip(t,e,i,r,n)}clone(){return new Pp(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(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new Pp(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Pp(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?Ip(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):Ip(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const 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(e){if(this.overscaledZ>=e)return[new Pp(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Pp(t,this.wrap,t,i,r),new Pp(t,this.wrap,t,i+1,r),new Pp(t,this.wrap,t,i,r+1),new Pp(t,this.wrap,t,i+1,r+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 Pp(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Pp(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Sp(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new gp(e.x-this.wrap,e.y))}normalizeCoordinates(e,t,i=8192){if(e>=0&&e<i&&t>=0&&t<i)return{tileID:this,x:e,y:t};const r=Math.floor(e/i),n=Math.floor(t/i),o=e-r*i,s=t-n*i,a=this.canonical.z,l=1<<a,c=this.canonical.y+n;if(c<0||c>=l)return null;let h=this.canonical.x+r,u=this.wrap;return h<0?(u-=Math.ceil(-h/l),h=(h%l+l)%l):h>=l&&(u+=Math.floor(h/l),h%=l),{tileID:new Pp(this.overscaledZ,u,a,h,c),x:o,y:s}}}function Ip(e,t,i,r,n){(e*=2)<0&&(e=-1*e-1);const o=1<<i;return(o*o*e+o*n+r).toString(36)+i.toString(36)+t.toString(36)}function Mp(e,t){const 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}gs("CanonicalTileID",Tp),gs("OverscaledTileID",Pp,{omit:["terrainRttPosMatrix32f"]});class Ep extends xp{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=Te({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}loadTile(e){return n(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i=yield this.map._requestManager.transformRequest(t,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const t=yield gt.getImage(i,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(null==t?void 0:t.data){const i=t.data;this.map._refreshExpiredTiles&&(t.cacheControl||t.expires)&&e.setExpiryData({cacheControl:t.cacheControl,expires:t.expires});const r=Ve(i)&&u()?i:yield this.readImageNow(i),n={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;e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor()),e.dem=yield e.actor.sendAsync({type:"LDT",data:n}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return n(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&function(){if(null==h&&(h=!1,u())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let i=0;i<e*e;i++){const r=4*i;t.fillStyle=`rgb(${r},${r+1},${r+2})`,t.fillRect(i%e,Math.floor(i/e),1,1)}const i=t.getImageData(0,0,e,e).data;for(let t=0;t<e*e*4;t++)if(t%4!=3&&i[t]!==t){h=!0;break}}}return h||!1}()){const t=e.width+2,i=e.height+2;try{return new kc({width:t,height:i},yield function(e,t,i,r,o){return n(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const i=null==t?void 0:t.format;if(!i||!i.startsWith("BGR")&&!i.startsWith("RGB"))throw new Error(`Unrecognized format ${i}`);const n=i.startsWith("BGR"),s=new Uint8ClampedArray(r*o*4);if(yield t.copyTo(s,function(e,t,i,r,n){const o=4*Math.max(1,0),s=(Math.max(0,-1)- -1)*r*4+o,a=4*r,l=Math.max(0,-1),c=Math.max(0,-1);return{rect:{x:l,y:c,width:Math.min(e.width,-1+r)-l,height:Math.min(e.height,-1+n)-c},layout:[{offset:s,stride:a}]}}(e,0,0,r,o)),n)for(let e=0;e<s.length;e+=4){const t=s[e];s[e]=s[e+2],s[e+2]=t}return s}finally{t.close()}}))}(e,0,0,t,i))}catch(e){}}return nt.getImageData(e,1)}))}_getNeighboringTiles(e){const t=e.canonical,i=Math.pow(2,t.z),r=(t.x-1+i)%i,n=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+i)%i,s=t.x+1===i?e.wrap+1:e.wrap,a={};return a[new Pp(e.overscaledZ,n,t.z,r,t.y).key]={backfilled:!1},a[new Pp(e.overscaledZ,s,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(a[new Pp(e.overscaledZ,n,t.z,r,t.y-1).key]={backfilled:!1},a[new Pp(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},a[new Pp(e.overscaledZ,s,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1<i&&(a[new Pp(e.overscaledZ,n,t.z,r,t.y+1).key]={backfilled:!1},a[new Pp(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},a[new Pp(e.overscaledZ,s,t.z,o,t.y+1).key]={backfilled:!1}),a}unloadTile(e){return n(this,void 0,void 0,(function*(){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&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))}))}}function Cp(e,t){return t?e.properties[t]:e.id}function Ap(e,t){const i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(const i of t.removeProperties){const t=e.addOrUpdateProperties.findIndex((e=>e.key===i));t>-1&&e.addOrUpdateProperties.splice(t,1)}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 zp(e){var t,i;if(!e)return{};const r={};return r.removeAll=e.removeAll,r.remove=new Set(e.remove||[]),r.add=new Map(null===(t=e.add)||void 0===t?void 0:t.map((e=>[e.id,e]))),r.update=new Map(null===(i=e.update)||void 0===i?void 0:i.map((e=>[e.id,e]))),r}function Dp(e){return e&&0!==e.length?"number"==typeof e[0]?[e]:e.flatMap((e=>Dp(e))):[]}function Rp(e){return"GeometryCollection"===e.type?e.geometries.flatMap((e=>Rp(e))):Dp(e.coordinates)}function kp(e){const t=new lp;let i;switch(e.type){case"FeatureCollection":i=e.features.flatMap((e=>Rp(e.geometry)));break;case"Feature":i=Rp(e.geometry);break;default:i=Rp(e)}if(0===i.length)return t;for(const e of i){const[i,r]=e;t.extend([i,r])}return t}class Lp extends Tt{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.actor=i.getActor(),this.setEventedParent(r),this._data="string"==typeof t.data?{url:t.data}:{geojson:t.data},this._options=Te({},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&&Le(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions=Te({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==t.buffer?t.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==t.tolerance?t.tolerance:.375),extent:Q,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:Q,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*(Q/this.tileSize)}_getClusterMaxZoom(e){const t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||Le(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}load(){return n(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(e){this.map=e,this.load()}setData(e,t){this._data="string"==typeof e?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e};const i=this._updateWorkerData();return t?i:this}updateData(e,t){this._pendingWorkerUpdate.diff=function(e,t){if(!e)return t||{};if(!t)return e||{};const i=zp(e),r=zp(t);!function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(const i of t.remove)e.add.delete(i),e.update.delete(i);for(const[i,r]of t.update){const n=e.update.get(i);n&&(t.update.set(i,Ap(n,r)),e.update.delete(i))}}(i,r);const n={};if((i.removeAll||r.removeAll)&&(n.removeAll=!0),n.remove=new Set([...i.remove,...r.remove]),n.add=new Map([...i.add,...r.add]),n.update=new Map([...i.update,...r.update]),n.remove.size&&n.add.size)for(const e of n.add.keys())n.remove.delete(e);const o=function(e){const 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 o}(this._pendingWorkerUpdate.diff,e);const i=this._updateWorkerData();return t?i:this}getData(){return n(this,void 0,void 0,(function*(){return this._data.url&&(yield this.once("data")),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}))}getBounds(){return n(this,void 0,void 0,(function*(){return kp(yield 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(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,t,i){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}_updateWorkerData(){return n(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void Le(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:e,diff:t,updateCluster:i}=this._pendingWorkerUpdate,r=this._getLoadGeoJSONParameters(e,t,i);void 0!==e?this._pendingWorkerUpdate.data=void 0:t?this._pendingWorkerUpdate.diff=void 0:i&&(this._pendingWorkerUpdate.updateCluster=void 0),yield this._dispatchWorkerUpdate(r)}))}_getLoadGeoJSONParameters(e,t,i){return n(this,void 0,void 0,(function*(){const r=Te({type:this.type},this.workerOptions);return"string"==typeof e?(r.request=yield this.map._requestManager.transformRequest(nt.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}))}_dispatchWorkerUpdate(e){return n(this,void 0,void 0,(function*(){this._isUpdatingWorker=!0,this.fire(new bt("dataloading",{dataType:"source"}));try{const t=yield e,i=yield this.actor.sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||i.abandoned)return void this.fire(new bt("dataabort",{dataType:"source"}));i.data&&(this._data={geojson:i.data});const r=this._applyDiffToSource(t.dataDiff),n=this._getShouldReloadTileOptions(r),o={dataType:"source"};this._applyResourceTiming(o,i),this.fire(new bt("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new bt("data",Object.assign(Object.assign({},o),{sourceDataType:"content",shouldReloadTileOptions:n})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new bt("dataabort",{dataType:"source"}));this.fire(new wt(te(e)))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyResourceTiming(e,t){var i;if(!this._collectResourceTiming)return;const r=null===(i=t.resourceTiming)||void 0===i?void 0:i[this.id];if(!r)return;const n=r.slice(0);(null==n?void 0:n.length)&&Te(e,{resourceTiming:n})}_applyDiffToSource(e){if(!e)return;const t="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const e=function(e,t){const i=new Map;if(null==e)return i;if(null==e.type)return i;if("Feature"===e.type){const r=Cp(e,t);if(null==r)return;return i.set(r,e),i}if("FeatureCollection"===e.type){const r=new Set;for(const n of e.features){const e=Cp(n,t);if(null==e)return;if(r.has(e))return;r.add(e),i.set(e,n)}return i}}(this._data.geojson,t);if(!e)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;const i=function(e,t,i){var r,n;const o=[];if(t.removeAll)e.clear();else if(t.remove)for(const i of t.remove){const t=e.get(i);t&&(o.push(t.geometry),e.delete(i))}if(t.add)for(const r of t.add){const t=Cp(r,i);if(null==t)continue;const n=e.get(t);n&&o.push(n.geometry),o.push(r.geometry),e.set(t,r)}if(t.update)for(const i of t.update){const t=e.get(i.id);if(!t)continue;const s=!!i.newGeometry,a=i.removeAllProperties||(null===(r=i.removeProperties)||void 0===r?void 0:r.length)>0||(null===(n=i.addOrUpdateProperties)||void 0===n?void 0:n.length)>0;if(!s&&!a)continue;o.push(t.geometry);const l=Object.assign({},t);if(e.set(i.id,l),s&&(o.push(i.newGeometry),l.geometry=i.newGeometry),a){if(l.properties=i.removeAllProperties?{}:Object.assign({},l.properties||{}),i.removeProperties)for(const e of i.removeProperties)delete l.properties[e];if(i.addOrUpdateProperties)for(const{key:e,value:t}of i.addOrUpdateProperties)l.properties[e]=t}}return o}(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=>kp(e)))}}shouldReloadTile(e,{affectedBounds:t}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;const{buffer:i,extent:r}=this.workerOptions.geojsonVtOptions,n=function({x:e,y:t,z:i},r=0){const n=fp((e-r)/Math.pow(2,i)),o=mp((t+1+r)/Math.pow(2,i)),s=fp((e+1+r)/Math.pow(2,i)),a=mp((t-r)/Math.pow(2,i));return new lp([n,o],[s,a])}(e.tileID.canonical,i/r);for(const e of t)if(n.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return n(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const 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;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t)}))}abortTile(e){return n(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return n(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return Te({},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}}class Fp{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(e){const t=new Fp;return t.extend(e(new o(this.minX,this.minY))),t.extend(e(new o(this.maxX,this.minY))),t.extend(e(new o(this.minX,this.maxY))),t.extend(e(new o(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Fp;for(const i of e)t.extend(i);return t}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}}class Bp extends Tt{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,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}load(e){return n(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new bt("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield gt.getImage(yield this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,(null==t?void 0:t.data)&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,Qe(e)||this.fire(new wt(te(e)))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>this.texture=null)),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new bt("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const t=e.map(gp.fromLngLat);var i;return this.tileID=function(e){const t=Fp.fromPoints(e),i=t.width(),r=t.height(),n=Math.max(i,r),o=Math.max(0,Math.floor(-Math.log(n)/Math.LN2)),s=Math.pow(2,o);return new Tp(o,Math.floor((t.minX+t.maxX)/2*s),Math.floor((t.minY+t.maxY)/2*s))}(t),this.terrainTileRanges=this._getOverlappingTileRanges(t),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=t.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((i=this.tileCoords)[1].x-i[0].x)*(i[2].y-i[0].y)-(i[1].y-i[0].y)*(i[2].x-i[0].x)<0,this.fire(new bt("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,t=e.gl;this.texture||(this.texture=new Zc(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let i=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,i=!0)}i&&this.fire(new bt("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return n(this,void 0,void 0,(function*(){var t;(null===(t=this.tileID)||void 0===t?void 0:t.equals(e.tileID.canonical))?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:t,minY:i,maxX:r,maxY:n}=Fp.fromPoints(e),o={};for(let e=0;e<=25;e++){const s=Math.pow(2,e),a=Math.floor(t*s),l=Math.floor(i*s),c=Math.floor(r*s),h=Math.floor(n*s),u=(a%s+s)%s,d=c%s,p=Math.floor(a/s),f=Math.floor(c/s);o[e]={minWrap:p,maxWrap:f,minTileXWrapped:u,maxTileXWrapped:d,minTileY:l,maxTileY:h}}return o}}class Op extends Bp{constructor(e,t,i,r){super(e,t,i,r),this._onPlayingHandler=()=>{var e;null===(e=this.map)||void 0===e||e.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=t}load(){return n(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push((yield this.map._requestManager.transformRequest(t,"Source")).url);try{const e=yield(e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise((i=>{t.onloadstart=()=>{i(t)};for(const i of e){const e=window.document.createElement("source");_t(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 wt(te(e)))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new wt(new Bt(`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;const 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 Zc(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let i=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,i=!0)}i&&this.fire(new bt("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Vp extends Bp{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 wt(new Bt(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new wt(new Bt(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new wt(new Bt(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"==typeof t.canvas||t.canvas instanceof HTMLCanvasElement||this.fire(new wt(new Bt(`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 wt(new Bt(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.animate}load(){return n(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new wt(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}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())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context,i=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new Zc(t,this.canvas,i.RGBA,{premultiply:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new bt("data",{dataType:"source",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(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const jp={},Np=e=>{switch(e){case"geojson":return Lp;case"image":return Bp;case"raster":return xp;case"raster-dem":return Ep;case"vector":return vp;case"video":return Op;case"canvas":return Vp}return jp[e]};class Up{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const 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 new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Gp{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._x=i,this._y=r,this._z=t,this.properties=e.properties,this.id=n}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;const e=this._vectorTileFeature,t=e.extent*Math.pow(2,this._z),i=e.extent*this._x,r=e.extent*this._y,n=e.loadGeometry();switch(e.type){case 1:{const e=[];for(const t of n)e.push(t[0]);const o=this.projectLine(e,i,r,t);this._geometry=1===e.length?{type:"Point",coordinates:o[0]}:{type:"MultiPoint",coordinates:o};break}case 2:{const e=n.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:{const e=Gh(n),o=[];for(const n of e)o.push(n.map((e=>this.projectLine(e,i,r,t))));this._geometry=1===o.length?{type:"Polygon",coordinates:o[0]}:{type:"MultiPolygon",coordinates:o};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&"_x"!==t&&"_y"!==t&&"_z"!==t&&(e[t]=this[t]);return e}}class $p{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}}class Zp extends $p{}class qp extends Zp{getValueFromBuffer(e){return this.dataBuffer[e]}}class Wp extends Zp{getValueFromBuffer(e){return this.dataBuffer[e]}}class Hp extends $p{constructor(e,t,i,r){super(e,t,r),this.delta=i}}class Xp extends Hp{constructor(e,t,i,r){super(e,Int32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class Yp extends $p{constructor(e,t,i,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Kp{constructor(e,t,i,r,n=4096){this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=r,this._extent=n}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((e=>[e.name,e])))),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const e=[],t=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let r;if(this.idVector){const e=this.idVector.getValue(i);r=this.containsMaxSafeIntegerValues(this.idVector)&&null!==e?Number(e):e}const n={coordinates:t[i],type:this.geometryVector.geometryType(i)},o={};for(const e of this.propertyVectors){if(!e)continue;const t=e.name,r=e.getValue(i);null!==r&&(o[t]=r)}e.push({id:r,geometry:n,properties:o})}return e}containsMaxSafeIntegerValues(e){return e instanceof qp||e instanceof Yp||e instanceof Xp||e instanceof Wp}}class Jp{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var Qp,ef;!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(Qp||(Qp={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(ef||(ef={}));const tf=new Uint32Array(33);tf[0]=0;for(let e=1;e<=32;e++)tf[e]=32===e?4294967295:4294967295>>>32-e;const rf=tf,nf=256;function of(e,t){return e-e%t}function sf(e){const t=e>>>0;return((255&t)<<24|(65280&t)<<8|t>>>8&65280|t>>>24&255)>>>0}const af=function(){if(!Number.isFinite(65536))return 65536;const e=of(Math.floor(65536),nf);return 0===e?nf:e}(),lf=3*af/nf+af|0;function cf(){const e=new Uint8Array(lf);return{dataToBePacked:new Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function hf(e,t,i,r,n){switch(n){case 1:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0;i[n++]=t>>>0&1,i[n++]=t>>>1&1,i[n++]=t>>>2&1,i[n++]=t>>>3&1,i[n++]=t>>>4&1,i[n++]=t>>>5&1,i[n++]=t>>>6&1,i[n++]=t>>>7&1,i[n++]=t>>>8&1,i[n++]=t>>>9&1,i[n++]=t>>>10&1,i[n++]=t>>>11&1,i[n++]=t>>>12&1,i[n++]=t>>>13&1,i[n++]=t>>>14&1,i[n++]=t>>>15&1,i[n++]=t>>>16&1,i[n++]=t>>>17&1,i[n++]=t>>>18&1,i[n++]=t>>>19&1,i[n++]=t>>>20&1,i[n++]=t>>>21&1,i[n++]=t>>>22&1,i[n++]=t>>>23&1,i[n++]=t>>>24&1,i[n++]=t>>>25&1,i[n++]=t>>>26&1,i[n++]=t>>>27&1,i[n++]=t>>>28&1,i[n++]=t>>>29&1,i[n++]=t>>>30&1,i[n++]=t>>>31&1}}(e,t,i,r);break;case 2:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,r=e[o++]>>>0;i[n++]=t>>>0&3,i[n++]=t>>>2&3,i[n++]=t>>>4&3,i[n++]=t>>>6&3,i[n++]=t>>>8&3,i[n++]=t>>>10&3,i[n++]=t>>>12&3,i[n++]=t>>>14&3,i[n++]=t>>>16&3,i[n++]=t>>>18&3,i[n++]=t>>>20&3,i[n++]=t>>>22&3,i[n++]=t>>>24&3,i[n++]=t>>>26&3,i[n++]=t>>>28&3,i[n++]=t>>>30&3,i[n++]=r>>>0&3,i[n++]=r>>>2&3,i[n++]=r>>>4&3,i[n++]=r>>>6&3,i[n++]=r>>>8&3,i[n++]=r>>>10&3,i[n++]=r>>>12&3,i[n++]=r>>>14&3,i[n++]=r>>>16&3,i[n++]=r>>>18&3,i[n++]=r>>>20&3,i[n++]=r>>>22&3,i[n++]=r>>>24&3,i[n++]=r>>>26&3,i[n++]=r>>>28&3,i[n++]=r>>>30&3}}(e,t,i,r);break;case 3:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,r=e[o++]>>>0,s=e[o++]>>>0;i[n++]=t>>>0&7,i[n++]=t>>>3&7,i[n++]=t>>>6&7,i[n++]=t>>>9&7,i[n++]=t>>>12&7,i[n++]=t>>>15&7,i[n++]=t>>>18&7,i[n++]=t>>>21&7,i[n++]=t>>>24&7,i[n++]=t>>>27&7,i[n++]=7&(t>>>30|(1&r)<<2),i[n++]=r>>>1&7,i[n++]=r>>>4&7,i[n++]=r>>>7&7,i[n++]=r>>>10&7,i[n++]=r>>>13&7,i[n++]=r>>>16&7,i[n++]=r>>>19&7,i[n++]=r>>>22&7,i[n++]=r>>>25&7,i[n++]=r>>>28&7,i[n++]=7&(r>>>31|(3&s)<<1),i[n++]=s>>>2&7,i[n++]=s>>>5&7,i[n++]=s>>>8&7,i[n++]=s>>>11&7,i[n++]=s>>>14&7,i[n++]=s>>>17&7,i[n++]=s>>>20&7,i[n++]=s>>>23&7,i[n++]=s>>>26&7,i[n++]=s>>>29&7}}(e,t,i,r);break;case 4:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,r=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0;i[n++]=t>>>0&15,i[n++]=t>>>4&15,i[n++]=t>>>8&15,i[n++]=t>>>12&15,i[n++]=t>>>16&15,i[n++]=t>>>20&15,i[n++]=t>>>24&15,i[n++]=t>>>28&15,i[n++]=r>>>0&15,i[n++]=r>>>4&15,i[n++]=r>>>8&15,i[n++]=r>>>12&15,i[n++]=r>>>16&15,i[n++]=r>>>20&15,i[n++]=r>>>24&15,i[n++]=r>>>28&15,i[n++]=s>>>0&15,i[n++]=s>>>4&15,i[n++]=s>>>8&15,i[n++]=s>>>12&15,i[n++]=s>>>16&15,i[n++]=s>>>20&15,i[n++]=s>>>24&15,i[n++]=s>>>28&15,i[n++]=a>>>0&15,i[n++]=a>>>4&15,i[n++]=a>>>8&15,i[n++]=a>>>12&15,i[n++]=a>>>16&15,i[n++]=a>>>20&15,i[n++]=a>>>24&15,i[n++]=a>>>28&15}}(e,t,i,r);break;case 5:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,r=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0,l=e[o++]>>>0;i[n++]=t>>>0&31,i[n++]=t>>>5&31,i[n++]=t>>>10&31,i[n++]=t>>>15&31,i[n++]=t>>>20&31,i[n++]=t>>>25&31,i[n++]=31&(t>>>30|(7&r)<<2),i[n++]=r>>>3&31,i[n++]=r>>>8&31,i[n++]=r>>>13&31,i[n++]=r>>>18&31,i[n++]=r>>>23&31,i[n++]=31&(r>>>28|(1&s)<<4),i[n++]=s>>>1&31,i[n++]=s>>>6&31,i[n++]=s>>>11&31,i[n++]=s>>>16&31,i[n++]=s>>>21&31,i[n++]=s>>>26&31,i[n++]=31&(s>>>31|(15&a)<<1),i[n++]=a>>>4&31,i[n++]=a>>>9&31,i[n++]=a>>>14&31,i[n++]=a>>>19&31,i[n++]=a>>>24&31,i[n++]=31&(a>>>29|(3&l)<<3),i[n++]=l>>>2&31,i[n++]=l>>>7&31,i[n++]=l>>>12&31,i[n++]=l>>>17&31,i[n++]=l>>>22&31,i[n++]=l>>>27&31}}(e,t,i,r);break;case 6:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,r=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0,l=e[o++]>>>0,c=e[o++]>>>0;i[n++]=t>>>0&63,i[n++]=t>>>6&63,i[n++]=t>>>12&63,i[n++]=t>>>18&63,i[n++]=t>>>24&63,i[n++]=63&(t>>>30|(15&r)<<2),i[n++]=r>>>4&63,i[n++]=r>>>10&63,i[n++]=r>>>16&63,i[n++]=r>>>22&63,i[n++]=63&(r>>>28|(3&s)<<4),i[n++]=s>>>2&63,i[n++]=s>>>8&63,i[n++]=s>>>14&63,i[n++]=s>>>20&63,i[n++]=s>>>26&63,i[n++]=a>>>0&63,i[n++]=a>>>6&63,i[n++]=a>>>12&63,i[n++]=a>>>18&63,i[n++]=a>>>24&63,i[n++]=63&(a>>>30|(15&l)<<2),i[n++]=l>>>4&63,i[n++]=l>>>10&63,i[n++]=l>>>16&63,i[n++]=l>>>22&63,i[n++]=63&(l>>>28|(3&c)<<4),i[n++]=c>>>2&63,i[n++]=c>>>8&63,i[n++]=c>>>14&63,i[n++]=c>>>20&63,i[n++]=c>>>26&63}}(e,t,i,r);break;case 7:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,r=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0,l=e[o++]>>>0,c=e[o++]>>>0,h=e[o++]>>>0;i[n++]=t>>>0&127,i[n++]=t>>>7&127,i[n++]=t>>>14&127,i[n++]=t>>>21&127,i[n++]=127&(t>>>28|(7&r)<<4),i[n++]=r>>>3&127,i[n++]=r>>>10&127,i[n++]=r>>>17&127,i[n++]=r>>>24&127,i[n++]=127&(r>>>31|(63&s)<<1),i[n++]=s>>>6&127,i[n++]=s>>>13&127,i[n++]=s>>>20&127,i[n++]=127&(s>>>27|(3&a)<<5),i[n++]=a>>>2&127,i[n++]=a>>>9&127,i[n++]=a>>>16&127,i[n++]=a>>>23&127,i[n++]=127&(a>>>30|(31&l)<<2),i[n++]=l>>>5&127,i[n++]=l>>>12&127,i[n++]=l>>>19&127,i[n++]=127&(l>>>26|(1&c)<<6),i[n++]=c>>>1&127,i[n++]=c>>>8&127,i[n++]=c>>>15&127,i[n++]=c>>>22&127,i[n++]=127&(c>>>29|(15&h)<<3),i[n++]=h>>>4&127,i[n++]=h>>>11&127,i[n++]=h>>>18&127,i[n++]=h>>>25&127}}(e,t,i,r);break;case 8:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,r=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0,l=e[o++]>>>0,c=e[o++]>>>0,h=e[o++]>>>0,u=e[o++]>>>0;i[n++]=t>>>0&255,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=r>>>0&255,i[n++]=r>>>8&255,i[n++]=r>>>16&255,i[n++]=r>>>24&255,i[n++]=s>>>0&255,i[n++]=s>>>8&255,i[n++]=s>>>16&255,i[n++]=s>>>24&255,i[n++]=a>>>0&255,i[n++]=a>>>8&255,i[n++]=a>>>16&255,i[n++]=a>>>24&255,i[n++]=l>>>0&255,i[n++]=l>>>8&255,i[n++]=l>>>16&255,i[n++]=l>>>24&255,i[n++]=c>>>0&255,i[n++]=c>>>8&255,i[n++]=c>>>16&255,i[n++]=c>>>24&255,i[n++]=h>>>0&255,i[n++]=h>>>8&255,i[n++]=h>>>16&255,i[n++]=h>>>24&255,i[n++]=u>>>0&255,i[n++]=u>>>8&255,i[n++]=u>>>16&255,i[n++]=u>>>24&255}}(e,t,i,r);break;case 16:!function(e,t,i,r){let n=r,o=t;for(let t=0;t<128;t++){const t=e[o++]>>>0;i[n++]=65535&t,i[n++]=t>>>16&65535}}(e,t,i,r);break;default:!function(e,t,i,r,n){const o=rf[n]>>>0;let s=t,a=0,l=e[s]>>>0,c=r;for(let t=0;t<8;t++){for(let t=0;t<32;t++)if(a+n<=32)i[c+t]=l>>>a&o,a+=n,32===a&&(a=0,s++,31!==t&&(l=e[s]>>>0));else{const r=32-a,h=l>>>a;s++,l=e[s]>>>0;const u=n-r;i[c+t]=(h|(l&-1>>>32-u>>>0)<<r)&o,a=u}c+=32,a=0,t<7&&(l=e[s]>>>0)}}(e,t,i,r,n)}return t+(n<<3)|0}function uf(e,t,i,r){if(i+2>t)throw new Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${t})`);const n=e[i++],o=e[i++];if(n>32)throw new Error(`FastPFOR decode: invalid bitWidth=${n} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:n,exceptionCount:o,bytePosIn:i}}function df(e,t,i,r,n,o,s,a,l){const{maxBits:c,exceptionBitWidth:h,bytePosIn:u}=function(e,t,i,r,n,o){if(i+1>t)throw new Error(`FastPFOR decode: exception header underflow at block=${o} (need 1 byte for maxBits, bytePos=${i}, byteSize=${t})`);const s=e[i++];if(s<r||s>32)throw new Error(`FastPFOR decode: invalid maxBits=${s} at block=${o} (bitWidth=${r}, expected ${r}..32)`);const a=s-r|0;if(a<1||a>32)throw new Error(`FastPFOR decode: invalid exceptionBitWidth=${a} at block=${o} (bitWidth=${r}, maxBits=${s})`);if(i+n>t)throw new Error(`FastPFOR decode: exception positions underflow at block=${o} (need=${n}, have=${t-i})`);return{maxBits:s,exceptionBitWidth:a,bytePosIn:i}}(n,o,s,i,r,l);if(s=u,1===h){const o=1<<i;for(let i=0;i<r;i=i+1|0)e[n[s++]+t|0]|=o;return s}const d=a.dataToBePacked[h];if(!d)throw new Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${i}, maxBits=${c}) at block ${l}`);const p=a.dataPointers;let f=0|p[h];const m=0|a.exceptionSizes[h];if(f+r>m)throw new Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${r}, size=${m}) at block ${l}`);for(let o=0;o<r;o=o+1|0){const r=n[s++],o=0|d[f++];e[r+t|0]|=o<<i}return p[h]=f,s}function pf(e,t,i,r,n,o){const s=0|i,a=0|e[s];if(a<=0||s+a>e.length-1)throw new Error(`FastPFOR decode: invalid whereMeta=${a} at pageStart=${s} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);const l=s+1|0,c=s+a|0,h=e[c]>>>0,u=h+3>>>2,d=c+1,p=d+u;if(p>=e.length)throw new Error(`FastPFOR decode: invalid byteSize=${h} (metaInts=${u}, pageStart=${s}, packedEnd=${c}, byteContainerStart=${d}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);const f=function(e,t,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(2*i),r.byteContainerI32=void 0);const n=r.byteContainer,o=i>>>2;if(3&n.byteOffset)for(let i=0;i<o;i=i+1|0){const r=0|e[t+i|0],o=i<<2;n[o]=255&r,n[o+1|0]=r>>>8&255,n[o+2|0]=r>>>16&255,n[o+3|0]=r>>>24&255}else{let i=r.byteContainerI32;(!i||i.buffer!==n.buffer||i.byteOffset!==n.byteOffset||i.length<o)&&(i=r.byteContainerI32=new Int32Array(n.buffer,n.byteOffset,n.byteLength>>>2)),i.set(e.subarray(t,t+o))}const s=3&i;if(s>0){const i=0|e[t+o|0],r=o<<2;for(let e=0;e<s;e=e+1|0)n[r+e|0]=i>>>(e<<3)&255}return n}(e,d,h,o),m=h,_=function(e,t,i){const r=0|e[t++],n=i.dataToBePacked;for(let o=2;o<=32;o=o+1|0){if(!(r>>>o-1&1))continue;if(t>=e.length)throw new Error(`FastPFOR decode: truncated exception stream header (bitWidth=${o}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);const s=e[t++]>>>0,a=of(s+31,32),l=s*o+31>>>5;if(t+l>e.length)throw new Error(`FastPFOR decode: truncated exception stream (bitWidth=${o}, size=${s}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let c=n[o];(!c||c.length<a)&&(c=n[o]=new Uint32Array(a));let h=0;for(;h<s;h=h+32|0)ff(e,t,c,h,o),t=t+o|0;t=t-((h-s|0)*o>>>5)|0,i.exceptionSizes[o]=s}return t}(e,p,o);return o.dataPointers.fill(0),function(e,t,i,r,n,o,s,a,l,c){let h=0|i,u=0;for(let t=0;t<s;t=t+1|0){const i=uf(a,l,u,t);u=i.bytePosIn;const r=i.bitWidth,s=i.exceptionCount,d=o+t*nf|0;switch(r){case 0:n.fill(0,d,d+nf);break;case 32:for(let t=0;t<nf;t=t+1|0)n[d+t|0]=0|e[h+t|0];h=h+nf|0;break;default:h=hf(e,h,n,d,r)}s>0&&(u=df(n,d,r,s,a,l,u,c,t))}if(h!==r)throw new Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${h}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${e.length})`)}(e,s,l,c,t,0|r,n/nf|0,f,m,o),_}function ff(e,t,i,r,n){switch(n){case 2:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0;i[n++]=o>>>0&3,i[n++]=o>>>2&3,i[n++]=o>>>4&3,i[n++]=o>>>6&3,i[n++]=o>>>8&3,i[n++]=o>>>10&3,i[n++]=o>>>12&3,i[n++]=o>>>14&3,i[n++]=o>>>16&3,i[n++]=o>>>18&3,i[n++]=o>>>20&3,i[n++]=o>>>22&3,i[n++]=o>>>24&3,i[n++]=o>>>26&3,i[n++]=o>>>28&3,i[n++]=o>>>30&3,i[n++]=s>>>0&3,i[n++]=s>>>2&3,i[n++]=s>>>4&3,i[n++]=s>>>6&3,i[n++]=s>>>8&3,i[n++]=s>>>10&3,i[n++]=s>>>12&3,i[n++]=s>>>14&3,i[n++]=s>>>16&3,i[n++]=s>>>18&3,i[n++]=s>>>20&3,i[n++]=s>>>22&3,i[n++]=s>>>24&3,i[n++]=s>>>26&3,i[n++]=s>>>28&3,i[n]=s>>>30&3}(e,t,i,r);case 3:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0;i[n++]=o>>>0&7,i[n++]=o>>>3&7,i[n++]=o>>>6&7,i[n++]=o>>>9&7,i[n++]=o>>>12&7,i[n++]=o>>>15&7,i[n++]=o>>>18&7,i[n++]=o>>>21&7,i[n++]=o>>>24&7,i[n++]=o>>>27&7,i[n++]=7&(o>>>30|(1&s)<<2),i[n++]=s>>>1&7,i[n++]=s>>>4&7,i[n++]=s>>>7&7,i[n++]=s>>>10&7,i[n++]=s>>>13&7,i[n++]=s>>>16&7,i[n++]=s>>>19&7,i[n++]=s>>>22&7,i[n++]=s>>>25&7,i[n++]=s>>>28&7,i[n++]=7&(s>>>31|(3&a)<<1),i[n++]=a>>>2&7,i[n++]=a>>>5&7,i[n++]=a>>>8&7,i[n++]=a>>>11&7,i[n++]=a>>>14&7,i[n++]=a>>>17&7,i[n++]=a>>>20&7,i[n++]=a>>>23&7,i[n++]=a>>>26&7,i[n]=a>>>29&7}(e,t,i,r);case 4:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0;i[n++]=o>>>0&15,i[n++]=o>>>4&15,i[n++]=o>>>8&15,i[n++]=o>>>12&15,i[n++]=o>>>16&15,i[n++]=o>>>20&15,i[n++]=o>>>24&15,i[n++]=o>>>28&15,i[n++]=s>>>0&15,i[n++]=s>>>4&15,i[n++]=s>>>8&15,i[n++]=s>>>12&15,i[n++]=s>>>16&15,i[n++]=s>>>20&15,i[n++]=s>>>24&15,i[n++]=s>>>28&15,i[n++]=a>>>0&15,i[n++]=a>>>4&15,i[n++]=a>>>8&15,i[n++]=a>>>12&15,i[n++]=a>>>16&15,i[n++]=a>>>20&15,i[n++]=a>>>24&15,i[n++]=a>>>28&15,i[n++]=l>>>0&15,i[n++]=l>>>4&15,i[n++]=l>>>8&15,i[n++]=l>>>12&15,i[n++]=l>>>16&15,i[n++]=l>>>20&15,i[n++]=l>>>24&15,i[n]=l>>>28&15}(e,t,i,r);case 5:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0;i[n++]=o>>>0&31,i[n++]=o>>>5&31,i[n++]=o>>>10&31,i[n++]=o>>>15&31,i[n++]=o>>>20&31,i[n++]=o>>>25&31,i[n++]=31&(o>>>30|(7&s)<<2),i[n++]=s>>>3&31,i[n++]=s>>>8&31,i[n++]=s>>>13&31,i[n++]=s>>>18&31,i[n++]=s>>>23&31,i[n++]=31&(s>>>28|(1&a)<<4),i[n++]=a>>>1&31,i[n++]=a>>>6&31,i[n++]=a>>>11&31,i[n++]=a>>>16&31,i[n++]=a>>>21&31,i[n++]=a>>>26&31,i[n++]=31&(a>>>31|(15&l)<<1),i[n++]=l>>>4&31,i[n++]=l>>>9&31,i[n++]=l>>>14&31,i[n++]=l>>>19&31,i[n++]=l>>>24&31,i[n++]=31&(l>>>29|(3&c)<<3),i[n++]=c>>>2&31,i[n++]=c>>>7&31,i[n++]=c>>>12&31,i[n++]=c>>>17&31,i[n++]=c>>>22&31,i[n]=c>>>27&31}(e,t,i,r);case 6:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0;i[n++]=o>>>0&63,i[n++]=o>>>6&63,i[n++]=o>>>12&63,i[n++]=o>>>18&63,i[n++]=o>>>24&63,i[n++]=63&(o>>>30|(15&s)<<2),i[n++]=s>>>4&63,i[n++]=s>>>10&63,i[n++]=s>>>16&63,i[n++]=s>>>22&63,i[n++]=63&(s>>>28|(3&a)<<4),i[n++]=a>>>2&63,i[n++]=a>>>8&63,i[n++]=a>>>14&63,i[n++]=a>>>20&63,i[n++]=a>>>26&63,i[n++]=l>>>0&63,i[n++]=l>>>6&63,i[n++]=l>>>12&63,i[n++]=l>>>18&63,i[n++]=l>>>24&63,i[n++]=63&(l>>>30|(15&c)<<2),i[n++]=c>>>4&63,i[n++]=c>>>10&63,i[n++]=c>>>16&63,i[n++]=c>>>22&63,i[n++]=63&(c>>>28|(3&h)<<4),i[n++]=h>>>2&63,i[n++]=h>>>8&63,i[n++]=h>>>14&63,i[n++]=h>>>20&63,i[n]=h>>>26&63}(e,t,i,r);case 7:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0;i[n++]=o>>>0&127,i[n++]=o>>>7&127,i[n++]=o>>>14&127,i[n++]=o>>>21&127,i[n++]=127&(o>>>28|(7&s)<<4),i[n++]=s>>>3&127,i[n++]=s>>>10&127,i[n++]=s>>>17&127,i[n++]=s>>>24&127,i[n++]=127&(s>>>31|(63&a)<<1),i[n++]=a>>>6&127,i[n++]=a>>>13&127,i[n++]=a>>>20&127,i[n++]=127&(a>>>27|(3&l)<<5),i[n++]=l>>>2&127,i[n++]=l>>>9&127,i[n++]=l>>>16&127,i[n++]=l>>>23&127,i[n++]=127&(l>>>30|(31&c)<<2),i[n++]=c>>>5&127,i[n++]=c>>>12&127,i[n++]=c>>>19&127,i[n++]=127&(c>>>26|(1&h)<<6),i[n++]=h>>>1&127,i[n++]=h>>>8&127,i[n++]=h>>>15&127,i[n++]=h>>>22&127,i[n++]=127&(h>>>29|(15&u)<<3),i[n++]=u>>>4&127,i[n++]=u>>>11&127,i[n++]=u>>>18&127,i[n]=u>>>25&127}(e,t,i,r);case 8:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0;i[n++]=o>>>0&255,i[n++]=o>>>8&255,i[n++]=o>>>16&255,i[n++]=o>>>24&255,i[n++]=s>>>0&255,i[n++]=s>>>8&255,i[n++]=s>>>16&255,i[n++]=s>>>24&255,i[n++]=a>>>0&255,i[n++]=a>>>8&255,i[n++]=a>>>16&255,i[n++]=a>>>24&255,i[n++]=l>>>0&255,i[n++]=l>>>8&255,i[n++]=l>>>16&255,i[n++]=l>>>24&255,i[n++]=c>>>0&255,i[n++]=c>>>8&255,i[n++]=c>>>16&255,i[n++]=c>>>24&255,i[n++]=h>>>0&255,i[n++]=h>>>8&255,i[n++]=h>>>16&255,i[n++]=h>>>24&255,i[n++]=u>>>0&255,i[n++]=u>>>8&255,i[n++]=u>>>16&255,i[n++]=u>>>24&255,i[n++]=d>>>0&255,i[n++]=d>>>8&255,i[n++]=d>>>16&255,i[n]=d>>>24&255}(e,t,i,r);case 9:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0;i[n++]=o>>>0&511,i[n++]=o>>>9&511,i[n++]=o>>>18&511,i[n++]=511&(o>>>27|(15&s)<<5),i[n++]=s>>>4&511,i[n++]=s>>>13&511,i[n++]=s>>>22&511,i[n++]=511&(s>>>31|(255&a)<<1),i[n++]=a>>>8&511,i[n++]=a>>>17&511,i[n++]=511&(a>>>26|(7&l)<<6),i[n++]=l>>>3&511,i[n++]=l>>>12&511,i[n++]=l>>>21&511,i[n++]=511&(l>>>30|(127&c)<<2),i[n++]=c>>>7&511,i[n++]=c>>>16&511,i[n++]=511&(c>>>25|(3&h)<<7),i[n++]=h>>>2&511,i[n++]=h>>>11&511,i[n++]=h>>>20&511,i[n++]=511&(h>>>29|(63&u)<<3),i[n++]=u>>>6&511,i[n++]=u>>>15&511,i[n++]=511&(u>>>24|(1&d)<<8),i[n++]=d>>>1&511,i[n++]=d>>>10&511,i[n++]=d>>>19&511,i[n++]=511&(d>>>28|(31&p)<<4),i[n++]=p>>>5&511,i[n++]=p>>>14&511,i[n]=p>>>23&511}(e,t,i,r);case 10:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0;i[n++]=o>>>0&1023,i[n++]=o>>>10&1023,i[n++]=o>>>20&1023,i[n++]=1023&(o>>>30|(255&s)<<2),i[n++]=s>>>8&1023,i[n++]=s>>>18&1023,i[n++]=1023&(s>>>28|(63&a)<<4),i[n++]=a>>>6&1023,i[n++]=a>>>16&1023,i[n++]=1023&(a>>>26|(15&l)<<6),i[n++]=l>>>4&1023,i[n++]=l>>>14&1023,i[n++]=1023&(l>>>24|(3&c)<<8),i[n++]=c>>>2&1023,i[n++]=c>>>12&1023,i[n++]=c>>>22&1023,i[n++]=h>>>0&1023,i[n++]=h>>>10&1023,i[n++]=h>>>20&1023,i[n++]=1023&(h>>>30|(255&u)<<2),i[n++]=u>>>8&1023,i[n++]=u>>>18&1023,i[n++]=1023&(u>>>28|(63&d)<<4),i[n++]=d>>>6&1023,i[n++]=d>>>16&1023,i[n++]=1023&(d>>>26|(15&p)<<6),i[n++]=p>>>4&1023,i[n++]=p>>>14&1023,i[n++]=1023&(p>>>24|(3&f)<<8),i[n++]=f>>>2&1023,i[n++]=f>>>12&1023,i[n]=f>>>22&1023}(e,t,i,r);case 11:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=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[n++]=o>>>0&2047,i[n++]=o>>>11&2047,i[n++]=2047&(o>>>22|(1&s)<<10),i[n++]=s>>>1&2047,i[n++]=s>>>12&2047,i[n++]=2047&(s>>>23|(3&a)<<9),i[n++]=a>>>2&2047,i[n++]=a>>>13&2047,i[n++]=2047&(a>>>24|(7&l)<<8),i[n++]=l>>>3&2047,i[n++]=l>>>14&2047,i[n++]=2047&(l>>>25|(15&c)<<7),i[n++]=c>>>4&2047,i[n++]=c>>>15&2047,i[n++]=2047&(c>>>26|(31&h)<<6),i[n++]=h>>>5&2047,i[n++]=h>>>16&2047,i[n++]=2047&(h>>>27|(63&u)<<5),i[n++]=u>>>6&2047,i[n++]=u>>>17&2047,i[n++]=2047&(u>>>28|(127&d)<<4),i[n++]=d>>>7&2047,i[n++]=d>>>18&2047,i[n++]=2047&(d>>>29|(255&p)<<3),i[n++]=p>>>8&2047,i[n++]=p>>>19&2047,i[n++]=2047&(p>>>30|(511&f)<<2),i[n++]=f>>>9&2047,i[n++]=f>>>20&2047,i[n++]=2047&(f>>>31|(1023&m)<<1),i[n++]=m>>>10&2047,i[n]=m>>>21&2047}(e,t,i,r);case 12:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,_=e[t+11]>>>0;i[n++]=o>>>0&4095,i[n++]=o>>>12&4095,i[n++]=4095&(o>>>24|(15&s)<<8),i[n++]=s>>>4&4095,i[n++]=s>>>16&4095,i[n++]=4095&(s>>>28|(255&a)<<4),i[n++]=a>>>8&4095,i[n++]=a>>>20&4095,i[n++]=l>>>0&4095,i[n++]=l>>>12&4095,i[n++]=4095&(l>>>24|(15&c)<<8),i[n++]=c>>>4&4095,i[n++]=c>>>16&4095,i[n++]=4095&(c>>>28|(255&h)<<4),i[n++]=h>>>8&4095,i[n++]=h>>>20&4095,i[n++]=u>>>0&4095,i[n++]=u>>>12&4095,i[n++]=4095&(u>>>24|(15&d)<<8),i[n++]=d>>>4&4095,i[n++]=d>>>16&4095,i[n++]=4095&(d>>>28|(255&p)<<4),i[n++]=p>>>8&4095,i[n++]=p>>>20&4095,i[n++]=f>>>0&4095,i[n++]=f>>>12&4095,i[n++]=4095&(f>>>24|(15&m)<<8),i[n++]=m>>>4&4095,i[n++]=m>>>16&4095,i[n++]=4095&(m>>>28|(255&_)<<4),i[n++]=_>>>8&4095,i[n]=_>>>20&4095}(e,t,i,r);case 16:return void function(e,t,i,r){let n=r;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,_=e[t+11]>>>0,g=e[t+12]>>>0,y=e[t+13]>>>0,v=e[t+14]>>>0,x=e[t+15]>>>0;i[n++]=o>>>0&65535,i[n++]=o>>>16&65535,i[n++]=s>>>0&65535,i[n++]=s>>>16&65535,i[n++]=a>>>0&65535,i[n++]=a>>>16&65535,i[n++]=l>>>0&65535,i[n++]=l>>>16&65535,i[n++]=c>>>0&65535,i[n++]=c>>>16&65535,i[n++]=h>>>0&65535,i[n++]=h>>>16&65535,i[n++]=u>>>0&65535,i[n++]=u>>>16&65535,i[n++]=d>>>0&65535,i[n++]=d>>>16&65535,i[n++]=p>>>0&65535,i[n++]=p>>>16&65535,i[n++]=f>>>0&65535,i[n++]=f>>>16&65535,i[n++]=m>>>0&65535,i[n++]=m>>>16&65535,i[n++]=_>>>0&65535,i[n++]=_>>>16&65535,i[n++]=g>>>0&65535,i[n++]=g>>>16&65535,i[n++]=y>>>0&65535,i[n++]=y>>>16&65535,i[n++]=v>>>0&65535,i[n++]=v>>>16&65535,i[n++]=x>>>0&65535,i[n]=x>>>16&65535}(e,t,i,r);case 32:for(let n=0;n<32;n=n+1|0)i[r+n|0]=0|e[t+n|0];return}const o=rf[n]>>>0;let s=t,a=0,l=e[s]>>>0;for(let t=0;t<32;t++)if(a+n<=32)i[r+t]=l>>>a&o,a+=n,32===a&&(a=0,s++,31!==t&&(l=e[s]>>>0));else{const c=32-a,h=l>>>a;s++,l=e[s]>>>0,i[r+t]=(h|(l&rf[n-c]>>>0)<<c)&o,a=n-c}}function mf(e,t,i){const r=new Uint32Array(i);let n=0,o=t.get();for(let t=0;t<r.length;t++){let t=e[o++],i=127&t;t<128||(t=e[o++],i|=(127&t)<<7,t<128||(t=e[o++],i|=(127&t)<<14,t<128||(t=e[o++],i|=(127&t)<<21,t<128||(t=e[o++],i|=(15&t)<<28)))),r[n++]=i}return t.set(o),r}function _f(e,t,i){const r=new BigUint64Array(i);for(let i=0;i<r.length;i++)r[i]=gf(e,t);return r}function gf(e,t){let i=0n,r=0,n=t.get();for(;n<e.length;){const t=e[n++];if(i|=BigInt(127&t)<<BigInt(r),!(128&t))break;if(r+=7,r>=64)throw new Error("Varint too long")}return t.set(n),i}function yf(e,t){let i,r;return r=e[t.get()],t.increment(),i=127&r,r<128?i:(r=e[t.get()],t.increment(),i|=(127&r)<<7,r<128?i:(r=e[t.get()],t.increment(),i|=(127&r)<<14,r<128?i:(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,n;if(n=t[i.get()],i.increment(),r=(112&n)>>4,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<3,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<10,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<17,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<24,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(1&n)<<31,n<128)return 4294967296*r+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,e,t)))))}function vf(e){return e>>>1^-(1&e)}function xf(e){return e>>1n^-(1n&e)}function bf(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]}const r=new Uint32Array(i);let n=0;for(let i=0;i<t;i++){const o=e[i];r.fill(e[i+t],n,n+o),n+=o}return r}function Tf(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=Number(e[r])}const r=new BigUint64Array(i);let n=0;for(let i=0;i<t;i++){const o=Number(e[i]);r.fill(e[i+t],n,n+o),n+=o}return r}function Sf(e,t,i){const r=new Float64Array(i);let n=0;for(let i=0;i<t;i++){const o=e[i];r.fill(e[i+t],n,n+o),n+=o}return r}function Pf(e){const t=new Int32Array(e.length);t[0]=vf(e[0]);const i=e.length/4*4;let r=1;if(i>=4)for(;r<i-4;r+=4){const i=e[r+1],n=e[r+2],o=e[r+3];t[r]=vf(e[r])+t[r-1],t[r+1]=vf(i)+t[r],t[r+2]=vf(n)+t[r+1],t[r+3]=vf(o)+t[r+2]}for(;r!==e.length;++r)t[r]=vf(e[r])+t[r-1];return t}function If(e){const t=new BigInt64Array(e.length);t[0]=xf(e[0]);const i=e.length/4*4;let r=1;if(i>=4)for(;r<i-4;r+=4){const i=e[r+1],n=e[r+2],o=e[r+3];t[r]=xf(e[r])+t[r-1],t[r+1]=xf(i)+t[r],t[r+2]=xf(n)+t[r+1],t[r+3]=xf(o)+t[r+2]}for(;r!==t.length;++r)t[r]=xf(e[r])+t[r-1];return t}function Mf(e){const t=e.length/4*4;let 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}var Ef,Cf,Af,zf,Df,Rf,kf,Lf;function Ff(e,t){const i=function(e,t){const i=e[t.get()],r=Object.values(Ef)[i>>4];let n=null;switch(r){case Ef.DATA:n={dictionaryType:Object.values(Cf)[15&i]};break;case Ef.OFFSET:n={offsetType:Object.values(Af)[15&i]};break;case Ef.LENGTH:n={lengthType:Object.values(zf)[15&i]}}t.increment();const o=e[t.get()],s=Object.values(Qp)[o>>5],a=Object.values(Qp)[o>>2&7],l=Object.values(ef)[3&o];t.increment();const c=mf(e,t,2),h=c[0];return{physicalStreamType:r,logicalStreamType:n,logicalLevelTechnique1:s,logicalLevelTechnique2:a,physicalLevelTechnique:l,numValues:h,byteLength:c[1],decompressedCount:h}}(e,t);return i.logicalLevelTechnique1===Qp.MORTON?function(e,t,i){const r=mf(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):Qp.RLE!==i.logicalLevelTechnique1&&Qp.RLE!==i.logicalLevelTechnique2||ef.NONE===i.physicalLevelTechnique?i:function(e,t,i){const r=mf(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)}!function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(Ef||(Ef={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Cf||(Cf={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Af||(Af={})),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"}(zf||(zf={})),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"}(Df||(Df={}));class Bf{constructor(e,t){this.values=e,this._size=t}get(e){const t=Math.floor(e/8);return 1==(this.values[t]>>e%8&1)}set(e,t){const i=Math.floor(e/8);this.values[i]=this.values[i]|(t?1:0)<<e%8}getInt(e){const t=Math.floor(e/8);return this.values[t]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Of(e,t,i){if(!t)return e;const r=t.size(),n=new(0,e.constructor)(r);let o=0;for(let s=0;s<r;s++)n[s]=t.get(s)?e[o++]:i;return n}function Vf(e,t,i,r,n){return function(e,t,i,r){let n;switch(t.logicalLevelTechnique1){case Qp.DELTA:if(t.logicalLevelTechnique2===Qp.RLE){const i=t;if(!r)return function(e,t,i){const r=new Int32Array(i);let n=0,o=0;for(let i=0;i<t;i++){const s=e[i],a=vf(e[i+t]);for(let e=0;e<s;e++)o+=a,r[n++]=o}return r}(e,i.runs,i.numRleValues);n=Pf(e=wf(e,i.runs,i.numRleValues))}else n=Pf(e);break;case Qp.RLE:n=function(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=e[r]}const r=new Int32Array(i);let n=0;for(let i=0;i<t;i++){const o=e[i];let s=e[i+t];s=vf(s),r.fill(s,n,n+o),n+=o}return r}(e,t.runs,t.numRleValues);break;case Qp.MORTON:Mf(e),n=new Int32Array(e);break;case Qp.COMPONENTWISE_DELTA:n=function(e){if(e.length<2)return new Int32Array(e);const t=new Int32Array(e.length);t[0]=vf(e[0]),t[1]=vf(e[1]);const i=e.length/4*4;let r=2;if(i>=4)for(;r<i-4;r+=4){const i=e[r+1],n=e[r+2],o=e[r+3];t[r]=vf(e[r])+t[r-2],t[r+1]=vf(i)+t[r-1],t[r+2]=vf(n)+t[r],t[r+3]=vf(o)+t[r+1]}for(;r!==e.length;r+=2)t[r]=vf(e[r])+t[r-2],t[r+1]=vf(e[r+1])+t[r-1];return t}(e);break;case Qp.NONE:n=function(e){const t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=vf(e[i]);return t}(e);break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Of(n,r,0):n}(Uf(e,t,i),i,0,n)}function jf(e,t,i,r,n){return function(e,t,i,r){let n;switch(t.logicalLevelTechnique1){case Qp.DELTA:n=function(e){const t=new Uint32Array(e.length);t[0]=vf(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+vf(e[i])>>>0;return t}(t.logicalLevelTechnique2===Qp.RLE?wf(e,t.runs,t.numRleValues):e);break;case Qp.RLE:n=wf(e,t.runs,t.numRleValues);break;case Qp.MORTON:Mf(e),n=e;break;case Qp.COMPONENTWISE_DELTA:n=function(e){if(e.length<2)return new Uint32Array(e);const t=new Uint32Array(e.length);t[0]=vf(e[0])>>>0,t[1]=vf(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+vf(e[i])>>>0,t[i+1]=t[i-1]+vf(e[i+1])>>>0;return t}(e);break;case Qp.NONE:n=e;break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Of(n,r,0):n}(Uf(e,t,i),i,0,n)}function Nf(e,t,i){return function(e,t){if(t.logicalLevelTechnique1===Qp.DELTA&&t.logicalLevelTechnique2===Qp.NONE)return function(e){const t=new Int32Array(e.length+1);t[0]=0,t[1]=vf(e[0]);let i=t[1];for(let r=2;r!==t.length;++r)i+=vf(e[r-1]),t[r]=t[r-1]+i;return new Uint32Array(t)}(e);if(t.logicalLevelTechnique1===Qp.RLE&&t.logicalLevelTechnique2===Qp.NONE)return function(e,t,i){const r=new Uint32Array(i+1);r[0]=0;let n=1,o=r[0];for(let i=0;i<t;i++){const s=e[i],a=e[i+t];for(let e=n;e<n+s;e++)r[e]=a+o,o=r[e];n+=s}return r}(e,t.runs,t.numRleValues);if(t.logicalLevelTechnique1===Qp.NONE&&t.logicalLevelTechnique2===Qp.NONE){!function(e){let t=0;for(let i=0;i<e.length;i++)e[i]+=t,t=e[i]}(e);const i=new Uint32Array(t.numValues+1);return i[0]=0,i.set(e,1),i}if(t.logicalLevelTechnique1===Qp.DELTA&&t.logicalLevelTechnique2===Qp.RLE){const i=function(e,t,i){const r=new Int32Array(i+1);r[0]=0;let n=1,o=r[0];for(let i=0;i<t;i++){const s=e[i];let a=e[i+t];a=vf(a);for(let e=n;e<n+s;e++)r[e]=a+o,o=r[e];n+=s}return r}(e,t.runs,t.numRleValues);return Mf(i),new Uint32Array(i)}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")}(Uf(e,t,i),i)}function Uf(e,t,i){const r=i.physicalLevelTechnique;switch(r){case ef.FAST_PFOR:return function(e,t,i,r){return function(e,t,i,r,n){const o=r.get();if(3&i)throw new Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${o} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);const s=i>>>2,a=function(e,t){if(t<=e.encodedWords.length)return e.encodedWords;const i=new Uint32Array(Math.max(16,2*t));return e.encodedWords=i,i}(n,s);!function(e,t,i,r){if(t<0||i<0||t+i>e.length)throw new RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${i}, bytes.length=${e.length})`);const n=Math.floor(i/4),o=i%4!=0,s=o?n+1:n;if(r.length<s)throw new RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${s}`);if(n>0){const i=e.byteOffset+t;if(3&i)for(let i=0;i<n;i++){const n=t+4*i;r[i]=e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3]}else{const t=new Uint32Array(e.buffer,i,n);for(let e=0;e<n;e++)r[e]=0|sf(t[e])}}if(o){const o=t+4*n,s=i-4*n;let a=0;for(let t=0;t<s;t++)a|=e[o+t]<<24-8*t;r[n]=0|a}}(e,o,i,a);const l=function(e,t,i){let r=0,n=0;const o=new Uint32Array(t),s=i??cf();if(e.length>0){const t=0|e[r];if(r=r+1|0,255&t)throw new Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(n+t>o.length)throw new Error(`FastPFOR decode: output buffer too small (outPos=${n}, alignedLength=${t}, out.length=${o.length})`);r=function(e,t,i,r,n,o){const s=r+of(n,nf);let a=r,l=i;for(;a!==s;){const i=Math.min(af,s-a);l=pf(e,t,l,a,i,o),a=a+i|0}return l}(e,o,r,n,t,s),n=n+t|0}return function(e,t,i,r,n,o){if(0===o)return t;let s=0,a=t;const l=t+i,c=n;let h=n;const u=n+o;let d=0,p=0;for(;a<l&&h<u;){const t=e[a]>>>s&255;if(s+=8,a+=s>>>5,s&=31,d|=(127&t)<<p,128&t)r[h++]=0|d,d=0,p=0;else if(p+=7,p>28)throw new Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${d}, decoded=${h-c}/${o}, inPos=${a}, inEnd=${l})`)}if(h!==u)throw new Error(`FastPFOR VByte: truncated stream (decoded=${h-c}, expected=${o}, consumedWords=${a-t}/${i}, vbyteStart=${t}, vbyteEnd=${l})`)}(e,r,e.length-r|0,o,n,t-n|0),o}(a.subarray(0,s),t,n.decoderWorkspace);return r.add(i),l}(e,t,i,r,function(e=16){if(e<0)throw new RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);const t=Math.max(16,0|e);return{encodedWords:new Uint32Array(t),decoderWorkspace:cf()}}(i>>>2))}(e,i.numValues,i.byteLength,t);case ef.VARINT:return mf(e,t,i.numValues);case ef.NONE:{const r=t.get();t.add(i.byteLength);const n=e.subarray(r,t.get());return new Uint32Array(n)}default:throw new Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function Gf(e,t,i){const r=Uf(e,t,i);return 1===r.length?r[0]:function(e){return e[1]}(r)}function $f(e,t,i){return function(e){if(2===e.length){const t=vf(e[1]);return[t,t]}return[vf(e[2]),vf(e[3])]}(Uf(e,t,i))}function Zf(e,t,i){return function(e){if(2===e.length){const t=xf(e[1]);return[t,t]}return[xf(e[2]),xf(e[3])]}(_f(e,t,i.numValues))}function qf(e,t,i,r){return function(e,t,i){let r;switch(t.logicalLevelTechnique1){case Qp.DELTA:r=function(e){const t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,xf(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+xf(e[i]));return t}(t.logicalLevelTechnique2===Qp.RLE?Tf(e,t.runs,t.numRleValues):e);break;case Qp.RLE:r=Tf(e,t.runs,t.numRleValues);break;case Qp.NONE:r=e;break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?Of(r,i,0n):r}(_f(e,t,i.numValues),i,r)}function Wf(e,t,i){const r=_f(e,t,i.numValues);return 1===r.length?r[0]:function(e){return e[1]}(r)}function Hf(e,t,i,r,n="int32"){const o=e.logicalLevelTechnique1;if(o===Qp.RLE)return 1===e.runs?Df.CONST:Df.FLAT;if(o!==Qp.DELTA||e.logicalLevelTechnique2!==Qp.RLE)return 1===e.numValues?Df.CONST:Df.FLAT;const s=t instanceof Bf?t.size():t;if(e.numRleValues!==s)return Df.FLAT;if(1===e.runs)return Df.SEQUENCE;if(2!==e.runs)return 1===e.numValues?Df.CONST:Df.FLAT;const a=r.get();if(e.physicalLevelTechnique===ef.VARINT)return function(e,t,i){const r=new Jp(t.get());if("int64"===i){const t=_f(e,r,4);return 2n===t[2]&&2n===t[3]}const n=mf(e,r,4);return 2===n[2]&&2===n[3]}(i,r,n)?Df.SEQUENCE:1===e.numValues?Df.CONST:Df.FLAT;const l=r.get(),c=new Int32Array(i.buffer,i.byteOffset+l,4);return r.set(a),2===c[2]&&2===c[3]?Df.SEQUENCE:1===e.numValues?Df.CONST:Df.FLAT}class Xf extends Zp{getValueFromBuffer(e){return this.dataBuffer[e]}}class Yf extends Hp{constructor(e,t,i,r){super(e,BigInt64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}function Kf(e,t,i){return{x:Jf(e,t)-i,y:Jf(e>>1,t)-i}}function Jf(e,t){let i=0;for(let r=0;r<t;r++)i|=(e&1<<2*r)>>r;return i}function Qf(e,t,i,r,n,s,a){return e===Lf.MORTON?function(e,t,i,r,n,s){const a=new Array(n?r+1:r);for(let n=0;n<r;n++){const r=Kf(e[t[i+n]],s.numBits,s.coordinateShift);a[n]=new o(r.x,r.y)}return n&&(a[a.length-1]=a[0]),a}(t,i,r,n,s,a):function(e,t,i,r,n){const s=new Array(n?r+1:r);for(let n=0;n<2*r;n+=2){const r=2*t[i+n/2];s[n/2]=new o(e[r],e[r+1])}return n&&(s[s.length-1]=s[0]),s}(t,i,r,n,s)}function em(e,t,i,r){const n=new Array(r?i+1:i);for(let r=0;r<2*i;r+=2)n[r/2]=new o(e[t+r],e[t+r+1]);return r&&(n[n.length-1]=n[0]),n}!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"}(Rf||(Rf={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(kf||(kf={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(Lf||(Lf={}));class tm{constructor(e,t,i,r,n){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=n}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){const t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){const t=Kf(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[t.x,t.y]}const t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return function(e){const t=new Array(e.numGeometries);let i=1,r=1,n=1,s=0,a=0,l=0;const c=e.mortonSettings,h=e.topologyVector,u=h.geometryOffsets,d=h.partOffsets,p=h.ringOffsets,f=e.vertexOffsets,m=!f||0===f.length,_=e.containsPolygonGeometry(),g=e.vertexBuffer;for(let h=0;h<e.numGeometries;h++)switch(e.geometryType(h)){case Rf.POINT:{let h,_;if(m)h=g[a++],_=g[a++];else if(e.vertexBufferType===Lf.MORTON){const e=Kf(g[f[l++]],c.numBits,c.coordinateShift);h=e.x,_=e.y}else{const e=2*f[l++];h=g[e],_=g[e+1]}t[s++]=[[new o(h,_)]],u&&n++,d&&i++,p&&r++}break;case Rf.MULTIPOINT:{const e=u[n]-u[n-1];n++;const c=new Array(e);if(m)for(let t=0;t<e;t++){const e=g[a++],i=g[a++];c[t]=new o(e,i)}else for(let t=0;t<e;t++){const e=2*f[l++];c[t]=new o(g[e],g[e+1])}t[s++]=c.map((e=>[e])),i+=e,r+=e}break;case Rf.LINESTRING:{let o,h;_?(o=p[r]-p[r-1],r++):o=d[i]-d[i-1],i++,m?(h=em(g,a,o,!1),a+=2*o):(h=Qf(e.vertexBufferType,g,f,l,o,!1,c),l+=o),t[s++]=[h],u&&n++}break;case Rf.POLYGON:{const o=d[i]-d[i-1];i++;const h=new Array(o-1);let _,y=p[r]-p[r-1];if(r++,m){_=em(g,a,y,!0),a+=2*y;for(let e=0;e<h.length;e++)y=p[r]-p[r-1],r++,h[e]=em(g,a,y,!0),a+=2*y}else{_=Qf(e.vertexBufferType,g,f,l,y,!0,c),l+=y;for(let t=0;t<h.length;t++)y=p[r]-p[r-1],r++,h[t]=Qf(e.vertexBufferType,g,f,l,y,!0,c),l+=y}t[s++]=[_].concat(h),u&&n++}break;case Rf.MULTILINESTRING:{const o=u[n]-u[n-1];n++;const h=new Array(o);for(let t=0;t<o;t++){let n;if(_?(n=p[r]-p[r-1],r++):n=d[i]-d[i-1],i++,m)h[t]=em(g,a,n,!1),a+=2*n;else{const i=Qf(e.vertexBufferType,g,f,l,n,!1,c);h[t]=i,l+=n}}t[s++]=h}break;case Rf.MULTIPOLYGON:{const o=u[n]-u[n-1];n++;const h=new Array(o);for(let t=0;t<o;t++){const n=d[i]-d[i-1];let o;i++;const s=new Array(n-1),u=p[r]-p[r-1];r++,m?(o=em(g,a,u,!0),a+=2*u):(o=Qf(e.vertexBufferType,g,f,l,u,!0,c),l+=u);for(let t=0;t<s.length;t++){const i=p[r]-p[r-1];r++,m?(s[t]=em(g,a,i,!0),a+=2*i):(s[t]=Qf(e.vertexBufferType,g,f,l,i,!0,c),l+=i)}h[t]=[o].concat(s)}t[s++]=h.flat()}break;default:throw new Error("The specified geometry type is currently not supported.")}return t}(this)}get mortonSettings(){return this._mortonSettings}}class im extends tm{constructor(e,t,i,r,n,o,s){super(i,r,n,o,s),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Rf.POLYGON||this._geometryType===Rf.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class rm extends tm{constructor(e,t,i,r,n,o){super(e,i,r,n,o),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)===Rf.POLYGON||this.geometryType(e)===Rf.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class nm{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 new Error("Cannot convert GpuVector to coordinates without topology information");const e=new Array(this.numGeometries),t=this._topologyVector,i=t.partOffsets,r=t.ringOffsets,n=t.geometryOffsets;let s=0,a=1,l=1,c=1;for(let t=0;t<this.numGeometries;t++)switch(this.geometryType(t)){case Rf.POLYGON:{const h=i[a]-i[a-1];a++;const u=[];for(let e=0;e<h;e++){const e=r[l]-r[l-1];l++;const t=[];for(let i=0;i<e;i++){const e=this._vertexBuffer[s++],i=this._vertexBuffer[s++];t.push(new o(e,i))}t.length>0&&t.push(t[0]),u.push(t)}e[t]=u,n&&c++}break;case Rf.MULTIPOLYGON:{const h=n[c]-n[c-1];c++;const u=[];for(let e=0;e<h;e++){const e=i[a]-i[a-1];a++;for(let t=0;t<e;t++){const e=r[l]-r[l-1];l++;const t=[];for(let i=0;i<e;i++){const e=this._vertexBuffer[s++],i=this._vertexBuffer[s++];t.push(new o(e,i))}t.length>0&&t.push(t[0]),u.push(t)}}e[t]=u}}return e}[Symbol.iterator](){return null}}function om(e,t,i,r,n,o){return new sm(e,t,i,r,n,o)}class sm extends nm{constructor(e,t,i,r,n,o){super(i,r,n,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function am(e,t,i,r,n){return new lm(e,t,i,r,n)}class lm extends nm{constructor(e,t,i,r,n){super(t,i,r,n),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function cm(e,t,i,r,n){const o=Ff(e,i);let s,a,l,c;if(Hf(o,r,e,i)===Df.CONST){const n=Gf(e,i,o);let h,u,d,p;for(let r=0;r<t-1;r++){const t=Ff(e,i);switch(t.physicalStreamType){case Ef.LENGTH:switch(t.logicalStreamType.lengthType){case zf.GEOMETRIES:h=Nf(e,i,t);break;case zf.PARTS:u=Nf(e,i,t);break;case zf.RINGS:d=Nf(e,i,t);break;case zf.TRIANGLES:p=Nf(e,i,t)}break;case Ef.OFFSET:switch(t.logicalStreamType.offsetType){case Af.VERTEX:s=jf(e,i,t);break;case Af.INDEX:c=jf(e,i,t)}break;case Ef.DATA:Cf.VERTEX===t.logicalStreamType.dictionaryType?a=Vf(e,i,t):(l={numBits:t.numBits,coordinateShift:t.coordinateShift},a=jf(e,i,t))}}return c?void 0!==h||void 0!==u?om(r,n,p,c,a,{geometryOffsets:h,partOffsets:u,ringOffsets:d}):om(r,n,p,c,a):void 0===l?function(e,t,i,r,n){return new im(e,t,Lf.VEC_2,i,r,n)}(r,n,{geometryOffsets:h,partOffsets:u,ringOffsets:d},s,a):function(e,t,i,r,n,o){return new im(e,t,Lf.MORTON,i,r,n,o)}(r,n,{geometryOffsets:h,partOffsets:u,ringOffsets:d},s,a,l)}const h=jf(e,i,o);let u,d,p,f,m,_,g;for(let r=0;r<t-1;r++){const t=Ff(e,i);switch(t.physicalStreamType){case Ef.LENGTH:switch(t.logicalStreamType.lengthType){case zf.GEOMETRIES:u=jf(e,i,t);break;case zf.PARTS:d=jf(e,i,t);break;case zf.RINGS:p=jf(e,i,t);break;case zf.TRIANGLES:f=Nf(e,i,t)}break;case Ef.OFFSET:switch(t.logicalStreamType.offsetType){case Af.VERTEX:s=jf(e,i,t);break;case Af.INDEX:c=jf(e,i,t)}break;case Ef.DATA:Cf.VERTEX===t.logicalStreamType.dictionaryType?a=Vf(e,i,t):(l={numBits:t.numBits,coordinateShift:t.coordinateShift},a=jf(e,i,t))}}return u?(m=hm(h,u,2),d&&p?(_=um(h,m,d,!1),g=function(e,t,i,r){const n=new Uint32Array(i[i.length-1]+1);let o=0;n[0]=o;let s=1,a=1,l=0;for(let c=0;c<e.length;c++){const h=e[c],u=t[c+1]-t[c];if(0!==h&&3!==h)for(let e=0;e<u;e++){const e=i[s]-i[s-1];s++;for(let t=0;t<e;t++)o=n[a++]=o+r[l++]}else for(let e=0;e<u;e++)n[a++]=++o,s++}return n}(h,m,_,p)):d&&(_=function(e,t,i){const r=new Uint32Array(t[t.length-1]+1);let n=0;r[0]=n;let o=1,s=0;for(let a=0;a<e.length;a++){const l=e[a],c=t[a+1]-t[a];if(4===l||1===l)for(let e=0;e<c;e++)n=r[o++]=n+i[s++];else for(let e=0;e<c;e++)r[o++]=++n}return r}(h,m,d))):d&&p?(_=hm(h,d,1),g=um(h,_,p,!0)):d&&(_=hm(h,d,0)),c&&!_?am(h,f,c,a):c?am(h,f,c,a,{geometryOffsets:m,partOffsets:_,ringOffsets:g}):void 0===l?function(e,t,i,r){return new rm(Lf.VEC_2,e,t,i,r)}(h,{geometryOffsets:m,partOffsets:_,ringOffsets:g},s,a):function(e,t,i,r,n){return new rm(Lf.MORTON,e,t,i,r,n)}(h,{geometryOffsets:m,partOffsets:_,ringOffsets:g},s,a,l)}function hm(e,t,i){const r=new Uint32Array(e.length+1);let n=0;r[0]=n;let o=0;for(let s=0;s<e.length;s++)n=r[s+1]=n+(e[s]>i?t[o++]:1);return r}function um(e,t,i,r){const n=new Uint32Array(t[t.length-1]+1);let o=0;n[0]=o;let s=1,a=0;for(let l=0;l<e.length;l++){const c=e[l],h=t[l+1]-t[l];if(5===c||2===c||r&&(4===c||1===c))for(let e=0;e<h;e++)o=n[s++]=o+i[a++];else for(let e=0;e<h;e++)n[s++]=++o}return n}class dm extends $p{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}}class pm extends Zp{getValueFromBuffer(e){return this.dataBuffer[e]}}class fm extends $p{constructor(e,t,i,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}function mm(e,t,i,r,n){const o=function(e,t,i,r){const n=new Uint8Array(t);let o=0;const s=r.get()+i;for(;o<t&&!(r.get()>=s);){const i=e[r.increment()];if(i<=127){const s=i+3,a=e[r.increment()],l=Math.min(o+s,t);n.fill(a,o,l),o=l}else{const s=256-i;for(let i=0;i<s&&o<t;i++)n[o++]=e[r.increment()]}}return r.set(s),n}(e,Math.ceil(t/8),i,r);return n?function(e,t,i){if(!i)return e;const r=i.size(),n=new Bf(e,t),o=new Bf(new Uint8Array(Math.ceil(r/8)),r);let s=0;for(let e=0;e<r;e++){const t=!!i.get(e)&&n.get(s++);o.set(e,t)}return o.getBuffer()}(o,t,n):o}const _m=new TextDecoder;function gm(e,t,i){return i-t>=12?_m.decode(e.subarray(t,i)):function(e,t,i){let r="",n=t;for(;n<i;){const t=e[n];let o,s,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(n+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[n+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(e,t,i)}class ym extends $p{constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}}class vm extends ym{constructor(e,t,i,r){super(e,t,i,r??t.length-1)}getValueFromBuffer(e){return gm(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class xm extends ym{constructor(e,t,i,r,n){super(e,i,r,n??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){const t=this.indexBuffer[e];return gm(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class bm extends ym{constructor(e,t,i,r,n,o,s){super(e,i,r,s),this.indexBuffer=t,this.symbolOffsetBuffer=n,this.symbolTableBuffer=o}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),this.decodedDictionary=function(e,t,i){const r=[],n=new Array(t.length).fill(0);for(let e=1;e<t.length;e++)n[e]=n[e-1]+t[e-1];for(let o=0;o<i.length;o++)if(255===i[o])r.push(i[++o]);else{const s=t[i[o]],a=n[i[o]];for(let t=0;t<s;t++)r.push(e[a+t])}return new Uint8Array(r)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const t=this.indexBuffer[e];return gm(this.decodedDictionary,this.offsetBuffer[t],this.offsetBuffer[t+1])}offsetToLengthBuffer(e){const t=new Uint32Array(e.length-1);let i=e[0];for(let r=1;r<e.length;r++){const n=e[r];t[r-1]=n-i,i=n}return t}}function wm(e,t,i,r,n,o){return"scalarType"===i.type?function(e,t,i,r,n,o){let s=null;if(0===e)return null;if(o.nullable){const e=Ff(t,i),r=e.numValues,n=i.get(),o=mm(t,r,e.byteLength,i);i.set(n+e.byteLength),s=new Bf(o,e.numValues)}const a=s??r;switch(n.physicalType){case 4:case 3:return function(e,t,i,r,n){const o=Ff(e,t),s=Hf(o,n,e,t),a=3===r.physicalType;if(s===Df.FLAT){const r=Tm(n)?n:void 0,s=a?Vf(e,t,o,0,r):jf(e,t,o,0,r);return new qp(i.name,s,n)}if(s===Df.SEQUENCE){const r=$f(e,t,o);return new Xp(i.name,r[0],r[1],o.numRleValues)}const l=a?function(e,t,i){const r=Uf(e,t,i);return 1===r.length?vf(r[0]):function(e){return vf(e[1])}(r)}(e,t,o):Gf(e,t,o);return new Yp(i.name,l,n,a)}(t,i,o,n,a);case 9:return function(e,t,i,r,n){let o=null,s=null,a=null,l=null,c=null,h=n??null,u=null,d=null;for(let e=0;e<r;e++){const e=Ff(t,i);switch(e.physicalStreamType){case Ef.PRESENT:{const r=mm(t,e.numValues,e.byteLength,i),o=new Bf(r,e.numValues);h=n??o;break}case Ef.OFFSET:s=jf(t,i,e,0,h);break;case Ef.LENGTH:{const r=Nf(t,i,e);zf.DICTIONARY===e.logicalStreamType.lengthType?o=r:zf.SYMBOL===e.logicalStreamType.lengthType?l=r:u=r;break}case Ef.DATA:{const r=t.subarray(i.get(),i.get()+e.byteLength);i.add(e.byteLength);const n=e.logicalStreamType.dictionaryType;Cf.FSST===n?c=r:Cf.SINGLE===n||Cf.SHARED===n?a=r:Cf.NONE===n&&(d=r);break}}}return function(e,t,i,r,n,o,s){return t?new bm(e,i,r,n,o,t,s):null}(e,c,s,o,a,l,h)??function(e,t,i,r,n){return t?n?new xm(e,i,r,t,n):new xm(e,i,r,t):null}(e,a,s,o,h)??function(e,t,i,r,n){if(!t||!i)return null;if(r)return n?new xm(e,r,t,i,n):new xm(e,r,t,i);if(n&&n.size()!==t.length-1){const r=new Uint32Array(n.size());let o=0;for(let e=0;e<n.size();e++)r[e]=n.get(e)?o++:0;return new xm(e,r,t,i,n)}return n?new vm(e,t,i,n):new vm(e,t,i)}(e,u,d,s,h)}(o.name,t,i,o.nullable?e-1:e,s);case 0:return function(e,t,i,r,n){const o=Ff(e,t),s=o.numValues,a=t.get(),l=Tm(n)?n:void 0,c=mm(e,s,o.byteLength,t,l);t.set(a+o.byteLength);const h=new Bf(c,s);return new dm(i.name,h,n)}(t,i,o,0,a);case 6:case 5:return function(e,t,i,r,n){const o=Ff(e,t),s=Hf(o,r,e,t,"int64"),a=5===n.physicalType;if(s===Df.FLAT){const n=Tm(r)?r:void 0,s=a?function(e,t,i,r){return function(e,t,i){let r;switch(t.logicalLevelTechnique1){case Qp.DELTA:if(t.logicalLevelTechnique2===Qp.RLE){const n=t;if(!i)return function(e,t,i){const r=new BigInt64Array(i);let n=0,o=0n;for(let i=0;i<t;i++){const s=Number(e[i]),a=xf(e[i+t]);for(let e=0;e<s;e++)o+=a,r[n++]=o}return r}(e,n.runs,n.numRleValues);r=If(e=Tf(e,n.runs,n.numRleValues))}else r=If(e);break;case Qp.RLE:r=function(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=Number(e[r])}const r=new BigInt64Array(i);let n=0;for(let i=0;i<t;i++){const o=Number(e[i]);let s=e[i+t];s=xf(s),r.fill(s,n,n+o),n+=o}return r}(e,t.runs,t.numRleValues);break;case Qp.NONE:r=function(e){const t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=xf(e[i]);return t}(e);break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?Of(r,i,0n):r}(_f(e,t,i.numValues),i,r)}(e,t,o,n):qf(e,t,o,n);return new Xf(i.name,s,r)}if(s===Df.SEQUENCE){const r=Zf(e,t,o);return new Yf(i.name,r[0],r[1],o.numRleValues)}const l=a?function(e,t,i){const r=_f(e,t,i.numValues);return 1===r.length?xf(r[0]):function(e){return xf(e[1])}(r)}(e,t,o):Wf(e,t,o);return new fm(i.name,l,r,a)}(t,i,o,a,n);case 7:return function(e,t,i,r){const n=Ff(e,t),o=Tm(r)?r:void 0,s=function(e,t,i,r){const n=t.get(),o=n+i*Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(n,o)).buffer,a=new Float32Array(s);return t.set(o),r?Of(a,r,0):a}(e,t,n.numValues,o);return new pm(i.name,s,r)}(t,i,o,a);case 8:return function(e,t,i,r){const n=Ff(e,t),o=Tm(r)?r:void 0,s=function(e,t,i,r){const n=t.get(),o=n+i*Float64Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(n,o)).buffer,a=new Float64Array(s);return t.set(o),r?Of(a,r,0):a}(e,t,n.numValues,o);return new Wp(i.name,s,r)}(t,i,o,a);default:throw new Error(`The specified data type for the field is currently not supported: ${n}`)}}(r,e,t,n,i.scalarType,i):0===r?null:function(e,t,i,r){let n=null,o=null,s=null,a=null,l=!1;for(;!l;){const i=Ff(e,t);switch(i.physicalStreamType){case Ef.LENGTH:zf.DICTIONARY===i.logicalStreamType.lengthType?n=Nf(e,t,i):s=Nf(e,t,i);break;case Ef.DATA:Cf.SINGLE===i.logicalStreamType.dictionaryType||Cf.SHARED===i.logicalStreamType.dictionaryType?(o=e.subarray(t.get(),t.get()+i.byteLength),l=!0):a=e.subarray(t.get(),t.get()+i.byteLength),t.add(i.byteLength)}}const c=i.complexType.children,h=[];let u=0;for(const l of c){const c=mf(e,t,1)[0];if(0===c)continue;const d=l.name?`${i.name}${l.name}`:i.name;if(2!==c||"scalarField"!==l.type||9!==l.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const p=Ff(e,t),f=mm(e,p.numValues,p.byteLength,t),m=Ff(e,t),_=jf(e,t,m,0,m.decompressedCount!==r?new Bf(f,p.numValues):void 0);h[u++]=a?new bm(d,_,n,o,s,a,new Bf(f,p.numValues)):new xm(d,_,n,o,new Bf(f,p.numValues))}return h}(e,t,i,n)}function Tm(e){return e instanceof Bf}function Sm(e){switch(e){case 0:case 1:case 2:case 3:{const t={};t.nullable=!!(1&e),t.columnScope=0;const i={type:"logicalType",logicalType:0};return i.longID=!!(2&e),t.scalarType=i,t.type="scalarType",t}case 4:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}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}const i={};i.nullable=!!(1&e),i.columnScope=0;const r={type:"physicalType"};return r.physicalType=t,i.type="scalarType",i.scalarType=r,i}(e)}}function Pm(e){return e>=10}function Im(e){return 30===e}function Mm(e){if("scalarType"===e.type){const 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){const t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function Em(e){return"complexType"===e.type&&"physicalType"===e.complexType?.type&&0===e.complexType.physicalType}const Cm=new TextDecoder;function Am(e,t){const i=mf(e,t,1)[0];if(0===i)return"";const r=t.get(),n=e.subarray(r,r+i);return t.add(i),Cm.decode(n)}function zm(e,t){const i=mf(e,t,1)[0]>>>0;if(i<10||i>30)throw new Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT)`);const r=Sm(i);if(Pm(i)&&(r.name=Am(e,t)),Im(i)){const i=mf(e,t,1)[0]>>>0;r.complexType.children=new Array(i);for(let n=0;n<i;n++)r.complexType.children[n]=zm(e,t)}return function(e){return{name:e.name,nullable:e.nullable,scalarField:e.scalarType,complexField:e.complexType,type:"scalarType"===e.type?"scalarField":"complexField"}}(r)}function Dm(e,t){const i=mf(e,t,1)[0]>>>0,r=Sm(i);if(!r)throw new Error(`Unsupported column type code ${i}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Pm(i)?r.name=Am(e,t):i>=0&&i<=3?r.name="id":4===i&&(r.name="geometry"),Im(i)){const i=mf(e,t,1)[0]>>>0,n=r.complexType;n.children=new Array(i);for(let r=0;r<i;r++)n.children[r]=zm(e,t)}return r}function Rm(e,t){const i={featureTables:[]},r={};r.name=Am(e,t);const n=mf(e,t,1)[0]>>>0,o=mf(e,t,1)[0]>>>0;r.columns=new Array(o);for(let i=0;i<o;i++)r.columns[i]=Dm(e,t);return i.featureTables.push(r),[i,n]}function km(e,t,i,r,n,o,s=!1){const a=t.scalarType;if(!a||"logicalType"!==a.type||0!==a.logicalType)throw new Error(`ID column must be a logical ID scalar type: ${r}`);const l=a.longID?6:4,c="number"==typeof o?void 0:o,h=Hf(n,o,e,i,6===l?"int64":"int32");if(4===l)switch(h){case Df.FLAT:{const t=jf(e,i,n,0,c);return new qp(r,t,o)}case Df.SEQUENCE:{const t=$f(e,i,n);return new Xp(r,t[0],t[1],n.numRleValues)}case Df.CONST:{const t=Gf(e,i,n);return new Yp(r,t,o,!1)}}switch(h){case Df.FLAT:{if(s){const t=function(e,t,i){const r=function(e,t,i){const r=new Float64Array(i);for(let n=0;n<i;n++)r[n]=yf(e,t);return r}(e,t,i.numValues);return function(e,t){switch(t.logicalLevelTechnique1){case Qp.DELTA:return t.logicalLevelTechnique2===Qp.RLE&&(e=Sf(e,t.runs,t.numRleValues)),function(e){e[0]=bf(e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i<t-4;i+=4){const t=e[i+1],r=e[i+2],n=e[i+3];e[i]=bf(e[i])+e[i-1],e[i+1]=bf(t)+e[i],e[i+2]=bf(r)+e[i+1],e[i+3]=bf(n)+e[i+2]}for(;i!==e.length;++i)e[i]=bf(e[i])+e[i-1]}(e),e;case Qp.RLE:return function(e,t){return Sf(e,t.runs,t.numRleValues)}(e,t);case Qp.NONE:return e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}(r,i)}(e,i,n);return new Wp(r,t,o)}const t=qf(e,i,n,c);return new Xf(r,t,o)}case Df.SEQUENCE:{const t=Zf(e,i,n);return new Yf(r,t[0],t[1],n.numRleValues)}case Df.CONST:{const t=Wf(e,i,n);return new fm(r,t,o,!1)}}throw new Error("Vector type not supported for id column.")}class Lm{constructor(e,t){var i;switch(this._featureData=e,this.properties=this._featureData.properties||{},null===(i=this._featureData.geometry)||void 0===i?void 0:i.type){case Rf.POINT:case Rf.MULTIPOINT:this.type=1;break;case Rf.LINESTRING:case Rf.MULTILINESTRING:this.type=2;break;case Rf.POLYGON:case Rf.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){const e=[];for(const t of this._featureData.geometry.coordinates){const i=[];for(const e of t)i.push(new o(e.x,e.y));e.push(i)}return e}}class Fm{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 Lm(this.features[e],this.extent)}}class Bm{constructor(e){this.layers={};const t=function(e,t,i=!0){const r=new Jp(0),n=[];for(;r.get()<e.length;){const t=mf(e,r,1)[0]>>>0,s=r.get()+t;if(s>e.length)throw new Error(`Block overruns tile: ${s} > ${e.length}`);if(1!=mf(e,r,1)[0]>>>0){r.set(s);continue}const[a,l]=Rm(e,r),c=a.featureTables[0];let h=null,u=null;const d=[];let p=0;for(const t of c.columns){const n=t.name;if("scalarType"===(o=t).type&&"logicalType"===o.scalarType?.type&&0===o.scalarType.logicalType){let o=null;if(t.nullable){const t=Ff(e,r),i=r.get(),n=mm(e,t.numValues,t.byteLength,r);r.set(i+t.byteLength),o=new Bf(n,t.numValues)}const s=Ff(e,r);p=o?o.size():s.decompressedCount,h=km(e,t,r,n,s,o??p,i)}else if(Em(t)){const t=mf(e,r,1)[0];if(0===p){const t=r.get();p=Ff(e,r).decompressedCount,r.set(t)}u=cm(e,t,r,p)}else{const i=Mm(t)?mf(e,r,1)[0]:1;if(0===i)continue;const n=wm(e,r,t,i,p);if(n)if(Array.isArray(n))for(const e of n)d.push(e);else d.push(n)}}const f=new Kp(c.name,u,h,d,l);n.push(f),r.set(s)}var o;return n}(new Uint8Array(e));this.layers=t.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new Fm(t)})),{})}}const Om="_geojsonTileLayer";function Vm(e,t,i,r,n){return Ae(e,((e,o)=>{const s=t instanceof Ns?t.get(o):null;return(null==s?void 0:s.evaluate)?s.evaluate(i,r,n):s}))}function jm(e,t){return t-e}gs("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 ms(Q,16,0),this.grid3D=new ms(Q,16,0),this.featureIndexArray=new Na,this.promoteId=t}insert(e,t,i,r,n,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);const a=o?this.grid3D:this.grid;for(const e of t){const t=[1/0,1/0,-1/0,-1/0];for(const 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]<Q&&t[1]<Q&&t[2]>=0&&t[3]>=0&&a.insert(s,t[0],t[1],t[2],t[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Wh(new Nu(this.rawTileData)).layers:new Bm(this.rawTileData).layers,this.sourceLayerCoder=new Up(this.vtLayers?Object.keys(this.vtLayers).sort():[Om])),this.vtLayers}query(e,t,i,r){this.loadVTLayers();const n=e.params,s=Q/e.tileSize/e.scale,a=xo(n.filter,n.globalState),l=e.queryGeometry,c=e.queryPadding*s,h=Fp.fromPoints(l),u=this.grid.query(h.minX-c,h.minY-c,h.maxX+c,h.maxY+c),d=Fp.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,((t,i,r,n)=>function(e,t,i,r,n){for(const o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const s=[new o(t,i),new o(t,n),new o(r,n),new o(r,i)];if(e.length>2)for(const t of s)if(uc(e,t))return!0;for(let t=0;t<e.length-1;t++)if(dc(e[t],e[t+1],s))return!0;return!1}(e.cameraQueryGeometry,t-c,i-c,r+c,n+c)));for(const e of p)u.push(e);u.sort(jm);const f={};let m;for(const o of u){if(o===m)continue;m=o;const c=this.featureIndexArray.get(o);let h=null;this.loadMatchingFeature(f,c.bucketIndex,c.sourceLayerIndex,c.featureIndex,a,n.layers,n.availableImages,t,i,r,((t,i,r)=>(h||(h=Kl(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:r,geometry:h,zoom:this.z,transform:e.transform,pixelsToTileUnits:s,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return f}loadMatchingFeature(e,t,i,r,n,o,s,a,l,c,h){const u=this.bucketLayerIDs[t];if(o&&!u.some((e=>o.has(e))))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(r);if(n.needGeometry){const e=Jl(p,!0);if(!n.filter(new zs(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new zs(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(const t of u){if(o&&!o.has(t))continue;const i=a[t];if(!i)continue;let n={};f&&c&&(n=c.getState(i.sourceLayer||Om,f));const u=Te({},l[t]);u.paint=Vm(u.paint,i.paint,p,n,s),u.layout=Vm(u.layout,i.layout,p,n,s);const d=!h||h(p,i,n);if(!d)continue;const m=new Gp(p,this.z,this.x,this.y,f);m.layer=u;let _=e[t];void 0===_&&(_=e[t]=[]),_.push({featureIndex:r,feature:m,intersectionZ:d})}}lookupSymbolFeatures(e,t,i,r,n,o,s,a){const l={};this.loadVTLayers();const c=xo(n.filterSpec,n.globalState);for(const n of e)this.loadMatchingFeature(l,i,r,n,c,o,s,a,t);return l}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){var i;let r=e.id;return this.promoteId&&(r=e.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[t]],"boolean"==typeof r&&(r=Number(r)),void 0===r&&(null===(i=e.properties)||void 0===i?void 0:i.cluster)&&this.promoteId&&(r=Number(e.properties.cluster_id))),r}},{omit:["rawTileData","sourceLayerCoder"]});const Nm="RTLPluginLoaded";class Um extends Tt{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=ep()}_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}setRTLTextPlugin(e){return n(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=nt.resolveURL(e),!this.url)throw new 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()}))}_requestImport(){return n(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new bt(Nm))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let Gm=null;function $m(){return Gm||(Gm=new Um),Gm}var Zm,qm;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(Zm||(Zm={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(qm||(qm={}));class Wm{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=Ie(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading"}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=st(),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}loadVectorData(e,t,i){if(!0!==(null==e?void 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){const i={};if(!t)return i;for(const r of e){const 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(const t of e)i[t.id]=r}}return i}(e.buckets,null==t?void 0:t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof _d){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof _d&&t.hasRTLText){this.hasRTLText=!0,$m().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const 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 za;else this.state="loaded"}unloadVectorData(){for(const 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(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Zc(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Zc(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,n,o,s,a,l,c,h){var u;return(null===(u=this.latestFeatureIndex)||void 0===u?void 0:u.rawTileData)?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!(null==i?void 0:i.rawTileData))return;const r=i.loadVTLayers(),n=(null==t?void 0:t.sourceLayer)?t.sourceLayer:"",o=r[Om]||r[n];if(!o)return;const s=xo(null==t?void 0:t.filter,null==t?void 0:t.globalState),{z:a,x:l,y:c}=this.tileID.canonical,h={z:a,x:l,y:c};for(let t=0;t<o.length;t++){const r=o.feature(t);if(s.needGeometry){const e=Jl(r,!0);if(!s.filter(new zs(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new zs(this.tileID.overscaledZ),r))continue;const u=i.getId(r,n),d=new Gp(r,a,l,c,u);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){const t=this.expirationTime;if(e.cacheControl){const t=function(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const 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){const e=Date.now();let i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{const 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(),Math.pow(2,31)-1)}setFeatureState(e,t){var i,r,n;if(!(null===(i=this.latestFeatureIndex)||void 0===i?void 0:i.rawTileData)||0===Object.keys(e).length)return;const o=this.latestFeatureIndex.loadVTLayers();for(const i in this.buckets){if(!t.style.hasLayer(i))continue;const s=this.buckets[i],a=s.layers[0].sourceLayer||Om,l=o[a],c=e[a];if(!l||!c||0===Object.keys(c).length)continue;s.update(c,l,(null===(r=this.imageAtlas)||void 0===r?void 0:r.patternPositions)||{},this.dashPositions||{});const h=null===(n=null==t?void 0:t.style)||void 0===n?void 0:n.getLayer(i);h&&(this.queryPadding=Math.max(this.queryPadding,h.queryRadius(s)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<st()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=st()+e}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}}class Hm{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const 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){const 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){const 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;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class Xm{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,i){var r,n,o,s,a;const l=String(t);if((s=this.stateChanges)[e]||(s[e]={}),(a=this.stateChanges[e])[l]||(a[l]={}),Te(this.stateChanges[e][l],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==l&&(this.deletedStates[e][t]=null)}else if(null===(null===(r=this.deletedStates[e])||void 0===r?void 0:r[l])){this.deletedStates[e][l]={};for(const t in this.state[e][l])i[t]||(this.deletedStates[e][l][t]=null)}else for(const t in i)null===(null===(o=null===(n=this.deletedStates[e])||void 0===n?void 0:n[l])||void 0===o?void 0:o[t])&&delete this.deletedStates[e][l][t]}removeFeatureState(e,t,i){var r,n,o;if(null===this.deletedStates[e])return;const s=String(t);if((n=this.deletedStates)[e]||(n[e]={}),i&&void 0!==t)null!==this.deletedStates[e][s]&&((o=this.deletedStates[e])[s]||(o[s]={}),this.deletedStates[e][s][i]=null);else if(void 0!==t)if(null===(r=this.stateChanges[e])||void 0===r?void 0:r[s])for(i in this.deletedStates[e][s]={},this.stateChanges[e][s])this.deletedStates[e][s][i]=null;else this.deletedStates[e][s]=null;else this.deletedStates[e]=null}getState(e,t){const i=String(t),r=Te({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const i=this.deletedStates[e][t];if(null===i)return{};for(const e in i)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){var i,r,n;const o={};for(const e in this.stateChanges){(i=this.state)[e]||(i[e]={});const t={};for(const i in this.stateChanges[e])(r=this.state[e])[i]||(r[i]={}),Te(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];o[e]=t}for(const e in this.deletedStates){(n=this.state)[e]||(n[e]={});const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i]}o[e]||(o[e]={}),Te(o[e],t)}this.stateChanges={},this.deletedStates={},0!==Object.keys(o).length&&(this.revision++,e.setFeatureState(o,t))}}const Ym=89.25;function Km(e,t){const i=be(t.lat,-85.051129,We);return new o(up(t.lng)*e,dp(i)*e)}function Jm(e,t){return new gp(t.x/e,t.y/e).toLngLat()}function Qm(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(Ue(90-e.pitch)),Math.tan(Ue(Ym-e.pitch)))}function e_(e,t){const i=e.canonical,r=t/Me(i.z),n=i.x+Math.pow(2,i.z)*e.wrap,o=y(new Float64Array(16));return b(o,o,[n*r,i.y*r,0]),w(o,o,[r/Q,r/Q,1]),o}function t_(e,t,i,r,n){const o=gp.fromLngLat(e,t),s=n*pp(1,e.lat),{x:a,y:l,z:c}=i_(i,r);return new gp(o.x+s*-a,o.y+s*-l,o.z+s*-c)}function i_(e,t){const i=Ue(e),r=Ue(t),n=Math.cos(-i),o=Math.sin(i);return{x:o*Math.sin(r),y:-o*Math.cos(r),z:n}}function r_(e,t,i){const r=t.intersectsFrustum(e);if(!i||0===r)return r;const n=t.intersectsPlane(i);return 0===n?0:2===r&&2===n?2:1}function n_(e,t,i){let r=0;const n=(i-t)/10;for(let o=0;o<10;o++)r+=n*Math.pow(Math.cos(t+(o+.5)/10*(i-t)),e);return r}function o_(e,t){return function(i,r,n,o,s){const a=2*((e-1)/Ee(Math.cos(Ue(Ym-s))/Math.cos(Ue(Ym)))-1),l=Math.acos(n/o),c=2*n_(a-1,0,Ue(s/2)),h=Math.min(Ue(Ym),l+Ue(s/2)),u=n_(a-1,Math.min(h,l-Ue(s/2)),h),d=Math.atan(r/n);let p=i;return p+=Ee(o/Math.hypot(r,n)/Math.max(.5,Math.cos(Ue(s/2)))),p+=a*Ee(Math.cos(d))/2,p-=Ee(Math.max(1,u/c/t))/2,p}}const s_=o_(9.314,3);function a_(e,t){const i=(t.roundZoom?Math.round:Math.floor)(e.zoom+Ee(e.tileSize/t.tileSize));return Math.max(0,i)}function l_(e,t){const i=e.getCameraFrustum(),r=e.getClippingPlane(),n=e.screenPointToMercatorCoordinate(e.getCameraPoint()),o=gp.fromLngLat(e.center,e.elevation);n.z=o.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const s=e.getCoveringTilesDetailsProvider(),a=s.allowVariableZoom(e,t),l=a_(e,t),c=t.minzoom||0,h=void 0!==t.maxzoom?t.maxzoom:e.maxZoom,u=Math.min(Math.max(0,l),h),d=Math.pow(2,u),p=[d*n.x,d*n.y,0],f=[d*o.x,d*o.y,0],m=Math.hypot(o.x-n.x,o.y-n.y),_=Math.abs(o.z-n.z),g=Math.hypot(m,_),y=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],x=[];if(e.renderWorldCopies&&s.allowWorldCopies())for(let e=1;e<=3;e++)v.push(y(-e)),v.push(y(e));for(v.push(y(0));v.length>0;){const d=v.pop(),m=d.x,y=d.y;let b=d.fullyVisible;const w={x:m,y:y,z:d.zoom},T=s.getTileBoundingVolume(w,d.wrap,e.elevation,t);if(!b){const e=r_(i,T,r);if(0===e)continue;b=2===e}const S=s.distanceToTile2d(n.x,n.y,w,T);let P=l;a&&(P=(t.calculateTileZoom||s_)(e.zoom+Ee(e.tileSize/t.tileSize),S,_,g,e.fov)),P=(t.roundZoom?Math.round:Math.floor)(P),P=Math.max(0,P);const I=Math.min(P,h);if(d.wrap=s.getWrap(o,w,d.wrap),d.zoom>=I){if(d.zoom<c)continue;const e=u-d.zoom,i=p[0]-.5-(m<<e),r=p[1]-.5-(y<<e),n=t.reparseOverscaled?Math.max(d.zoom,P):d.zoom;x.push({tileID:new Pp(d.zoom===h?n:d.zoom,d.wrap,d.zoom,m,y),distanceSq:J([f[0]-.5-m,f[1]-.5-y]),tileDistanceToCamera:Math.sqrt(i*i+r*r)})}else for(let e=0;e<4;e++)v.push({zoom:d.zoom+1,x:(m<<1)+e%2,y:(y<<1)+(e>>1),wrap:d.wrap,fullyVisible:b})}return x.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}const c_=Fp.fromPoints([new o(0,0),new o(Q,Q)]);function h_(e){return"raster"===e||"image"===e||"video"===e}function u_(e,t,i,r,n,o,s){if(!t.hasData())return!1;const{tileID:a,fadingRole:l,fadingDirection:c,fadingParentID:h}=t;if(l===Zm.Base&&c===qm.Incoming&&h)return i[h.key]=h,!0;const u=Math.max(a.overscaledZ-n,o);for(let n=a.overscaledZ-1;n>=u;n--){const o=a.scaledTo(n),l=e.getLoadedTile(o);if(l)return t.setCrossFadeLogic({fadingRole:Zm.Base,fadingDirection:qm.Incoming,fadingParentID:l.tileID,fadeEndTime:r+s}),l.setCrossFadeLogic({fadingRole:Zm.Parent,fadingDirection:qm.Departing,fadeEndTime:r+s}),i[o.key]=o,!0}return!1}function d_(e,t,i,r,n,o){if(!t.hasData())return!1;const s=t.tileID.children(n);let a=p_(e,t,s,i,r,n,o);if(a)return!0;for(const l of s)p_(e,t,l.children(n),i,r,n,o)&&(a=!0);return a}function p_(e,t,i,r,n,o,s){if(i[0].overscaledZ>=o)return!1;let a=!1;for(const o of i){const i=e.getLoadedTile(o);if(!i)continue;const{fadingRole:l,fadingDirection:c,fadingParentID:h}=i;l===Zm.Base&&c===qm.Departing&&h||(i.setCrossFadeLogic({fadingRole:Zm.Base,fadingDirection:qm.Departing,fadingParentID:t.tileID,fadeEndTime:n+s}),t.setCrossFadeLogic({fadingRole:Zm.Parent,fadingDirection:qm.Incoming,fadeEndTime:n+s})),r[o.key]=o,a=!0}return a}function f_(e,t,i,r){const n=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(n)&&(e.setSelfFadeLogic(i+r),!0)}function m_(e,t){var i;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x;const n=t.tileID.canonical.y-e.tileID.canonical.y,o=Math.pow(2,e.tileID.canonical.z),s=t.tileID.key;0===r&&0===n||Math.abs(n)>1||(Math.abs(r)>1&&(1===Math.abs(r+o)?r+=o:1===Math.abs(r-o)&&(r-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,n),(null===(i=e.neighboringTiles)||void 0===i?void 0:i[s])&&(e.neighboringTiles[s].backfilled=!0)))}class __{constructor(){this._tiles={}}handleWrapJump(e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t){for(const i in this._tiles)this._tiles[i].setFeatureState(e,t)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(Mp).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){const t=this.getTileById(e.key);return(null==t?void 0:t.hasData())?t:null}isIdRenderable(e,t=!1){var i;return null===(i=this.getTileById(e))||void 0===i?void 0:i.isRenderable(t)}getRenderableIds(e=0,t){const i=[];for(const e of this.getAllIds())this.isIdRenderable(e,t)&&i.push(this.getTileById(e));return t?i.sort(((t,i)=>{const r=t.tileID,n=i.tileID,s=new o(r.canonical.x,r.canonical.y)._rotate(-e),a=new o(n.canonical.x,n.canonical.y)._rotate(-e);return r.overscaledZ-n.overscaledZ||a.y-s.y||a.x-s.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(Mp).map((e=>e.key))}}class g_ extends Tt{constructor(e,t,i){super(),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)=>{const n=new(Np(t.type))(e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return n})(e,t,i,this),this._inViewTiles=new __,this._outOfViewCache=new Hm(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new Xm,this._didEmitContent=!1,this._updated=!1}onAdd(e){var t;this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,(null===(t=this._source)||void 0===t?void 0:t.onAdd)&&this._source.onAdd(e)}onRemove(e){var t;for(const e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),(null===(t=this._source)||void 0===t?void 0:t.onRemove)&&this._source.onRemove(e),this._inViewTiles=new __}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!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(const 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;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,t,i){return n(this,void 0,void 0,(function*(){try{const r=yield this._source.loadTile(e);this._tileLoaded(e,t,i,r)}catch(t){e.state="errored",404!==t.status?this._source.fire(new wt(te(t),{tile:e})):this.update(this.transform,this.terrain)}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new bt("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}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(const t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var t;return this._inViewTiles.getRenderableIds(null===(t=this.transform)||void 0===t?void 0:t.bearingInRadians,e)}hasRenderableParent(e){const t=e.overscaledZ-1;if(t>=this._source.minzoom){const 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(const i of this._inViewTiles.getAllIds()){const r=this._inViewTiles.getTileById(i);t&&!this._source.shouldReloadTile(r,t)||(e?this._reloadTile(i,"expired"):"errored"!==r.state&&this._reloadTile(i,"reloading"))}}}_reloadTile(e,t){return n(this,void 0,void 0,(function*(){const i=this._inViewTiles.getTileById(e);i&&("loading"!==i.state&&(i.state=t),yield this._loadTile(i,e,t))}))}_tileLoaded(e,t,i,r){e.timeAdded=st(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),(null==r?void 0:r.unmodified)||("raster-dem"===this.getSource().type&&e.dem&&function(e,t){var i,r,n;const o=t.getRenderableIds();for(const s of o){if(!(null===(i=e.neighboringTiles)||void 0===i?void 0:i[s]))continue;const o=t.getTileById(s);e.neighboringTiles[s].backfilled||m_(e,o),(null===(n=null===(r=o.neighboringTiles)||void 0===r?void 0:r[e.tileID.key])||void 0===n?void 0:n.backfilled)||m_(o,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new bt("data",{dataType:"source",tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,t){const i=this._getLoadedDescendents(t),r=new Set;for(const n of t){const t=i[n.key];if(!(null==t?void 0:t.length)){r.add(n);continue}const o=n.overscaledZ+g_.maxOverzooming,s=t.filter((e=>e.tileID.overscaledZ<=o));if(!s.length){r.add(n);continue}const a=Math.min(...s.map((e=>e.tileID.overscaledZ))),l=s.filter((e=>e.tileID.overscaledZ===a)).map((e=>e.tileID));for(const t of l)e[t.key]=t;this._areDescendentsComplete(l,a,n.overscaledZ)||r.add(n)}return r}_getLoadedDescendents(e){var t;const i={};for(const r of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(const n of e)r.tileID.isChildOf(n)&&(i[t=n.key]||(i[t]=[]),i[n.key].push(r));return i}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:Math.pow(4,t-i)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const t=Math.ceil(e.width/this._source.tileSize)+1,i=Math.ceil(e.height/this._source.tileSize)+1,r=Math.floor(t*i*(null===this._maxTileCacheZoomLevels?ct.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._outOfViewCache.setMaxSize(n)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,t&&(this._inViewTiles.handleWrapJump(t),this._resetTileReloadTimers())}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 Pp(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(i=l_(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:t,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(i=i.filter((e=>this._source.hasTile(e))))):i=[],this.usedForTerrain&&(i=this._addTerrainIdealTiles(i));const r=0===i.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new bt("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const n=a_(e,this._source),o=this._updateRetainedTiles(i,n),s=h_(this._source.type);s&&this._rasterFadeDuration>0&&!t&&function(e,t,i,r,n,o,s){const a=st(),l=function(e){if(!e.length)return new Set;const t=Math.max(...e.map((e=>e.canonical.z)));let i=1/0,r=-1/0,n=1/0,o=-1/0;const s=[];for(const a of e){const{x:e,y:l,z:c}=a.canonical,h=Math.pow(2,t-c),u=e*h,d=l*h;s.push({id:a,x:u,y:d}),u<i&&(i=u),u>r&&(r=u),d<n&&(n=d),d>o&&(o=d)}const a=new Set;for(const e of s)e.x!==i&&e.x!==r&&e.y!==n&&e.y!==o||a.add(e.id);return a}(t);for(const c of t){const t=e.getTileById(c.key);t.fadingDirection!==qm.Departing&&0!==t.fadeOpacity||t.resetFadeLogic(),u_(e,t,i,a,r,n,s)||d_(e,t,i,a,o,s)||f_(t,l,a,s)||t.resetFadeLogic()}}(this._inViewTiles,i,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),s?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(e){for(const t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(const t of this._inViewTiles.getAllIds()){const 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){const t=[];for(const i of e)if(i.canonical.z>this._source.minzoom){const e=i.scaledTo(i.canonical.z-1);t.push(e);const r=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(r)}return e.concat(t)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const r=new Set;for(const t of e)this._addTile(t).hasData()||r.add(t);const n=e.reduce(((e,t)=>(e[t.key]=t,e)),{}),o=this._retainLoadedChildren(n,r),s={},a=Math.max(t-g_.maxUnderzooming,this._source.minzoom);for(const e of o){let t=this._inViewTiles.getTileById(e.key),r=null==t?void 0:t.wasRequested();for(let o=e.overscaledZ-1;o>=a;--o){const a=e.scaledTo(o);if(s[a.key])break;if(s[a.key]=!0,t=this.getTile(a),!t&&r&&(t=this._addTile(a)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||r)&&(n[a.key]=a),r=t.wasRequested(),e)break}}}return n}_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));const i=t;return t||(t=new Wm(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(t,e.key,t.state)),t.uses++,this._inViewTiles.setTile(e.key,t),i||this._source.fire(new bt("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),i))}_clearTileReloadTimer(e){const t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e of this._inViewTiles.getAllIds()){const t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t)}}refreshTiles(e){for(const t of this._inViewTiles.getAllIds()){const 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){const 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){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,t,i){const r=[],n=this.transform;if(!n)return r;const o=n.getCoveringTilesDetailsProvider().allowWorldCopies(),s=i?n.getCameraQueryGeometry(e):e,a=e=>n.screenPointToMercatorCoordinate(e,this.terrain),l=this.transformBbox(e,a,!o),c=this.transformBbox(s,a,!o),h=this.getIds(),u=Fp.fromPoints(c);for(const e of h){const i=this._inViewTiles.getTileById(e);if(i.holdingForSymbolFade())continue;const s=o?[i.tileID]:[i.tileID.unwrapTo(-1),i.tileID.unwrapTo(0)],a=Math.pow(2,n.zoom-i.tileID.overscaledZ),h=t*i.queryPadding*Q/i.tileSize/a;for(const e of s){const t=u.map((t=>e.getTilePoint(new gp(t.x,t.y))));if(t.expandBy(h),t.intersects(c_)){const t=l.map((t=>e.getTilePoint(t))),n=c.map((t=>e.getTilePoint(t)));r.push({tile:i,tileID:o?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:n,scale:a})}}}return r}transformBbox(e,t,i){let r=e.map(t);if(i){const i=Fp.fromPoints(e);i.shrinkBy(.001*Math.min(i.width(),i.height()));const n=i.map(t);Fp.fromPoints(r).covers(n)||(r=r.map((e=>e.x>.5?new gp(e.x-1,e.y,e.z):e)))}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._inViewTiles.getTileById(e).tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){return!!this._source.hasTransition()||h_(this._source.type)&&function(e,t){if(t<=0)return!1;const i=st();for(const 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||(e=Om),this._state.updateState(e,t,i)}removeFeatureState(e,t,i){e||(e=Om),this._state.removeFeatureState(e,t,i)}getFeatureState(e,t){return e||(e=Om),this._state.getState(e,t)}setDependencies(e,t,i){const r=this._inViewTiles.getTileById(e);r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const 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(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}}g_.maxUnderzooming=10,g_.maxOverzooming=3;class y_{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=be(e,0,1);let t=1,i=this._distances[t];const r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];const n=t-1,o=this._distances[n],s=i-o,a=s>0?(r-o)/s:0;return this.points[n].mult(1-a).add(this.points[t].mult(a))}}function v_(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class x_{constructor(e,t,i){const r=this.boxCells=[],n=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([]),n.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,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}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,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,i,r,n,o){this.circleCells[n].push(o)}_query(e,t,i,r,n,o,s){if(i<0||e>this.width||r<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e<this.boxKeys.length;e++)a.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++){const t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];a.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}}else this._forEachCell(e,t,i,r,this._queryCell,a,{hitTest:n,overlapMode:o,seenUids:{box:{},circle:{}}},s);return a}query(e,t,i,r){return this._query(e,t,i,r,!1,null)}hitTest(e,t,i,r,n,o){return this._query(e,t,i,r,!0,n,o).length>0}hitTestCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),c.length>0}_queryCell(e,t,i,r,n,o,s,a){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[n],d=1e-6;if(null!==u){const n=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,p=this.boxKeys[s];if(e<=n[u+2]+d&&t<=n[u+3]+d&&i>=n[u+0]-d&&r>=n[u+1]-d&&(!a||a(p))&&(!c||!v_(h,p.overlapMode))&&(o.push({key:p,x1:n[u],y1:n[u+1],x2:n[u+2],y2:n[u+3]}),c))return!0}}const p=this.circleCells[n];if(null!==p){const n=this.circles;for(const s of p)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,i,r)&&(!a||a(d))&&(!c||!v_(h,d.overlapMode))){const e=n[u],t=n[u+1],i=n[u+2];if(o.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,r,n,o,s,a){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const 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])&&(!a||a(r))&&!v_(h,r.overlapMode))return o.push(!0),!0}}const d=this.circleCells[n];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(r))&&!v_(h,r.overlapMode))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,s,a))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,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,h=Math.abs(t-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}function b_(e,t){const 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]),n=t[0]*i,o=t[4]*i,s=t[8]*r,a=t[1]*i,l=t[5]*i,c=t[9]*r,h=t[2]*i,u=t[6]*i,d=t[10]*r;e[0]=n,e[1]=o,e[2]=s,e[4]=a,e[5]=l,e[6]=c,e[8]=h,e[9]=u,e[10]=d;const p=t[12],f=t[13],m=t[14];return e[12]=-n*p-a*f-h*m,e[13]=-o*p-l*f-u*m,e[14]=-s*p-c*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}const w_=_();function T_(e,t,i){const r=_();if(!e){const{vecSouth:e,vecEast:i}=P_(t),u=f();u[0]=i[0],u[1]=i[1],u[2]=e[0],u[3]=e[1],n=u,(h=(s=(o=u)[0])*(c=o[3])-(l=o[2])*(a=o[1]))&&(n[0]=c*(h=1/h),n[1]=-a*h,n[2]=-l*h,n[3]=s*h),r[0]=u[0],r[1]=u[1],r[4]=u[2],r[5]=u[3]}var n,o,s,a,l,c,h;return w(r,r,[1/i,1/i,1]),r}function S_(e,t,i,r){if(e){const e=_();if(!t){const{vecSouth:t,vecEast:r}=P_(i);e[0]=r[0],e[1]=r[1],e[4]=t[0],e[5]=t[1]}return w(e,e,[r,r,1]),e}return i.pixelsToClipSpaceMatrix}function P_(e){const t=Math.cos(e.rollInRadians),i=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),n=Math.cos(e.bearingInRadians),o=Math.sin(e.bearingInRadians),s=W();s[0]=-n*r*i-o*t,s[1]=-o*r*i+n*t;const a=Y(s);a<1e-9?K(s):X(s,s,1/a);const l=W();l[0]=n*r*t-o*i,l[1]=o*r*t+n*i;const c=Y(l);return c<1e-9?K(l):X(l,l,1/c),{vecEast:l,vecSouth:s}}function I_(e,t,i,r){let n;r?(n=[e,t,r(e,t),1],$(n,n,i)):(n=[e,t,0,1],G_(n,n,i));const s=n[3];return{point:new o(n[0]/s,n[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function M_(e,t){return.5+e/t*.5}function E_(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function C_(e,t,i,r,n,s,a,l,c,h,u,d,p){const f=i?e.textSizeData:e.iconSizeData,m=ld(f,t.transform.zoom),_=[256/t.width*2+1,256/t.height*2+1],g=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const y=e.lineVertexArray,v=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=t.transform.width/t.transform.height;let b=!1;for(let i=0;i<v.length;i++){const w=v.get(i);if(w.hidden||w.writingMode===nd.vertical&&!b){U_(w.numGlyphs,g);continue}b=!1;const T=new o(w.anchorX,w.anchorY),S={getElevation:p,pitchedLabelPlaneMatrix:r,lineVertexArray:y,pitchWithMap:s,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:T,unwrappedTileID:c,width:h,height:u,translation:d},P=B_(w.anchorX,w.anchorY,S);if(!E_(P.point,_)){U_(w.numGlyphs,g);continue}const I=M_(t.transform.cameraToCenterDistance,P.signedDistanceFromCamera),M=ad(f,m,w),E=s?M*t.transform.getPitchedTextCorrection(w.anchorX,w.anchorY,c)/I:M*I,C=D_({projectionContext:S,pitchedLabelPlaneMatrixInverse:n,symbol:w,fontSize:E,flip:!1,keepUpright:a,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:x,rotateToLine:l});b=C.useVertical,(C.notEnoughRoom||b||C.needsFlipping&&D_({projectionContext:S,pitchedLabelPlaneMatrixInverse:n,symbol:w,fontSize:E,flip:!0,keepUpright:a,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:x,rotateToLine:l}).notEnoughRoom)&&U_(w.numGlyphs,g)}i?e.text.dynamicLayoutVertexBuffer.updateData(g):e.icon.dynamicLayoutVertexBuffer.updateData(g)}function A_(e,t,i,r,n,o,s,a){const l=o.glyphStartIndex+o.numGlyphs,c=o.lineStartIndex,h=o.lineStartIndex+o.lineLength,u=t.getoffsetX(o.glyphStartIndex),d=t.getoffsetX(l-1),p=j_(e*u,i,r,n,o.segment,c,h,a,s);if(!p)return null;const f=j_(e*d,i,r,n,o.segment,c,h,a,s);return f?a.projectionCache.anyProjectionOccluded?null:{first:p,last:f}:null}function z_(e,t,i,r){return e===nd.horizontal&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:(e===nd.vertical?t.y<i.y:t.x>i.x)?{needsFlipping:!0}:null}function D_(e){const{projectionContext:t,pitchedLabelPlaneMatrixInverse:i,symbol:r,fontSize:n,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=n/24,p=r.lineOffsetX*d,f=r.lineOffsetY*d;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,n=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=A_(d,l,p,f,s,r,u,t);if(!c)return{notEnoughRoom:!0};const _=F_(c.first.point.x,c.first.point.y,t,i),g=F_(c.last.point.x,c.last.point.y,t,i);if(a&&!s){const e=z_(r.writingMode,_,g,h);if(e)return e}m=[c.first];for(let i=r.glyphStartIndex+1;i<e-1;i++){const e=j_(d*l.getoffsetX(i),p,f,s,r.segment,n,o,t,u);if(!e)return{notEnoughRoom:!0};m.push(e)}m.push(c.last)}else{if(a&&!s){const e=L_(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,n=r.lineStartIndex+r.segment+1,s=new o(t.lineVertexArray.getx(n),t.lineVertexArray.gety(n)),a=L_(s.x,s.y,t),l=a.signedDistanceFromCamera>0?a.point:R_(t.tileAnchorPoint,s,e,1,t),c=F_(e.x,e.y,t,i),u=F_(l.x,l.y,t,i),d=z_(r.writingMode,c,u,h);if(d)return d}const e=j_(d*l.getoffsetX(r.glyphStartIndex),p,f,s,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,t,u);if(!e||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const e of m)dd(c,e.point,e.angle);return{}}function R_(e,t,i,r,n){const o=e.add(e.sub(t)._unit()),s=L_(o.x,o.y,n).point,a=i.sub(s);return i.add(a._mult(r/a.mag()))}function k_(e,t,i){const r=t.projectionCache;if(r.projections[e])return r.projections[e];const n=new o(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),s=L_(n.x,n.y,t);if(s.signedDistanceFromCamera>0)return r.projections[e]=s.point,r.anyProjectionOccluded||(r.anyProjectionOccluded=s.isOccluded),s.point;const a=e-i.direction;return R_(0===i.distanceFromAnchor?t.tileAnchorPoint:new o(t.lineVertexArray.getx(a),t.lineVertexArray.gety(a)),n,i.previousVertex,i.absOffsetX-i.distanceFromAnchor+1,t)}function L_(e,t,i){const r=e+i.translation[0],n=t+i.translation[1];let o;return i.pitchWithMap?(o=I_(r,n,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(r,n,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function F_(e,t,i,r){if(i.pitchWithMap){const n=[e,t,0,1];return $(n,n,r),i.transform.projectTileCoordinates(n[0]/n[3],n[1]/n[3],i.unwrappedTileID,i.getElevation).point}return{x:e/i.width*2-1,y:1-t/i.height*2}}function B_(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function O_(e,t,i){return e._unit()._perp()._mult(t*i)}function V_(e,t,i,r,n,s,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=i.add(t);if(e+c.direction<r||e+c.direction>=n)return l.projectionCache.offsets[e]=h,h;const u=k_(e+c.direction,l,c),d=O_(u.sub(i),a,c.direction),p=i.add(d),f=u.add(d);return l.projectionCache.offsets[e]=function(e,t,i,r){const n=t.y-e.y,s=t.x-e.x,a=r.y-i.y,l=r.x-i.x,c=a*s-l*n;if(0===c)return null;const h=(l*(e.y-i.y)-a*(e.x-i.x))/c;return new o(e.x+h*s,e.y+h*n)}(s,h,p,f)||h,l.projectionCache.offsets[e]}function j_(e,t,i,r,n,o,s,a,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,p=h>0?o+n:o+n+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=L_(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,_=d,g=d,y=0,v=0;const x=Math.abs(c),b=[];let w;for(;y+v<=x;){if(p+=h,p<o||p>=s)return null;y+=v,g=_,m=f;const e={absOffsetX:x,direction:h,distanceFromAnchor:y,previousVertex:g};if(_=k_(p,a,e),0===i)b.push(g),w=_.sub(g);else{let t;const r=_.sub(g);t=0===r.mag()?O_(k_(p+h,a,e).sub(_),i,h):O_(r,i,h),m||(m=g.add(t)),f=V_(p,t,_,o,s,m,i,a,e),b.push(m),w=f.sub(m)}v=w.mag()}const T=w._mult((x-y)/v)._add(m||g),S=u+Math.atan2(_.y-g.y,_.x-g.x);return b.push(T),{point:T,angle:l?S:0,path:b}}const N_=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function U_(e,t){for(let i=0;i<e;i++){const e=t.length;t.resize(e+4),t.float32.set(N_,3*e)}}function G_(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const $_=100;class Z_{constructor(e,t=new x_(e.width+200,e.height+200,25),i=new x_(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+$_,this.screenBottomBoundary=e.height+$_,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,i,r,n,o,s,a,l,c,h,u){const d=this.projectAndGetPerspectiveRatio(e.anchorPointX+a[0],e.anchorPointY+a[1],n,c,u),p=i*d.perspectiveRatio;let f;if(o||s)f=this._projectCollisionBox(e,p,r,n,o,s,a,d,c,h,u);else{const t=d.x+(h?h.x*p:0),i=d.y+(h?h.y*p:0);f={allPointsOccluded:!1,box:[t+e.x1*p,i+e.y1*p,t+e.x2*p,i+e.y2*p]}}const[m,_,g,y]=f.box,v=o?f.allPointsOccluded:d.isOccluded;let x=v;return x||(x=d.perspectiveRatio<this.perspectiveRatioCutoff),x||(x=!this.isInsideGrid(m,_,g,y)),x||"always"!==t&&this.grid.hitTest(m,_,g,y,t,l)?{box:[m,_,g,y],placeable:!1,offscreen:!1,occluded:v}:{box:[m,_,g,y],placeable:!0,offscreen:this.isOffscreen(m,_,g,y),occluded:v}}placeCollisionCircles(e,t,i,r,n,s,a,l,c,h,u,d,p,f){const m=[],_=new o(t.anchorX,t.anchorY),g=this.getPerspectiveRatio(_.x,_.y,s,f),y=(c?n*this.transform.getPitchedTextCorrection(t.anchorX,t.anchorY,s)/g:n*g)/24,v={getElevation:f,pitchedLabelPlaneMatrix:a,lineVertexArray:i,pitchWithMap:c,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:_,unwrappedTileID:s,width:this.transform.width,height:this.transform.height,translation:p},x=A_(y,r,t.lineOffsetX*y,t.lineOffsetY*y,!1,t,!1,v);let b=!1,w=!1,T=!0;if(x){const t=.5*u*g+d,i=new o(-100,-100),r=new o(this.screenRightBoundary,this.screenBottomBoundary),n=new y_,s=x.first,a=x.last;let p=[];for(let e=s.path.length-1;e>=1;e--)p.push(s.path[e]);for(let e=1;e<a.path.length;e++)p.push(a.path[e]);const f=2.5*t;if(c){const e=this.projectPathToScreenSpace(p,v);p=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let _=[];if(p.length>0){const 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);_=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?[]:function(e,t,i,r,n){const s=[];for(const a of e){let e;for(let l=0;l<a.length-1;l++){let c=a[l],h=a[l+1];c.x<t&&h.x<t||(c.x<t?c=new o(t,c.y+(t-c.x)/(h.x-c.x)*(h.y-c.y))._round():h.x<t&&(h=new o(t,c.y+(t-c.x)/(h.x-c.x)*(h.y-c.y))._round()),c.y<i&&h.y<i||(c.y<i?c=new o(c.x+(i-c.y)/(h.y-c.y)*(h.x-c.x),i)._round():h.y<i&&(h=new o(c.x+(i-c.y)/(h.y-c.y)*(h.x-c.x),i)._round()),c.x>=r&&h.x>=r||(c.x>=r?c=new o(r,c.y+(r-c.x)/(h.x-c.x)*(h.y-c.y))._round():h.x>=r&&(h=new o(r,c.y+(r-c.x)/(h.x-c.x)*(h.y-c.y))._round()),c.y>=n&&h.y>=n||(c.y>=n?c=new o(c.x+(n-c.y)/(h.y-c.y)*(h.x-c.x),n)._round():h.y>=n&&(h=new o(c.x+(n-c.y)/(h.y-c.y)*(h.x-c.x),n)._round()),e&&c.equals(e[e.length-1])||(e=[c],s.push(e)),e.push(h)))))}}return s}([p],i.x,i.y,r.x,r.y)}for(const i of _){n.reset(i,.25*t);let r=0;r=n.length<=.5*t?1:Math.ceil(n.paddedLength/f)+1;for(let i=0;i<r;i++){const o=i/Math.max(r-1,1),s=n.lerp(o),a=s.x+$_,c=s.y+$_;m.push(a,c,t,0);const u=a-t,d=c-t,p=a+t,f=c+t;if(T&&(T=this.isOffscreen(u,d,p,f)),w||(w=this.isInsideGrid(u,d,p,f)),"always"!==e&&this.grid.hitTestCircle(a,c,t,e,h)&&(b=!0,!l))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!l&&b||!w||g<this.perspectiveRatioCutoff?[]:m,offscreen:T,collisionDetected:b}}projectPathToScreenSpace(e,t){const i=function(e,t){const i=w_;return function(e,t){const 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=>{const r=I_(e.x,e.y,i,t.getElevation),n=t.transform.projectTileCoordinates(r.point.x,r.point.y,t.unwrappedTileID,t.getElevation);return n.point.x=(.5*n.point.x+.5)*t.width,n.point.y=(.5*-n.point.y+.5)*t.height,n}))}(e,t);return function(e){let t=0,i=0,r=0,n=0;for(let o=0;o<e.length;o++)e[o].isOccluded?(r=o+1,n=0):(n++,n>i&&(i=n,t=r));return e.slice(t,t+i)}(i)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const t=[],i=new Fp;for(const r of e){const e=new o(r.x+$_,r.y+$_);i.extend(e),t.push(e)}const{minX:r,minY:n,maxX:s,maxY:a}=i,l=this.grid.query(r,n,s,a).concat(this.ignoredGrid.query(r,n,s,a)),c={},h={};for(const e of l){const i=e.key;void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]={}),c[i.bucketInstanceId][i.featureIndex]||ic(t,[new o(e.x1,e.y1),new o(e.x2,e.y1),new o(e.x2,e.y2),new o(e.x1,e.y2)])&&(c[i.bucketInstanceId][i.featureIndex]=!0,void 0===h[i.bucketInstanceId]&&(h[i.bucketInstanceId]=[]),h[i.bucketInstanceId].push(i.featureIndex))}return h}insertCollisionBox(e,t,i,r,n,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,n,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:t};for(let t=0;t<e.length;t+=4)s.insertCircle(a,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,t,i,r,n){if(n){let i;r?(i=[e,t,r(e,t),1],$(i,i,n)):(i=[e,t,0,1],G_(i,i,n));const o=i[3];return{x:(i[0]/o+1)/2*this.transform.width+$_,y:(-i[1]/o+1)/2*this.transform.height+$_,perspectiveRatio:.5+this.transform.cameraToCenterDistance/o*.5,isOccluded:!1,signedDistanceFromCamera:o}}{const n=this.transform.projectTileCoordinates(e,t,i,r);return{x:(n.point.x+1)/2*this.transform.width+$_,y:(1-n.point.y)/2*this.transform.height+$_,perspectiveRatio:.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5,isOccluded:n.isOccluded,signedDistanceFromCamera:n.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,i,r){const n=this.transform.projectTileCoordinates(e,t,i,r);return.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5}isOffscreen(e,t,i,r){return i<$_||e>=this.screenRightBoundary||r<$_||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=y([]);return b(e,e,[-100,-100,0]),e}_projectCollisionBox(e,t,i,r,n,s,a,l,c,h,u){let d=1,p=0,f=0,m=1;const _=e.anchorPointX+a[0],g=e.anchorPointY+a[1];if(s&&!n){const e=this.projectAndGetPerspectiveRatio(_+1,g,r,c,u),t=e.x-l.x,i=Math.atan((e.y-l.y)/t)+(t<0?Math.PI:0),n=Math.sin(i),o=Math.cos(i);d=o,p=n,f=-n,m=o}else if(!s&&n){const e=P_(this.transform);d=e.vecEast[0],p=e.vecEast[1],f=e.vecSouth[0],m=e.vecSouth[1]}let y=l.x,v=l.y,x=t;n&&(y=_,v=g,x=Math.pow(2,-(this.transform.zoom-i.overscaledZ)),x*=this.transform.getPitchedTextCorrection(_,g,r),h||(x*=be(.5+l.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),h&&(y+=d*h.x*x+f*h.y*x,v+=p*h.x*x+m*h.y*x);const b=e.x1*x,w=e.x2*x,T=(b+w)/2,S=e.y1*x,P=e.y2*x,I=(S+P)/2,M=[{offsetX:b,offsetY:S},{offsetX:T,offsetY:S},{offsetX:w,offsetY:S},{offsetX:w,offsetY:I},{offsetX:w,offsetY:P},{offsetX:T,offsetY:P},{offsetX:b,offsetY:P},{offsetX:b,offsetY:I}];let E=[];for(const{offsetX:e,offsetY:t}of M)E.push(new o(y+d*e+f*t,v+p*e+m*t));let C=!1;if(n){const e=E.map((e=>this.projectAndGetPerspectiveRatio(e.x,e.y,r,c,u)));C=e.some((e=>!e.isOccluded)),E=e.map((e=>new o(e.x,e.y)))}else C=!0;return{box:ge(E),allPointsOccluded:!C}}}class q_ extends o{constructor(e,t,i,r){super(e,t),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new q_(this.x,this.y,this.angle,this.segment)}}var W_;gs("Anchor",q_),function(e){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"}(W_||(W_={}));class H_{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}}class X_{constructor(e,t,i,r,n){this.text=new H_(e?e.text:null,t,i,n),this.icon=new H_(e?e.icon:null,t,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Y_{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class K_{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class J_{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function Q_(e,t,i,r,n){const{horizontalAlign:s,verticalAlign:a}=od(e);return new o(-(s-.5)*t+r[0]*n,-(a-.5)*i+r[1]*n)}class eg{constructor(e,t,i,r,n){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Z_(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new J_(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,t,i,r){const n=i.getBucket(t),o=i.latestFeatureIndex;if(!n||!o||t.id!==n.layerIds[0])return;const s=i.collisionBoxArray,a=n.layers[0].layout,l=n.layers[0].paint,c=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),h=i.tileSize/Q,u=i.tileID.toUnwrapped(),d="map"===a.get("text-rotation-alignment"),p=ee(i,1,this.transform.zoom),f=ae(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=ae(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),_=T_(d,this.transform,p);this.retainedQueryData[n.bucketInstanceId]=new K_(n.bucketInstanceId,o,n.sourceLayerIndex,n.index,i.tileID);const g={bucket:n,layout:a,translationText:f,translationIcon:m,unwrappedTileID:u,pitchedLabelPlaneMatrix:_,scale:c,textPixelRatio:h,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:ld(n.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const t of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:g})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:g})}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v){var x,b,w;const T=W_[e.textAnchor],S=[e.textOffset0,e.textOffset1],P=Q_(T,i,r,S,n),I=this.collisionIndex.placeCollisionBox(t,u,a,l,c,s,o,m,h.predicate,y,P,v);if((!g||this.collisionIndex.placeCollisionBox(g,u,a,l,c,s,o,_,h.predicate,y,P,v).placeable)&&I.placeable){let e;if((null===(x=this.prevPlacement)||void 0===x?void 0:x.variableOffsets[d.crossTileID])&&(null===(w=null===(b=this.prevPlacement)||void 0===b?void 0:b.placements[d.crossTileID])||void 0===w?void 0:w.text)&&(e=this.prevPlacement.variableOffsets[d.crossTileID].anchor),0===d.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:S,width:i,height:r,anchor:T,textBoxScale:n,prevAnchor:e},this.markUsedJustification(p,T,d,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,d),this.placedOrientations[d.crossTileID]=f),{shift:P,placedGlyphBoxes:I}}}placeLayerBucketPart(e,t,i){const{bucket:r,layout:n,translationText:o,translationIcon:s,unwrappedTileID:a,pitchedLabelPlaneMatrix:l,textPixelRatio:c,holdingForFade:h,collisionBoxArray:u,partiallyEvaluatedTextSize:d,collisionGroup:p}=e.parameters,f=n.get("text-optional"),m=n.get("icon-optional"),_=cd(n,"text-overlap","text-allow-overlap"),g="always"===_,y=cd(n,"icon-overlap","icon-allow-overlap"),v="always"===y,x="map"===n.get("text-rotation-alignment"),b="map"===n.get("text-pitch-alignment"),w="none"!==n.get("icon-text-fit"),T="viewport-y"===n.get("symbol-z-order"),S=g&&(v||!r.hasIconData()||m),P=v&&(g||!r.hasTextData()||f);!r.collisionArrays&&u&&r.deserializeCollisionBoxes(u);const I=this.retainedQueryData[r.bucketInstanceId].tileID,M=this._getTerrainElevationFunc(I),E=this.transform.getFastPathSimpleProjectionMatrix(I),C=(e,u,v)=>{var T,C;if(t[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new Y_(!1,!1,!1));let A=!1,z=!1,D=!0,R=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},L={placeable:!1},F=null,B=null,O=null,V=0,j=0,N=0;u.textFeatureIndex?V=u.textFeatureIndex:e.useRuntimeCollisionCircles&&(V=e.featureIndex),u.verticalTextFeatureIndex&&(j=u.verticalTextFeatureIndex);const U=u.textBox;if(U){const t=t=>{let i=nd.horizontal;if(r.allowVerticalPlacement&&!t&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,i=t,this.markUsedOrientation(r,i,e))}return i},n=(t,i)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&u.verticalTextBox){for(const e of r.writingModes)if(e===nd.vertical?(k=i(),L=k):k=t(),null==k?void 0:k.placeable)break}else k=t()},l=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===l){const i=(t,i)=>{const n=this.collisionIndex.placeCollisionBox(t,_,c,I,a,b,x,o,p.predicate,M,void 0,E);return(null==n?void 0:n.placeable)&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),n};n((()=>i(U,nd.horizontal)),(()=>{const t=u.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&t?i(t,nd.vertical):{box:null,offscreen:null}})),t(null==k?void 0:k.placeable)}else{let d=W_[null===(C=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[e.crossTileID])||void 0===C?void 0:C.anchor];const f=(t,n,u)=>{const f=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,v=w&&"never"===y?n:null;let T=null,S="never"===_?1:2,P="never";d&&S++;for(let i=0;i<S;i++){for(let i=l;i<h;i++){const n=r.textAnchorOffsets.get(i);if(d&&n.textAnchor!==d)continue;const l=this.attemptAnchorPlacement(n,t,f,m,g,x,b,c,I,a,p,P,e,r,u,o,s,v,M);if(l&&(T=l.placedGlyphBoxes,null==T?void 0:T.placeable))return A=!0,R=l.shift,T}d?d=null:P=_}return i&&!T&&(T={box:this.collisionIndex.placeCollisionBox(U,"always",c,I,a,b,x,o,p.predicate,M,void 0,E).box,offscreen:!1,placeable:!1,occluded:!1}),T};n((()=>f(U,u.iconBox,nd.horizontal)),(()=>{const t=u.verticalTextBox;return r.allowVerticalPlacement&&!(null==k?void 0:k.placeable)&&e.numVerticalGlyphVertices>0&&t?f(t,u.verticalIconBox,nd.vertical):{box:null,occluded:!0,offscreen:null}})),k&&(A=k.placeable,D=k.offscreen);const m=t(null==k?void 0:k.placeable);if(!A&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,m))}}}if(F=k,A=null==F?void 0:F.placeable,D=null==F?void 0:F.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const t=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),s=ad(r.textSizeData,d,t),c=n.get("text-padding");B=this.collisionIndex.placeCollisionCircles(_,t,r.lineVertexArray,r.glyphOffsetArray,s,a,l,i,b,p.predicate,e.collisionCircleDiameter,c,o,M),B.circles.length&&B.collisionDetected&&!i&&Le("Collisions detected, but collision boxes are not shown"),A=g||B.circles.length>0&&!B.collisionDetected,D&&(D=B.offscreen)}if(u.iconFeatureIndex&&(N=u.iconFeatureIndex),u.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,y,c,I,a,b,x,s,p.predicate,M,w&&R?R:void 0,E);L&&L.placeable&&u.verticalIconBox?(O=e(u.verticalIconBox),z=O.placeable):(O=e(u.iconBox),z=O.placeable),D&&(D=O.offscreen)}const G=f||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,$=m||0===e.numIconVertices;G||$?$?G||z&&(z=A):A=z&&A:z=A=z&&A;const Z=z&&O.placeable;if(A&&F.placeable&&this.collisionIndex.insertCollisionBox(F.box,_,n.get("text-ignore-placement"),r.bucketInstanceId,L&&L.placeable&&j?j:V,p.ID),Z&&this.collisionIndex.insertCollisionBox(O.box,y,n.get("icon-ignore-placement"),r.bucketInstanceId,N,p.ID),B&&A&&this.collisionIndex.insertCollisionCircles(B.circles,_,n.get("text-ignore-placement"),r.bucketInstanceId,V,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,v,u,F,O,B),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Y_((A||S)&&!(null==F?void 0:F.occluded),(z||P)&&!(null==O?void 0:O.occluded),D||r.justReloaded),t[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const 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,n,o){if(i.textBox||i.iconBox){let o,s;this.collisionBoxArrays.has(e)?o=this.collisionBoxArrays.get(e):(o=new Map,this.collisionBoxArrays.set(e,o)),o.has(t)?s=o.get(t):(s={text:null,icon:null},o.set(t,s)),i.textBox&&(s.text=r.box),i.iconBox&&(s.icon=n.box)}if(o){let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<o.circles.length;e+=4)t.push(o.circles[e+0]-$_),t.push(o.circles[e+1]-$_),t.push(o.circles[e+2]),t.push(o.collisionDetected?1:0)}}markUsedJustification(e,t,i,r){let n;n=r===nd.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[function(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"}(t)];const o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const t of o)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=n>=0&&t!==n?0:i.crossTileID)}markUsedOrientation(e,t,i){const r=t===nd.horizontal||t===nd.horizontalOnly?t:0,n=t===nd.vertical?t:0,o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const t of o)e.text.placedSymbolArray.get(t).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new X_(o,r,t.text,t.icon),i||(i=t.text!==o.text.placed),i||(i=t.icon!==o.icon.placed)):(this.opacities[e]=new X_(null,r,t.text,t.icon,t.skipFade),i||(i=t.text||t.icon))}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new X_(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i||(i=t.text.placed),i||(i=t.icon.placed))}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new 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){const i={};for(const r of t){const 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();const n=e.layers[0],s=n.layout,a=new X_(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new X_(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const m=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i);e.hasVisibleVertices||(e.hasVisibleVertices=i!==hg)},_=this.collisionBoxArrays.get(e.bucketInstanceId);for(let t=0;t<e.symbolInstances.length;t++){const r=e.symbolInstances.get(t),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:s,crossTileID:l}=r;let c=this.opacities[l];i[l]?c=a:c||(c=f,this.opacities[l]=c),i[l]=!0;const g=r.numIconVertices>0,y=this.placedOrientations[r.crossTileID],v=y===nd.vertical,x=y===nd.horizontal||y===nd.horizontalOnly;if(n>0||s>0){const t=cg(c.text);m(e.text,n,v?hg:t),m(e.text,s,x?hg:t);const i=c.text.isHidden(),o=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(const t of o)t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||v?1:0);r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||x?1:0);const a=this.variableOffsets[r.crossTileID];a&&this.markUsedJustification(e,a.anchor,r,y);const l=this.placedOrientations[r.crossTileID];l&&(this.markUsedJustification(e,"left",r,l),this.markUsedOrientation(e,l,r))}if(g){const t=cg(c.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&v);r.placedIconSymbolIndex>=0&&(m(e.icon,r.numIconVertices,i?t:hg),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=c.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,r.numVerticalIconVertices,i?hg:t),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const b=(null==_?void 0:_.has(t))?_.get(t):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[t];if(i){let t=new o(0,0);if(i.textBox||i.verticalTextBox){let r=!0;if(h){const e=this.variableOffsets[l];e?(t=Q_(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&t._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):r=!1}if(i.textBox||i.verticalTextBox){let n;i.textBox&&(n=v),i.verticalTextBox&&(n=x),tg(e.textCollisionBox.collisionVertexArray,c.text.placed,!r||n,b.text,t.x,t.y)}}if(i.iconBox||i.verticalIconBox){const r=Boolean(!x&&i.verticalIconBox);let n;i.iconBox&&(n=r),i.verticalIconBox&&(n=!r),tg(e.iconCollisionBox.collisionVertexArray,c.icon.placed,n,b.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 new 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 new 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){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function tg(e,t,i,r,n,o){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-$_,a=r[1]-$_,l=r[2]-$_,c=r[3]-$_;e.emplaceBack(t?1:0,i?1:0,n||0,o||0,s,a),e.emplaceBack(t?1:0,i?1:0,n||0,o||0,l,a),e.emplaceBack(t?1:0,i?1:0,n||0,o||0,l,c),e.emplaceBack(t?1:0,i?1:0,n||0,o||0,s,c)}const ig=Math.pow(2,25),rg=Math.pow(2,24),ng=Math.pow(2,17),og=Math.pow(2,16),sg=Math.pow(2,9),ag=Math.pow(2,8),lg=Math.pow(2,1);function cg(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*ig+t*rg+i*ng+t*og+i*sg+t*ag+i*lg+t}const hg=0;class ug{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,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<o.length;)if(t.placeLayerBucketPart(o[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,n())return!0;return!1}}class dg{constructor(e,t,i,r,n,o,s,a){this.placement=new eg(e,t,o,s,a),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){const r=st(),n=()=>!this._forceFullPlacement&&st()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(bd(r)&&r.layout&&(!r.minzoom||r.minzoom<=o)&&(!r.maxzoom||r.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new ug(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const pg=.03125;class fg{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this._symbolsByKey={};const r=new Map;for(let e=0;e<t.length;e++){const i=t.get(e),n=i.key,o=r.get(n);o?o.push(i):r.set(n,[i])}for(const[e,t]of r){const i={positions:t.map((e=>({x:Math.floor(e.anchorX*pg),y:Math.floor(e.anchorY*pg)}))),crossTileIDs:t.map((e=>e.crossTileID))};if(i.positions.length>128){const e=new au(i.positions.length,16,Uint16Array);for(const{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){const{x:i,y:r,z:n}=this.tileID.canonical,{x:o,y:s,z:a}=t.canonical,l=pg/Math.pow(2,a-n),c=(s*Q+e.anchorY)*l,h=r*Q*pg;return{x:Math.floor((o*Q+e.anchorX)*l-i*Q*pg),y:Math.floor(c-h)}}findMatches(e,t,i){const r=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let n=0;n<e.length;n++){const o=e.get(n);if(o.crossTileID)continue;const s=this._symbolsByKey[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,t);if(s.index){const e=s.index.range(a.x-r,a.y-r,a.x+r,a.y+r).sort();for(const t of e){const e=s.crossTileIDs[t];if(!i[e]){i[e]=!0,o.crossTileID=e;break}}}else if(s.positions)for(let e=0;e<s.positions.length;e++){const t=s.positions[e],n=s.crossTileIDs[e];if(Math.abs(t.x-a.x)<=r&&Math.abs(t.y-a.y)<=r&&!i[n]){i[n]=!0,o.crossTileID=n;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:e})=>e))}}class mg{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class _g{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){var r,n,o;if(null===(r=this.indexes[e.overscaledZ])||void 0===r?void 0:r[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;(n=this.usedCrossTileIDs)[o=e.overscaledZ]||(n[o]={});const s=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const r=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in r){const n=r[i];n.tileID.isChildOf(e)&&n.findMatches(t.symbolInstances,e,s)}else{const n=r[e.scaledTo(Number(i)).key];n&&n.findMatches(t.symbolInstances,e,s)}}for(let e=0;e<t.symbolInstances.length;e++){const r=t.symbolInstances.get(e);r.crossTileID||(r.crossTileID=i.generate(),s[r.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new fg(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.getCrossTileIDsLists())for(const t of i)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0)}return t}}class gg{constructor(){this.layerIndexes={},this.crossTileIDs=new mg,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let r=this.layerIndexes[e.id];void 0===r&&(r=this.layerIndexes[e.id]=new _g);let n=!1;const o={};r.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);e.id===(null==t?void 0:t.layerIds[0])&&(t.bucketInstanceId||(this.maxBucketInstanceId+=1,t.bucketInstanceId=this.maxBucketInstanceId),r.addBucket(i.tileID,t,this.crossTileIDs)&&(n=!0),o[t.bucketInstanceId]=!0)}return r.removeStaleBuckets(o)&&(n=!0),n}pruneUnusedLayers(e){const t={};for(const i of e)t[i]=!0;for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var yg="void main() {fragColor=vec4(1.0);}";const vg={prelude:xg("#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;","#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 float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}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 float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\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(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*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+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));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;uniform mat4 u_projection_matrix;"),projectionMercator:xg("","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:xg("","#define GLOBE_RADIUS 6371008.8\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;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 spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\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) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:xg("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}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:xg("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;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:xg("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float 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 lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+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:xg(yg,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:xg("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);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;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/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=floor(pos_raw/8.0);\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:xg("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;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:xg("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:xg("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:xg("#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) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,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;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.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:xg("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);}","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:xg(yg,"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:xg("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:xg("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);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_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:xg("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;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 mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: 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);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_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;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 mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: 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;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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:xg("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: 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);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;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: 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 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:xg("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;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=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=mod(normal.x,2.0);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:xg("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 mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: 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;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin 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 mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: 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=a_normal_ed.xyz;float edgedistance=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=mod(normal.x,2.0);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=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\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:xg("#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(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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;in vec2 a_pos;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:xg("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() {vec4 pixel=texture(u_image,v_pos);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;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:xg("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat 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\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;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 mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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:xg("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;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 mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat 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\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;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 mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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:xg("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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 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\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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:xg("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat 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\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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:xg("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat 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\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*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=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;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);}"),raster:xg("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 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);vec4 color1=texture(u_image1,v_pos1);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 vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:xg("uniform sampler2D u_texture;in vec2 v_tex;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}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;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 highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;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;out vec2 v_tex;out float v_total_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);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_fade_change :-u_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);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:xg("#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 lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: 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}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);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_fade_change :-u_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);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:xg("#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;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_data1.w==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}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;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;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);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_fade_change :-u_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);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=vec4(gamma_scale,size,total_opacity,is_sdf);}"),terrain:xg("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;}}","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:xg("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);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:xg("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:xg("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:xg("#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;}","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:xg("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;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 (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);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function xg(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(n):n,a={};return{fragmentSource:e=e.replace(i,((e,t,i,r,n)=>(a[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,n)=>{const o="float"===r?"vec2":"vec4",s=n.match(/color/)?"color":o;return a[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${o} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${o} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:r,staticUniforms:s}}class bg{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}}var wg=na([{name:"a_pos",type:"Int16",components:2}]);const Tg="#define PROJECTION_MERCATOR",Sg="mercator";class Pg{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Sg}get shaderDefine(){return Tg}get shaderPreludeCode(){return vg.projectionMercator}get vertexShaderPreludeCode(){return vg.projectionMercator.vertexSource}get subdivisionGranularity(){return Sh.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,t,i,r,n){if(this._cachedMesh)return this._cachedMesh;const o=new Ua;o.emplaceBack(0,0),o.emplaceBack(Q,0),o.emplaceBack(0,Q),o.emplaceBack(Q,Q);const s=e.createVertexBuffer(o,wg.members),a=hl.simpleSegment(0,0,4,2),l=new ol;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);const c=e.createIndexBuffer(l);return this._cachedMesh=new bg(s,c,a),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Ig{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 new 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=br.number(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=br.number(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=br.number(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=br.number(e.right,t.right,i)),this}getCenter(e,t){return new o(be((this.left+e-this.right)/2,0,e),be((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 Ig(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Mg(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function Eg(e){return Math.max(0,Math.floor(e))}class Cg{constructor(e,t){var i;this.applyConstrain=(e,t)=>null!==this._constrainOverride?this._constrainOverride(e,t):this._callbacks.defaultConstrain(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==t?void 0:t.renderWorldCopies)||!!(null==t?void 0:t.renderWorldCopies),this._minZoom=(null==t?void 0:t.minZoom)||0,this._maxZoom=(null==t?void 0:t.maxZoom)||22,this._minPitch=null==(null==t?void 0:t.minPitch)?0:null==t?void 0:t.minPitch,this._maxPitch=null==(null==t?void 0:t.maxPitch)?60:null==t?void 0:t.maxPitch,this._constrainOverride=null!==(i=null==t?void 0:t.constrainOverride)&&void 0!==i?i:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new ap(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Eg(this._zoom),this._scale=Me(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ig,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=Eg(this._zoom),this._scale=Me(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 Ig(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){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}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 o(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const t=we(e,-180,180)*Math.PI/180;var i,r,n,o,s,a,l,c,h;this._bearingInRadians!==t&&(this._unmodified=!1,this._bearingInRadians=t,this._calcMatrices(),this._rotationMatrix=f(),i=this._rotationMatrix,n=-this._bearingInRadians,o=(r=this._rotationMatrix)[0],s=r[1],a=r[2],l=r[3],c=Math.sin(n),h=Math.cos(n),i[0]=o*h+a*c,i[1]=s*h+l*c,i[2]=o*-c+a*h,i[3]=s*-c+l*h)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const t=be(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){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return Ge(this._fovInRadians)}setFov(e){e=be(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=Ue(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const 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=Me(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(){var e,t;return 2!==(null===(e=this._latRange)||void 0===e?void 0:e.length)||2!==(null===(t=this._lngRange)||void 0===t?void 0:t.length)?null:new lp([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=[-85.051129,We])}getCameraQueryGeometry(e,t){if(1===t.length)return[t[0],e];{const{minX:i,minY:r,maxX:n,maxY:s}=Fp.fromPoints(t).extend(e);return[new o(i,r),new o(n,r),new o(n,s),new o(i,s),new o(i,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const 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._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=y(new Float64Array(16));w(e,e,[this._width/2,-this._height/2,1]),b(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=y(new Float64Array(16)),w(e,e,[1,-1,1]),b(e,e,[-1,-1,0]),w(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,t,i,r){const n=void 0!==i?i:this.bearing,o=r=void 0!==r?r:this.pitch,{distanceToCenter:s,clampedElevation:a}=this._distanceToCenterFromAltElevationPitch(t,this.elevation,o),{x:l,y:c}=i_(o,n),h=gp.fromLngLat(e,t);let u,d,p=_p(1,h.y),f=0;do{if(f+=1,f>10)break;d=s/p,u=new gp(h.x+l*d,h.y+c*d),p=1/u.meterInMercatorCoordinateUnits()}while(Math.abs(s-d*p)>1e-12);return{center:u.toLngLat(),elevation:a,zoom:Ee(this.height/2/Math.tan(this.fovInRadians/2)/d/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const t=1/this.worldSize,i=pp(1,this.center.lat)*this.worldSize,r=gp.fromLngLat(this.center,this.elevation),n=r.x/t,o=r.y/t,s=r.z/t,a=this.pitch,l=this.bearing,{x:c,y:h,z:u}=i_(a,l),d=this.cameraToCenterDistance,p=n+d*-c,f=o+d*-h,m=s+d*u,{distanceToCenter:_,clampedElevation:g}=this._distanceToCenterFromAltElevationPitch(m/i,e,a),y=_*i,v=new gp((p+c*y)*t,(f+h*y)*t,0).toLngLat(),x=pp(1,v.lat),b=Ee(this.height/2/Math.tan(this.fovInRadians/2)/_/x/this.tileSize);this._elevation=g,this._center=v,this.setZoom(b)}_distanceToCenterFromAltElevationPitch(e,t,i){const r=-Math.cos(Ue(i)),n=e-t;let o,s=t;return r*n>=0||Math.abs(r)<.1?(o=1e4,s=e+o*r):o=-n/r,{distanceToCenter:o,clampedElevation:s}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=pp(1,this.center.lat)*this.worldSize;return t_(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const t=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/t,e.canonical.y/t,1/t/Q,1/t/Q]}}class Ag{constructor(e,t){this.min=e,this.max=t,this.center=R([],D([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=C(this.min),r=C(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],r[e]=t[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new Ag(i,r)}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(const i of e.planes){const 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}}class zg{distanceToTile2d(e,t,i,r){const n=r,o=n.distanceX([e,t]),s=n.distanceY([e,t]);return Math.hypot(o,s)}getWrap(e,t,i){return i}getTileBoundingVolume(e,t,i,r){var n,o;let s=0,a=0;if(null==r?void 0:r.terrain){const l=new Pp(e.z,t,e.z,e.x,e.y),c=r.terrain.getMinMaxElevation(l);s=null!==(n=c.minElevation)&&void 0!==n?n:Math.min(0,i),a=null!==(o=c.maxElevation)&&void 0!==o?o:Math.max(0,i)}const l=1<<e.z;return new Ag([t+e.x/l,e.y/l,s],[t+(e.x+1)/l,(e.y+1)/l,a])}allowVariableZoom(e,t){const i=be(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(){}}class Dg{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,t=1,i=0,r,n){const 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=Math.pow(2,i),a=[[-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((i=>function(e,t,i,r){const n=$([],e,t),o=1/n[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}(n,n,[o,o,1/n[3],o])}(i,e,t,s)));r&&function(e,t,i,r){const n=r?4:0,o=r?0:4;let s=0;const a=[],l=[];for(let t=0;t<4;t++){const i=U([],e[t+o],e[t+n]),r=A(i);R(i,i,1/r),a.push(r),l.push(i)}for(let t=0;t<4;t++){const r=he(e[t+n],l[t],i);s=null!==r&&r>=0?Math.max(s,r):Math.max(s,a[t])}const c=function(e,t){const i=[0,0,0,0];return k(i,F([],U([],e[t[0]],e[t[1]]),U([],e[t[2]],e[t[1]]))),i[3]=-L(i,e[t[0]]),i}(e,t),h=function(e,t){const i=G(e),r=((s=[])[0]=(a=e)[0]*(l=1/i),s[1]=a[1]*l,s[2]=a[2]*l,s[3]=a[3]*l,s),n=U([],t,R([],r,L(t,r))),o=G(n);var s,a,l;if(o>0){const e=Math.sqrt(1-r[3]*r[3]);return le(t,D([],R([],r,-r[3]),R([],n,e/o)))}return null}(i,c);if(null!==h){const e=h/L(l[0],c);s=Math.min(s,e)}for(let t=0;t<4;t++){const i=Math.min(s,a[t]);e[t+o]=[e[t+n][0]+l[t][0]*i,e[t+n][1]+l[t][1]*i,e[t+n][2]+l[t][2]*i,1]}}(a,o[0],r,n);const l=o.map((e=>{const t=k([],F([],U([],a[e[0]],a[e[1]]),U([],a[e[2]],a[e[1]]))),i=-L(t,a[e[1]]);return t.concat(i)})),c=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],h=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of a)for(let t=0;t<3;t++)c[t]=Math.min(c[t],e[t]),h[t]=Math.max(h[t],e[t]);return new Dg(a,l,new Ag(c,h))}}class Rg{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,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,t)=>{t=be(+t,this.minZoom,this.maxZoom);const i={center:new ap(e.lng,e.lat),zoom:t};let r=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===r){const e=180-1e-10;r=[-e,e]}const n=this.tileSize*Me(i.zoom);let s=0,a=n,l=0,c=n,h=0,u=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=dp(e[1])*n,a=dp(e[0])*n,a-s<p&&(h=p/(a-s))}r&&(l=we(up(r[0])*n,0,n),c=we(up(r[1])*n,0,n),c<l&&(c+=n),c-l<d&&(u=d/(c-l)));const{x:f,y:m}=Km(n,e);let _,g;const y=Math.max(u||0,h||0);if(y){const e=new o(u?(c+l)/2:f,h?(a+s)/2:m);return i.center=Jm(n,e).wrap(),i.zoom+=Ee(y),i}if(this._helper._latRange){const e=p/2;m-e<s&&(g=s+e),m+e>a&&(g=a-e)}if(r){const e=(l+c)/2;let t=f;this._helper._renderWorldCopies&&(t=we(f,e-n/2,e+n/2));const i=d/2;t-i<l&&(_=l+i),t+i>c&&(_=c-i)}if(void 0!==_||void 0!==g){const e=new o(null!=_?_:f,null!=g?g:m);i.center=Jm(n,e).wrap()}return i},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Cg({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new zg}clone(){const e=new Rg;return e.apply(this,!1),e}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){const t=[new Sp(0,e)];if(this._helper._renderWorldCopies){const i=this.screenPointToMercatorCoordinate(new o(0,0)),r=this.screenPointToMercatorCoordinate(new o(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new o(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new o(0,this._helper._height)),a=Math.floor(Math.min(i.x,r.x,n.x,s.x)),l=Math.floor(Math.max(i.x,r.x,n.x,s.x)),c=1;for(let i=a-c;i<=l+c;i++)0!==i&&t.push(new Sp(i,e))}return t}getCameraFrustum(){return Dg.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,t){const i=pp(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(t,i),n=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,i),o=gp.fromLngLat(e),s=new gp(o.x-(r.x-n.x),o.y-(r.y-n.y));this.setCenter(null==s?void 0:s.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,t){return t?this.coordinatePoint(gp.fromLngLat(e),t.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(gp.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,t){const i=t||0,r=[e.x,e.y,0,1],n=[e.x,e.y,1,1];$(r,r,this._pixelMatrixInverse),$(n,n,this._pixelMatrixInverse);const o=r[3],s=n[3],a=r[1]/o,l=n[1]/s,c=r[2]/o,h=n[2]/s,u=c===h?0:(i-c)/(h-c);return new gp(br.number(r[0]/o,n[0]/s,u)/this.worldSize,br.number(a,l,u)/this.worldSize,i)}coordinatePoint(e,t=0,i=this._pixelMatrix){const r=[e.x*this.worldSize,e.y*this.worldSize,t,1];return $(r,r,i),new o(r[0]/r[3],r[1]/r[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Qm(this));return(new lp).extend(this.screenPointToLocation(new o(0,e))).extend(this.screenPointToLocation(new o(this._helper._width,e))).extend(this.screenPointToLocation(new o(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new o(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-Qm(this)}calculatePosMatrix(e,t=!1,i){var r;const n=null!==(r=e.key)&&void 0!==r?r:Ip(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),o=t?this._alignedPosMatrixCache:this._posMatrixCache;if(o.has(n)){const e=o.get(n);return i?e.f32:e.f64}const s=e_(e,this.worldSize);x(s,t?this._alignedProjMatrix:this._viewProjMatrix,s);const a={f64:s,f32:new Float32Array(s)};return o.set(n,a),i?a.f32:a.f64}calculateFogMatrix(e){const t=e.key,i=this._fogMatrixCacheF32;if(i.has(t))return i.get(t);const r=e_(e,this.worldSize);return x(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)}_calculateNearFarZIfNeeded(e,t,i){if(!this._helper.autoCalculateNearFarZ)return;const r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),n=e-r*this._helper._pixelPerMeter/Math.cos(t),o=r<0?n:e,s=Math.PI/2+this.pitchInRadians,a=Ue(this.fov)*(Math.abs(Math.cos(Ue(this.roll)))*this.height+Math.abs(Math.sin(Ue(this.roll)))*this.width)/this.height*(.5+i.y/this.height),l=Math.sin(a)*o/Math.sin(be(Math.PI-s-a,.01,Math.PI-.01)),c=Qm(this),h=Math.atan(c/this._helper.cameraToCenterDistance),u=Ue(.75),d=h>u?2*h*(.5+i.y/(2*c)):u,p=Math.sin(d)*o/Math.sin(be(Math.PI-s-d,.01,Math.PI-.01)),f=Math.min(l,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-t)*f+o),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,t=Km(this.worldSize,this.center),i=t.x,r=t.y;this._helper._pixelPerMeter=pp(1,this.center.lat)*this.worldSize;const n=Ue(Math.min(this.pitch,Ym)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(n));let s;var a,l;this._calculateNearFarZIfNeeded(o,n,e),s=new Float64Array(16),I(s,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),(a=this._invProjMatrix)[0]=1/(l=s)[0],a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1/l[5],a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=0,a[11]=1/l[14],a[12]=0,a[13]=0,a[14]=-1,a[15]=l[10]/l[14],s[8]=2*-e.x/this._helper._width,s[9]=2*e.y/this._helper._height,this._projectionMatrix=g(s),w(s,s,[1,-1,1]),b(s,s,[0,0,-this._helper.cameraToCenterDistance]),P(s,s,-this.rollInRadians),T(s,s,this.pitchInRadians),P(s,s,-this.bearingInRadians),b(s,s,[-i,-r,0]),this._mercatorMatrix=w([],s,[this.worldSize,this.worldSize,this.worldSize]),w(s,s,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=x(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),b(s,s,[0,0,-this.elevation]),this._viewProjMatrix=s,this._invViewProjMatrix=v([],s);const c=[0,0,-1,1];$(c,c,this._invViewProjMatrix),this._cameraPosition=[c[0]/c[3],c[1]/c[3],c[2]/c[3]],this._fogMatrix=new Float64Array(16),I(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,w(this._fogMatrix,this._fogMatrix,[1,-1,1]),b(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),P(this._fogMatrix,this._fogMatrix,-this.rollInRadians),T(this._fogMatrix,this._fogMatrix,this.pitchInRadians),P(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),b(this._fogMatrix,this._fogMatrix,[-i,-r,0]),w(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),b(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=x(new Float64Array(16),this.clipSpaceToPixelsMatrix,s);const h=this._helper._width%2/2,u=this._helper._height%2/2,d=Math.cos(this.bearingInRadians),p=Math.sin(-this.bearingInRadians),f=i-Math.round(i)+d*h+p*u,m=r-Math.round(r)+d*u+p*h,_=new Float64Array(s);if(b(_,_,[f>.5?f-1:f,m>.5?m-1:m,0]),this._alignedProjMatrix=_,s=v(new Float64Array(16),this._pixelMatrix),!s)throw new Error("failed to invert matrix");this._pixelMatrixInverse=s,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new o(0,0)),t=[e.x*this.worldSize,e.y*this.worldSize,0,1];return $(t,t,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=pp(1,this.center.lat)*this.worldSize;return t_(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,t){const i=gp.fromLngLat(e),r=[i.x*this.worldSize,i.y*this.worldSize,t,1];return $(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){const{overscaledTileID:t,aligned:i,applyTerrainMatrix:r}=e,n=this._helper.getMercatorTileCoordinates(t),o=t?this.calculatePosMatrix(t,i,!0):null;let s;return s=(null==t?void 0:t.terrainRttPosMatrix32f)&&r?t.terrainRttPosMatrix32f:o||se(),{mainMatrix:s,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return C(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,t,i,r){const n=this.calculatePosMatrix(i);let s;r?(s=[e,t,r(e,t),1],$(s,s,n)):(s=[e,t,0,1],G_(s,s,n));const a=s[3];return{point:new o(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,t){const i=gp.fromLngLat(e,t),r=i.meterInMercatorCoordinateUnits(),n=oe();return b(n,n,[i.x,i.y,i.z]),P(n,n,Math.PI),T(n,n,Math.PI/2),w(n,n,[-r,r,r]),n}getProjectionDataForCustomLayer(e=!0){const t=new Pp(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:t,applyGlobeMatrix:e}),r=e_(t,this.worldSize);x(r,this._viewProjMatrix,r),i.tileMercatorCoords=[0,0,1,1];const n=[Q,Q,this.worldSize/this._helper.pixelsPerMeter],o=ne();return w(o,r,n),i.fallbackMatrix=o,i.mainMatrix=o,i}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function kg(){Le("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Lg(e){if(e.useSlerp)if(e.k<1){const t=qe(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),i=qe(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);!function(e,t,i,r){var n,o,s,a,l,c=t[0],h=t[1],u=t[2],p=t[3],f=i[0],m=i[1],_=i[2],g=i[3];(o=c*f+h*m+u*_+p*g)<0&&(o=-o,f=-f,m=-m,_=-_,g=-g),1-o>d?(n=Math.acos(o),s=Math.sin(n),a=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(a=1-r,l=r),e[0]=a*c+l*f,e[1]=a*h+l*m,e[2]=a*u+l*_,e[3]=a*p+l*g}(r,t,i,e.k);const n=function(e){const t=new Float64Array(9);var i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v;u=(n=(r=e)[0])*(l=n+n),d=(o=r[1])*l,f=(s=r[2])*l,m=s*(c=o+o),g=(a=r[3])*l,y=a*c,v=a*(h=s+s),(i=t)[0]=1-(p=o*c)-(_=s*h),i[3]=d-v,i[6]=f+y,i[1]=d+v,i[4]=1-u-_,i[7]=m-g,i[2]=f-y,i[5]=m+g,i[8]=1-u-p;const x=Ge(-Math.asin(be(t[2],-1,1)));let b,w;return Math.hypot(t[5],t[8])<.001?(b=0,w=-Ge(Math.atan2(t[3],t[4]))):(b=Ge(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),w=Ge(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:b,pitch:x+90,bearing:w}}(r);e.tr.setRoll(n.roll),e.tr.setPitch(n.pitch),e.tr.setBearing(n.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(br.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(br.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(br.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Fg(e,t,i,r,n){const s=n.padding,a=Km(n.worldSize,i.getNorthWest()),l=Km(n.worldSize,i.getNorthEast()),c=Km(n.worldSize,i.getSouthEast()),h=Km(n.worldSize,i.getSouthWest()),u=Ue(-r),d=a.rotate(u),p=l.rotate(u),f=c.rotate(u),m=h.rotate(u),_=new o(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),g=new o(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),y=_.sub(g),v=(n.width-(s.left+s.right+t.left+t.right))/y.x,x=(n.height-(s.top+s.bottom+t.top+t.bottom))/y.y;if(x<0||v<0)return void kg();const b=Math.min(Ee(n.scale*Math.min(v,x)),e.maxZoom),w=o.convert(e.offset),T=new o((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(Ue(r)),S=w.add(T).mult(n.scale/Me(b));return{center:Jm(n.worldSize,a.add(c).div(2).sub(S)),zoom:b,bearing:r}}class Bg{get useGlobeControls(){return!1}handlePanInertia(e,t){const i=e.mag(),r=Math.abs(Qm(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)}cameraForBoxAndBearing(e,t,i,r,n){return Fg(e,t,i,r,n)}handleJumpToCenterZoom(e,t){e.zoom!==(void 0!==t.zoom?+t.zoom:e.zoom)&&e.setZoom(+t.zoom),void 0!==t.center&&e.setCenter(ap.convert(t.center))}handleEaseTo(e,t){const i=e.zoom,r=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,a=!e.isPaddingEqual(t.padding);let l=!1;const c=s?+t.zoom:e.zoom;let h=e.centerPoint.add(t.offsetAsPoint);const u=e.screenPointToLocation(h),{center:d,zoom:p}=e.applyConstrain(ap.convert(t.center||u),null!=c?c:i);Mg(e,d);const f=Km(e.worldSize,u),m=Km(e.worldSize,d).sub(f),_=Me(p-i);return l=p!==i,{easeFunc:s=>{if(l&&e.setZoom(br.number(i,p,s)),$e(n,o)||Lg({startEulerAngles:n,endEulerAngles:o,tr:e,k:s,useSlerp:n.roll!=o.roll}),a&&(e.interpolatePadding(r,t.padding,s),h=e.centerPoint.add(t.offsetAsPoint)),t.around)e.setLocationAtPoint(t.around,t.aroundPoint);else{const t=Me(e.zoom-i),r=p>i?Math.min(2,_):Math.max(.5,_),n=Math.pow(r,1-s),o=Jm(e.worldSize,f.add(m.mult(s*n)).mult(t));e.setLocationAtPoint(e.renderWorldCopies?o.wrap():o,h)}},isZooming:l,elevationCenter:d}}handleFlyTo(e,t){const i=void 0!==t.zoom,r=e.zoom,n=e.applyConstrain(ap.convert(t.center||t.locationAtOffset),i?+t.zoom:r),o=n.center,s=n.zoom;Mg(e,o);const a=Km(e.worldSize,t.locationAtOffset),l=Km(e.worldSize,o).sub(a),c=l.mag(),h=Me(s-r);let u;if(void 0!==t.minZoom){const i=Math.min(+t.minZoom,r,s);u=Me(e.applyConstrain(o,i).zoom-r)}return{easeFunc:(t,i,n,c)=>{e.setZoom(1===t?s:r+Ee(i));const h=1===t?o:Jm(e.worldSize,a.add(l.mult(n)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,c)},scaleOfZoom:h,targetCenter:o,scaleOfMinZoom:u,pixelPathLength:c}}}class Og{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}Og.Replace=[1,0],Og.disabled=new Og(Og.Replace,Ri.transparent,[!1,!1,!1,!1]),Og.unblended=new Og(Og.Replace,Ri.transparent,[!0,!0,!0,!0]),Og.alphaBlended=new Og([1,771],Ri.transparent,[!0,!0,!0,!0]);const Vg=2305;class jg{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}jg.disabled=new jg(!1,1029,Vg),jg.backCCW=new jg(!0,1029,Vg),jg.frontCCW=new jg(!0,1028,Vg);class Ng{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}Ng.ReadOnly=!1,Ng.ReadWrite=!0,Ng.disabled=new Ng(519,Ng.ReadOnly,[0,1]);const Ug=7680;class Gg{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}function $g(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext}Gg.disabled=new Gg({func:519,mask:0},0,0,Ug,Ug,Ug);class Zg{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const t=e.context,i=t.gl;this._texFormat=i.RGBA,this._texType=i.UNSIGNED_BYTE;const r=new Ua;r.emplaceBack(-1,-1),r.emplaceBack(2,-1),r.emplaceBack(-1,2);const n=new ol;n.emplaceBack(0,1,2),this._fullscreenTriangle=new bg(t.createVertexBuffer(r,wg.members),t.createIndexBuffer(n),hl.simpleSegment(0,0,r.length,n.length)),this._resultBuffer=new Uint8Array(4),t.activeTexture.set(i.TEXTURE1);const o=i.createTexture();i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texImage2D(i.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=t.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),$g(i)&&(this._pbo=i.createBuffer(),i.bindBuffer(i.PIXEL_PACK_BUFFER,this._pbo),i.bufferData(i.PIXEL_PACK_BUFFER,4,i.STREAM_READ),i.bindBuffer(i.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,t){const i=this._cachedRenderContext.context,r=i.gl;if(this._bindFramebuffer(),i.viewport.set([0,0,this._texWidth,this._texHeight]),i.clear({color:Ri.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(i,r.TRIANGLES,Ng.disabled,Gg.disabled,Og.unblended,jg.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,t),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&$g(r)){r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.readBuffer(r.COLOR_ATTACHMENT0),r.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null);const e=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);r.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&$g(e)){const t=e.clientWaitSync(this._readbackQueue.sync,0,0);if(t===e.WAIT_FAILED)return Le("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(t===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Zg._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}function qg(e,t){const i=void 0!==e.granularity?Math.max(e.granularity,1):1,r=i+(e.generateBorders?2:0),n=i+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),o=r+1,s=n+1,a=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,c=i+(e.generateBorders?1:0),h=i+(e.generateBorders||e.extendToSouthPole?1:0),u=o*s,d=r*n*6,p=o*s>65536;if(p&&"16bit"===t)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const f=p||"32bit"===t,m=new Int16Array(2*u);let _=0;for(let t=l;t<=h;t++)for(let r=a;r<=c;r++){let n=r/i*Q;-1===r&&(n=-64),r===i+1&&(n=8256);let o=t/i*Q;-1===t&&(o=e.extendToNorthPole?Ph:-64),t===i+1&&(o=e.extendToSouthPole?Ih:8256),m[_++]=n,m[_++]=o}const g=f?new Uint32Array(d):new Uint16Array(d);let y=0;for(let e=0;e<n;e++)for(let t=0;t<r;t++){const i=t+1+e*o,r=t+(e+1)*o,n=t+1+(e+1)*o;g[y++]=t+e*o,g[y++]=r,g[y++]=i,g[y++]=i,g[y++]=r,g[y++]=n}return{vertices:m.buffer.slice(0),indices:g.buffer.slice(0),uses32bitIndices:f}}const Wg=new Sh({fill:new Th(128,2),line:new Th(512,0),tile:new Th(128,32),stencil:new Th(128,1),circle:3});class Hg{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}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 vg.projectionGlobe}get vertexShaderPreludeCode(){return vg.projectionMercator.vertexSource}get subdivisionGranularity(){return Wg}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new Zg(e));const t=dp(this._errorQueryLatitudeDegrees),i=2*Math.atan(Math.exp(Math.PI-t*Math.PI*2))-.5*Math.PI,r=this._errorMeasurement.updateErrorLoop(t,i),n=st();r!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=r,this._errorMeasurementLastChangeTime=n);const o=Math.min(Math.max((n-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=_e(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,ye(o))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,r,n){const o=("stencil"===n?Wg.stencil:Wg.tile).getGranularityForZoomLevel(t.z);return this._getMesh(e,{granularity:o,generateBorders:i,extendToNorthPole:0===t.y&&r,extendToSouthPole:t.y===(1<<t.z)-1&&r})}_getMesh(e,t){const i=this._getMeshKey(t);if(i in this._tileMeshCache)return this._tileMeshCache[i];const r=function(e,t){const i=qg(t,"16bit"),r=Ua.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),n=ol.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new bg(e.createVertexBuffer(r,wg.members),e.createIndexBuffer(n),hl.simpleSegment(0,0,r.length,n.length))}(e,t);return this._tileMeshCache[i]=r,r}recalculate(e){}hasTransition(){var e;const t=st();let i=!1;return i||(i=(t-this._errorMeasurementLastChangeTime)/1e3<.7),i||(i=null===(e=this._errorMeasurement)||void 0===e?void 0:e.awaitingQuery),i}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const Xg=new Ws({type:new Us(St.projection.type)});class Yg extends Tt{constructor(e){super(),this._transitionable=new Fs(Xg,void 0),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new zs(0)),this._mercatorProjection=new Pg,this._verticalPerspectiveProjection=new Hg}get transitionState(){const 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 Zi){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 latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,r,n){return this.currentProjection.getMeshFromTileID(e,t,i,r,n)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function Kg(e){const t=ey(e.worldSize,e.center.lat);return 2*Math.PI*t}function Jg(e,t,i,r,n){const o=1/(1<<n),s=t/Q*o+r*o,a=fe((e/Q*o+i*o)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI,c=Math.cos(l),h=new Float64Array(3);return h[0]=Math.sin(a)*c,h[1]=Math.sin(l),h[2]=Math.cos(a)*c,h}function Qg(e){return function(e,t){const 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 ey(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function ty(e){const t=Math.asin(e[1])/Math.PI*180,i=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(i>1e-6){const r=e[0]/i,n=Math.acos(e[2]/i),o=(r>0?n:-n)/Math.PI*180;return new ap(we(o,-180,180),t)}return new ap(0,t)}function iy(e){return Math.cos(e*Math.PI/180)}function ry(e,t){const i=iy(e);return Ee(iy(t)/i)}function ny(e,t){const i=e.rotate(t.bearingInRadians),r=t.zoom+ry(t.center.lat,0),n=_e(1/iy(t.center.lat),1/iy(Math.min(Math.abs(t.center.lat),60)),me(r,7,3,0,1)),o=360/Kg({worldSize:t.worldSize,center:{lat:t.center.lat}});return new ap(t.center.lng-i.x*o*n,be(t.center.lat+i.y*o,-85.051129,We))}function oy(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function sy(e,t,i,r){const n=e.lat+i*r;if(Math.abs(i)>1){const o=(Math.sign(e.lat+i)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,s=Math.abs(e.lat+i)*Math.PI/180,a=oy(o+r*(s-o)),l=oy(o),c=oy(s);return new ap(e.lng+t*((a-l)/(c-l)),n)}return new ap(e.lng+t*r,n)}class ay{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,r){const n=`${e.z}_${e.x}_${e.y}_${(null==r?void 0:r.terrain)?"t":""}`,o=this._cache.get(n);if(o)return o;const s=this._cachePrevious.get(n);if(s)return this._cache.set(n,s),s;const a=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(n,a),this._hadAnyChanges=!0,a}}class ly{constructor(e,t,i,r){this.min=i,this.max=r,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let r=0;r<8;r++)i.push([1&~r?e[0]:t[0],1==(r>>1&1)?t[1]:e[1],1==(r>>2&1)?t[2]:e[2]]);return new ly(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,t,i){const r=q([],i[0],i[1],i[2]),n=B([],[t[0],0,0],r),o=B([],[0,t[1],0],r),s=B([],[0,0,t[2]],r),a=[...e],l=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const r=e[i]+n[i]*(1&~t?-1:1)+o[i]*(1==(t>>1&1)?1:-1)+s[i]*(1==(t>>2&1)?1:-1);a[i]=Math.min(a[i],r),l[i]=Math.max(l[i],r)}const c=[];for(let t=0;t<8;t++){const i=[...e];D(i,i,R([],n,1&~t?-1:1)),D(i,i,R([],o,1==(t>>1&1)?1:-1)),D(i,i,R([],s,1==(t>>2&1)?1:-1)),c.push(i)}return new ly(c,[[...n,-L(n,c[0])],[...o,-L(o,c[0])],[...s,-L(s,c[0])],[-n[0],-n[1],-n[2],-L(n,c[7])],[-o[0],-o[1],-o[2],-L(o,c[7])],[-s[0],-s[1],-s[2],-L(s,c[7])]],a,l)}intersectsFrustum(e){let t=!0;const i=this.points.length,r=this.planes.length,n=e.planes.length,o=e.points.length;for(let r=0;r<n;r++){const n=e.planes[r];let o=0;for(let e=0;e<i;e++){const t=this.points[e];n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]>=0&&o++}if(0===o)return 0;o<i&&(t=!1)}if(t)return 2;for(let t=0;t<r;t++){const i=this.planes[t];let r=0;for(let t=0;t<o;t++){const n=e.points[t];i[0]*n[0]+i[1]*n[1]+i[2]*n[2]+i[3]>=0&&r++}if(0===r)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let r=0;r<t;r++){const 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 cy(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function hy(e,t,i,r,n){const o=e-i;let s;return s=o<0?Math.min(-o,1+o-n):o>n?Math.min(Math.max(o-n,0),1-o):0,Math.max(s,cy(t,r,n))}class uy{constructor(){this._boundingVolumeCache=new ay(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){const n=1<<i.z,o=1/n,s=i.x/n,a=i.y/n;let l=2;return l=Math.min(l,hy(e,t,s,a,o)),l=Math.min(l,hy(e,t,s+.5,-a-o,o)),l=Math.min(l,hy(e,t,s+.5,2-a-o,o)),l}getWrap(e,t,i){const r=1<<t.z,n=1/r,o=t.x/r,s=cy(e.x,o,n),a=cy(e.x,o-1,n),l=cy(e.x,o+1,n),c=Math.min(s,a,l);return c===l?1:c===a?-1:0}allowVariableZoom(e,t){return a_(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,r)}_computeTileBoundingVolume(e,t,i,r){var n,o;let s=0,a=0;if(null==r?void 0:r.terrain){const l=new Pp(e.z,t,e.z,e.x,e.y),c=r.terrain.getMinMaxElevation(l);s=null!==(n=c.minElevation)&&void 0!==n?n:Math.min(0,i),a=null!==(o=c.maxElevation)&&void 0!==o?o:Math.max(0,i)}if(s/=sp,a/=sp,s+=1,a+=1,e.z<=0)return ly.fromAabb([-a,-a,-a],[a,a,a]);if(1===e.z)return ly.fromAabb([0===e.x?-a:0,0===e.y?0:-a,-a],[0===e.x?0:a,0===e.y?a:0,a]);{const t=[Jg(0,0,e.x,e.y,e.z),Jg(Q,0,e.x,e.y,e.z),Jg(Q,Q,e.x,e.y,e.z),Jg(0,Q,e.x,e.y,e.z)],i=[];for(const e of t)i.push(R([],e,a));if(a!==s)for(const e of t)i.push(R([],e,s));0===e.y&&i.push([0,1,0]),e.y===(1<<e.z)-1&&i.push([0,-1,0]);const r=[1,1,1],n=[-1,-1,-1];for(const e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),n[t]=Math.max(n[t],e[t]);const o=Jg(4096,4096,e.x,e.y,e.z),l=F([],[0,1,0],o);k(l,l);const c=F([],o,l);k(c,c);const h=F([],t[2],t[1]);k(h,h);const u=F([],t[0],t[3]);k(u,u),i.push(R([],o,a)),e.y>=(1<<e.z)/2&&i.push(R([],Jg(4096,0,e.x,e.y,e.z),a)),e.y<(1<<e.z)/2&&i.push(R([],Jg(4096,Q,e.x,e.y,e.z),a));const d=dy(o,i),p=dy(c,i),f=[-o[0],-o[1],-o[2],d.max],m=[o[0],o[1],o[2],-d.min],_=[-c[0],-c[1],-c[2],p.max],g=[c[0],c[1],c[2],-p.min],y=[...h,0],v=[...u,0],x=[];return 0===e.y?x.push(ce(v,y,f),ce(v,y,m)):x.push(ce(_,y,f),ce(_,y,m),ce(_,v,f),ce(_,v,m)),e.y===(1<<e.z)-1?x.push(ce(v,y,f),ce(v,y,m)):x.push(ce(g,y,f),ce(g,y,m),ce(g,v,f),ce(g,v,m)),new ly(x,[f,m,_,g,y,v],r,n)}}}function dy(e,t){let i=1/0,r=-1/0;for(const n of t){const t=L(e,n);i=Math.min(i,t),r=Math.max(r,t)}return{min:i,max:r}}class py{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=ie(),this._projectionMatrix=oe(),this._globeViewProjMatrix32f=se(),this._globeViewProjMatrixNoCorrection=oe(),this._globeViewProjMatrixNoCorrectionInverted=oe(),this._globeProjMatrixInverted=oe(),this._cameraPosition=re(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(e,t)=>{const i=be(e.lat,-85.051129,We),r=be(+t,this.minZoom+ry(0,i),this.maxZoom);return{center:new ap(e.lng,i),zoom:r}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Cg({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new uy}clone(){const e=new py;return e.apply(this,!1),e}apply(e,t,i){this._globeLatitudeErrorCorrectionRadians=i||0,this._helper.apply(e,t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=re();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){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const t=this.pitchInRadians,i=this.cameraToCenterDistance/e,r=Math.sin(t)*i,n=Math.cos(t)*i+1,o=1/Math.sqrt(r*r+n*n)*1;let s=-r,a=n;const l=Math.sqrt(s*s+a*a);s/=l,a/=l;const c=[0,s,a];j(c,c,[0,0,0],-this.bearingInRadians),O(c,c,[0,0,0],-1*this.center.lat*Math.PI/180),V(c,c,[0,0,0],this.center.lng*Math.PI/180);const h=1/A(c);return R(c,c,h),[...c,-o*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(Qg(e))}transformLightDirection(e){const t=this._helper._center.lng*Math.PI/180,i=this._helper._center.lat*Math.PI/180,r=Math.cos(i),n=[Math.sin(t)*r,Math.sin(i),Math.cos(t)*r],o=[n[2],0,-n[0]],s=[0,0,0];F(s,o,n),k(o,o),k(s,s);const a=[0,0,0];return k(a,[o[0]*e[0]+s[0]*e[1]+n[0]*e[2],o[1]*e[0]+s[1]*e[1]+n[1]*e[2],o[2]*e[0]+s[2]*e[1]+n[2]*e[2]]),a}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){const r=function(e,t,i){const r=1/(1<<i.z);return new gp(e/Q*r+i.x*r,t/Q*r+i.y*r)}(e,t,i.canonical),n=(o=r.y,[fe(r.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);var o;return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(e,t,i,r){const n=i.canonical,s=Jg(e,t,n.x,n.y,n.z),a=1+(r?r(e,t):0)/sp,l=[s[0]*a,s[1]*a,s[2]*a,1];$(l,l,this._globeViewProjMatrixNoCorrection);const c=this._cachedClippingPlane,h=c[0]*s[0]+c[1]*s[1]+c[2]*s[2]+c[3]<0;return{point:new o(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:h}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=ey(this.worldSize,this.center.lat),t=ne(),i=ne();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);const r=this.centerOffset;t[8]=2*-r.x/this._helper._width,t[9]=2*r.y/this._helper._height,this._projectionMatrix=g(t),this._globeProjMatrixInverted=ne(),v(this._globeProjMatrixInverted,t),b(t,t,[0,0,-this.cameraToCenterDistance]),P(t,t,this.rollInRadians),T(t,t,-this.pitchInRadians),P(t,t,this.bearingInRadians),b(t,t,[0,0,-e]);const n=re();n[0]=e,n[1]=e,n[2]=e,T(i,t,this.center.lat*Math.PI/180),S(i,i,-this.center.lng*Math.PI/180),w(i,i,n),this._globeViewProjMatrixNoCorrection=i,T(t,t,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),S(t,t,-this.center.lng*Math.PI/180),w(t,t,n),this._globeViewProjMatrix32f=new Float32Array(t),this._globeViewProjMatrixNoCorrectionInverted=ne(),v(this._globeViewProjMatrixNoCorrectionInverted,i);const o=re();this._cameraPosition=re(),this._cameraPosition[2]=this.cameraToCenterDistance/e,j(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),O(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),j(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),D(this._cameraPosition,this._cameraPosition,[0,0,1]),O(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),V(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const s=g(this._globeViewProjMatrixNoCorrectionInverted);w(s,s,[1,1,-1]),this._cachedFrustum=Dg.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){Le("calculateFogMatrix is not supported on globe projection.");const t=ne();return y(t),t}getVisibleUnwrappedCoordinates(e){return[new Sp(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&Le("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){if(!this._globeViewProjMatrixNoCorrection)return 1;const i=Qg(e);R(i,i,1+t/sp);const r=ie();return $(r,[i[0],i[1],i[2],1],this._globeViewProjMatrixNoCorrection),r[2]/r[3]}populateCache(e){}getBounds(){const e=.5*this.width,t=.5*this.height,i=[new o(0,0),new o(e,0),new o(this.width,0),new o(this.width,t),new o(this.width,this.height),new o(e,this.height),new o(0,this.height),new o(0,t)],r=[];for(const e of i)r.push(this.unprojectScreenPoint(e));let n=0,s=0,a=0,l=0;const c=this.center;for(const e of r){const t=de(c.lng,e.lng),i=de(c.lat,e.lat);t<s&&(s=t),t>n&&(n=t),i<l&&(l=i),i>a&&(a=i)}const h=[c.lng+s,c.lat+l,c.lng+n,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new lp(h)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){const i=Qg(this.unprojectScreenPoint(t)),r=Qg(e),n=re();var o;(o=n)[0]=0,o[1]=0,o[2]=0;const s=re();V(s,i,n,-this.center.lng*Math.PI/180),O(s,s,n,this.center.lat*Math.PI/180);const a=r[0]*r[0]+r[2]*r[2],l=s[0]*s[0];if(a<l)return;const c=Math.sqrt(a-l),h=-c,u=ue(r[0],r[2],s[0],c),d=ue(r[0],r[2],s[0],h),p=re();V(p,r,n,-u);const f=ue(p[1],p[2],s[1],s[2]),m=re();V(m,r,n,-d);const _=ue(m[1],m[2],s[1],s[2]),g=.5*Math.PI,y=f>=-g&&f<=g,v=_>=-g&&_<=g;let x,b;if(y&&v){const e=this.center.lng*Math.PI/180,t=this.center.lat*Math.PI/180;pe(u,e)+pe(f,t)<pe(d,e)+pe(_,t)?(x=u,b=f):(x=d,b=_)}else if(y)x=u,b=f;else{if(!v)return;x=d,b=_}const w=x/Math.PI*180,T=b/Math.PI*180,S=this.center.lat;this.setCenter(new ap(w,be(T,-90,90))),this.setZoom(this.zoom+ry(S,this.center.lat))}locationToScreenPoint(e,t){const i=Qg(e);return t&&R(i,i,1+t.getElevationForLngLatZoom(e,this._helper._tileZoom)/sp),this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(e){const t=ie();return $(t,[...e,1],this._globeViewProjMatrixNoCorrection),t[0]/=t[3],t[1]/=t[3],new o((.5*t[0]+.5)*this.width,(.5*-t[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(i)return i}return gp.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}isPointOnMapSurface(e,t){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(i,r)}getRayDirectionFromPixel(e){const t=ie();t[0]=e.x/this.width*2-1,t[1]=-1*(e.y/this.height*2-1),t[2]=1,t[3]=1,$(t,t,this._globeViewProjMatrixNoCorrectionInverted),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3];const i=re();i[0]=t[0]-this._cameraPosition[0],i[1]=t[1]-this._cameraPosition[1],i[2]=t[2]-this._cameraPosition[2];const r=re();return k(r,i),r}isSurfacePointVisible(e){const 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;const t=ie();return $(t,[...e,1],this._globeViewProjMatrixNoCorrection),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}rayPlanetIntersection(e,t){const i=L(e,t),r=re(),n=re();R(n,t,i),U(r,e,n);const o=1-L(r,r);if(o<0)return null;const s=L(e,e)-1,a=-i+(i<0?1:-1)*Math.sqrt(o),l=s/a,c=a;return{tMin:Math.min(l,c),tMax:Math.max(l,c)}}unprojectScreenPoint(e){const t=this._cameraPosition,i=this.getRayDirectionFromPixel(e),r=this.rayPlanetIntersection(t,i);if(r){const e=re();D(e,t,[i[0]*r.tMin,i[1]*r.tMin,i[2]*r.tMin]);const n=re();return k(n,e),ty(n)}const n=this._cachedClippingPlane,o=n[0]*i[0]+n[1]*i[1]+n[2]*i[2],s=-le(n,t)/o,a=re();if(s>0)D(a,t,[i[0]*s,i[1]*s,i[2]*s]);else{const e=re();D(e,t,[2*i[0],2*i[1],2*i[2]]);const r=le(this._cachedClippingPlane,e);U(a,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}const l=function(e){const t=re();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])}}(n),c=function(e,t,i){const r=re();U(r,i,e);const n=re();return function(e,t,i,r){e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r}(n,e,r,t/G(r)),n}(l.center,l.radius,a);return ty(c)}getMatrixForModel(e,t){const i=ap.convert(e),r=1/sp,n=oe();return S(n,n,i.lng/180*Math.PI),T(n,n,-i.lat/180*Math.PI),b(n,n,[0,0,1+t/sp]),T(n,n,.5*Math.PI),w(n,n,[r,r,r]),n}getProjectionDataForCustomLayer(e=!0){const t=this.getProjectionData({overscaledTileID:new Pp(0,0,0,0,0),applyGlobeMatrix:e});return t.tileMercatorCoords=[0,0,1,1],t}getFastPathSimpleProjectionMatrix(e){}}class fy{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,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Cg({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Rg,this._verticalPerspectiveTransform=new py}clone(){const e=new fy;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,t){this._helper.apply(e,t),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const 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}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return _e(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return _e(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,t,i){return _e(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._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(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._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.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)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class my{get useGlobeControls(){return!0}handlePanInertia(e,t){const i=ny(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 o(0,0)}}handleMapControlsRollPitchBearingZoom(e,t){const 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);const n=t.zoom;e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);const o=t.zoom-n;if(0===o)return;const s=de(t.center.lng,r.lng),a=s/(Math.abs(s/180)+1),l=de(t.center.lat,r.lat),c=t.getRayDirectionFromPixel(i),h=t.cameraPosition,u=-1*L(h,c),d=re();D(d,h,[c[0]*u,c[1]*u,c[2]*u]);const p=A(d)-1,f=Math.exp(.5*-Math.max(p-.3,0)),m=ey(t.worldSize,t.center.lat)/Math.min(t.width,t.height),_=me(m,.9,.5,1,.25),g=(1-Me(-o))*Math.min(f,_),y=t.center.lat,v=t.zoom,x=new ap(t.center.lng+a*g,be(t.center.lat+l*g,-85.051129,We));t.setLocationAtPoint(r,i);const b=t.center,w=me(Math.abs(s),45,85,0,1),T=me(m,.75,.35,0,1),S=Math.pow(Math.max(w,T),.25),P=de(b.lng,x.lng),I=de(b.lat,x.lat);t.setCenter(new ap(b.lng+P*S,b.lat+I*S).wrap()),t.setZoom(v+ry(y,t.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,n=t.zoom;t.setCenter(ny(e.panDelta,t).wrap()),t.setZoom(n+ry(r,t.center.lat))}cameraForBoxAndBearing(e,t,i,r,n){const o=Fg(e,t,i,r,n),s=t.left/n.width*2-1,a=(n.width-t.right)/n.width*2-1,l=t.top/n.height*-2+1,c=(n.height-t.bottom)/n.height*-2+1,h=de(i.getWest(),i.getEast())<0,u=h?i.getEast():i.getWest(),d=h?i.getWest():i.getEast(),p=Math.max(i.getNorth(),i.getSouth()),f=Math.min(i.getNorth(),i.getSouth()),m=u+.5*de(u,d),_=p+.5*de(p,f),g=n.clone();g.setCenter(o.center),g.setBearing(o.bearing),g.setPitch(0),g.setRoll(0),g.setZoom(o.zoom);const y=g.modelViewProjectionMatrix,v=[Qg(i.getNorthWest()),Qg(i.getNorthEast()),Qg(i.getSouthWest()),Qg(i.getSouthEast()),Qg(new ap(d,_)),Qg(new ap(u,_)),Qg(new ap(m,p)),Qg(new ap(m,f))],x=Qg(o.center);let b=Number.POSITIVE_INFINITY;for(const e of v)s<0&&(b=my.getLesserNonNegativeNonNull(b,my.solveVectorScale(e,x,y,"x",s))),a>0&&(b=my.getLesserNonNegativeNonNull(b,my.solveVectorScale(e,x,y,"x",a))),l>0&&(b=my.getLesserNonNegativeNonNull(b,my.solveVectorScale(e,x,y,"y",l))),c<0&&(b=my.getLesserNonNegativeNonNull(b,my.solveVectorScale(e,x,y,"y",c)));if(Number.isFinite(b)&&0!==b)return o.zoom=Math.min(g.zoom+Ee(b),e.maxZoom),o;kg()}handleJumpToCenterZoom(e,t){const i=e.center.lat,r=e.applyConstrain(t.center?ap.convert(t.center):e.center,e.zoom).center;e.setCenter(r.wrap());const n=void 0!==t.zoom?+t.zoom:e.zoom+ry(i,r.lat);e.zoom!==n&&e.setZoom(n)}handleEaseTo(e,t){const i=e.zoom,r=e.center,n=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={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},l=void 0!==t.zoom,c=!e.isPaddingEqual(t.padding);let h=!1;const u=t.center?ap.convert(t.center):r,d=e.applyConstrain(u,i).center;Mg(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+t.zoom:i+ry(r.lat,u.lat)),p.setBearing(t.bearing);const f=new o(be(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),be(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(t.offset&&t.offsetAsPoint.mag())>0?p.center:d,_=l?+t.zoom:i+ry(r.lat,m.lat),g=i+ry(r.lat,0),y=_+ry(m.lat,0),v=de(r.lng,m.lng),x=de(r.lat,m.lat),b=Me(y-g);return h=_!==i,{easeFunc:i=>{if($e(s,a)||Lg({startEulerAngles:s,endEulerAngles:a,tr:e,k:i,useSlerp:s.roll!=a.roll}),c&&e.interpolatePadding(n,t.padding,i),t.around)Le("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(t.around,t.aroundPoint);else{const t=y>g?Math.min(2,b):Math.max(.5,b),n=Math.pow(t,1-i),o=sy(r,v,x,i*n);e.setCenter(o.wrap())}if(h){const t=br.number(g,y,i)+ry(0,e.center.lat);e.setZoom(t)}},isZooming:h,elevationCenter:m}}handleFlyTo(e,t){const i=void 0!==t.zoom,r=e.center,n=e.zoom,s=e.padding,a=!e.isPaddingEqual(t.padding),l=e.applyConstrain(ap.convert(t.center||t.locationAtOffset),n).center,c=i?+t.zoom:e.zoom+ry(e.center.lat,l.lat),h=e.clone();h.setCenter(l),h.setZoom(c),h.setBearing(t.bearing);const u=new o(be(e.centerPoint.x+t.offsetAsPoint.x,0,e.width),be(e.centerPoint.y+t.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(l,u);const d=h.center;Mg(e,d);const p=function(e,t,i){const r=L(Qg(t),Qg(i)),n=Math.acos(r),o=Kg(e);return n/(2*Math.PI)*o}(e,r,d),f=n+ry(r.lat,0),m=c+ry(d.lat,0),_=Me(m-f);let g;if("number"==typeof t.minZoom){const i=+t.minZoom+ry(d.lat,0),r=Math.min(i,f,m)+ry(0,d.lat);g=Me(e.applyConstrain(d,r).zoom+ry(d.lat,0)-f)}const y=de(r.lng,d.lng),v=de(r.lat,d.lat);return{easeFunc:(i,n,o,l)=>{const h=sy(r,y,v,o);a&&e.interpolatePadding(s,t.padding,i);const u=1===i?d:h;e.setCenter(u.wrap());const p=f+Ee(n);e.setZoom(1===i?c:p+ry(0,u.lat))},scaleOfZoom:_,targetCenter:d,scaleOfMinZoom:g,pixelPathLength:p}}static solveVectorScale(e,t,i,r,n){const 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]],a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],h=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+n*l===a+n*h||s[3]*(a-c)+o[3]*(h-l)+a*h==c*l?null:(c+o[3]-n*h-n*s[3])/(c-a-n*h+n*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&t<e?t:e}}class _y{constructor(e){this._globe=e,this._mercatorCameraHelper=new Bg,this._verticalPerspectiveCameraHelper=new my}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,n){return this.currentHelper.cameraForBoxAndBearing(e,t,i,r,n)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}}const gy=(e,t)=>fs(e,null==t?void 0:t.filter((e=>"source.canvas"!==e.identifier))),yy=function(){const e={},t=St.$version;for(const i in St.$root){const r=St.$root[i];if(r.required){let n=null;n="version"===i?t:"array"===r.type?[]:{},null!=n&&(e[i]=n)}}return e}();class vy extends Tt{constructor(e,t={}){var i,r;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const t=this.tileManagers[e].getSource().type;"vector"!==t&&"geojson"!==t||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new Qd(Jd(),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 zd,this.imageManager.setEventedParent(this);const n=(null===(i=e._container)||void 0===i?void 0:i.lang)||"undefined"!=typeof document&&(null===(r=document.documentElement)||void 0===r?void 0:r.lang)||void 0;this.glyphManager=new Bd(e._requestManager,t.localIdeographFontFamily,n),this.lineAtlas=new Gd(256,512),this.crossTileSymbolIndex=new gg,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",pt()),$m().on(Nm,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.tileManagers[e.sourceId];if(!t)return;const i=t.getSource();if(null==i?void 0:i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t)}}))}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new Ts,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,t){var i,r,n;this._checkLoaded();const o=null===t?null!==(n=null===(r=null===(i=this.stylesheet.state)||void 0===i?void 0:i[e])||void 0===r?void 0:r.default)&&void 0!==n?n:null:t;if(De(o,this._globalState[e]))return this;this._globalState[e]=o,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const t=[];for(const i in e)!De(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;const t=new Set,i={};for(const r of e){i[r]=this._globalState[r];for(const e in this._layers){const i=this._layers[e],n=i.getLayoutAffectingGlobalStateRefs(),o=i.getPaintAffectingGlobalStateRefs(),s=i.getVisibilityAffectingGlobalStateRefs();if(n.has(r)&&t.add(i.source),o.has(r))for(const{name:e,value:t}of o.get(r))this._updatePaintProperty(i,e,t);(null==s?void 0:s.has(r))&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(const e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e){return n(this,arguments,void 0,(function*(e,t={},i){this.fire(new bt("dataloading",{dataType:"style"})),t.validate="boolean"!=typeof t.validate||t.validate,this._loadStyleRequest=new AbortController;const r=this._loadStyleRequest;try{const n=yield this.map._requestManager.transformRequest(e,"Style");et(r.signal);const o=yield mt(n,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(o.data,t,i)}catch(e){this._loadStyleRequest===r&&(this._loadStyleRequest=null),e&&!r.signal.aborted&&this.fire(new wt(te(e)))}}))}loadJSON(e,t={},i){this.fire(new bt("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,nt.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 bt("dataloading",{dataType:"style"})),this._load(yy,{validate:!1})}_load(e,t,i){var r,n;let o=t.transformStyle?t.transformStyle(i,e):e;if(!t.validate||!gy(this,cs(o))){o=Object.assign({},o),this._loaded=!0,this.stylesheet=o;for(const e in o.sources)this.addSource(e,o.sources[e],{validate:!1});o.sprite?this._loadSprite(o.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(o.glyphs),this._createLayers(),this.light=new jd(this.stylesheet.light),this._setProjectionInternal((null===(r=this.stylesheet.projection)||void 0===r?void 0:r.type)||"mercator"),this.sky=new Ud(this.stylesheet.sky),this.map.setTerrain(null!==(n=this.stylesheet.terrain)&&void 0!==n?n:null),this.fire(new bt("data",{dataType:"style"})),this.fire(new bt("style.load"))}}_createLayers(){var e,t,i;const r=Mt(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",r),this._order=r.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of r){const r=Md(e,this._globalState);if(r.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=r,Qs(r)&&this.tileManagers[r.source]){const n=null!==(i=null===(t=e.paint)||void 0===t?void 0:t["raster-fade-duration"])&&void 0!==i?i:r.paint.get("raster-fade-duration");this.tileManagers[r.source].setRasterFadeDuration(n)}}}_loadSprite(e,t=!1,i=void 0){this.imageManager.setLoaded(!1);const r=new AbortController;let o;this._spriteRequest=r,function(e,t,i,r){return n(this,void 0,void 0,(function*(){const o=Ed(e),s=i>1?"@2x":"",a={},l={};for(const{id:e,url:i}of o){const n=yield t.transformRequest(Cd(i,s,".json"),"SpriteJSON");a[e]=mt(n,r);const o=yield t.transformRequest(Cd(i,s,".png"),"SpriteImage");l[e]=gt.getImage(o,r)}return yield Promise.all([...Object.values(a),...Object.values(l)]),function(e,t){return n(this,void 0,void 0,(function*(){const i={};for(const r in e){i[r]={};const n=nt.getImageCanvasContext((yield t[r]).data),o=(yield e[r]).data;for(const e in o){const{width:t,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e];i[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:t,height:s,x:a,y:l,context:n}}}}return i}))}(a,l)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const i in e){this._spritesImagesIds[i]=[];const r=this._spritesImagesIds[i]?this._spritesImagesIds[i].filter((t=>!(t in e))):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[i]){const n="default"===i?r:`${i}:${r}`;this._spritesImagesIds[i].push(n),n in this.imageManager.images?this.imageManager.updateImage(n,e[i][r],!1):this.imageManager.addImage(n,e[i][r]),t&&(this._changedImages[n]=!0)}}})).catch((e=>{this._spriteRequest=null,o=e,r.signal.aborted||this.fire(new wt(o))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),t&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new bt("data",{dataType:"style"})),i&&i(o)}))}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new bt("data",{dataType:"style"}))}_validateLayer(e){const t=this.tileManagers[e.source];if(!t)return;const i=e.sourceLayer;if(!i)return;const r=t.getSource();("geojson"===r.type||r.vectorLayerIds&&!r.vectorLayerIds.includes(i))&&this.fire(new wt(new Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,t=!1){const i=this._serializedAllLayers();if(!e||0===e.length)return Object.values(t?Re(i):i);const r=[];for(const n of e)if(i[n]){const e=t?Re(i[n]):i[n];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const t=this._changed;if(t){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const i={};for(const e in this.tileManagers){const t=this.tileManagers[e];i[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const e in i){const t=this.tileManagers[e];!!i[e]!=!!t.used&&t.fire(new bt("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,t&&this.fire(new bt("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const 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={}){var i;this._checkLoaded();const r=this.serialize();if(e=t.transformStyle?t.transformStyle(r,e):e,(null===(i=t.validate)||void 0===i||i)&&gy(this,cs(e)))return!1;(e=Re(e)).layers=Mt(e.layers);const n=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!Et(e.version,t.version))return[{command:"setStyle",args:[t]}];Et(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),Et(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),Et(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Et(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),Et(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),Et(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),Et(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),Et(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),Et(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),Et(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),Et(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),Et(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),Et(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),Et(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)||zt(n,i,r));for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)?Et(e[n],t[n])||("geojson"===e[n].type&&"geojson"===t[n].type&&Rt(e,t,n)?Ct(i,{command:"setGeoJSONSourceData",args:[n,t[n].data]}):Dt(n,t,i,r)):At(n,t,i))}(e.sources,t.sources,n,r);const o=[];e.layers&&e.layers.forEach((e=>{"source"in e&&r[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)})),i=i.concat(n),function(e,t,i){t=t||[];const r=(e=e||[]).map(Lt),n=t.map(Lt),o=e.reduce(Ft,{}),s=t.reduce(Ft,{}),a=r.slice(),l=Object.create(null);let c,h,u,d,p;for(let e=0,t=0;e<r.length;e++)c=r[e],Object.prototype.hasOwnProperty.call(s,c)?t++:(Ct(i,{command:"removeLayer",args:[c]}),a.splice(a.indexOf(c,t),1));for(let e=0,t=0;e<n.length;e++)c=n[n.length-1-e],a[a.length-1-e]!==c&&(Object.prototype.hasOwnProperty.call(o,c)?(Ct(i,{command:"removeLayer",args:[c]}),a.splice(a.lastIndexOf(c,a.length-t),1)):t++,d=a[a.length-e],Ct(i,{command:"addLayer",args:[s[c],d]}),a.splice(a.length-e,0,c),l[c]=!0);for(let e=0;e<n.length;e++)if(c=n[e],h=o[c],u=s[c],!l[c]&&!Et(h,u))if(Et(h.source,u.source)&&Et(h["source-layer"],u["source-layer"])&&Et(h.type,u.type)){for(p in kt(h.layout,u.layout,i,c,null,"setLayoutProperty"),kt(h.paint,u.paint,i,c,null,"setPaintProperty"),Et(h.filter,u.filter)||Ct(i,{command:"setFilter",args:[c,u.filter]}),Et(h.minzoom,u.minzoom)&&Et(h.maxzoom,u.maxzoom)||Ct(i,{command:"setLayerZoomRange",args:[c,u.minzoom,u.maxzoom]}),h)Object.prototype.hasOwnProperty.call(h,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?kt(h[p],u[p],i,c,p.slice(6),"setPaintProperty"):Et(h[p],u[p])||Ct(i,{command:"setLayerProperty",args:[c,p,u[p]]}));for(p in u)Object.prototype.hasOwnProperty.call(u,p)&&!Object.prototype.hasOwnProperty.call(h,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?kt(h[p],u[p],i,c,p.slice(6),"setPaintProperty"):Et(h[p],u[p])||Ct(i,{command:"setLayerProperty",args:[c,p,u[p]]}))}else Ct(i,{command:"removeLayer",args:[c]}),d=a[a.lastIndexOf(c)+1],Ct(i,{command:"addLayer",args:[u,d]})}(o,t.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:"setStyle",args:[t]}]}return i}(r,e),o=this._getOperationsToPerform(n);if(o.unimplemented.length>0)throw new Error(`Unimplemented: ${o.unimplemented.join(", ")}.`);if(0===o.operations.length)return!1;for(const e of o.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new bt("style.load",{style:this})),!0}_getOperationsToPerform(e){const t=[],i=[];for(const 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"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){if(this.getImage(e))return this.fire(new wt(new 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)}removeImage(e){if(!this.getImage(e))return this.fire(new wt(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new bt("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,i={}){var r;if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!t.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(t.type)&&this._validate(cs.source,`sources.${e}`,t,null,i))return;(null===(r=this.map)||void 0===r?void 0:r._collectResourceTiming)&&(t.collectResourceTiming=!0);const n=this.tileManagers[e]=new g_(e,t,this.dispatcher);n.style=this,n.setEventedParent(this,(()=>({isSourceLoaded:n.loaded(),source:n.serialize(),sourceId:e}))),n.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new wt(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));const t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new bt("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),t.setEventedParent(null),t.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){var t;return null===(t=this.tileManagers[e])||void 0===t?void 0:t.getSource()}addLayer(e,t,i={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new wt(new Error(`Layer "${r}" already exists on this map.`)));let n;if("custom"===e.type){if(gy(this,function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t}(e)))return;n=Md(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(r,e.source),e=Te(e=Re(e),{source:r})),this._validate(cs.layer,`layers.${r}`,e,{arrayIndex:-1},i))return;n=Md(e,this._globalState),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}})}const o=t?this._order.indexOf(t):this._order.length;if(t&&-1===o)this.fire(new wt(new Error(`Cannot add layer "${r}" before non-existing layer "${t}".`)));else{if(this._order.splice(o,0,r),this._layerOrderChanged=!0,this._layers[r]=n,this._removedLayers[r]&&n.source&&"custom"!==n.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",this.tileManagers[n.source].pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map)}}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new wt(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===t)return;const i=this._order.indexOf(e);this._order.splice(i,1);const r=t?this._order.indexOf(t):this._order.length;t&&-1===r?this.fire(new wt(new Error(`Cannot move layer "${e}" before non-existing layer "${t}".`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const t=this._layers[e];if(!t)return void this.fire(new wt(new Error(`Cannot remove non-existing layer "${e}".`)));t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.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();const 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 wt(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,t,i={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!De(r.filter,t))return null==t?(r.setFilter(void 0),void this._updateLayer(r)):void(this._validate(cs.filter,`layers.${r.id}.filter`,t,null,i)||(r.setFilter(Re(t)),this._updateLayer(r)))}else this.fire(new wt(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return Re(this.getLayer(e).filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();const n=this.getLayer(e);n?De(n.getLayoutProperty(t),i)||(n.setLayoutProperty(t,i,r),this._updateLayer(n)):this.fire(new wt(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,t){const i=this.getLayer(e);if(i)return i.getLayoutProperty(t);this.fire(new wt(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,t,i,r={}){this._checkLoaded();const n=this.getLayer(e);n?De(n.getPaintProperty(t),i)||this._updatePaintProperty(n,t,i,r):this.fire(new wt(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,i,r={}){e.setPaintProperty(t,i,r)&&this._updateLayer(e),Qs(e)&&"raster-fade-duration"===t&&this.tileManagers[e.source].setRasterFadeDuration(i),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.tileManagers[i];if(void 0===n)return void this.fire(new wt(new Error(`The source '${i}' does not exist in the map's style.`)));const o=n.getSource().type;"geojson"===o&&r?this.fire(new wt(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==o||r?(void 0===e.id&&this.fire(new wt(new Error("The feature id parameter must be provided."))),n.setFeatureState(r,e.id,t)):this.fire(new wt(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,t){this._checkLoaded();const i=e.source,r=this.tileManagers[i];if(void 0===r)return void this.fire(new wt(new Error(`The source '${i}' does not exist in the map's style.`)));const n=r.getSource().type,o="vector"===n?e.sourceLayer:void 0;"vector"!==n||o?t&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new wt(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(o,e.id,t):this.fire(new wt(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const t=e.source,i=e.sourceLayer,r=this.tileManagers[t];if(void 0!==r)return"vector"!==r.getSource().type||i?(void 0===e.id&&this.fire(new wt(new Error("The feature id parameter must be provided."))),r.getFeatureState(i,e.id)):void this.fire(new wt(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new wt(new Error(`The source '${t}' does not exist in the map's style.`)))}getTransition(){var e;return Te({duration:300,delay:0},null===(e=this.stylesheet)||void 0===e?void 0:e.transition)}serialize(){if(!this._loaded)return;const e=Ae(this.tileManagers,(e=>e.serialize())),t=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return ze({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,transition:r.transition,projection:r.projection,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){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(t(o)){i[o]=n;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]<o)break;n.push(t),r.pop()}else for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t.feature)}}return n}queryRenderedFeatures(e,t,i){(null==t?void 0:t.filter)&&this._validate(cs.filter,"queryRenderedFeatures.filter",t.filter,null,t);const r={};if(null==t?void 0:t.layers){if(!(Array.isArray(t.layers)||t.layers instanceof Set))return this.fire(new wt(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const e of t.layers){const t=this._layers[e];if(!t)return this.fire(new wt(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[t.source]=!0}}const n=[];t.availableImages=this._availableImages;const o=this._serializedAllLayers(),s=t.layers instanceof Set?t.layers:Array.isArray(t.layers)?new Set(t.layers):null,a=Object.assign(Object.assign({},t),{layers:s,globalState:this._globalState});for(const s in this.tileManagers)t.layers&&!r[s]||n.push(ip(this.tileManagers[s],this._layers,o,e,a,i,this.map.terrain?(e,t,i)=>this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&n.push(function(e,t,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(rp);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,{filterSpec:n.filter,globalState:n.globalState},n.layers,n.availableImages,e);for(const e in r){a[e]||(a[e]=[]);const t=r[e];t.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const i of t)a[e].push(i)}}return function(e,t,i){for(const r in e)for(const n of e[r])np(n,i[t[r].source]);return e}(a,e,i)}(this._layers,o,this.tileManagers,e,a,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,t){(null==t?void 0:t.filter)&&this._validate(cs.filter,"querySourceFeatures.filter",t.filter,null,t);const i=this.tileManagers[e];return i?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(const e of i){const i=e.tileID.canonical.key;n[i]||(n[i]=!0,e.querySourceFeatures(r,t))}return r}(i,t?Object.assign(Object.assign({},t),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const t in e)if(!De(e[t],i[t])){r=!0;break}if(!r)return;const n={now:st(),transition:Te({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,t),this.light.updateTransitions(n)}getProjection(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.projection}setProjection(e){this._checkLoaded();const t=null!=e?e:{type:"mercator"};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.sky}setSky(e,t={}){this._checkLoaded();const i=this.getSky();let r=!1;if(!e&&!i)return;if(e&&!i)r=!0;else if(!e&&i)r=!0;else for(const t in e)if(!De(e[t],i[t])){r=!0;break}if(!r)return;const n={now:st(),transition:Te({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,t),this.sky.updateTransitions(n)}_setProjectionInternal(e){const t=function(e,t){const i={constrainOverride:t};if(Array.isArray(e)){const t=new Yg({type:e});return{projection:t,transform:new fy(i),cameraHelper:new _y(t)}}switch(e){case"mercator":return{projection:new Pg,transform:new Rg(i),cameraHelper:new Bg};case"globe":{const e=new Yg({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:e,transform:new fy(i),cameraHelper:new _y(e)}}case"vertical-perspective":return{projection:new Hg,transform:new py(i),cameraHelper:new my};default:return Le(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Pg,transform:new Rg(i),cameraHelper:new Bg}}}(e,this.map.transformConstrain);this.projection=t.projection,this.map.migrateProjection(t.transform,t.cameraHelper);for(const e in this.tileManagers)this.tileManagers[e].reload()}_validate(e,t,i,r,n={}){return!1!==(null==n?void 0:n.validate)&&gy(this,e.call(cs,Te({key:t,style:this.serialize(),value:i,styleSpec:St},r)))}_remove(e=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),$m().off(Nm,this._rtlPluginLoaded);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this.tileManagers){const 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(const t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.tileManagers)this._reloadSource(e)}_updatePlacement(e,t,i,r,n=!1){let o=!1,s=!1;const a={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!a[i.source]){const e=this.tileManagers[i.source];a[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)))}const r=this.crossTileSymbolIndex.addLayer(i,a[i.source],e.center.lng);o||(o=r)}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n||(n=this._layerOrderChanged||0===i),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(st(),e.zoom))&&(this.pauseablePlacement=new dg(e,this.map.terrain,this._order,n,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(st()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,a[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(st())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,t){return n(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();const i=this.tileManagers[t.source];return i&&i.setDependencies(t.tileID.key,t.type,t.icons),e}))}getGlyphs(e,t){return n(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(t.stacks),i=this.tileManagers[t.source];return i&&i.setDependencies(t.tileID.key,t.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),e&&this._validate(cs.glyphs,"glyphs",e,null,t)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,t){return n(this,void 0,void 0,(function*(){const e={};for(const[i,r]of Object.entries(t.dashes))e[i]=this.lineAtlas.getDash(r.dasharray,r.round);return e}))}addSprite(e,t,i={},r){this._checkLoaded();const n=[{id:e,url:t}],o=[...Ed(this.stylesheet.sprite),...n];this._validate(cs.sprite,"sprite",o,null,i)||(this.stylesheet.sprite=o,this._loadSprite(n,!0,r))}removeSprite(e){this._checkLoaded();const t=Ed(this.stylesheet.sprite);if(t.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;t.splice(t.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=t.length>0?t:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new bt("data",{dataType:"style"}))}else this.fire(new wt(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return Ed(this.stylesheet.sprite)}setSprite(e,t={},i){this._checkLoaded(),e&&this._validate(cs.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(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const 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={}}}var xy=na([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class by{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,n,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(c=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==o||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,r,n,o,s,a,l):(e.bindVertexArray.set(this.vao),s&&s.bind(),(null==n?void 0:n.dynamicDraw)&&n.bind(),a&&a.bind(),l&&l.bind())}freshBind(e,t,i,r,n,o,s,a){const l=e.numAttributes,c=this.context,h=c.gl;this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=a,t.enableAttributes(h,e);for(const t of i)t.enableAttributes(h,e);o&&o.enableAttributes(h,e),s&&s.enableAttributes(h,e),a&&a.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,n);for(const t of i)t.bind(),t.setVertexAttribPointers(h,e,n);o&&(o.bind(),o.setVertexAttribPointers(h,e,n)),r&&r.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,e,n)),a&&(a.bind(),a.setVertexAttribPointers(h,e,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const wy=(e,t,i,r,n)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:t,u_fog_color:i?i.properties.get("fog-color"):Ri.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:n?0:i?i.calculateFogBlendOpacity(r):0,u_horizon_color:i?i.properties.get("horizon-color"):Ri.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1,u_is_globe_mode:n?1:0}),Ty={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Sy(e){const t=[];for(const i of e){if(null===i)continue;const e=i.split(" ");t.push(e.pop())}return t}class Py{constructor(e,t,i,r,n,o,s,a,l=[]){const c=e.gl;this.program=c.createProgram();const h=Sy(t.staticAttributes),u=i?i.getBinderAttributes():[],d=h.concat(u),p=vg.prelude.staticUniforms?Sy(vg.prelude.staticUniforms):[],f=s.staticUniforms?Sy(s.staticUniforms):[],m=t.staticUniforms?Sy(t.staticUniforms):[],_=i?i.getBinderUniforms():[],g=p.concat(f).concat(m).concat(_),y=[];for(const e of g)y.includes(e)||y.push(e);const v=i?i.defines():[];$g(c)&&v.unshift("#version 300 es"),n&&v.push("#define OVERDRAW_INSPECTOR;"),o&&v.push("#define TERRAIN3D;"),a&&v.push(a),l&&v.push(...l);let x=v.concat(vg.prelude.fragmentSource,s.fragmentSource,t.fragmentSource).join("\n"),b=v.concat(vg.prelude.vertexSource,s.vertexSource,t.vertexSource).join("\n");$g(c)||(x=function(e){return e.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(x),b=function(e){return e.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(b));const w=c.createShader(c.FRAGMENT_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);if(c.shaderSource(w,x),c.compileShader(w),!c.getShaderParameter(w,c.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${c.getShaderInfoLog(w)}`);c.attachShader(this.program,w);const T=c.createShader(c.VERTEX_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);if(c.shaderSource(T,b),c.compileShader(T),!c.getShaderParameter(T,c.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${c.getShaderInfoLog(T)}`);c.attachShader(this.program,T),this.attributes={};const S={};this.numAttributes=d.length;for(let e=0;e<this.numAttributes;e++)d[e]&&(c.bindAttribLocation(this.program,e,d[e]),this.attributes[d[e]]=e);if(c.linkProgram(this.program),!c.getProgramParameter(this.program,c.LINK_STATUS))throw new Error(`Program failed to link: ${c.getProgramInfoLog(this.program)}`);c.deleteShader(T),c.deleteShader(w);for(const e of y)if(e&&!S[e]){const t=c.getUniformLocation(this.program,e);t&&(S[e]=t)}this.fixedUniforms=r(e,S),this.terrainUniforms=((e,t)=>({u_depth:new Ml(e,t.u_depth),u_terrain:new Ml(e,t.u_terrain),u_terrain_dim:new El(e,t.u_terrain_dim),u_terrain_matrix:new Fl(e,t.u_terrain_matrix),u_terrain_unpack:new zl(e,t.u_terrain_unpack),u_terrain_exaggeration:new El(e,t.u_terrain_exaggeration)}))(e,S),this.projectionUniforms=((e,t)=>({u_projection_matrix:new Fl(e,t.u_projection_matrix),u_projection_tile_mercator_coords:new zl(e,t.u_projection_tile_mercator_coords),u_projection_clipping_plane:new zl(e,t.u_projection_clipping_plane),u_projection_transition:new El(e,t.u_projection_transition),u_projection_fallback_matrix:new Fl(e,t.u_projection_fallback_matrix)}))(e,S),this.binderUniforms=i?i.getUniforms(e,S):[]}draw(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){var v;const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(n),e.setCullFace(o),a){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,a.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const e in l)this.projectionUniforms[Ty[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1}for(const i of d.get())i.vaos||(i.vaos={}),(v=i.vaos)[c]||(v[c]=new by),i.vaos[c].bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,_,g,y),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2)}}function Iy(e,t,i){const r=1/ee(i,1,t.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/n,s=o*(i.tileID.canonical.x+i.tileID.wrap*n),a=o*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:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const My=(e,t,i,r)=>{const n=e.style.light,o=n.properties.get("position"),s=[o.x,o.y,o.z],a=m();var l,c,h,u;"viewport"===n.properties.get("anchor")&&(l=a,c=e.transform.bearingInRadians,h=Math.sin(c),u=Math.cos(c),l[0]=u,l[1]=h,l[2]=0,l[3]=-h,l[4]=u,l[5]=0,l[6]=0,l[7]=0,l[8]=1),function(e,t,i){var r=t[0],n=t[1],o=t[2];e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8]}(s,s,a);const d=e.transform.transformLightDirection(s),p=n.properties.get("color");return{u_lightpos:s,u_lightpos_globe:d,u_lightintensity:n.properties.get("intensity"),u_lightcolor:[p.r,p.g,p.b],u_vertical_gradient:+t,u_opacity:i,u_fill_translate:r}},Ey=(e,t,i,r,n,o,s)=>Te(My(e,t,i,r),Iy(o,e,s),{u_height_factor:-Math.pow(2,n.overscaledZ)/s.tileSize/8}),Cy=(e,t,i,r)=>Te(Iy(t,e,i),{u_fill_translate:r}),Ay=e=>({u_fill_translate:e}),zy=(e,t)=>({u_world:e,u_fill_translate:t}),Dy=(e,t,i,r,n)=>Te(Cy(e,t,i,n),{u_world:r}),Ry=(e,t,i,r,n)=>{const o=e.transform;let s,a,l=0;if("map"===i.paint.get("circle-pitch-alignment")){const e=ee(t,1,o.zoom);s=!0,a=[e,e],l=e/(Q*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*n}else s=!1,a=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+("map"===i.paint.get("circle-pitch-scale")),u_pitch_with_map:+s,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:a,u_globe_extrude_scale:l,u_translate:r}},ky=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Ly=e=>({u_viewport_size:[e.width,e.height]}),Fy=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),By=(e,t,i,r)=>{const n=ee(e,1,t)/(Q*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*r;return{u_extrude_scale:ee(e,1,t),u_intensity:i,u_globe_extrude_scale:n}},Oy=(e,t,i,r)=>{const n=_();M(n,0,e.width,e.height,0,0,1);const o=e.context.gl;return{u_matrix:n,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:i,u_color_ramp:r,u_opacity:t.paint.get("heatmap-opacity")}},Vy=(e,t,i)=>{const r=i.paint.get("hillshade-accent-color");let n;switch(i.paint.get("hillshade-method")){case"basic":n=4;break;case"combined":n=1;break;case"igor":n=2;break;case"multidirectional":n=3;break;default:n=0}const o=i.getIlluminationProperties();for(let t=0;t<o.directionRadians.length;t++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(o.directionRadians[t]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:Ny(0,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:o.altitudeRadians,u_azimuths:o.directionRadians,u_accent:r,u_method:n,u_highlights:o.highlightColor,u_shadows:o.shadowColor}},jy=(e,t)=>{const i=t.stride,r=_();return M(r,0,Q,-8192,0,0,1),b(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.getUnpackVector()}};function Ny(e,t){const i=Math.pow(2,t.canonical.z),r=t.canonical.y;return[new gp(0,r/i).toLngLat().lat,new gp(0,(r+1)/i).toLngLat().lat]}const Uy=(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")}),Gy=(e,t,i,r)=>{const n=e.transform;return{u_translation:Xy(e,t,i),u_ratio:r/ee(t,1,n.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},$y=(e,t,i,r,n)=>Te(Gy(e,t,i,r),{u_image:0,u_image_height:n}),Zy=(e,t,i,r,n)=>{const o=e.transform,s=Hy(t,o);return{u_translation:Xy(e,t,i),u_texsize:t.imageAtlasTexture.size,u_ratio:r/ee(t,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[s,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},qy=(e,t,i,r,n)=>{const o=Hy(t,e.transform);return Te(Gy(e,t,i,r),{u_tileratio:o,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image:0,u_mix:n.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},Wy=(e,t,i,r,n,o)=>{const s=Hy(t,e.transform);return Te(Gy(e,t,i,r),{u_image:0,u_image_height:o,u_tileratio:s,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image_dash:1,u_mix:n.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function Hy(e,t){return 1/ee(e,1,t.tileZoom)}function Xy(e,t,i){return ae(e.transform,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Yy=(e,t,i,r,n)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,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:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=r.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:Ky(r.paint.get("raster-hue-rotate")),u_coords_top:[n[0].x,n[0].y,n[1].x,n[1].y],u_coords_bottom:[n[3].x,n[3].y,n[2].x,n[2].y]};var o,s};function Ky(e){e*=Math.PI/180;const 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]}const Jy=(e,t,i,r,n,o,s,a,l,c,h,u,d)=>{const p=s.transform;return{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_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:n,u_is_variable_anchor:o,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},Qy=(e,t,i,r,n,o,s,a,l,c,h,u,d,p)=>{const f=s.transform;return Te(Jy(e,t,i,r,n,o,s,a,l,c,h,u,p),{u_gamma_scale:r?Math.cos(f.pitch*Math.PI/180)*f.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:d?1:0,u_is_plain:1})},ev=(e,t,i,r,n,o,s,a,l,c,h,u,d)=>Te(Qy(e,t,i,r,n,o,s,a,l,c,!0,h,!0,d),{u_texsize_icon:u,u_texture_icon:1}),tv=(e,t)=>({u_opacity:e,u_color:t}),iv=(e,t,i,r,n)=>Te(function(e,t,i,r){const n=i.imageManager.getPattern(e.from.toString()),o=i.imageManager.getPattern(e.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,a],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/ee(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(i,n,t,r),{u_opacity:e}),rv=(e,t)=>{},nv={fillExtrusion:(e,t)=>({u_lightpos:new Al(e,t.u_lightpos),u_lightpos_globe:new Al(e,t.u_lightpos_globe),u_lightintensity:new El(e,t.u_lightintensity),u_lightcolor:new Al(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 Cl(e,t.u_fill_translate)}),fillExtrusionPattern:(e,t)=>({u_lightpos:new Al(e,t.u_lightpos),u_lightpos_globe:new Al(e,t.u_lightpos_globe),u_lightintensity:new El(e,t.u_lightintensity),u_lightcolor:new Al(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 Cl(e,t.u_fill_translate),u_image:new Ml(e,t.u_image),u_texsize:new Cl(e,t.u_texsize),u_pixel_coord_upper:new Cl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new Cl(e,t.u_pixel_coord_lower),u_scale:new Al(e,t.u_scale),u_fade:new El(e,t.u_fade)}),fill:(e,t)=>({u_fill_translate:new Cl(e,t.u_fill_translate)}),fillPattern:(e,t)=>({u_image:new Ml(e,t.u_image),u_texsize:new Cl(e,t.u_texsize),u_pixel_coord_upper:new Cl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new Cl(e,t.u_pixel_coord_lower),u_scale:new Al(e,t.u_scale),u_fade:new El(e,t.u_fade),u_fill_translate:new Cl(e,t.u_fill_translate)}),fillOutline:(e,t)=>({u_world:new Cl(e,t.u_world),u_fill_translate:new Cl(e,t.u_fill_translate)}),fillOutlinePattern:(e,t)=>({u_world:new Cl(e,t.u_world),u_image:new Ml(e,t.u_image),u_texsize:new Cl(e,t.u_texsize),u_pixel_coord_upper:new Cl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new Cl(e,t.u_pixel_coord_lower),u_scale:new Al(e,t.u_scale),u_fade:new El(e,t.u_fade),u_fill_translate:new Cl(e,t.u_fill_translate)}),circle:(e,t)=>({u_camera_to_center_distance:new El(e,t.u_camera_to_center_distance),u_scale_with_map:new Ml(e,t.u_scale_with_map),u_pitch_with_map:new Ml(e,t.u_pitch_with_map),u_extrude_scale:new Cl(e,t.u_extrude_scale),u_device_pixel_ratio:new El(e,t.u_device_pixel_ratio),u_globe_extrude_scale:new El(e,t.u_globe_extrude_scale),u_translate:new Cl(e,t.u_translate)}),collisionBox:(e,t)=>({u_pixel_extrude_scale:new Cl(e,t.u_pixel_extrude_scale)}),collisionCircle:(e,t)=>({u_viewport_size:new Cl(e,t.u_viewport_size)}),debug:(e,t)=>({u_color:new Dl(e,t.u_color),u_overlay:new Ml(e,t.u_overlay),u_overlay_scale:new El(e,t.u_overlay_scale)}),depth:rv,clippingMask:rv,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 Fl(e,t.u_matrix),u_world:new Cl(e,t.u_world),u_image:new Ml(e,t.u_image),u_color_ramp:new Ml(e,t.u_color_ramp),u_opacity:new El(e,t.u_opacity)}),hillshade:(e,t)=>({u_image:new Ml(e,t.u_image),u_latrange:new Cl(e,t.u_latrange),u_exaggeration:new El(e,t.u_exaggeration),u_altitudes:new kl(e,t.u_altitudes),u_azimuths:new kl(e,t.u_azimuths),u_accent:new Dl(e,t.u_accent),u_method:new Ml(e,t.u_method),u_shadows:new Rl(e,t.u_shadows),u_highlights:new Rl(e,t.u_highlights)}),hillshadePrepare:(e,t)=>({u_matrix:new Fl(e,t.u_matrix),u_image:new Ml(e,t.u_image),u_dimension:new Cl(e,t.u_dimension),u_zoom:new El(e,t.u_zoom),u_unpack:new zl(e,t.u_unpack)}),colorRelief:(e,t)=>({u_image:new Ml(e,t.u_image),u_unpack:new zl(e,t.u_unpack),u_dimension:new Cl(e,t.u_dimension),u_elevation_stops:new Ml(e,t.u_elevation_stops),u_color_stops:new Ml(e,t.u_color_stops),u_color_ramp_size:new Ml(e,t.u_color_ramp_size),u_opacity:new El(e,t.u_opacity)}),line:(e,t)=>({u_translation:new Cl(e,t.u_translation),u_ratio:new El(e,t.u_ratio),u_device_pixel_ratio:new El(e,t.u_device_pixel_ratio),u_units_to_pixels:new Cl(e,t.u_units_to_pixels)}),lineGradient:(e,t)=>({u_translation:new Cl(e,t.u_translation),u_ratio:new El(e,t.u_ratio),u_device_pixel_ratio:new El(e,t.u_device_pixel_ratio),u_units_to_pixels:new Cl(e,t.u_units_to_pixels),u_image:new Ml(e,t.u_image),u_image_height:new El(e,t.u_image_height)}),linePattern:(e,t)=>({u_translation:new Cl(e,t.u_translation),u_texsize:new Cl(e,t.u_texsize),u_ratio:new El(e,t.u_ratio),u_device_pixel_ratio:new El(e,t.u_device_pixel_ratio),u_image:new Ml(e,t.u_image),u_units_to_pixels:new Cl(e,t.u_units_to_pixels),u_scale:new Al(e,t.u_scale),u_fade:new El(e,t.u_fade)}),lineSDF:(e,t)=>({u_translation:new Cl(e,t.u_translation),u_ratio:new El(e,t.u_ratio),u_device_pixel_ratio:new El(e,t.u_device_pixel_ratio),u_units_to_pixels:new Cl(e,t.u_units_to_pixels),u_image:new Ml(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 Cl(e,t.u_translation),u_ratio:new El(e,t.u_ratio),u_device_pixel_ratio:new El(e,t.u_device_pixel_ratio),u_units_to_pixels:new Cl(e,t.u_units_to_pixels),u_image:new Ml(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 Ml(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)}),raster:(e,t)=>({u_tl_parent:new Cl(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_fade_t:new El(e,t.u_fade_t),u_opacity:new El(e,t.u_opacity),u_image0:new Ml(e,t.u_image0),u_image1:new Ml(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 Al(e,t.u_spin_weights),u_coords_top:new zl(e,t.u_coords_top),u_coords_bottom:new zl(e,t.u_coords_bottom)}),symbolIcon:(e,t)=>({u_is_size_zoom_constant:new Ml(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new Ml(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_camera_to_center_distance:new El(e,t.u_camera_to_center_distance),u_pitch:new El(e,t.u_pitch),u_rotate_symbol:new Ml(e,t.u_rotate_symbol),u_aspect_ratio:new El(e,t.u_aspect_ratio),u_fade_change:new El(e,t.u_fade_change),u_label_plane_matrix:new Fl(e,t.u_label_plane_matrix),u_coord_matrix:new Fl(e,t.u_coord_matrix),u_is_text:new Ml(e,t.u_is_text),u_pitch_with_map:new Ml(e,t.u_pitch_with_map),u_is_along_line:new Ml(e,t.u_is_along_line),u_is_variable_anchor:new Ml(e,t.u_is_variable_anchor),u_texsize:new Cl(e,t.u_texsize),u_texture:new Ml(e,t.u_texture),u_translation:new Cl(e,t.u_translation),u_pitched_scale:new El(e,t.u_pitched_scale)}),symbolSDF:(e,t)=>({u_is_size_zoom_constant:new Ml(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new Ml(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_camera_to_center_distance:new El(e,t.u_camera_to_center_distance),u_pitch:new El(e,t.u_pitch),u_rotate_symbol:new Ml(e,t.u_rotate_symbol),u_aspect_ratio:new El(e,t.u_aspect_ratio),u_fade_change:new El(e,t.u_fade_change),u_label_plane_matrix:new Fl(e,t.u_label_plane_matrix),u_coord_matrix:new Fl(e,t.u_coord_matrix),u_is_text:new Ml(e,t.u_is_text),u_pitch_with_map:new Ml(e,t.u_pitch_with_map),u_is_along_line:new Ml(e,t.u_is_along_line),u_is_variable_anchor:new Ml(e,t.u_is_variable_anchor),u_texsize:new Cl(e,t.u_texsize),u_texture:new Ml(e,t.u_texture),u_gamma_scale:new El(e,t.u_gamma_scale),u_device_pixel_ratio:new El(e,t.u_device_pixel_ratio),u_is_halo:new Ml(e,t.u_is_halo),u_is_plain:new Ml(e,t.u_is_plain),u_translation:new Cl(e,t.u_translation),u_pitched_scale:new El(e,t.u_pitched_scale)}),symbolTextAndIcon:(e,t)=>({u_is_size_zoom_constant:new Ml(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new Ml(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_camera_to_center_distance:new El(e,t.u_camera_to_center_distance),u_pitch:new El(e,t.u_pitch),u_rotate_symbol:new Ml(e,t.u_rotate_symbol),u_aspect_ratio:new El(e,t.u_aspect_ratio),u_fade_change:new El(e,t.u_fade_change),u_label_plane_matrix:new Fl(e,t.u_label_plane_matrix),u_coord_matrix:new Fl(e,t.u_coord_matrix),u_is_text:new Ml(e,t.u_is_text),u_pitch_with_map:new Ml(e,t.u_pitch_with_map),u_is_along_line:new Ml(e,t.u_is_along_line),u_is_variable_anchor:new Ml(e,t.u_is_variable_anchor),u_texsize:new Cl(e,t.u_texsize),u_texsize_icon:new Cl(e,t.u_texsize_icon),u_texture:new Ml(e,t.u_texture),u_texture_icon:new Ml(e,t.u_texture_icon),u_gamma_scale:new El(e,t.u_gamma_scale),u_device_pixel_ratio:new El(e,t.u_device_pixel_ratio),u_is_halo:new Ml(e,t.u_is_halo),u_translation:new Cl(e,t.u_translation),u_pitched_scale:new El(e,t.u_pitched_scale)}),background:(e,t)=>({u_opacity:new El(e,t.u_opacity),u_color:new Dl(e,t.u_color)}),backgroundPattern:(e,t)=>({u_opacity:new El(e,t.u_opacity),u_image:new Ml(e,t.u_image),u_pattern_tl_a:new Cl(e,t.u_pattern_tl_a),u_pattern_br_a:new Cl(e,t.u_pattern_br_a),u_pattern_tl_b:new Cl(e,t.u_pattern_tl_b),u_pattern_br_b:new Cl(e,t.u_pattern_br_b),u_texsize:new Cl(e,t.u_texsize),u_mix:new El(e,t.u_mix),u_pattern_size_a:new Cl(e,t.u_pattern_size_a),u_pattern_size_b:new Cl(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 Cl(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new Cl(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 Ml(e,t.u_texture),u_ele_delta:new El(e,t.u_ele_delta),u_fog_matrix:new Fl(e,t.u_fog_matrix),u_fog_color:new Dl(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 Dl(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)}),terrainCoords:(e,t)=>({u_texture:new Ml(e,t.u_texture),u_terrain_coords_id:new El(e,t.u_terrain_coords_id),u_ele_delta:new El(e,t.u_ele_delta)}),projectionErrorMeasurement:(e,t)=>({u_input:new El(e,t.u_input),u_output_expected:new El(e,t.u_output_expected)}),atmosphere:(e,t)=>({u_sun_pos:new Al(e,t.u_sun_pos),u_atmosphere_blend:new El(e,t.u_atmosphere_blend),u_globe_position:new Al(e,t.u_globe_position),u_globe_radius:new El(e,t.u_globe_radius),u_inv_proj_matrix:new Fl(e,t.u_inv_proj_matrix)}),sky:(e,t)=>({u_sky_color:new Dl(e,t.u_sky_color),u_horizon_color:new Dl(e,t.u_horizon_color),u_horizon:new Cl(e,t.u_horizon),u_horizon_normal:new Cl(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)})};class ov{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(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){const t=this.context.gl;if(!this.dynamicDraw)throw new 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(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const sv={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class av{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(const i of this.attributes){const r=t.attributes[i.name];void 0!==r&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,i){for(const r of this.attributes){const n=t.attributes[r.name];void 0!==n&&e.vertexAttribPointer(n,r.components,e[sv[r.type]],!1,this.itemSize,r.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class lv{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)}}class cv extends lv{getDefault(){return Ri.transparent}set(e){const 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)}}class hv extends lv{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class uv extends lv{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class dv extends lv{getDefault(){return[!0,!0,!0,!0]}set(e){const 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)}}class pv extends lv{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class fv extends lv{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class mv extends lv{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const 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)}}class _v extends lv{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const 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)}}class gv extends lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class yv extends lv{getDefault(){return[0,1]}set(e){const 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)}}class vv extends lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class xv extends lv{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class bv extends lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class wv extends lv{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const 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)}}class Tv extends lv{getDefault(){return Ri.transparent}set(e){const 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)}}class Sv extends lv{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class Pv extends lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class Iv extends lv{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Mv extends lv{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Ev extends lv{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Cv extends lv{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Av extends lv{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const 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)}}class zv extends lv{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class Dv extends lv{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Rv extends lv{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class kv extends lv{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Lv extends lv{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Fv extends lv{getDefault(){return null}set(e){var t;if(e===this.current&&!this.dirty)return;const i=this.gl;$g(i)?i.bindVertexArray(e):null===(t=i.getExtension("OES_vertex_array_object"))||void 0===t||t.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Bv extends lv{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Ov extends lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Vv extends lv{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class jv extends lv{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Nv extends jv{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Uv extends jv{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Gv extends jv{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const $v="Framebuffer is not complete";class Zv{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const o=e.gl,s=this.framebuffer=o.createFramebuffer();if(this.colorAttachment=new Nv(e,s),r)this.depthAttachment=n?new Gv(e,s):new Uv(e,s);else if(n)throw new Error("Stencil cannot be set without depth");if(o.checkFramebufferStatus(o.FRAMEBUFFER)!==o.FRAMEBUFFER_COMPLETE)throw new Error($v)}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class qv{constructor(e){var t,i;if(this.gl=e,this.clearColor=new cv(this),this.clearDepth=new hv(this),this.clearStencil=new uv(this),this.colorMask=new dv(this),this.depthMask=new pv(this),this.stencilMask=new fv(this),this.stencilFunc=new mv(this),this.stencilOp=new _v(this),this.stencilTest=new gv(this),this.depthRange=new yv(this),this.depthTest=new vv(this),this.depthFunc=new xv(this),this.blend=new bv(this),this.blendFunc=new wv(this),this.blendColor=new Tv(this),this.blendEquation=new Sv(this),this.cullFace=new Pv(this),this.cullFaceSide=new Iv(this),this.frontFace=new Mv(this),this.program=new Ev(this),this.activeTexture=new Cv(this),this.viewport=new Av(this),this.bindFramebuffer=new zv(this),this.bindRenderbuffer=new Dv(this),this.bindTexture=new Rv(this),this.bindVertexBuffer=new kv(this),this.bindElementBuffer=new Lv(this),this.bindVertexArray=new Fv(this),this.pixelStoreUnpack=new Bv(this),this.pixelStoreUnpackPremultiplyAlpha=new Ov(this),this.pixelStoreUnpackFlipY=new Vv(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),$g(e)){this.HALF_FLOAT=e.HALF_FLOAT;const r=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(t=e.RGBA16F)&&void 0!==t?t:null==r?void 0:r.RGBA16F_EXT,this.RGB16F=null!==(i=e.RGB16F)&&void 0!==i?i:null==r?void 0:r.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const t=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==t?void 0:t.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new ov(this,e,t)}createVertexBuffer(e,t,i){return new av(this,e,t,i)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new Zv(this,e,t,i,r)}clear({color:e,depth:t,stencil:i}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}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){De(e.blendFunction,Og.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(){var e;return $g(this.gl)?this.gl.createVertexArray():null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var t;$g(this.gl)?this.gl.deleteVertexArray(e):null===(t=this.gl.getExtension("OES_vertex_array_object"))||void 0===t||t.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let Wv;function Hv(e,t,i,r,n){var o,s;const a=e.context,l=e.transform,c=a.gl,h=e.useProgram("collisionBox"),u=[];let d=0,p=0;for(const s of r){const r=t.getTile(s).getBucket(i);if(!r)continue;const f=n?r.textCollisionBox:r.iconCollisionBox,m=r.collisionCircleArray;m.length>0&&(u.push({circleArray:m,circleOffset:p,coord:s}),d+=m.length/4,p=d),f&&h.draw(a,c.LINES,Ng.disabled,Gg.disabled,e.colorModeForRenderPass(),jg.disabled,ky(e.transform),null===(o=e.style.map.terrain)||void 0===o?void 0:o.getTerrainData(s),l.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),i.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,null,e.transform.zoom,null,null,f.collisionVertexBuffer)}if(!n||!u.length)return;const f=e.useProgram("collisionCircle"),m=new il;m.resize(4*d),m._trim();let _=0;for(const e of u)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,r=e.circleArray[i+0],n=e.circleArray[i+1],o=e.circleArray[i+2],s=e.circleArray[i+3];m.emplace(_++,r,n,o,s,0),m.emplace(_++,r,n,o,s,1),m.emplace(_++,r,n,o,s,2),m.emplace(_++,r,n,o,s,3)}(!Wv||Wv.length<2*d)&&(Wv=function(e){const t=2*e,i=new nl;i.resize(t),i._trim();for(let e=0;e<t;e++){const 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}(d));const g=a.createIndexBuffer(Wv,!0),y=a.createVertexBuffer(m,ku.members,!0);for(const t of u){const r=Ly(e.transform);f.draw(a,c.TRIANGLES,Ng.disabled,Gg.disabled,e.colorModeForRenderPass(),jg.disabled,r,null===(s=e.style.map.terrain)||void 0===s?void 0:s.getTerrainData(t.coord),null,i.id,y,g,hl.simpleSegment(0,2*t.circleOffset,t.circleArray.length,t.circleArray.length/2),null,e.transform.zoom,null,null,null)}y.destroy(),g.destroy()}const Xv=y(new Float32Array(16));function Yv(e,t,i,r,n,s){const{horizontalAlign:a,verticalAlign:l}=od(e);return new o((-(a-.5)*t/n+r[0])*s,(-(l-.5)*i/n+r[1])*s)}function Kv(e,t,i,r,n,s){const a=t.tileAnchorPoint.add(new o(t.translation[0],t.translation[1]));if(t.pitchWithMap){let e=r.mult(s);i||(e=e.rotate(-n));const o=a.add(e);return I_(o.x,o.y,t.pitchedLabelPlaneMatrix,t.getElevation).point}if(i){const i=L_(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),n=Math.atan(i.y/i.x)+(i.x<0?Math.PI:0);return e.add(r.rotate(n))}return e.add(r)}function Jv(e,t,i,r,n,s,a,l,c,h,u,d){const p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,_={};f.clear();for(let m=0;m<p.length;m++){const g=p.get(m),y=g.hidden||!g.crossTileID||e.allowVerticalPlacement&&!g.placedOrientation?null:r[g.crossTileID];if(y){const r=new o(g.anchorX,g.anchorY),p={getElevation:d,width:n.width,height:n.height,pitchedLabelPlaneMatrix:s,pitchWithMap:i,transform:n,tileAnchorPoint:r,translation:h,unwrappedTileID:u},m=i?B_(r.x,r.y,p):L_(r.x,r.y,p),v=M_(n.cameraToCenterDistance,m.signedDistanceFromCamera);let x=ad(e.textSizeData,l,g)*v/24;i&&(x*=e.tilePixelRatio/a);const{width:b,height:w,anchor:T,textOffset:S,textBoxScale:P}=y,I=Yv(T,b,w,S,P,x),M=n.getPitchedTextCorrection(r.x+h[0],r.y+h[1],u),E=Kv(m.point,p,t,I,-n.bearingInRadians,M),C=e.allowVerticalPlacement&&g.placedOrientation===nd.vertical?Math.PI/2:0;for(let e=0;e<g.numGlyphs;e++)dd(f,E,C);c&&g.associatedIconIndex>=0&&(_[g.associatedIconIndex]={shiftedAnchor:E,angle:C})}else U_(g.numGlyphs,f)}if(c){m.clear();const t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){const i=t.get(e);if(i.hidden)U_(i.numGlyphs,m);else{const t=_[e];if(t)for(let e=0;e<i.numGlyphs;e++)dd(m,t.shiftedAnchor,t.angle);else U_(i.numGlyphs,m)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function Qv(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function ex(e,t,i,r,n,o,s,a,l,c,h,u,d){var p,f;const m=e.context,g=m.gl,y=e.transform,v="map"===a,x="map"===l,b="viewport"!==a&&"point"!==i.layout.get("symbol-placement"),w=v&&!x&&!b,T=!i.layout.get("symbol-sort-key").isConstant();let S=!1;const P=e.getDepthModeForSublayer(0,Ng.ReadOnly),I=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),M=[],E=y.getCircleRadiusCorrection();for(const a of r){const r=t.getTile(a),l=r.getBucket(i);if(!l)continue;const h=n?l.text:l.icon;if(!(null==h?void 0:h.segments.get().length)||!h.hasVisibleVertices)continue;const u=h.programConfigurations.get(i.id),f=n||l.sdfIcons,m=n?l.textSizeData:l.iconSizeData,P=x||0!==y.pitch,C=e.useProgram(Qv(f,n,l),u),A=ld(m,y.zoom),z=null===(p=e.style.map.terrain)||void 0===p?void 0:p.getTerrainData(a);let D,R,k,L,F=[0,0],B=null;if(n)R=r.glyphAtlasTexture,k=g.LINEAR,D=r.glyphAtlasTexture.size,l.iconsInText&&(F=r.imageAtlasTexture.size,B=r.imageAtlasTexture,L=P||e.options.rotating||e.options.zooming||"composite"===m.kind||"camera"===m.kind?g.LINEAR:g.NEAREST);else{const t=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;R=r.imageAtlasTexture,k=f||e.options.rotating||e.options.zooming||t||P?g.LINEAR:g.NEAREST,D=r.imageAtlasTexture.size}const O=ee(r,1,e.transform.zoom),V=T_(v,e.transform,O),j=S_(x,v,e.transform,O),N=ae(y,r,o,s),U=y.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!d,applyTerrainMatrix:!0}),G=I&&l.hasTextData(),$="none"!==i.layout.get("icon-text-fit")&&G&&l.hasIconData();if(b){const t=_();b_(t,V);const r=e.style.map.terrain?(t,i)=>e.style.map.terrain.getElevation(a,t,i):null,o="map"===i.layout.get("text-rotation-alignment");C_(l,e,n,V,t,x,c,o,a.toUnwrapped(),y.width,y.height,N,r)}const Z=n&&I||$,q=b||Z?Xv:x?V:e.transform.clipSpaceToPixelsMatrix,W=f&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let H;H=f?l.iconsInText?ev(m.kind,A,w,x,b,Z,e,q,j,N,D,F,E):Qy(m.kind,A,w,x,b,Z,e,q,j,N,n,D,W,E):Jy(m.kind,A,w,x,b,Z,e,q,j,N,n,D,E);const X={program:C,buffers:h,uniformValues:H,projectionData:U,atlasTexture:R,atlasTextureIcon:B,atlasInterpolation:k,atlasInterpolationIcon:L,isSDF:f,hasHalo:W};if(T&&l.canOverlap){S=!0;const e=h.segments.get();for(const t of e)M.push({segments:new hl([t]),sortKey:t.sortKey,state:X,terrainData:z})}else M.push({segments:h.segments,sortKey:0,state:X,terrainData:z})}S&&M.sort(((e,t)=>e.sortKey-t.sortKey));const C=null!==(f=i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(null))&&void 0!==f?f:1/0,A=24*i.layout.get("text-letter-spacing").constantOr(0)<0||C>1;for(const t of M){const r=t.state;m.activeTexture.set(g.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,g.CLAMP_TO_EDGE),r.atlasTextureIcon&&(m.activeTexture.set(g.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,g.CLAMP_TO_EDGE));const n=r.isSDF&&r.hasHalo;if(n){const n=r.uniformValues;n.u_is_halo=1,A&&(n.u_is_plain=0,tx(r.buffers,t.segments,i,e,r.program,P,h,u,n,r.projectionData,t.terrainData),n.u_is_halo=0,n.u_is_plain=1)}tx(r.buffers,t.segments,i,e,r.program,P,h,u,r.uniformValues,r.projectionData,t.terrainData),n&&!A&&(r.uniformValues.u_is_halo=0)}}function tx(e,t,i,r,n,o,s,a,l,c,h){const u=r.context;n.draw(u,u.gl.TRIANGLES,o,s,a,jg.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function ix(e,t,i,r,n){const o=e.context,s=o.gl,a=Gg.disabled,l=new Og([s.ONE,s.ONE],Ri.transparent,[!0,!0,!0,!0]),c=t.getBucket(i);if(!c)return;const h=r.key;let u=i.heatmapFbos.get(h);u||(u=nx(o,t.tileSize,t.tileSize),i.heatmapFbos.set(h,u)),o.bindFramebuffer.set(u.framebuffer),o.viewport.set([0,0,t.tileSize,t.tileSize]),o.clear({color:Ri.transparent});const d=c.programConfigurations.get(i.id),p=e.useProgram("heatmap",d,!n),f=e.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),m=e.style.map.terrain.getTerrainData(r);p.draw(o,s.TRIANGLES,Ng.disabled,a,l,jg.disabled,By(t,e.transform.zoom,i.paint.get("heatmap-intensity"),1),m,f,i.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,i.paint,e.transform.zoom,d)}function rx(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform;o.setColorMode(e.colorModeForRenderPass());const l=ox(o,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:n,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(o,s.TRIANGLES,Ng.disabled,Gg.disabled,e.colorModeForRenderPass(),jg.disabled,Oy(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),h.destroy(),t.heatmapFbos.delete(c)}function nx(e,t,i){var r,n;const o=e.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:o.UNSIGNED_BYTE,l=null!==(n=e.RGBA16F)&&void 0!==n?n:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,t,i,0,o.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function ox(e,t){return t.colorRampTexture||(t.colorRampTexture=new Zc(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function sx(e,t,i,r,n,o,s,a){let l=256;if(n.stepInterpolant){const r=t.getSource().maxzoom,n=s.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-s.canonical.z):1;l=be((c=o.maxLineLength/Q*1024*n)<=1?1:Math.pow(2,Math.ceil(Math.log(c)/Math.LN2)),256,i.maxTextureSize)}var c;return a.gradient=Fc({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:a.gradient||void 0,clips:o.lineClipsArray}),a.texture?a.texture.update(a.gradient):a.texture=new Zc(i,a.gradient,r.RGBA),a.version=n.gradientVersion,a.texture}function ax(e,t,i,r,n){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(n)}function lx(e,t,i,r,n,o){(n||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(o)}function cx(e,t,i,r,n,o,s){const a=o.gradients[n.id];let l=a.texture;n.gradientVersion!==a.version&&(l=sx(e,t,i,r,n,o,s,a)),i.activeTexture.set(r.TEXTURE0),l.bind(n.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function hx(e,t,i,r,n,o,s,a,l){const c=o.gradients[n.id];let h=c.texture;n.gradientVersion!==c.version&&(h=sx(e,t,i,r,n,o,s,c)),i.activeTexture.set(r.TEXTURE0),h.bind(n.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(i),a.updatePaintBuffers(l)}function ux(e,t,i,r,n){if(!i||!(null==r?void 0:r.imageAtlas))return;const o=r.imageAtlas.patternPositions;let s=o[i.to.toString()],a=o[i.from.toString()];if(!s&&a&&(s=a),!a&&s&&(a=s),!s||!a){const e=n.getPaintProperty(t);s=o[e],a=o[e]}s&&a&&e.setConstantPatternPositions(s,a)}function dx(e,t,i,r,n,o,s,a){var l;const c=e.context.gl,h="fill-pattern",u=i.paint.get(h),d=null==u?void 0:u.constantOr(1),p=i.getCrossfadeParameters();let f,m,_,g,y;const v=e.transform,x=i.paint.get("fill-translate"),b=i.paint.get("fill-translate-anchor");s?(m=d&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=c.LINES):(m=d?"fillPattern":"fill",f=c.TRIANGLES);const w=u.constantOr(null);for(const u of r){const r=t.getTile(u);if(d&&!r.patternsLoaded())continue;const T=r.getBucket(i);if(!T)continue;const S=T.programConfigurations.get(i.id),P=e.useProgram(m,S),I=null===(l=e.style.map.terrain)||void 0===l?void 0:l.getTerrainData(u);d&&(e.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),S.updatePaintBuffers(p)),ux(S,h,w,r,i);const M=v.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),E=ae(v,r,x,b);if(s){g=T.indexBuffer2,y=T.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];_="fillOutlinePattern"===m&&d?Dy(e,p,r,t,E):zy(t,E)}else g=T.indexBuffer,y=T.segments,_=d?Cy(e,p,r,E):Ay(E);const C=e.stencilModeForClipping(u);P.draw(e.context,f,n,C,o,jg.backCCW,_,I,M,i.id,T.layoutVertexBuffer,g,y,i.paint,e.transform.zoom,S)}}function px(e,t,i,r,n,o,s,a){var l;const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=i.paint.get(u),p=d.constantOr(1),f=i.getCrossfadeParameters(),m=i.paint.get("fill-extrusion-opacity"),_=d.constantOr(null),g=e.transform;for(const d of r){const r=t.getTile(d),y=r.getBucket(i);if(!y)continue;const v=null===(l=e.style.map.terrain)||void 0===l?void 0:l.getTerrainData(d),x=y.programConfigurations.get(i.id),b=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",x);p&&(e.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),x.updatePaintBuffers(f));const w=g.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!a,applyTerrainMatrix:!0});ux(x,u,_,r,i);const T=ae(g,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),S=i.paint.get("fill-extrusion-vertical-gradient"),P=p?Ey(e,S,m,T,d,f,r):My(e,S,m,T);b.draw(c,c.gl.TRIANGLES,n,o,s,jg.backCCW,P,v,w,i.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,i.paint,e.transform.zoom,x,e.style.map.terrain&&y.centroidVertexBuffer)}}function fx(e,t,i,r,n,o,s,a,l){var c;const h=e.style.projection,u=e.context,d=e.transform,p=u.gl,f=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,f),_=!e.options.moving;for(const f of r){const r=t.getTile(f),g=r.fbo;if(!g)continue;const y=h.getMeshFromTileID(u,f.canonical,a,!0,"raster"),v=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);u.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,g.colorAttachment.get());const x=d.getProjectionData({overscaledTileID:f,aligned:_,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(u,p.TRIANGLES,o,n[f.overscaledZ],s,jg.backCCW,Vy(e,r,i),v,x,i.id,y.vertexBuffer,y.indexBuffer,y.segments)}}let mx=0;function _x(e,t,i,r,n,o,s,a,l){var c;const h=e.style.projection,u=e.context,d=e.transform,p=u.gl,f=e.useProgram("colorRelief"),m=!e.options.moving,_="nearest"===i.paint.get("resampling")?p.NEAREST:p.LINEAR;let g=!0,y=0;for(const v of r){const r=t.getTile(v),x=r.dem;if(g){mx||(mx=p.getParameter(p.MAX_TEXTURE_SIZE));const e=mx,{elevationTexture:t,colorTexture:r}=i.getColorRampTextures(u,e,x.getUnpackVector());u.activeTexture.set(p.TEXTURE1),t.bind(p.NEAREST,p.CLAMP_TO_EDGE),u.activeTexture.set(p.TEXTURE4),r.bind(p.LINEAR,p.CLAMP_TO_EDGE),g=!1,y=t.size[0]}if(!(null==x?void 0:x.data))continue;const b=x.stride,w=x.getPixels();if(u.activeTexture.set(p.TEXTURE0),u.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||(r.demTexture=e.getTileTexture(b)),r.demTexture){const e=r.demTexture;e.update(w,{premultiply:!1}),e.bind(_,p.CLAMP_TO_EDGE)}else r.demTexture=new Zc(u,w,p.RGBA,{premultiply:!1}),r.demTexture.bind(_,p.CLAMP_TO_EDGE);const T=h.getMeshFromTileID(u,v.canonical,a,!0,"raster"),S=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(v),P=d.getProjectionData({overscaledTileID:v,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});f.draw(u,p.TRIANGLES,o,n[v.overscaledZ],s,jg.backCCW,Uy(i,r.dem,y),S,P,i.id,T.vertexBuffer,T.indexBuffer,T.segments)}}const gx=[new o(0,0),new o(Q,0),new o(Q,Q),new o(0,Q)];function yx(e,t,i,r,n,o,s,a,l=!1,c=!1){var h;const u=r[r.length-1].overscaledZ,d=e.context,p=d.gl,f=e.useProgram("raster"),m=e.transform,_=e.style.projection,g=e.colorModeForRenderPass(),y=!e.options.moving,v=i.paint.get("raster-opacity"),x="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?p.NEAREST:p.LINEAR,b=i.paint.get("raster-fade-duration"),w=!!e.style.map.terrain;for(const T of r){const r=e.getDepthModeForSublayer(T.overscaledZ-u,1===v?Ng.ReadWrite:Ng.ReadOnly,p.LESS),S=t.getTile(T);d.activeTexture.set(p.TEXTURE0),S.texture.bind(x,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(p.TEXTURE1);const{parentTile:P,parentScaleBy:I,parentTopLeft:M,fadeValues:E}=vx(S,t,b,w);S.fadeOpacity=E.tileOpacity,P?(P.fadeOpacity=E.parentTileOpacity,P.texture.bind(x,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST)):S.texture.bind(x,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),S.texture.useMipmap&&d.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&p.texParameterf(p.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);const C=null===(h=e.style.map.terrain)||void 0===h?void 0:h.getTerrainData(T),A=m.getProjectionData({overscaledTileID:T,aligned:y,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),z=Yy(M,I,E.fadeMix,i,a),D=_.getMeshFromTileID(d,T.canonical,o,s,"raster");f.draw(d,p.TRIANGLES,r,n?n[T.overscaledZ]:Gg.disabled,g,l?jg.frontCCW:jg.backCCW,z,C,A,i.id,D.vertexBuffer,D.indexBuffer,D.segments)}}function vx(e,t,i,r){const n={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===i||r)return n;if(e.fadingParentID){const r=t.getLoadedTile(e.fadingParentID);if(!r)return n;const o=Math.pow(2,r.tileID.overscaledZ-e.tileID.overscaledZ),s=[e.tileID.canonical.x*o%1,e.tileID.canonical.y*o%1],a=function(e,t,i){const r=st(),n=(r-t.timeAdded)/i,o=e.fadingDirection===qm.Incoming,s=be((r-e.timeAdded)/i,0,1),a=be(1-n,0,1),l=o?s:a;return{tileOpacity:l,parentTileOpacity:o?a:s,fadeMix:{opacity:1,mix:1-l}}}(e,r,i);return{parentTile:r,parentScaleBy:o,parentTopLeft:s,fadeValues:a}}if(e.selfFading){const t=function(e,t){const i=be((st()-e.timeAdded)/t,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}(e,i);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:t}}return n}const xx=new Ri(1,0,0,1),bx=new Ri(0,1,0,1),wx=new Ri(0,0,1,1),Tx=new Ri(1,0,1,1),Sx=new Ri(0,1,1,1);function Px(e,t,i,r){Mx(e,0,t+i/2,e.transform.width,i,r)}function Ix(e,t,i,r){Mx(e,t-i/2,0,i,e.transform.height,r)}function Mx(e,t,i,r,n,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,n*e.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Ex(e,t,i){var r;const n=e.context,o=n.gl,s=e.useProgram("debug"),a=Ng.disabled,l=Gg.disabled,c=e.colorModeForRenderPass(),h="$debug",u=null===(r=e.style.map.terrain)||void 0===r?void 0:r.getTerrainData(i);n.activeTexture.set(o.TEXTURE0);const d=t.getTileByID(i.key).latestRawTileData,p=Math.floor(((null==d?void 0:d.byteLength)||0)/1024),f=t.getTile(i).tileSize,m=512/Math.min(f,512)*(i.overscaledZ/e.transform.zoom)*.5;let _=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(_+=` => ${i.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${_} ${p}kB`);const g=e.transform.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(n,o.TRIANGLES,a,l,Og.alphaBlended,jg.disabled,Fy(Ri.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(n,o.LINE_STRIP,a,l,c,jg.disabled,Fy(Ri.red),u,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Cx(e,t,i,r){const{isRenderingGlobe:n}=r,o=e.context,s=o.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),u=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(r.tileID.toUnwrapped()),m=wy(p,f,e.style.sky,a.pitch,n),_=a.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(o,s.TRIANGLES,c,Gg.disabled,l,jg.backCCW,m,d,_,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Ax(e,t){if(!t.mesh){const i=new Ua;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1);const r=new ol;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),t.mesh=new bg(e.createVertexBuffer(i,wg.members),e.createIndexBuffer(r),hl.simpleSegment(0,0,i.length,r.length))}return t.mesh}const zx={symbol:function(e,t,i,r,n,o){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=o,a=Gg.disabled,l=e.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,t,i,r,n,o,s,a,l){var c;const h=t.transform,u=t.style.map.terrain,d="map"===n,p="map"===o;for(const n of e){const e=r.getTile(n),o=e.getBucket(i);if(!(null===(c=null==o?void 0:o.text)||void 0===c?void 0:c.segments.get().length))continue;const f=ld(o.textSizeData,h.zoom),m=ee(e,1,t.transform.zoom),_=T_(d,t.transform,m),g="none"!==i.layout.get("icon-text-fit")&&o.hasIconData();if(f){const t=Math.pow(2,h.zoom-e.tileID.overscaledZ),i=u?(e,t)=>u.getElevation(n,e,t):null;Jv(o,d,p,l,h,_,t,f,g,ae(h,e,s,a),n.toUnwrapped(),i)}}}(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"),n),0!==i.paint.get("icon-opacity").constantOr(1)&&ex(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),a,l,s),0!==i.paint.get("text-opacity").constantOr(1)&&ex(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"),a,l,s),t.map.showCollisionBoxes&&(Hv(e,t,i,r,!0),Hv(e,t,i,r,!1))},circle:function(e,t,i,r,n){var o;if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=n,a=i.paint.get("circle-opacity"),l=i.paint.get("circle-stroke-width"),c=i.paint.get("circle-stroke-opacity"),h=!i.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,p=e.transform,f=e.getDepthModeForSublayer(0,Ng.ReadOnly),m=Gg.disabled,_=e.colorModeForRenderPass(),g=[],y=p.getCircleRadiusCorrection();for(const n of r){const r=t.getTile(n),a=r.getBucket(i);if(!a)continue;const l=ae(p,r,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),c=a.programConfigurations.get(i.id),u=e.useProgram("circle",c),d=a.layoutVertexBuffer,f=a.indexBuffer,m=null===(o=e.style.map.terrain)||void 0===o?void 0:o.getTerrainData(n),_={programConfiguration:c,program:u,layoutVertexBuffer:d,indexBuffer:f,uniformValues:Ry(e,r,i,l,y),terrainData:m,projectionData:p.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!s,applyTerrainMatrix:!0})};if(h){const e=a.segments.get();for(const t of e)g.push({segments:new hl([t]),sortKey:t.sortKey,state:_})}else g.push({segments:a.segments,sortKey:0,state:_})}h&&g.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of g){const{programConfiguration:r,program:n,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=t.state;n.draw(u,d.TRIANGLES,f,m,_,jg.backCCW,a,l,c,i.id,o,s,t.segments,i.paint,e.transform.zoom,r)}},heatmap:function(e,t,i,r,n){if(0===i.paint.get("heatmap-opacity"))return;const o=e.context,{isRenderingToTexture:s,isRenderingGlobe:a}=n;if(e.style.map.terrain){for(const n of r){const r=t.getTile(n);t.hasRenderableParent(n)||("offscreen"===e.renderPass?ix(e,r,i,n,a):"translucent"===e.renderPass&&rx(e,i,n,s,a))}o.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,t,i,r){const n=e.context,o=n.gl,s=e.transform,a=Gg.disabled,l=new Og([o.ONE,o.ONE],Ri.transparent,[!0,!0,!0,!0]);(function(e,t,i){const r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let n=i.heatmapFbos.get(Bc);n?(r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),e.bindFramebuffer.set(n.framebuffer)):(n=nx(e,t.width/4,t.height/4),i.heatmapFbos.set(Bc,n))})(n,e,i),n.clear({color:Ri.transparent});for(const c of r){if(t.hasRenderableParent(c))continue;const r=t.getTile(c),h=r.getBucket(i);if(!h)continue;const u=h.programConfigurations.get(i.id),d=e.useProgram("heatmap",u),p=s.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),f=s.getCircleRadiusCorrection();d.draw(n,o.TRIANGLES,Ng.disabled,a,l,jg.backCCW,By(r,s.zoom,i.paint.get("heatmap-intensity"),f),null,p,i.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,i.paint,s.zoom,u)}n.viewport.set([0,0,e.width,e.height])}(e,t,i,r):"translucent"===e.renderPass&&function(e,t){const i=e.context,r=i.gl;i.setColorMode(e.colorModeForRenderPass());const n=t.heatmapFbos.get(Bc);n&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),ox(i,t).bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(i,r.TRIANGLES,Ng.disabled,Gg.disabled,e.colorModeForRenderPass(),jg.disabled,Oy(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,n){var o;if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=n,a=i.paint.get("line-opacity"),l=i.paint.get("line-width");if(0===a.constantOr(1)||0===l.constantOr(1))return;const c=e.getDepthModeForSublayer(0,Ng.ReadOnly),h=e.colorModeForRenderPass(),u=i.paint.get("line-dasharray"),d=u.constantOr(1),p=i.paint.get("line-pattern"),f=p.constantOr(1),m=i.paint.get("line-gradient"),_=i.getCrossfadeParameters();let g;g=f?"linePattern":d&&m?"lineGradientSDF":d?"lineSDF":m?"lineGradient":"line";const y=e.context,v=y.gl,x=e.transform;let b=!0;for(const n of r){const r=t.getTile(n);if(f&&!r.patternsLoaded())continue;const a=r.getBucket(i);if(!a)continue;const l=a.programConfigurations.get(i.id),w=e.context.program.get(),T=e.useProgram(g,l),S=b||T.program!==w,P=null===(o=e.style.map.terrain)||void 0===o?void 0:o.getTerrainData(n),I=p.constantOr(null),M=null==u?void 0:u.constantOr(null);if(I&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[I.to.toString()],i=e.patternPositions[I.from.toString()];t&&i&&l.setConstantPatternPositions(t,i)}else if(M){const t="round"===i.layout.get("line-cap").constantOr(null),r=e.lineAtlas.getDash(M.to,t),n=e.lineAtlas.getDash(M.from,t);l.setConstantDashPositions(r,n)}const E=x.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),C=x.getPixelScale();let A;f?(A=Zy(e,r,i,C,_),ax(y,v,r,l,_)):d&&m?(A=Wy(e,r,i,C,_,a.lineClipsArray.length),hx(e,t,y,v,i,a,n,l,_)):d?(A=qy(e,r,i,C,_),lx(e,y,v,l,S,_)):m?(A=$y(e,r,i,C,a.lineClipsArray.length),cx(e,t,y,v,i,a,n)):A=Gy(e,r,i,C);const z=e.stencilModeForClipping(n);T.draw(y,v.TRIANGLES,c,z,h,jg.disabled,A,P,E,i.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,i.paint,e.transform.zoom,l,a.layoutVertexBuffer2),b=!1}},fill:function(e,t,i,r,n){const o=i.paint.get("fill-color"),s=i.paint.get("fill-opacity");if(0===s.constantOr(1))return;const{isRenderingToTexture:a}=n,l=e.colorModeForRenderPass(),c=i.paint.get("fill-pattern"),h=e.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(Ri.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(e.renderPass===h){const n=e.getDepthModeForSublayer(1,"opaque"===e.renderPass?Ng.ReadWrite:Ng.ReadOnly);dx(e,t,i,r,n,l,!1,a)}if("translucent"===e.renderPass&&i.paint.get("fill-antialias")){const n=e.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,Ng.ReadOnly);dx(e,t,i,r,n,l,!0,a)}},fillExtrusion:function(e,t,i,r,n){const o=i.paint.get("fill-extrusion-opacity");if(0===o)return;const{isRenderingToTexture:s}=n;if("translucent"===e.renderPass){const n=new Ng(e.context.gl.LEQUAL,Ng.ReadWrite,e.depthRangeFor3D);if(1!==o||i.paint.get("fill-extrusion-pattern").constantOr(1))px(e,t,i,r,n,Gg.disabled,Og.disabled,s),px(e,t,i,r,n,e.stencilModeFor3D(),e.colorModeForRenderPass(),s);else{const o=e.colorModeForRenderPass();px(e,t,i,r,n,Gg.disabled,o,s)}}},hillshade:function(e,t,i,r,n){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const{isRenderingToTexture:o}=n,s=e.context,a=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,Ng.ReadOnly),c=e.colorModeForRenderPass();if("offscreen"===e.renderPass)!function(e,t,i,r,n,o,s){const a=e.context,l=a.gl,c="nearest"===r.paint.get("resampling")?l.NEAREST:l.LINEAR;for(const h of i){const i=t.getTile(h),u=i.dem;if(!(null==u?void 0:u.data))continue;if(!i.needsHillshadePrepare)continue;const d=u.dim,p=u.stride,f=u.getPixels();if(a.activeTexture.set(l.TEXTURE1),a.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||(i.demTexture=e.getTileTexture(p)),i.demTexture){const e=i.demTexture;e.update(f,{premultiply:!1}),e.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new Zc(a,f,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);a.activeTexture.set(l.TEXTURE0);let m=i.fbo;if(!m){const e=new Zc(a,{width:d,height:d,data:null},l.RGBA);e.bind(c,l.CLAMP_TO_EDGE),m=i.fbo=a.createFramebuffer(d,d,!0,!1),m.colorAttachment.set(e.texture)}a.bindFramebuffer.set(m.framebuffer),a.viewport.set([0,0,d,d]),e.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,o,s,jg.disabled,jy(i.tileID,u),null,null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),i.needsHillshadePrepare=!1}}(e,t,r,i,l,Gg.disabled,c),s.viewport.set([0,0,e.width,e.height]);else if("translucent"===e.renderPass)if(a){const[n,s,a]=e.stencilConfigForOverlapTwoPass(r);fx(e,t,i,a,n,l,c,!1,o),fx(e,t,i,a,s,l,c,!0,o)}else{const[n,s]=e.getStencilConfigForOverlapAndUpdateStencilID(r);fx(e,t,i,s,n,l,c,!1,o)}},colorRelief:function(e,t,i,r,n){if("translucent"!==e.renderPass)return;if(!r.length)return;const{isRenderingToTexture:o}=n,s=e.style.projection.useSubdivision,a=e.getDepthModeForSublayer(0,Ng.ReadOnly),l=e.colorModeForRenderPass();if(s){const[n,s,c]=e.stencilConfigForOverlapTwoPass(r);_x(e,t,i,c,n,a,l,!1,o),_x(e,t,i,c,s,a,l,!0,o)}else{const[n,s]=e.getStencilConfigForOverlapAndUpdateStencilID(r);_x(e,t,i,s,n,a,l,!1,o)}},raster:function(e,t,i,r,n){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const{isRenderingToTexture:o}=n,s=t.getSource(),a=e.style.projection.useSubdivision;if(s instanceof Bp)yx(e,t,i,r,null,!1,!1,s.tileCoords,s.flippedWindingOrder,o);else if(a){const[n,s,a]=e.stencilConfigForOverlapTwoPass(r);yx(e,t,i,a,n,!1,!0,gx,!1,o),yx(e,t,i,a,s,!0,!0,gx,!1,o)}else{const[n,s]=e.getStencilConfigForOverlapAndUpdateStencilID(r);yx(e,t,i,s,n,!1,!0,gx,!1,o)}},background:function(e,t,i,r,n){var o;const s=i.paint.get("background-color"),a=i.paint.get("background-opacity");if(0===a)return;const{isRenderingToTexture:l}=n,c=e.context,h=c.gl,u=e.style.projection,d=e.transform,p=d.tileSize,f=i.paint.get("background-pattern");if(e.isPatternMissing(f))return;const m=!f&&1===s.a&&1===a&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==m)return;const _=Gg.disabled,g=e.getDepthModeForSublayer(0,"opaque"===m?Ng.ReadWrite:Ng.ReadOnly),y=e.colorModeForRenderPass(),v=e.useProgram(f?"backgroundPattern":"background"),x=r||l_(d,{tileSize:p,terrain:e.style.map.terrain});f&&(c.activeTexture.set(h.TEXTURE0),e.imageManager.bind(e.context));const b=i.getCrossfadeParameters();for(const t of x){const r=d.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),n=f?iv(a,e,f,{tileID:t,tileSize:p},b):tv(a,s),m=null===(o=e.style.map.terrain)||void 0===o?void 0:o.getTerrainData(t),x=u.getMeshFromTileID(c,t.canonical,!1,!0,"raster");v.draw(c,h.TRIANGLES,g,_,y,jg.backCCW,n,m,r,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}},sky:function(e,t){const i=e.context,r=i.gl,n=((e,t,i)=>{const r=Math.cos(t.rollInRadians),n=Math.sin(t.rollInRadians),o=Qm(t),s=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-o*n)*i,(t.height/2+o*r)*i],u_horizon_normal:[-n,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),o=new Ng(r.LEQUAL,Ng.ReadWrite,[0,1]),s=Gg.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Ax(i,t);l.draw(i,r.TRIANGLES,o,s,a,jg.disabled,n,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)},atmosphere:function(e,t,i){const r=e.context,n=r.gl,o=e.useProgram("atmosphere"),s=new Ng(n.LEQUAL,Ng.ReadOnly,[0,1]),a=e.transform,l=function(e,t){const i=e.properties.get("position"),r=[-i.x,-i.y,-i.z],n=y(new Float64Array(16));var o,s,a,l,c,h,u;return"map"===e.properties.get("anchor")&&(P(n,n,t.rollInRadians),T(n,n,-t.pitchInRadians),P(n,n,t.bearingInRadians),T(n,n,t.center.lat*Math.PI/180),S(n,n,-t.center.lng*Math.PI/180)),(o=r)[0]=((a=n)[0]*(l=(s=r)[0])+a[4]*(c=s[1])+a[8]*(h=s[2])+a[12])/(u=(u=a[3]*l+a[7]*c+a[11]*h+a[15])||1),o[1]=(a[1]*l+a[5]*c+a[9]*h+a[13])/u,o[2]=(a[2]*l+a[6]*c+a[10]*h+a[14])/u,r}(i,e.transform),c=a.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),h=t.properties.get("atmosphere-blend")*c.projectionTransition;if(0===h)return;const u=ey(a.worldSize,a.center.lat),d=a.inverseProjectionMatrix,p=new Float64Array(4);p[3]=1,$(p,p,a.modelViewProjectionMatrix),p[0]/=p[3],p[1]/=p[3],p[2]/=p[3],p[3]=1,$(p,p,d),p[0]/=p[3],p[1]/=p[3],p[2]/=p[3],p[3]=1;const f=((e,t,i,r,n)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:n}))(l,h,[p[0],p[1],p[2]],u,d),m=Ax(r,t);o.draw(r,n.TRIANGLES,s,Gg.disabled,Og.alphaBlended,jg.disabled,f,null,null,"atmosphere",m.vertexBuffer,m.indexBuffer,m.segments)},custom:function(e,t,i,r){const{isRenderingGlobe:n}=r,o=e.context,s=i.implementation,a=e.style.projection,l=e.transform,c=l.getProjectionDataForCustomLayer(n),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:c},u=s.renderingMode?s.renderingMode:"2d";if("offscreen"===e.renderPass){const t=s.prerender;t&&(e.setCustomLayerDefaults(),o.setColorMode(e.colorModeForRenderPass()),t.call(s,o.gl,h),o.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),o.setColorMode(e.colorModeForRenderPass()),o.setStencilMode(Gg.disabled);const t="3d"===u?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,Ng.ReadOnly);o.setDepthMode(t),s.render(o.gl,h),o.setDirty(),e.setBaseState(),o.bindFramebuffer.set(null)}},debug:function(e,t,i){for(const r of i)Ex(e,t,r)},debugPadding:function(e){const t=e.transform.padding;Px(e,e.transform.height-(t.top||0),3,xx),Px(e,t.bottom||0,3,bx),Ix(e,t.left||0,3,wx),Ix(e,e.transform.width-(t.right||0),3,Tx);const i=e.transform.centerPoint;!function(e,t,i,r){Mx(e,t-1,i-10,2,20,r),Mx(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,Sx)},terrainDepth:function(e,t){const i=e.context,r=i.gl,n=e.transform,o=Og.unblended,s=new Ng(r.LEQUAL,Ng.ReadWrite,[0,1]),a=t.tileManager.getRenderableTiles(),l=e.useProgram("terrainDepth");i.bindFramebuffer.set(t.getFramebuffer("depth").framebuffer),i.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),i.clear({color:Ri.transparent,depth:1});for(const e of a){const a=t.getTerrainMesh(e.tileID),c=t.getTerrainData(e.tileID),h=n.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),u={u_ele_delta:t.getMeshFrameDelta(n.zoom)};l.draw(i,r.TRIANGLES,s,Gg.disabled,o,jg.backCCW,u,c,h,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height])},terrainCoords:function(e,t){const i=e.context,r=i.gl,n=e.transform,o=Og.unblended,s=new Ng(r.LEQUAL,Ng.ReadWrite,[0,1]),a=t.getCoordsTexture(),l=t.tileManager.getRenderableTiles(),c=e.useProgram("terrainCoords");i.bindFramebuffer.set(t.getFramebuffer("coords").framebuffer),i.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),i.clear({color:Ri.transparent,depth:1}),t.coordsIndex=[];for(const e of l){const l=t.getTerrainMesh(e.tileID),h=t.getTerrainData(e.tileID);i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.texture);const u={u_terrain_coords_id:(255-t.coordsIndex.length)/255,u_texture:0,u_ele_delta:t.getMeshFrameDelta(n.zoom)},d=n.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});c.draw(i,r.TRIANGLES,s,Gg.disabled,o,jg.backCCW,u,h,d,"terrain",l.vertexBuffer,l.indexBuffer,l.segments),t.coordsIndex.push(e.tileID.key)}i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height])}};class Dx{constructor(e,t){this.drawFunctions=zx,this.context=new qv(e),this.transform=t,this._tileTextures={},this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:y(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=g_.maxOverzooming+g_.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new gg}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(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,t=new Ua;t.emplaceBack(0,0),t.emplaceBack(Q,0),t.emplaceBack(0,Q),t.emplaceBack(Q,Q),this.tileExtentBuffer=e.createVertexBuffer(t,wg.members),this.tileExtentSegments=hl.simpleSegment(0,0,4,2);const i=new Ua;i.emplaceBack(0,0),i.emplaceBack(Q,0),i.emplaceBack(0,Q),i.emplaceBack(Q,Q),this.debugBuffer=e.createVertexBuffer(i,wg.members),this.debugSegments=hl.simpleSegment(0,0,4,5);const r=new $a;r.emplaceBack(0,0,0,0),r.emplaceBack(Q,0,Q,0),r.emplaceBack(0,Q,0,Q),r.emplaceBack(Q,Q,Q,Q),this.rasterBoundsBuffer=e.createVertexBuffer(r,xy.members),this.rasterBoundsSegments=hl.simpleSegment(0,0,4,2);const n=new Ua;n.emplaceBack(0,0),n.emplaceBack(Q,0),n.emplaceBack(0,Q),n.emplaceBack(Q,Q),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(n,wg.members),this.rasterBoundsSegmentsPosOnly=hl.simpleSegment(0,0,4,5);const o=new Ua;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,wg.members),this.viewportSegments=hl.simpleSegment(0,0,4,2);const s=new al;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(s);const a=new ol;a.emplaceBack(1,0,2),a.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(a);const l=this.context.gl;this.stencilClearMode=new Gg({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new bg(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,t=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const i=_();M(i,0,this.width,this.height,0,0,1),w(i,i,[t.drawingBufferWidth,t.drawingBufferHeight,0]);const r={mainMatrix:i,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:i};this.useProgram("clippingMask",null,!0).draw(e,t.TRIANGLES,Ng.disabled,this.stencilClearMode,Og.disabled,jg.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!(null==t?void 0:t.length))return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Og.disabled),r.setDepthMode(Ng.disabled);const n={};for(const e of t)n[e.key]=this.nextStencilID++;this._renderTileMasks(n,t,i,!0),this._renderTileMasks(n,t,i,!1),this._tileClippingMaskIDs=n}_renderTileMasks(e,t,i,r){var n;const o=this.context,s=o.gl,a=this.style.projection,l=this.transform,c=this.useProgram("clippingMask");for(const h of t){const t=e[h.key],u=null===(n=this.style.map.terrain)||void 0===n?void 0:n.getTerrainData(h),d=a.getMeshFromTileID(this.context,h.canonical,r,!0,"stencil"),p=l.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!i,applyTerrainMatrix:!0});c.draw(o,s.TRIANGLES,Ng.disabled,new Gg({func:s.ALWAYS,mask:0},t,255,s.KEEP,s.KEEP,s.REPLACE),Og.disabled,i?jg.disabled:jg.backCCW,null,u,p,"$clipping",d.vertexBuffer,d.indexBuffer,d.segments)}}_renderTilesDepthBuffer(){var e;const t=this.context,i=t.gl,r=this.style.projection,n=this.transform,o=this.useProgram("depth"),s=this.getDepthModeFor3D(),a=l_(n,{tileSize:n.tileSize});for(const l of a){const a=null===(e=this.style.map.terrain)||void 0===e?void 0:e.getTerrainData(l),c=r.getMeshFromTileID(this.context,l.canonical,!0,!0,"raster"),h=n.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(t,i.TRIANGLES,s,Gg.disabled,Og.disabled,jg.backCCW,null,a,h,"$clipping",c.vertexBuffer,c.indexBuffer,c.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Gg({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Gg({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;i<n;i++)e[i+r]=new Gg({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,i]}return[{[r]:Gg.disabled},i]}stencilConfigForOverlapTwoPass(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(this.clearStencil(),n>1){const e={},o={};for(let i=0;i<n;i++)e[i+r]=new Gg({func:t.GREATER,mask:255},n+1+i,255,t.KEEP,t.KEEP,t.REPLACE),o[i+r]=new Gg({func:t.GREATER,mask:255},1+i,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*n+1,[e,o,i]}return this.nextStencilID=3,[{[r]:new Gg({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new Gg({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const t=1/8;return new Og([e.CONSTANT_COLOR,e.ONE],new Ri(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Og.unblended:Og.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return Ng.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Ng(i||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new Ng(this.context.gl.LEQUAL,Ng.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,t){var i,r,n;this.style=e,this.options=t,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(st()),this.imageManager.beginFrame();const o=this.style._order,s=this.style.tileManagers,a={},l={},c={},h={isRenderingToTexture:!1,isRenderingGlobe:(null===(i=e.projection)||void 0===i?void 0:i.transitionState)>0};for(const e in s){const t=s[e];t.used&&t.prepare(this.context),a[e]=t.getVisibleCoordinates(!1),l[e]=a[e].slice().reverse(),c[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<o.length;e++)if(this.style._layers[o[e]].is3D()){this.opaquePassCutoff=e;break}this.maybeDrawDepth(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const e of o){const t=this.style._layers[e];if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;const i=l[t.source];("custom"===t.type||i.length)&&this.renderLayer(this,s[t.source],t,i,h)}if(null===(r=this.style.projection)||void 0===r||r.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:t.showOverdrawInspector?Ri.black:Ri.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=t.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[o[this.currentLayer]],t=s[e.source],i=a[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,h)}this.renderPass="translucent";let u=!1;for(this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){const e=this.style._layers[o[this.currentLayer]],t=s[e.source];if(null===(n=this.renderToTexture)||void 0===n?void 0:n.renderLayer(e,h))continue;this.opaquePassEnabledForLayer()||u||(u=!0,h.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const i=("symbol"===e.type?c:l)[e.source];this._renderTileClippingMasks(e,a[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,i,h)}if(h.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[])),n=r.filter((e=>"vector"===e.getSource().type)),o=r.filter((e=>"vector"!==e.getSource().type)),s=e=>{(!i||i.getSource().maxzoom<e.getSource().maxzoom)&&(i=e)};for(const e of n)s(e);if(!i)for(const e of o)s(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(e){var t,i;if(!(null===(i=null===(t=this.style)||void 0===t?void 0:t.map)||void 0===i?void 0:i.terrain))return;const r=this.terrainFacilitator.matrix,n=this.transform.modelViewProjectionMatrix;let o=this.terrainFacilitator.depthDirty;var s,a;o||(o=e?!((s=r)[0]===(a=n)[0]&&s[1]===a[1]&&s[2]===a[2]&&s[3]===a[3]&&s[4]===a[4]&&s[5]===a[5]&&s[6]===a[6]&&s[7]===a[7]&&s[8]===a[8]&&s[9]===a[9]&&s[10]===a[10]&&s[11]===a[11]&&s[12]===a[12]&&s[13]===a[13]&&s[14]===a[14]&&s[15]===a[15]):!function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],v=t[0],x=t[1],b=t[2],w=t[3],T=t[4],S=t[5],P=t[6],I=t[7],M=t[8],E=t[9],C=t[10],A=t[11],z=t[12],D=t[13],R=t[14],k=t[15];return Math.abs(i-v)<=d*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(r-x)<=d*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-b)<=d*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(o-w)<=d*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-T)<=d*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(a-S)<=d*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(l-P)<=d*Math.max(1,Math.abs(l),Math.abs(P))&&Math.abs(c-I)<=d*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-M)<=d*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(u-E)<=d*Math.max(1,Math.abs(u),Math.abs(E))&&Math.abs(p-C)<=d*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(f-A)<=d*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(m-z)<=d*Math.max(1,Math.abs(m),Math.abs(z))&&Math.abs(_-D)<=d*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(g-R)<=d*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(y-k)<=d*Math.max(1,Math.abs(y),Math.abs(k))}(r,n)),o||(o=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),o&&(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]}(r,n),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.depthDirty=!1,this.terrainFacilitator.coordsDirty=!0,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}maybeDrawCoords(){var e,t;(null===(t=null===(e=this.style)||void 0===e?void 0:e.map)||void 0===t?void 0:t.terrain)&&this.terrainFacilitator.coordsDirty&&(this.terrainFacilitator.coordsDirty=!1,this.drawFunctions.terrainCoords(this,this.style.map.terrain))}renderLayer(e,t,i,r,n){if(i.isHidden(this.transform.zoom))return;if("background"!==i.type&&"custom"!==i.type&&!(r||[]).length)return;this.id=i.id;const o=this.drawFunctions;bd(i)?o.symbol(e,t,i,r,this.style.placement.variableOffsets,n):(e=>"circle"===e.type)(i)?o.circle(e,t,i,r,n):(e=>"heatmap"===e.type)(i)?o.heatmap(e,t,i,r,n):(e=>"line"===e.type)(i)?o.line(e,t,i,r,n):(e=>"fill"===e.type)(i)?o.fill(e,t,i,r,n):(e=>"fill-extrusion"===e.type)(i)?o.fillExtrusion(e,t,i,r,n):(e=>"hillshade"===e.type)(i)?o.hillshade(e,t,i,r,n):(e=>"color-relief"===e.type)(i)?o.colorRelief(e,t,i,r,n):Qs(i)?o.raster(e,t,i,r,n):(e=>"background"===e.type)(i)?o.background(e,t,i,r,n):(e=>"custom"===e.type)(i)&&o.custom(e,t,i,n)}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.length<Dx.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?t.push(e):e.destroy():this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,r=[]){var n;this.cache||(this.cache={});const o=!!this.style.map.terrain,s=this.style.projection,a=i?vg.projectionMercator:s.shaderPreludeCode,l=i?Tg:s.shaderDefine,c=e+(t?t.cacheKey:"")+`/${i?Sg:s.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(o?"/terrain":"")+(r?`/${r.join("/")}`:"");return(n=this.cache)[c]||(n[c]=new Py(this.context,vg[e],t,nv[e],this._showOverdrawInspector,o,a,l,r)),this.cache[c]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const 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(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Zc(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;if(this._tileTextures){for(const e in this._tileTextures){const t=this._tileTextures[e];if(t)for(const e of t)e.destroy()}this._tileTextures={}}if(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&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.indexBuffer)||void 0===t||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const t=this.cache[e];(null==t?void 0:t.program)&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Rx(e,t){let i,r=!1,n=null;const o=()=>{n=null,r&&(e(...i),n=setTimeout(o,t),r=!1)};return(...e)=>(r=!0,i=e,n||o(),n)}Dx.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50;class kx{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;const i=e.split("&").map((e=>e.split("=")));for(const e of i)e[0]===this._hashName&&(t=e);return(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const 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=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let n=window.location.href.replace(/(#.+)?$/,r);n=n.replace("&&","&"),window.history.replaceState(window.history.state,null,n)},this._updateHash=Rx(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){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),o=Math.round(t.lng*n)/n,s=Math.round(t.lat*n)/n,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new ap(+e[2],+e[1])}catch(e){return!1}const 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 Lx={linearity:.3,easing:ve(0,0,.3,1)},Fx=Te({deceleration:2500,maxSpeed:1400},Lx),Bx=Te({deceleration:20,maxSpeed:1400},Lx),Ox=Te({deceleration:1e3,maxSpeed:360},Lx),Vx=Te({deceleration:1e3,maxSpeed:90},Lx),jx=Te({deceleration:1e3,maxSpeed:360},Lx);class Nx{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:st(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=st();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,roll:0,pan:new o(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)t.zoom+=e.zoomDelta||0,t.bearing+=e.bearingDelta||0,t.pitch+=e.pitchDelta||0,t.roll+=e.rollDelta||0,e.panDelta&&t.pan._add(e.panDelta),e.around&&(t.around=e.around),e.pinchAround&&(t.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(t.pan.mag()){const n=Gx(t.pan.mag(),i,Te({},Fx,e||{})),o=t.pan.mult(n.amount/t.pan.mag()),s=this._map.cameraHelper.handlePanInertia(o,this._map.transform);r.center=s.easingCenter,r.offset=s.easingOffset,Ux(r,n)}if(t.zoom){const e=Gx(t.zoom,i,Bx);r.zoom=Ce(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount),Ux(r,e)}if(t.bearing){const e=Gx(t.bearing,i,Ox);r.bearing=this._map.transform.bearing+be(e.amount,-179,179),Ux(r,e)}if(t.pitch){const e=Gx(t.pitch,i,Vx);r.pitch=this._map.transform.pitch+e.amount,Ux(r,e)}if(t.roll){const e=Gx(t.roll,i,jx);r.roll=this._map.transform.roll+be(e.amount,-179,179),Ux(r,e)}if(r.zoom||r.bearing){const e=void 0===t.pinchAround?t.around:t.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),Te(r,{noMoveStart:!0})}}function Ux(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Gx(e,t,i){const{maxSpeed:r,linearity:n,deceleration:o}=i,s=be(e*n/(t/1e3),-r,r),a=Math.abs(s)/(o*n);return{easing:i.easing,duration:1e3*a,amount:s*(a/2)}}class $x extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){i=i instanceof MouseEvent?i:new MouseEvent(e,i);const n=lt.mousePos(t.getCanvas(),i);super(e,Te({point:n,lngLat:t.unproject(n),originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}}class Zx extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){const r="touchend"===e?i.changedTouches:i.touches,n=lt.touchPos(t.getCanvasContainer(),r),s=n.map((e=>t.unproject(e))),a=n.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new o(0,0));super(e,{points:n,point:a,lngLats:s,lngLat:t.unproject(a),originalEvent:i}),this._defaultPrevented=!1}}class qx extends bt{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class Wx{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new qx(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new $x(e.type,this._map,e))}mouseup(e){this._map.fire(new $x(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new $x(e.type,this._map,e))}dblclick(e){return this._firePreventable(new $x(e.type,this._map,e))}mouseover(e){this._map.fire(new $x(e.type,this._map,e))}mouseout(e){this._map.fire(new $x(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Zx(e.type,this._map,e))}touchmove(e){this._map.fire(new Zx(e.type,this._map,e))}touchend(e){this._map.fire(new Zx(e.type,this._map,e))}touchcancel(e){this._map.fire(new Zx(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Hx{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new $x(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new $x("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new $x(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Xx{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.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(o.convert(e),this._map.terrain)}}class Yx{constructor(e,t){this._map=e,this._tr=new Xx(e),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&&(lt.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=lt.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),s=Math.min(r.y,i.y),a=Math.max(r.y,i.y);this._box.style.transform=`translate(${n}px,${s}px)`,this._box.style.width=o-n+"px",this._box.style.height=a-s+"px"}mouseupWindow(e,t){if(!this._active)return;if(0!==e.button)return;const i=this._startPos,r=t;if(this.reset(),lt.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new bt("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(),this._box=null),lt.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new bt(e,{originalEvent:t}))}}function Kx(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}class Jx{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){const t=new o(0,0);for(const i of e)t._add(i);return t.div(e.length)}(t),this.touches=Kx(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=Kx(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Qx{constructor(e){this.singleTap=new Jx(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){const r=this.singleTap.touchend(e,t,i);if(r){const 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}}}class eb{constructor(e){this._tr=new Xx(e),this._zoomIn=new Qx({numTouches:1,numTaps:2}),this._zoomOut=new Qx({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){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i),o=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:Ce(o.zoom+1,t.getZoomSnap()),around:o.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:Ce(o.zoom-1,t.getZoomSnap()),around:o.unproject(n)},{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}}class tb{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){const 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;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const 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&<.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 ib=0,rb=2,nb={[ib]:1,[rb]:2};class ob{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){const i=nb[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}}class sb{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return 1===e.targetTouches.length}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class ab{constructor(e=new ob({checkCorrectEvent:()=>!0}),t=new sb){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>{this.mouseMoveStateManager.startMove(e)}),(e=>{this.oneFingerTouchMoveStateManager.startMove(e)}))}endMove(e){this._executeRelevantHandler(e,(e=>{this.mouseMoveStateManager.endMove(e)}),(e=>{this.oneFingerTouchMoveStateManager.endMove(e)}))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const lb=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class cb{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new o(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}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);const r=Kx(i,t),n=new o(0,0),s=new o(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(n._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(a),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class hb{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();const[r,n]=this._firstTwoTouches,o=ub(i,t,r),s=ub(i,t,n);if(!o||!s)return;const a=this._aroundCenter?null:o.add(s).div(2);return this._move([o,s],a,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=ub(i,t,r),s=ub(i,t,n);o&&s||(this._active&<.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 ub(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function db(e,t){return Math.log(e/t)/Math.LN2}class pb extends hb{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(e){this._zoomRate=null!=e?e:1}setZoomThreshold(e){this._zoomThreshold=null!=e?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){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(db(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:db(this._distance,i)*this._zoomRate,pinchAround:t}}}function fb(e,t){return 180*e.angleWith(t)/Math.PI}class mb extends hb{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){const r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:fb(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=fb(e,this._startVector);return Math.abs(i)<t}}function _b(e){return Math.abs(e.y)>Math.abs(e.x)}class gb extends hb{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,_b(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),n=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return _b(e)&&_b(t)&&o}}const yb={panStep:100,bearingStep:15,pitchStep:10};class vb{constructor(e){this._tr=new Xx(e);const t=yb;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.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,n=0,o=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(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:xb,zoom:t?Ce(a.zoom+t*(e.shiftKey?2:1),s.getZoomSnap()):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:a.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 xb(e){return e*(2-e)}const bb=4.000244140625,wb=1/450;class Tb{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new Xx(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=wb}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;const i=st(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%bb==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);const t=lt.mousePos(this._map.getCanvas(),e),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(ap.convert(i.center)):t,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender)return;if(this._needsRerender=!1,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>bb?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==i&&(i=1/i);const r="number"!=typeof this._targetZoom?e.scale:Me(this._targetZoom),n=e.applyConstrain(e.getCameraLngLat(),Ee(r*i)).zoom,o=this._map.getZoomSnap();if("wheel"===this._type&&o>0){const t=Ce(e.zoom,o);this._targetZoom=Ce(n,o,n-t)}else this._targetZoom=n;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const t="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,i=this._startZoom,r=this._easing;let n,o=!1;if("wheel"===this._type&&i&&r){const e=st()-this._lastWheelEventTime,s=Math.min((e+5)/200,1),a=r(s);n=br.number(i,t,a),s<1?this._needsRerender=!0:o=!0}else n=t,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=n,{noInertia:!0,needsRenderFrame:!o,zoomDelta:n-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=xe;if(this._prevEase){const e=this._prevEase,i=(st()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;t=ve(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:st(),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)}}class Sb{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()}}class Pb{constructor(e){this._tr=new Xx(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:Ce(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}}class Ib{constructor(){this._tap=new Qx({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=null!=e?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){const r=t[0],n=e.timeStamp-this._tapTime<500,o=this._tapPoint.dist(r)<30;n&&o?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;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/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{const 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}}class Mb{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()}}class Eb{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()}}class Cb{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()}}class Ab{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;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=lt.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const n=document.createElement("div");n.className="maplibregl-mobile-message",n.textContent=i,this._container.appendChild(n),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,t){this._enabled&&(this._map.fire(new bt("cooperativegestureprevented",{gestureType:e,originalEvent:t})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const zb=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Db extends bt{}function Rb(e){var t;return(null===(t=e.panDelta)||void 0===t?void 0:t.mag())||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class kb{get _ownerDocument(){var e;return(null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,t;return(null===(t=null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window}constructor(e,t){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;const i="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},n={},o={};for(const{handlerName:a,handler:l,allowed:c}of this._handlers){if(!l.isEnabled())continue;let h;if(this._blockedByActive(o,c,a))l.reset();else if(l[t||e.type]){if(Ye(e,t||e.type)){const i=lt.mousePos(this._map.getCanvas(),e);h=l[t||e.type](e,i)}else if(He[t||e.type]&&"touches"in e){const i=this._getMapTouches(e.touches),r=lt.touchPos(this._map.getCanvas(),i);h=l[t||e.type](e,r,i)}else He[s=t||e.type]||Xe[s]||(h=l[t||e.type](e));this.mergeHandlerResult(r,n,h,a,i),(null==h?void 0:h.needsRenderFrame)&&this._triggerRenderFrame()}(h||l.isActive())&&(o[a]=l)}var s;const a={};for(const e in this._previousActiveHandlers)o[e]||(a[e]=i);this._previousActiveHandlers=o,(Object.keys(a).length||Rb(r))&&(this._changes.push([r,n,a]),this._triggerRenderFrame()),(Object.keys(o).length||Rb(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=r;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Nx(e),this._bearingSnap=t.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(t);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[e,t,i]of this._listeners)e.addEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Wx(t,e));const r=t.boxZoom=new Yx(t,e);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();const n=t.cooperativeGestures=new Ab(t,e.cooperativeGestures);this._add("cooperativeGestures",n),e.cooperativeGestures&&n.enable();const s=new eb(t),a=new Pb(t);t.doubleClickZoom=new Sb(a,s),this._add("tapZoom",s),this._add("clickZoom",a),e.interactive&&e.doubleClickZoom&&t.doubleClickZoom.enable();const l=new Ib;this._add("tapDragZoom",l);const c=t.touchPitch=new gb(t);this._add("touchPitch",c),e.interactive&&e.touchPitch&&t.touchPitch.enable(e.touchPitch);const h=()=>t.project(t.getCenter()),u=function({enable:e,clickTolerance:t,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateDegreesPerPixelMoved:n=.8},s){const a=new ob({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button&&!e.ctrlKey});return new tb({clickTolerance:t,move:(e,t)=>{const a=s();if(i&&Math.abs(a.y-e.y)>r)return{bearingDelta:Ze(new o(e.x,t.y),t,a)};let l=(t.x-e.x)*n;return i&&t.y<a.y&&(l=-l),{bearingDelta:l}},moveStateManager:a,enable:e,assignEvents:lb})}(e,h),d=function({enable:e,clickTolerance:t,pitchDegreesPerPixelMoved:i=-.5}){const r=new ob({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button});return new tb({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:lb})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const n=new ob({checkCorrectEvent:e=>2===e.button&&e.ctrlKey});return new tb({clickTolerance:t,move:(e,t)=>{const n=r();let o=(t.x-e.x)*i;return t.y<n.y&&(o=-o),{rollDelta:o}},moveStateManager:n,enable:e,assignEvents:lb})}(e,h);t.dragRotate=new Eb(e,u,d,p),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",p,["mousePitch"]),e.interactive&&e.dragRotate&&t.dragRotate.enable();const f=function({enable:e,clickTolerance:t}){const i=new ob({checkCorrectEvent:e=>0===e.button&&!e.ctrlKey});return new tb({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:lb})}(e),m=new cb(e,t);t.dragPan=new Mb(i,f,m),this._add("mousePan",f),this._add("touchPan",m,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&t.dragPan.enable(e.dragPan);const _=new mb,g=new pb;t.touchZoomRotate=new Cb(i,g,_,l),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",g,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&t.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new Hx(t));const y=t.scrollZoom=new Tb(t,(()=>this._triggerRenderFrame()));this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&t.scrollZoom.enable(e.scrollZoom);const v=t.keyboard=new vb(t);this._add("keyboard",v),e.interactive&&e.keyboard&&t.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{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 Boolean(zb(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&!(null==t?void 0:t.includes(r)))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,t,i,r,n){if(!i)return;Te(e,i);const o={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.rollDelta&&(t.roll=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o)}_applyChanges(){const e={},t={},i={};for(const[r,n,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new o(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),Te(t,n),Te(i,s);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){const r=this._map,n=r._getTransformForUpdate(),o=r.terrain;if(!(Rb(e)||o&&this._terrainMovement))return void this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u||(u=r.transform.centerPoint),o&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const f=u.distSqr(n.centerPoint)<.01?n.center:n.screenPointToLocation(s?u.sub(s):u);this._handleMapControls({terrain:o,tr:n,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:s}),r._applyUpdatedTransform(n),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:n,panDelta:o}){const s=this._map.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),e)return s.useGlobeControls?(this._terrainMovement||!n.drag&&!n.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void s.handleMapControlsPan(i,t,r)):this._terrainMovement||!n.drag&&!n.zoom?void(n.drag&&this._terrainMovement&&o?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(o))):s.handleMapControlsPan(i,t,r)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void s.handleMapControlsPan(i,t,r));s.handleMapControlsPan(i,t,r)}_fireEvents(e,t,i){const r=zb(this._eventsInProgress),n=zb(e),o={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in o)this._fireEvent(e,o[e]);n&&this._fireEvent("move",n.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const s={};let a;for(const e in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[e];this._handlersById[i].isActive()||(delete this._eventsInProgress[e],a=t[i]||r,s[`${e}end`]=a)}for(const e in s)this._fireEvent(e,s[e]);const l=zb(this._eventsInProgress),c=(r||n)&&!l;if(c&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(i&&c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&nt.prefersReducedMotion?(this._map.fire(new bt("moveend",{originalEvent:a})),t(this._map.getBearing())&&this._map.resetNorth()):(t(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:a})),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new bt(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new Db("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Lb extends Tt{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((st()-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._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this._zoomSnap=i.zoomSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,t){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t}getCenter(){return new ap(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=o.convert(e).mult(-1),this.panTo(this.transform.center,Te({offset:e},t),i)}panTo(e,t,i){return this.easeTo(Te({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(Te({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(Ce(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo(Ce(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 bt("movestart",t)).fire(new bt("move",t)).fire(new bt("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(Te({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Te({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Te({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=lp.convert(e).adjustAntiMeridian();const i=(null==t?void 0:t.bearing)||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,t,i,r){const n={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=Te({padding:n,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){const e=r.padding;r.padding={top:e,bottom:e,right:e,left:e}}const o=Te(n,r.padding);r.padding=o;const s=this.transform,a=new lp(e,t),l=this.cameraHelper.cameraForBoxAndBearing(r,o,a,i,s);return l&&this._zoomSnap&&(l.zoom=Ce(l.zoom,this._zoomSnap,-1)),l}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,t,i,r,n){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(o.convert(e)),this.transform.screenPointToLocation(o.convert(t)),i,r),r,n)}_fitInternal(e,t,i){return e?(delete(t=Te(e,t)).padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop(),"zoom"in e&&this._zoomSnap&&(e.zoom=Ce(e.zoom,this._zoomSnap));const i=this._getTransformForUpdate();let r=!1,n=!1,o=!1;const s=i.zoom;this.terrain&&i.setElevation(this.terrain.getElevationForLngLatZoom(e.center?ap.convert(e.center):i.center,e.zoom||i.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(i,e);const a=i.zoom!==s;return"elevation"in e&&i.elevation!==+e.elevation&&i.setElevation(+e.elevation),"bearing"in e&&i.bearing!==+e.bearing&&(r=!0,i.setBearing(+e.bearing)),"pitch"in e&&i.pitch!==+e.pitch&&(n=!0,i.setPitch(+e.pitch)),"roll"in e&&i.roll!==+e.roll&&(o=!0,i.setRoll(+e.roll)),null==e.padding||i.isPaddingEqual(e.padding)||i.setPadding(e.padding),this._applyUpdatedTransform(i),this.fire(new bt("movestart",t)).fire(new bt("move",t)),a&&this.fire(new bt("zoomstart",t)).fire(new bt("zoom",t)).fire(new bt("zoomend",t)),r&&this.fire(new bt("rotatestart",t)).fire(new bt("rotate",t)).fire(new bt("rotateend",t)),n&&this.fire(new bt("pitchstart",t)).fire(new bt("pitch",t)).fire(new bt("pitchend",t)),o&&this.fire(new bt("rollstart",t)).fire(new bt("roll",t)).fire(new bt("rollend",t)),this.fire(new bt("moveend",t))}calculateCameraOptionsFromTo(e,t,i,r=0){const n=gp.fromLngLat(e,t),o=gp.fromLngLat(i,r),s=o.x-n.x,a=o.y-n.y,l=o.z-n.z,c=Math.hypot(s,a,l);if(0===c)throw new Error("Can't calculate camera options with same From and To");const h=Math.hypot(s,a),u=Ee(this.transform.cameraToCenterDistance/c/this.transform.tileSize),d=180*Math.atan2(s,-a)/Math.PI;let p=180*Math.acos(h/c)/Math.PI;return p=l<0?90-p:90+p,{center:o.toLngLat(),elevation:r,zoom:u,pitch:p,bearing:d}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,n){const o=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,r);return{center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:i,pitch:r,roll:n}}easeTo(e,t){this._stop(!1,e.easeId),"zoom"in(e=Te({offset:[0,0],duration:500,easing:xe},e))&&this._zoomSnap&&(e.zoom=Ce(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&nt.prefersReducedMotion)&&(e.duration=0);const i=this._getTransformForUpdate(),r=this.getBearing(),n=i.pitch,s=i.roll,a="bearing"in e?this._normalizeBearing(e.bearing,r):r,l="pitch"in e?+e.pitch:n,c="roll"in e?this._normalizeBearing(e.roll,s):s,h="padding"in e?e.padding:i.padding,u=o.convert(e.offset);let d,p;e.around&&(d=ap.convert(e.around),p=i.locationToScreenPoint(d));const f={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},m=this.cameraHelper.handleEaseTo(i,{bearing:a,pitch:l,roll:c,padding:h,around:d,aroundPoint:p,offsetAsPoint:u,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||(this._rotating=r!==a),this._pitching||(this._pitching=l!==n),this._rolling||(this._rolling=c!==s),this._padding=!i.isPaddingEqual(h),this._zooming||(this._zooming=m.isZooming),this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,f),this.terrain&&this._prepareElevation(m.elevationCenter),this._ease((r=>{m.easeFunc(r),this.terrain&&!e.freezeElevation&&this._updateElevation(r),this._applyUpdatedTransform(i),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 bt("movestart",e)),this._zooming&&!i.zooming&&this.fire(new bt("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new bt("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new bt("pitchstart",e)),this._rolling&&!i.rolling&&this.fire(new bt("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),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));const t=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&t!==this._elevationTarget){const i=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(i-(t-(i*e+this._elevationStart))/(1-e)),this._elevationTarget=t}this.transform.setElevation(br.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._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(i<r){const i=this.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}_applyUpdatedTransform(e){const t=[];if(t.push((e=>this._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:n,roll:o,pitch:s,bearing:a,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==n&&t.setZoom(n),void 0!==o&&t.setRoll(o),void 0!==s&&t.setPitch(s),void 0!==a&&t.setBearing(a),i.apply(t,!1)}this.transform.apply(i,!1)}_fireMoveEvents(e){this.fire(new bt("move",e)),this._zooming&&this.fire(new bt("zoom",e)),this._rotating&&this.fire(new bt("rotate",e)),this._pitching&&this.fire(new bt("pitch",e)),this._rolling&&this.fire(new bt("roll",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;delete this._easeId;const i=this._zooming,r=this._rotating,n=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,i&&this.fire(new bt("zoomend",e)),r&&this.fire(new bt("rotateend",e)),n&&this.fire(new bt("pitchend",e)),o&&this.fire(new bt("rollend",e)),this.fire(new bt("moveend",e))}flyTo(e,t){if(!e.essential&&nt.prefersReducedMotion){const i=Se(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(i,t)}this.stop(),"zoom"in(e=Te({offset:[0,0],speed:1.2,curve:1.42,easing:xe},e))&&this._zoomSnap&&(e.zoom=Ce(e.zoom,this._zoomSnap));const i=this._getTransformForUpdate(),r=i.bearing,n=i.pitch,s=i.roll,a=i.padding,l="bearing"in e?this._normalizeBearing(e.bearing,r):r,c="pitch"in e?+e.pitch:n,h="roll"in e?this._normalizeBearing(e.roll,s):s,u="padding"in e?e.padding:i.padding,d=o.convert(e.offset);let p=i.centerPoint.add(d);const f=i.screenPointToLocation(p),m=this.cameraHelper.handleFlyTo(i,{bearing:l,pitch:c,roll:h,padding:u,locationAtOffset:f,offsetAsPoint:d,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let _=e.curve;const g=Math.max(i.width,i.height),y=g/m.scaleOfZoom,v=m.pixelPathLength;"number"==typeof m.scaleOfMinZoom&&(_=Math.sqrt(g/m.scaleOfMinZoom/v*2));const x=_*_;function b(e){const t=(y*y-g*g+(e?-1:1)*x*x*v*v)/(2*(e?y:g)*x*v);return Math.log(Math.sqrt(t*t+1)-t)}function w(e){return(Math.exp(e)-Math.exp(-e))/2}function T(e){return(Math.exp(e)+Math.exp(-e))/2}const S=b(!1);let P=function(e){return T(S)/T(S+_*e)},I=function(e){return g*((T(S)*(w(t=S+_*e)/T(t))-w(S))/x)/v;var t},M=(b(!0)-S)/_;if(Math.abs(v)<2e-6||!isFinite(M)){if(Math.abs(g-y)<1e-6)return this.easeTo(e,t);const i=y<g?-1:1;M=Math.abs(Math.log(y/g))/_,I=()=>0,P=e=>Math.exp(i*_*e)}return e.duration="duration"in e?+e.duration:1e3*M/("screenSpeed"in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==l,this._pitching=c!==n,this._rolling=h!==s,this._padding=!i.isPaddingEqual(u),this._prepareEase(t,!1),this.terrain&&this._prepareElevation(m.targetCenter),this._ease((o=>{const f=o*M,_=1/P(f),g=I(f);this._rotating&&i.setBearing(br.number(r,l,o)),this._pitching&&i.setPitch(br.number(n,c,o)),this._rolling&&i.setRoll(br.number(s,h,o)),this._padding&&(i.interpolatePadding(a,u,o),p=i.centerPoint.add(d)),m.easeFunc(o,_,g,p),this.terrain&&!e.freezeElevation&&this._updateElevation(o),this._applyUpdatedTransform(i),this._fireMoveEvents(t)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(t)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=st(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,t){e=we(e,-180,180);const i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(ap.convert(e),this.transform):null}}const Fb={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Bb{constructor(e=Fb){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||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||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=lt.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=lt.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=lt.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){const 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){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.tileManagers;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const 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}));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=lt.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Ob{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const 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){var t;this._map=e,this._compact=null===(t=this.options)||void 0===t?void 0:t.compact,this._container=lt.create("div","maplibregl-ctrl");const i=lt.create("a","maplibregl-ctrl-logo");return i.target="_blank",i.rel="noopener nofollow",i.href="https://maplibre.org/",i.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),i.setAttribute("rel","noopener nofollow"),this._container.appendChild(i),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}}class Vb{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var jb=na([{name:"a_pos3d",type:"Int16",components:3}]);class Nb extends Tt{constructor(e){super(),this._lastTilesetChange=st(),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}getSource(){return this.tileManager._source}update(e,t){this.tileManager.update(e,t),this._renderableTilesKeys=[];const i={};for(const r of l_(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:t,calculateTileZoom:this.tileManager._source.calculateTileZoom}))i[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=new Float64Array(16),M(r.terrainRttPosMatrix32f,0,Q,Q,0,0,1),this._tiles[r.key]=new Wm(r,this.tileSize),this._lastTilesetChange=st());for(const e in this._tiles)i[e]||delete this._tiles[e]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}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){const t={};for(const i of this._renderableTilesKeys){const r=this._tiles[i].tileID,n=e.clone(),o=ne();if(r.canonical.equals(e.canonical))M(o,0,Q,Q,0,0,1);else if(r.canonical.isChildOf(e.canonical)){const t=r.canonical.z-e.canonical.z,i=r.canonical.x-(r.canonical.x>>t<<t),n=r.canonical.y-(r.canonical.y>>t<<t),s=Q>>t;M(o,0,s,s,0,0,1),b(o,o,[-i*s,-n*s,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{const t=e.canonical.z-r.canonical.z,i=e.canonical.x-(e.canonical.x>>t<<t),n=e.canonical.y-(e.canonical.y>>t<<t),s=Q>>t;M(o,0,Q,Q,0,0,1),b(o,o,[i*s,n*s,0]),w(o,o,[1/2**t,1/2**t,0])}}n.terrainRttPosMatrix32f=new Float32Array(o),t[i]=n}return t}_getTerrainCoordsForTileRanges(e,t){const i={};for(const r of this._renderableTilesKeys){const n=this._tiles[r].tileID;if(!this._isWithinTileRanges(n,t))continue;const o=e.clone(),s=ne();if(n.canonical.z===e.canonical.z){const t=e.canonical.x-n.canonical.x+e.wrap*(1<<e.canonical.z),i=e.canonical.y-n.canonical.y;M(s,0,Q,Q,0,0,1),b(s,s,[t*Q,i*Q,0])}else if(n.canonical.z>e.canonical.z){const t=n.canonical.z-e.canonical.z,i=n.canonical.x-(n.canonical.x>>t<<t)+e.wrap*(1<<n.canonical.z),r=n.canonical.y-(n.canonical.y>>t<<t),o=e.canonical.x-(n.canonical.x>>t),a=e.canonical.y-(n.canonical.y>>t),l=Q>>t;M(s,0,l,l,0,0,1),b(s,s,[-i*l+o*Q,-r*l+a*Q,0])}else{const t=e.canonical.z-n.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),o=(e.canonical.x>>t)-n.canonical.x,a=(e.canonical.y>>t)-n.canonical.y,l=Q<<t;M(s,0,l,l,0,0,1),b(s,s,[i*Q+o*l,r*Q+a*l,0])}o.terrainRttPosMatrix32f=new Float32Array(s),i[r]=o}return i}getSourceTile(e,t){var i,r;const n=this.tileManager._source;let o=e.overscaledZ-this.deltaZoom;if(o>n.maxzoom&&(o=n.maxzoom),o<n.minzoom)return;(i=this._sourceTileCache)[r=e.key]||(i[r]=e.scaledTo(o).key);let s=this.findTileInCaches(this._sourceTileCache[e.key]);if(!(null==s?void 0:s.dem)&&t)for(;o>=n.minzoom&&!(null==s?void 0:s.dem);)s=this.findTileInCaches(e.scaledTo(o--).key);return s}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){const 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)}}class Ub{constructor(e,t,i){this._meshCache={},this.painter=e,this.tileManager=new Nb(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&(this._fbo.destroy(),this._fbo=null),this._fboCoordsTexture&&(this._fboCoordsTexture.destroy(),this._fboCoordsTexture=null),this._fboDepthTexture&&(this._fboDepthTexture.destroy(),this._fboDepthTexture=null),this._emptyDemTexture&&(this._emptyDemTexture.destroy(),this._emptyDemTexture=null),this._emptyDepthTexture&&(this._emptyDepthTexture.destroy(),this._emptyDepthTexture=null),this._coordsTexture&&(this._coordsTexture.destroy(),this._coordsTexture=null);for(const e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,i,r=8192){var n;const o=e.normalizeCoordinates(t,i,r);if(!o)return 0;const s=this.getTerrainData(o.tileID),a=null===(n=s.tile)||void 0===n?void 0:n.dem;if(!a)return 0;const l=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e}([],[o.x/r*Q,o.y/r*Q],s.u_terrain_matrix),c=[l[0]*a.dim,l[1]*a.dim],h=Math.floor(c[0]),u=Math.floor(c[1]),d=c[0]-h,p=c[1]-u;return a.get(h,u)*(1-d)*(1-p)+a.get(h+1,u)*d*(1-p)+a.get(h,u+1)*(1-d)*p+a.get(h+1,u+1)*d*p}getElevationForLngLatZoom(e,t){if(!wp(t,e.wrap()))return 0;const{tileID:i,mercatorX:r,mercatorY:n}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(i,r%Q,n%Q,Q)}getElevationForLngLat(e,t){const i=l_(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let r=0;for(const e of i)e.canonical.z>r&&(r=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,r)}getElevation(e,t,i,r=8192){return this.getDEMElevation(e,t,i,r)*this.exaggeration}getTerrainData(e){var t,i;if(!this._emptyDemTexture){const e=this.painter.context,t=new kc({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Zc(e,t,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Zc(e,new kc({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=y([])}const r=this.tileManager.getSourceTile(e,!0);if((null==r?void 0:r.dem)&&(!r.demTexture||r.needsTerrainPrepare)){const e=this.painter.context;r.demTexture=this.painter.getTileTexture(r.dem.stride),r.demTexture?r.demTexture.update(r.dem.getPixels(),{premultiply:!1}):r.demTexture=new Zc(e,r.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),r.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),r.needsTerrainPrepare=!1}const n=r&&r.toString()+r.tileID.key+e.key;if(n&&!this._demMatrixCache[n]){const t=this.tileManager.getSource().maxzoom;let i=e.canonical.z-r.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=t?i=e.canonical.z-t:Le("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=e.canonical.x-(e.canonical.x>>i<<i),l=e.canonical.y-(e.canonical.y>>i<<i),c=((o=new Float64Array(16))[0]=(s=[1/(Q<<i),1/(Q<<i),0])[0],o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=s[1],o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=s[2],o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o);b(c,c,[a*Q,l*Q,0]),this._demMatrixCache[n]={matrix:c,coord:e}}var o,s;return{u_depth:2,u_terrain:3,u_terrain_dim:(null===(t=null==r?void 0:r.dem)||void 0===t?void 0:t.dim)||1,u_terrain_matrix:n?this._demMatrixCache[n].matrix:this._emptyDemMatrix,u_terrain_unpack:(null===(i=null==r?void 0:r.dem)||void 0===i?void 0:i.getUnpackVector())||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:((null==r?void 0:r.demTexture)||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:r}}getFramebuffer(e){const t=this.painter,i=t.width/devicePixelRatio,r=t.height/devicePixelRatio;return!this._fbo||this._fbo.width===i&&this._fbo.height===r||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Zc(t.context,{width:i,height:r,data:null},t.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(t.context.gl.NEAREST,t.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Zc(t.context,{width:i,height:r,data:null},t.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(t.context.gl.NEAREST,t.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=t.context.createFramebuffer(i,r,!0,!1),this._fbo.depthAttachment.set(t.context.createRenderbuffer(t.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set("coords"===e?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const t=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let e=0,i=0;e<this._coordsTextureSize;e++)for(let r=0;r<this._coordsTextureSize;r++,i+=4)t[i+0]=255&r,t[i+1]=255&e,t[i+2]=r>>8<<4|e>>8,t[i+3]=0;const i=new kc({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(t.buffer)),r=new Zc(e,i,e.gl.RGBA,{premultiply:!1});return r.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(e){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();const t=new Uint8Array(4),i=this.painter.context,r=i.gl,n=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);i.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(n,s-o-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),i.bindFramebuffer.set(null);const a=t[0]+(t[2]>>4<<8),l=t[1]+((15&t[2])<<8),c=this.coordsIndex[255-t[3]],h=c&&this.tileManager.getTileByID(c);if(!h)return null;const u=this._coordsTextureSize,d=(1<<h.tileID.canonical.z)*u;return new gp((h.tileID.canonical.x*u+a)/d+h.tileID.wrap,(h.tileID.canonical.y*u+l)/d,this.getElevation(h.tileID,a,l,u))}depthAtPoint(e){const t=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").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){var t;const i=(null===(t=this.painter.style.projection)||void 0===t?void 0:t.transitionState)>0,r=i&&0===e.canonical.y,n=i&&e.canonical.y===(1<<e.canonical.z)-1,o=`m_${r?"n":""}_${n?"s":""}`;if(this._meshCache[o])return this._meshCache[o];const s=this.painter.context,a=new Ga,l=new ol,c=this.meshSize,h=Q/c,u=c*c;for(let e=0;e<=c;e++)for(let t=0;t<=c;t++)a.emplaceBack(t*h,e*h,0);for(let e=0;e<u;e+=c+1)for(let t=0;t<c;t++)l.emplaceBack(t+e,c+t+e+1,c+t+e+2),l.emplaceBack(t+e,c+t+e+2,t+e+1);const d=a.length,p=d+(c+1),f=(c+1)*c,m=r?Ph:0,_=r?0:1,g=n?Ih:Q,y=n?0:1;for(let e=0;e<=c;e++)a.emplaceBack(e*h,m,_);for(let e=0;e<=c;e++)a.emplaceBack(e*h,g,y);for(let e=0;e<c;e++)l.emplaceBack(f+e,p+e,p+e+1),l.emplaceBack(f+e,p+e+1,f+e+1),l.emplaceBack(0+e,d+e+1,d+e),l.emplaceBack(0+e,0+e+1,d+e+1);const v=a.length,x=v+2*(c+1);for(const e of[0,1])for(let t=0;t<=c;t++)for(const i of[0,1])a.emplaceBack(e*Q,t*h,i);for(let e=0;e<2*c;e+=2)l.emplaceBack(v+e,v+e+1,v+e+3),l.emplaceBack(v+e,v+e+3,v+e+2),l.emplaceBack(x+e,x+e+3,x+e+1),l.emplaceBack(x+e,x+e+2,x+e+3);const b=new bg(s.createVertexBuffer(a,jb.members),s.createIndexBuffer(l),hl.simpleSegment(0,0,a.length,l.length));return this._meshCache[o]=b,b}getMeshFrameDelta(e){return 2*Math.PI*sp/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,t){var i;if(!wp(t,e.wrap()))return 0;const{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,t);return null!==(i=this.getMinMaxElevation(r).minElevation)&&void 0!==i?i:0}getMinMaxElevation(e){const t=this.getTerrainData(e).tile,i={minElevation:null,maxElevation:null};return(null==t?void 0:t.dem)&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(e,t){const i=gp.fromLngLat(e.wrap()),r=(1<<t)*Q,n=i.x*r,o=i.y*r,s=Math.floor(n/Q),a=Math.floor(o/Q);return{tileID:new Pp(t,0,t,s,a),mercatorX:n,mercatorY:o}}}class Gb{constructor(e,t,i){this._context=e,this._size=t,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const t=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),i=new Zc(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return i.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),t.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),t.colorAttachment.set(i.texture),{id:e,fbo:t,texture:i,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((t=>e.id!==t)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some((e=>!e.inUse))}}const $b={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Zb{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Gb(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){var i,r,n;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.tileManagers){this._coordsAscending[t]={};const i=e.tileManagers[t].getVisibleCoordinates(),r=e.tileManagers[t].getSource(),o=r instanceof Bp?r.terrainTileRanges:null;for(const e of i){const i=this.terrain.tileManager.getTerrainCoords(e,o);for(const e in i)(n=this._coordsAscending[t])[e]||(n[e]=[]),this._coordsAscending[t][e].push(i[e])}}this._rttFingerprints={};for(const t of e._order){const n=e._layers[t],o=n.source;if($b[n.type]&&!this._rttFingerprints[o]){this._rttFingerprints[o]={};const t=null!==(r=null===(i=e.tileManagers[o])||void 0===i?void 0:i.getState().revision)&&void 0!==r?r:0;for(const e in this._coordsAscending[o])this._rttFingerprints[o][e]=`${this._coordsAscending[o][e].map((e=>e.key)).sort().join()}#${t}`}}for(const e of this._renderableTiles)for(const t in this._rttFingerprints){const i=this._rttFingerprints[t][e.tileID.key];i&&i!==e.rttFingerprint[t]&&(e.rtt=[])}}renderLayer(e,t){if(e.isHidden(this.painter.transform.zoom))return!1;const i=Object.assign(Object.assign({},t),{isRenderingToTexture:!0}),r=e.type,n=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if($b[r]&&(this._prevType&&$b[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if($b[this._prevType]||$b[r]&&o){this._prevType=r;const e=this._stacks.length-1,t=this._stacks[e]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&(Cx(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[e]){const t=this.pool.getObjectForId(r.rtt[e].id);if(t.stamp===r.rtt[e].stamp){this.pool.useObject(t);continue}}const o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),r.rtt[e]={id:o.id,stamp:o.stamp},n.context.bindFramebuffer.set(o.fbo.framebuffer),n.context.clear({color:Ri.transparent,stencil:0}),n.currentStencilSource=void 0;for(const e of t){const t=n.style._layers[e],s=t.source?this._coordsAscending[t.source][r.tileID.key]:[r.tileID];n.context.viewport.set([0,0,o.fbo.width,o.fbo.height]),n._renderTileClippingMasks(t,s,!0),n.renderLayer(n,n.style.tileManagers[t.source],t,s,i),t.source&&(r.rttFingerprint[t.source]=this._rttFingerprints[t.source][r.tileID.key])}}return Cx(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],this.pool.freeAllObjects(),$b[r]}return!1}}const qb={"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"},Wb=r,Hb={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Fb,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:ct.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0,anisotropicFilterPitch:20};let Xb=class extends Lb{get _ownerWindow(){var e,t;return(null===(t=null===(e=this._container)||void 0===e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window}constructor(e){var t,i,r;const n=Object.assign(Object.assign(Object.assign({},Hb),e),{canvasContextAttributes:Object.assign(Object.assign({},Hb.canvasContextAttributes),e.canvasContextAttributes)});if(null!=n.minZoom&&null!=n.maxZoom&&n.minZoom>n.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=n.minPitch&&null!=n.maxPitch&&n.minPitch>n.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=n.minPitch&&n.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=n.maxPitch&&n.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Rg,s=new Bg;void 0!==n.minZoom&&o.setMinZoom(n.minZoom),void 0!==n.maxZoom&&o.setMaxZoom(n.maxZoom),void 0!==n.minPitch&&o.setMinPitch(n.minPitch),void 0!==n.maxPitch&&o.setMaxPitch(n.maxPitch),void 0!==n.renderWorldCopies&&o.setRenderWorldCopies(n.renderWorldCopies),null!==n.transformConstrain&&o.setConstrainOverride(n.transformConstrain),super(o,s,{bearingSnap:n.bearingSnap,zoomSnap:n.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Vb,this._controls=[],this._mapId=Ie(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(const 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(const[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 bt("webglcontextlost",{originalEvent:e}))}else this.fire(new bt("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new bt("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()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},n.canvasContextAttributes),this._trackResize=!0===n.trackResize,this._bearingSnap=n.bearingSnap,this._zoomSnap=n.zoomSnap,this._centerClampedToGround=n.centerClampedToGround,this._refreshExpiredTiles=!0===n.refreshExpiredTiles,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=!0===n.crossSourceCollisions,this._collectResourceTiming=!0===n.collectResourceTiming,this._locale=Object.assign(Object.assign({},qb),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this._zoomLevelsToOverscale=n.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=n.transformCameraUpdate,this.transformConstrain=n.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===n.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(n.anisotropicFilterPitch),void 0!==n.reduceMotion&&(nt.prefersReducedMotion=n.reduceMotion),this._imageQueueHandle=gt.addThrottleControl((()=>this.isMoving())),this._requestManager=new yt(n.transformRequest),this._container=this._resolveContainer(n.container),n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),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)),"undefined"!=typeof window&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new kb(this,n),this._hash=n.hash?new kx("string"==typeof n.hash&&n.hash||void 0).addTo(this):void 0,(null===(t=this._hash)||void 0===t?void 0:t._onHashChange())||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,Te({},n.fitBoundsOptions,{duration:0}))));const a="string"==typeof n.style||!("globe"===(null===(r=null===(i=n.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,a),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style&&this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}),n.attributionControl&&this.addControl(new Bb("boolean"==typeof n.attributionControl?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Ob,n.logoPosition),this.on("style.load",(()=>{if(a||this._resizeTransform(),this.transform.unmodified){const e=Se(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new bt(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new bt(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new bt("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"),!(null==e?void 0:e.onAdd))return this.fire(new wt(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return t.includes("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!(null==e?void 0:e.onRemove))return this.fire(new wt(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const 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 l_(this.transform,e)}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this.transform)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,t=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(t);const i=!this._moving;return i&&(this.stop(),this.fire(new bt("movestart",e)).fire(new bt("move",e))),this.fire(new bt("resize",e)),i&&this.fire(new bt("moveend",e)),this}_resizeInternal(e=!0){const[t,i]=this._containerDimensions(),r=this._getClampedPixelRatio(t,i);if(this._resizeCanvas(t,i,r),this.painter.resize(t,i,r),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const r=this._getClampedPixelRatio(t,i);this._resizeCanvas(t,i,r),this.painter.resize(t,i,r)}this._resizeTransform(e)}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e)}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,n=this.getPixelRatio(),o=e*n,s=t*n;return Math.min(o>i?i/o:1,s>r?r/s:1)*n}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(lp.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom){const t=this.transform.zoom,i=this._getTransformForUpdate();return i.setMinZoom(e),this._applyUpdatedTransform(i),this._update(),t!==this.transform.zoom&&this.fire(new bt("zoomstart")).fire(new bt("zoom")).fire(new bt("zoomend")).fire(new bt("movestart")).fire(new bt("move")).fire(new bt("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom){const t=this.transform.zoom,i=this._getTransformForUpdate();return i.setMaxZoom(e),this._applyUpdatedTransform(i),this._update(),t!==this.transform.zoom&&this.fire(new bt("zoomstart")).fire(new bt("zoom")).fire(new bt("zoomend")).fire(new bt("movestart")).fire(new bt("move")).fire(new bt("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch){const t=this.transform.pitch,i=this._getTransformForUpdate();return i.setMinPitch(e),this._applyUpdatedTransform(i),this._update(),t!==this.transform.pitch&&this.fire(new bt("pitchstart")).fire(new bt("pitch")).fire(new bt("pitchend")).fire(new bt("movestart")).fire(new bt("move")).fire(new bt("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?60:e)>180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch){const t=this.transform.pitch,i=this._getTransformForUpdate();return i.setMaxPitch(e),this._applyUpdatedTransform(i),this._update(),t!==this.transform.pitch&&this.fire(new bt("pitchstart")).fire(new bt("pitch")).fire(new bt("pitchend")).fire(new bt("movestart")).fire(new bt("move")).fire(new bt("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if((e=null==e?20:e)>180)throw new Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw new Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(ap.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(o.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),s=0!==o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new $x(e,this,n.originalEvent,{features:s}))):r=!1};return{layers:t,listener:i,delegates:{mousemove:n,mouseout:()=>{r=!1}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(0!==o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new $x(e,this,n.originalEvent)))},o=t=>{r&&(r=!1,i.call(this,new $x(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),n=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){var i;this._delegatedListeners||(this._delegatedListeners={}),(i=this._delegatedListeners)[e]||(i[e]=[]),this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){var r;if(!(null===(r=this._delegatedListeners)||void 0===r?void 0:r[e]))return;const n=this._delegatedListeners[e];for(let e=0;e<n.length;e++){const r=n[e];if(r.listener===i&&r.layers.length===t.length&&r.layers.every((e=>t.includes(e)))){for(const e in r.delegates)this.off(e,r.delegates[e]);return void n.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,n=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,n);for(const e in n.delegates)this.on(e,n.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,n=this._createDelegatedListener(e,r,i);for(const t in n.delegates){const o=n.delegates[t];n.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),o(...t)}}this._saveDelegatedListener(e,n);for(const e in n.delegates)this.once(e,n.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,t){if(!this.style)return[];let i;const r=e instanceof o||Array.isArray(e),n=r?e:[[0,0],[this.transform.width,this.transform.height]];if(t||(t=(r?{}:e)||{}),n instanceof o||"number"==typeof n[0])i=[o.convert(n)];else{const e=o.convert(n[0]),t=o.convert(n[1]);i=[e,new o(t.x,e.y),t,new o(e.x,t.y),e]}return this.style.queryRenderedFeatures(i,t,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return!1!==(t=Te({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},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){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r,n;if(null===(i=this._diffStyleRequest)||void 0===i||i.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new vy(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),null===(n=null===(r=this.style)||void 0===r?void 0:r.projection)||void 0===n||n.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new vy(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,t){return n(this,void 0,void 0,(function*(){var i;if(null===(i=this._diffStyleRequest)||void 0===i||i.abort(),"string"==typeof e){const i=e;this._diffStyleRequest=new AbortController;const r=this._diffStyleRequest;try{const e=yield this._requestManager.transformRequest(i,"Style");if(r.signal.aborted)return void(this._diffStyleRequest=null);const n=yield mt(e,r);this._diffStyleRequest=null,this._updateDiff(n.data,t)}catch(e){this._diffStyleRequest=null,Qe(e)||this.fire(new wt(te(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){Le(`Unable to perform style diff: ${te(i).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();Le("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){var t;const i=null===(t=this.style)||void 0===t?void 0:t.tileManagers[e];if(void 0!==i)return i.loaded();this.fire(new wt(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const t=this.style.tileManagers[e.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&t.reload();for(const t in this.style._layers){const i=this.style._layers[t];"hillshade"===i.type&&i.source===e.source&&Le("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&&Le("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Ub(this.painter,t,e),this.painter.renderToTexture=new Zb(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.tileManager.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new bt("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){var e;const t=null===(e=this.style)||void 0===e?void 0:e.tileManagers;for(const e of Object.values(t))if(!e.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){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=o_(Math.max(1,e),Math.max(1,t))}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=o_(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){const i=this.style.tileManagers[e];if(!i)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===t?i.reload(!0):i.refreshTiles(t.map((e=>new Tp(e.z,e.x,e.y))))}addImage(e,t,i={}){const{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a,textFitWidth:l,textFitHeight:c}=i;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||Ve(t))){if(void 0===t.width||void 0===t.height)return this.fire(new wt(new 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`")));{const{width:i,height:h,data:u}=t,d=t;return this.style.addImage(e,{data:new kc({width:i,height:h},new Uint8Array(u)),pixelRatio:r,stretchX:o,stretchY:s,content:a,textFitWidth:l,textFitHeight:c,sdf:n,version:0,userImage:d}),d.onAdd&&d.onAdd(this,e),this}}{const{width:i,height:h,data:u}=nt.getImageData(t);this.style.addImage(e,{data:new kc({width:i,height:h},u),pixelRatio:r,stretchX:o,stretchY:s,content:a,textFitWidth:l,textFitHeight:c,sdf:n,version:0})}}updateImage(e,t){const i=this.style.getImage(e);if(!i)return this.fire(new wt(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=t instanceof HTMLImageElement||Ve(t)?nt.getImageData(t):t,{width:n,height:o,data:s}=r;if(void 0===n||void 0===o)return this.fire(new wt(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(n!==i.data.width||o!==i.data.height)return this.fire(new wt(new Error("The width and height of the updated image must be that same as the previous version of the image")));const a=!(t instanceof HTMLImageElement||Ve(t));return i.data.replace(s,a),this.style.updateImage(e,i),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new wt(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return n(this,void 0,void 0,(function*(){return gt.getImage(yield this._requestManager.transformRequest(e,"Image"),new AbortController)}))}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()}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]}_setupResizeObserver(){var e;let t=!1;const i=Rx((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50),r=null!==(e=this._ownerWindow.ResizeObserver)&&void 0!==e?e:ResizeObserver;this._resizeObserver=new r((e=>{t?i(e):t=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){const t=document.getElementById(e);if(!t)throw new Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement)return e;if(e&&"object"==typeof e&&1===e.nodeType)return e;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=lt.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=lt.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");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const n=this._controlContainer=lt.create("div","maplibregl-control-container",e),o=this._controlPositions={};for(const e of["top-left","top-right","bottom-left","bottom-right"])o[e]=lt.create("div",`maplibregl-ctrl-${e} `,n);this._container.addEventListener("scroll",this._onMapScroll,!1)}_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(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Dx(i,this.transform)}migrateProjection(e,t){super.migrateProjection(e,t),this.painter.transform=e,this.fire(new bt("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){var t;return(null===(t=this.style)||void 0===t?void 0:t._loaded)?(this._styleDirty||(this._styleDirty=e),this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var t,i,r,n,o,s;const a=this._idleTriggered?this._fadeDuration:0,l=(null===(t=this.style.projection)||void 0===t?void 0:t.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let c=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,t=st();this.style.zoomHistory.update(e,t);const i=new zs(e,{now:t,fadeDuration:a,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),r=i.crossFadingFactor();1===r&&r===this._crossFadingFactor||(c=!0,this._crossFadingFactor=r),this.style.update(i)}const h=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0!==l;null===(r=this.style.projection)||void 0===r||r.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(n=this.style.projection)||void 0===n?void 0:n.transitionState,null===(o=this.style.projection)||void 0===o?void 0:o.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||h)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=null===(s=this.style)||void 0===s?void 0:s._updatePlacement(this.transform,this.showCollisionBoxes,a,this._crossSourceCollisions,h),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new bt("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new bt("load"))),this.style&&(this.style.hasTransitions()||c)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const u=this._sourcesDirty||this._styleDirty||this._placementDirty;return u||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new bt("idle")),!this._loaded||this._fullyLoaded||u||(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e,t;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),null===(e=this._diffStyleRequest)||void 0===e||e.abort(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),gt.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),this._removed=!0,this.fire(new bt("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,nt.frame(this._frameRequest,(e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!Qe(e)&&!function(e){return e.message===$v}(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 Wb}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};const Yb={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Kb{constructor(e,t,i=!1){this.mousedown=e=>{this.startMove(e,lt.mousePos(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,lt.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=lt.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=lt.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=t;const r=new ab;this._rotatePitchHandler=new tb({clickTolerance:3,move:(e,r)=>{const n=t.getBoundingClientRect(),s=new o((n.bottom-n.top)/2,(n.right-n.left)/2);return{bearingDelta:Ze(new o(e.x,r.y),r,s),pitchDelta:i?-.5*(r.y-e.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),lt.disableDrag()}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:n}=this._rotatePitchHandler.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),n&&i.setPitch(i.getPitch()+n)}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){lt.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}}let Jb;function Qb(e,t,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const n=new ap(e.lng,e.lat);if(e=new ap(e.lng,e.lat),t){const r=new ap(e.lng-360,e.lat),n=new ap(e.lng+360,e.lat),o=i.locationToScreenPoint(e).distSqr(t);i.locationToScreenPoint(r).distSqr(t)<o?e=r:i.locationToScreenPoint(n).distSqr(t)<o&&(e=n)}for(;Math.abs(e.lng-i.center.lng)>180;){const t=i.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=i.width&&t.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e.lng!==n.lng&&i.isPointOnMapSurface(i.locationToScreenPoint(e))?e:n}const ew={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function tw(e,t,i){const r=e.classList;for(const e in ew)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`)}class iw extends Tt{constructor(e){if(super(),this._onClick=e=>{this.fire(new bt("click",{originalEvent:e}))},this._onKeyPress=e=>{"Space"!==e.code&&"Enter"!==e.code||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=Qb(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),this._element.style.transform=`${ew[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`,nt.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity("moveend"===(null==e?void 0:e.type))})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new bt("dragstart"))),this.fire(new bt("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new bt("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=(null==e?void 0:e.anchor)||"center",this._color=(null==e?void 0:e.color)||"#3FB1CE",this._scale=(null==e?void 0:e.scale)||1,this._draggable=(null==e?void 0:e.draggable)||!1,this._clickTolerance=(null==e?void 0:e.clickTolerance)||0,this._subpixelPositioning=(null==e?void 0:e.subpixelPositioning)||!1,this._isDragging=!1,this._state="inactive",this._rotation=(null==e?void 0:e.rotation)||0,this._rotationAlignment=(null==e?void 0:e.rotationAlignment)||"auto",this._pitchAlignment=(null==e?void 0:e.pitchAlignment)&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),null==e?void 0:e.element)this._element=e.element,this._offset=o.convert((null==e?void 0:e.offset)||[0,0]);else{this._defaultMarker=!0,this._element=lt.create("div");const t=lt.createNS("http://www.w3.org/2000/svg","svg"),i=41,r=27;t.setAttributeNS(null,"display","block"),t.setAttributeNS(null,"height",`${i}px`),t.setAttributeNS(null,"width",`${r}px`),t.setAttributeNS(null,"viewBox",`0 0 ${r} ${i}`);const n=lt.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"stroke","none"),n.setAttributeNS(null,"stroke-width","1"),n.setAttributeNS(null,"fill","none"),n.setAttributeNS(null,"fill-rule","evenodd");const s=lt.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const a=lt.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of l){const t=lt.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),a.appendChild(t)}const c=lt.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const h=lt.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(h);const u=lt.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"opacity","0.25"),u.setAttributeNS(null,"fill","#000000");const d=lt.createNS("http://www.w3.org/2000/svg","path");d.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),u.appendChild(d);const p=lt.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const f=lt.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(8.0, 8.0)");const m=lt.createNS("http://www.w3.org/2000/svg","circle");m.setAttributeNS(null,"fill","#000000"),m.setAttributeNS(null,"opacity","0.25"),m.setAttributeNS(null,"cx","5.5"),m.setAttributeNS(null,"cy","5.5"),m.setAttributeNS(null,"r","5.4999962");const _=lt.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),f.appendChild(m),f.appendChild(_),s.appendChild(a),s.appendChild(c),s.appendChild(u),s.appendChild(p),s.appendChild(f),t.appendChild(s),t.setAttributeNS(null,"height",i*this._scale+"px"),t.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(t),this._offset=o.convert((null==e?void 0:e.offset)||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()})),tw(this._element,this._anchor,"marker"),null==e?void 0:e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=ap.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var t,i;const r=null===(t=this._map)||void 0===t?void 0:t.terrain,n=this._map.transform.isLocationOccluded(this._lngLat);if(!r||n){const e=n?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle("maplibregl-marker-covered",n)))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const s=this._map,a=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLat(this._lngLat,s.transform);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove("maplibregl-marker-covered");const c=-this._offset.y/s.transform.pixelsPerMeter,h=Math.sin(s.getPitch()*Math.PI/180)*c,u=s.terrain.depthAtPoint(new o(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+h)-u>.006;(null===(i=this._popup)||void 0===i?void 0:i.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",d)}getOffset(){return this._offset}setOffset(e){return this._offset=o.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=String(e)),void 0!==t&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(!0),this}}const rw={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let nw=0,ow=!1;const sw={maxWidth:100,unit:"metric"};function aw(e,t,i){const r=(null==i?void 0:i.maxWidth)||100,n=e._container.clientHeight/2,o=e._container.clientWidth/2,s=e.unproject([o-r/2,n]),a=e.unproject([o+r/2,n]),l=Math.round(e.project(a).x-e.project(s).x),c=Math.min(r,l,e._container.clientWidth),h=s.distanceTo(a);if("imperial"===(null==i?void 0:i.unit)){const i=3.2808*h;i>5280?lw(t,c,i/5280,e._getUIString("ScaleControl.Miles")):lw(t,c,i,e._getUIString("ScaleControl.Feet"))}else"nautical"===(null==i?void 0:i.unit)?lw(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?lw(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):lw(t,c,h,e._getUIString("ScaleControl.Meters"))}function lw(e,t,i,r){const n=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(n/i)+"px",e.innerHTML=`${n} ${r}`}const cw={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},hw=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function uw(e){if(e){if("number"==typeof e){const t=Math.round(Math.abs(e)/Math.SQRT2);return{center:new o(0,0),top:new o(0,e),"top-left":new o(t,t),"top-right":new o(-t,t),bottom:new o(0,-e),"bottom-left":new o(t,-t),"bottom-right":new o(-t,-t),left:new o(e,0),right:new o(-e,0)}}if(e instanceof o||Array.isArray(e)){const t=o.convert(e);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:o.convert(e.center||[0,0]),top:o.convert(e.top||[0,0]),"top-left":o.convert(e["top-left"]||[0,0]),"top-right":o.convert(e["top-right"]||[0,0]),bottom:o.convert(e.bottom||[0,0]),"bottom-left":o.convert(e["bottom-left"]||[0,0]),"bottom-right":o.convert(e["bottom-right"]||[0,0]),left:o.convert(e.left||[0,0]),right:o.convert(e.right||[0,0])}}return uw(new o(0,0))}const dw=r;e.AJAXError=dt,e.AttributionControl=Bb,e.BoxZoomHandler=Yx,e.CanvasSource=Vp,e.CooperativeGesturesHandler=Ab,e.DoubleClickZoomHandler=Sb,e.DragPanHandler=Mb,e.DragRotateHandler=Eb,e.EXTENT=Q,e.EdgeInsets=Ig,e.Event=bt,e.Evented=Tt,e.FullscreenControl=class extends Tt{constructor(e={}){var t;super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=null!==(t=e.pseudo)&&void 0!==t&&t,(null==e?void 0:e.container)&&(e.container instanceof HTMLElement?this._container=e.container:Le("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=lt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=lt.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);lt.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new bt("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new bt("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=Lp,e.GeolocateControl=class extends Tt{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new bt("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new bt("geolocate",e)),this._finish()}},this._updateCamera=e=>{const t=new ap(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=Te({bearing:this._map.getBearing()},this.options.fitBoundsOptions),n=lp.fromLngLat(t,i);this._map.fitBounds(n,r,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const t=new ap(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&ow)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new bt("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=e=>{if(!this._map)return;const t=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new bt("trackuserlocationend")),this.fire(new bt("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>{e.preventDefault()})),this._geolocateButton=lt.create("button","maplibregl-ctrl-geolocate",this._container),lt.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){Le("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=lt.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new iw({element:this._dotElement}),this._circleElement=lt.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new iw({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart)}},this.options=Te({},rw,e)}onAdd(e){return this._map=e,this._container=lt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return n(this,arguments,void 0,(function*(e=!1){if(void 0!==Jb&&!e)return Jb;if(void 0===window.navigator.permissions)return Jb=!!window.navigator.geolocation,Jb;try{const e=yield window.navigator.permissions.query({name:"geolocation"});Jb="denied"!==e.state}catch(e){Jb=!!window.navigator.geolocation}return Jb}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,nw=0,ow=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),r=e.distanceTo(i)/100,n=2*this._accuracy/r;this._circleElement.style.width=`${n.toFixed(2)}px`,this._circleElement.style.height=`${n.toFixed(2)}px`}trigger(){if(!this._setup)return Le("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new bt("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":nw--,ow=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new bt("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new bt("trackuserlocationstart")),this.fire(new bt("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),nw++,nw>1?(e={maximumAge:6e5,timeout:0},ow=!0):(e=this.options.positionOptions,ow=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=lt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=lt.create("button","maplibregl-ctrl-globe",this._container),lt.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=kx,e.ImageSource=Bp,e.KeyboardHandler=vb,e.LngLat=ap,e.LngLatBounds=lp,e.LogoControl=Ob,e.Map=Xb,e.MapLibreMap=Xb,e.MapMouseEvent=$x,e.MapTouchEvent=Zx,e.MapWheelEvent=qx,e.Marker=iw,e.MercatorCoordinate=gp,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=Te({},Yb,e),this._container=lt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),lt.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),lt.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=lt.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Kb(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=lt.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Point=o,e.Popup=class extends Tt{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new bt("close"))),this),this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=lt.create("div","maplibregl-popup",this._map.getContainer()),this._tip=lt.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}let t;if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Qb(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),e&&"point"in e&&e.point&&(t=e.point),this._trackPointer&&!t)return;const i=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor;const n=uw(this.options.offset);if(!r){const e=this._container.offsetWidth,t=this._container.offsetHeight,o=function(e){var t,i,r,n;return e?{top:null!==(t=e.top)&&void 0!==t?t:0,right:null!==(i=e.right)&&void 0!==i?i:0,bottom:null!==(r=e.bottom)&&void 0!==r?r:0,left:null!==(n=e.left)&&void 0!==n?n:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let s;s=i.y+n.bottom.y<t+o.top?["top"]:i.y>this._map.transform.height-t-o.bottom?["bottom"]:[],i.x<e/2+o.left?s.push("left"):i.x>this._map.transform.width-e/2-o.right&&s.push("right"),r=0===s.length?"bottom":s.join("-")}let o=i.add(n[r]);this.options.subpixelPositioning||(o=o.round()),this._container.style.transform=`${ew[r]} translate(${o.x}px,${o.y}px)`,tw(this._container,r,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=Te(Object.create(cw),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new bt("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=ap.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=lt.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=lt.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(hw);e&&e.focus()}},e.RasterDEMTileSource=Ep,e.RasterTileSource=xp,e.ScaleControl=class{constructor(e){this._onMove=()=>{aw(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,aw(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},sw),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=lt.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=Tb,e.Style=vy,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=lt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=lt.create("button","maplibregl-ctrl-terrain",this._container),lt.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=gb,e.TwoFingersTouchRotateHandler=mb,e.TwoFingersTouchZoomHandler=pb,e.TwoFingersTouchZoomRotateHandler=Cb,e.VectorTileSource=vp,e.VideoSource=Op,e.addProtocol=function(e,t){ct.REGISTERED_PROTOCOLS[e]=t},e.addSourceType=(e,t)=>n(void 0,void 0,void 0,(function*(){if(Np(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{jp[e]=t})(e,t)})),e.clearPrewarmedResources=function(){const e=Yd;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Wd),Yd=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.config=ct,e.createTileMesh=qg,e.getGlobalDispatcher=ep,e.getMaxParallelImageRequests=function(){return ct.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return $m().getRTLTextPluginStatus()},e.getVersion=function(){return dw},e.getWorkerCount=function(){return Hd.workerCount},e.getWorkerUrl=function(){return ct.WORKER_URL},e.importScriptInWorkers=function(e){return ep().broadcast("IS",e)},e.isTimeFrozen=function(){return ot.isFrozen()},e.now=st,e.prewarm=function(){Jd().acquire(Wd)},e.removeProtocol=function(e){delete ct.REGISTERED_PROTOCOLS[e]},e.restoreNow=function(){ot.restoreNow()},e.setMaxParallelImageRequests=function(e){ct.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){ot.setNow(e)},e.setRTLTextPlugin=function(e,t){return $m().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){Hd.workerCount=e},e.setWorkerUrl=function(e){ct.WORKER_URL=e}}));
|
||
//# sourceMappingURL=maplibre-gl-csp.js.map
|